//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.Interfaces;
using System.Collections.Immutable;
///
/// Describes the relationship between two guilds.
///
public enum GuildRelationship
{
///
/// No special relationship.
///
None = 0,
///
/// Both guilds are in the same alliance.
///
Union = 1,
///
/// The guilds are rivals / hostile to each other.
///
Rival = 2,
}
///
/// Defines the result of an alliance creation attempt.
///
public enum AllianceCreationResult
{
///
/// The alliance creation failed for an unspecified reason.
///
Failed,
///
/// The alliance was created successfully.
///
Success,
///
/// The master guild could not be found.
///
MasterGuildNotFound,
///
/// The target guild could not be found.
///
TargetGuildNotFound,
///
/// The target guild is already a member of an alliance.
///
TargetGuildAlreadyInAlliance,
///
/// The maximum number of guilds allowed in an alliance has been reached.
///
MaximumAllianceSizeReached,
///
/// The guild could not be found in the target context.
///
GuildNotFoundInTargetContext,
///
/// An unexpected error occurred during alliance creation.
///
Error,
}
///
/// Interface for the guild server.
///
///
/// A little note about the guild id:
/// The original GMO server uses an 32-bit integer in all of its messages. However, actually it's only using (or used?) 16 bits of it for created guilds (see struct SDHP_GUILDCREATED).
/// Some people may remember the "guildbug" on GMO - I guess the keys exceeded these 16 bits and somehow caused a crash... but after restart of the servers it started working again.
///
public interface IGuildServer
{
///
/// Checks if the guild with the specified name exists.
///
/// Name of the guild.
/// True, if the guild exists; False, otherwise.
ValueTask GuildExistsAsync(string guildName);
///
/// Gets the guild by the guild identifier.
///
/// The guild identifier.
/// The guild.
ValueTask GetGuildAsync(uint guildId);
///
/// Gets the guild id by the guild name.
///
/// The guild name.
/// The guild id. 0, if not found.
ValueTask GetGuildIdByNameAsync(string guildName);
///
/// Creates the guild and sets the guild master online at the guild server. A separate call to is not required.
///
/// The name.
/// Name of the master.
/// The master identifier.
/// The logo.
/// The identifier of the server on which the guild is getting created.
/// A flag, indicating if the guild has been created successfully.
ValueTask CreateGuildAsync(string name, string masterName, Guid masterId, byte[] logo, byte serverId);
///
/// Creates the guild member and sets it online at the guild server. A separate call to is not required.
///
/// The guild identifier.
/// The identifier.
/// The name.
/// The role of the member.
/// The identifier of the server on which the guild member is getting created.
ValueTask CreateGuildMemberAsync(uint guildId, Guid characterId, string characterName, GuildPosition role, byte serverId);
///
/// Updates the guild member position.
///
/// The guild identifier.
/// The id of the character.
/// The role.
ValueTask ChangeGuildMemberPositionAsync(uint guildId, Guid characterId, GuildPosition role);
///
/// Notifies the guild server that a player (potential guild member) entered the game.
///
/// The character identifier.
/// Name of the character.
/// The identifier of the server on which the guild member entered.
ValueTask PlayerEnteredGameAsync(Guid characterId, string characterName, byte serverId);
///
/// Notifies the guild server that a guild member left the game.
///
/// The guild identifier.
/// The identifier of the guild member.
/// The identifier of the server from which the guild member left.
ValueTask GuildMemberLeftGameAsync(uint guildId, Guid guildMemberId, byte serverId);
///
/// Gets the guild member list.
///
/// The guild identifier.
/// The guild member list.
ValueTask> GetGuildListAsync(uint guildId);
///
/// Kicks a guild member from a guild.
///
/// The guild identifier.
/// Name of the player which is getting kicked.
ValueTask KickMemberAsync(uint guildId, string playerName);
///
/// Gets the guild position of a specific character.
///
/// The character identifier.
/// The guild position.
ValueTask GetGuildPositionAsync(Guid characterId);
///
/// Increases the guild score by one.
///
/// The identifier of the guild.
ValueTask IncreaseGuildScoreAsync(uint guildId);
///
/// Creates an alliance between the master guild and the target guild.
/// The master guild becomes (or remains) the alliance master.
///
/// The identifier of the master guild that initiates the alliance.
/// The identifier of the target guild to add to the alliance.
/// true if the alliance was created successfully; false otherwise.
ValueTask CreateAllianceAsync(uint masterGuildId, uint targetGuildId);
///
/// Removes a guild from an alliance.
///
/// The identifier of the guild to remove from its alliance.
/// true if the guild was removed successfully; false otherwise.
ValueTask RemoveAllianceAsync(uint targetGuildId);
///
/// Gets the list of guilds in the alliance of the specified guild.
///
/// The identifier of any guild in the alliance.
/// The list of alliance guilds.
ValueTask> GetAllianceGuildsAsync(uint guildId);
///
/// Determines whether the specified guild is the alliance master.
///
/// The guild identifier.
/// true if the guild is the alliance master; false otherwise.
ValueTask IsAllianceMasterAsync(uint guildId);
///
/// Sets or clears the hostility between guilds.
///
/// The guild identifier of the requesting guild.
/// The identifier of the target guild. Only used when is true.
/// true to set hostility; false to clear any existing hostility.
/// true if the hostility state was changed successfully; false otherwise.
ValueTask SetHostilityAsync(uint guildIdA, uint guildIdB, bool create);
///
/// Gets the relationship between two guilds.
///
/// The first guild identifier.
/// The second guild identifier.
/// The relationship between the two guilds.
ValueTask GetGuildRelationshipAsync(uint guild1, uint guild2);
}
///
/// The guild list entry.
///
public class GuildListEntry
{
///
/// Gets or sets the name of the player.
///
public string? PlayerName { get; set; }
///
/// Gets or sets the server identifier on which the player is playing.
///
public byte ServerId { get; set; }
///
/// Gets or sets the players position in the guild.
///
public GuildPosition PlayerPosition { get; set; }
}