コード例 #1
0
ファイル: GuildWarContext.cs プロジェクト: psydox/OpenMU
 /// <summary>
 /// Initializes a new instance of the <see cref="GuildWarContext"/> class.
 /// </summary>
 /// <param name="warType">Type of the war.</param>
 /// <param name="score">The score.</param>
 /// <param name="team">The team.</param>
 /// <param name="requester">The requester.</param>
 public GuildWarContext(GuildWarType warType, GuildWarScore score, GuildWarTeam team, Player?requester)
 {
     this.WarType   = warType;
     this.Score     = score;
     this.Team      = team;
     this.Requester = requester;
 }
コード例 #2
0
        private void TryRequestWar(Player player, string targetGuildName, GuildWarType guildWarType)
        {
            if (player.GuildStatus is not {
            } guildStatus ||
                player.GameContext is not IGameServerContext serverContext ||
                serverContext.GuildServer.GetGuild(player.GuildStatus.GuildId) is not {
                Name : not null
            } guild)
            {
                player.ViewPlugIns.GetPlugIn <IShowShowGuildWarRequestResultPlugIn>()?.ShowResult(GuildWarRequestResult.NotInGuild);
                return;
            }

            if (guildStatus.Position != GuildPosition.GuildMaster)
            {
                player.ViewPlugIns.GetPlugIn <IShowShowGuildWarRequestResultPlugIn>()?.ShowResult(GuildWarRequestResult.NotTheGuildMaster);
                return;
            }

            if (!serverContext.GuildServer.GuildExists(targetGuildName))
            {
                player.ViewPlugIns.GetPlugIn <IShowShowGuildWarRequestResultPlugIn>()?.ShowResult(GuildWarRequestResult.GuildNotFound);
                return;
            }

            var targetGuildId = serverContext.GuildServer.GetGuildIdByName(targetGuildName);

            if (serverContext.PlayerList.FirstOrDefault(p => p.GuildStatus?.GuildId == targetGuildId) is not {
            } targetGuildMaster)
            {
                player.ViewPlugIns.GetPlugIn <IShowShowGuildWarRequestResultPlugIn>()?.ShowResult(GuildWarRequestResult.GuildMasterOffline);
                return;
            }

            if (targetGuildMaster.GuildWarContext is not null || player.GuildWarContext is not null)
            {
                player.ViewPlugIns.GetPlugIn <IShowShowGuildWarRequestResultPlugIn>()?.ShowResult(GuildWarRequestResult.AlreadyInWar);
                return;
            }

            var score = new GuildWarScore
            {
                FirstGuildName  = targetGuildName,
                SecondGuildName = guild.Name !,
                MaximumScore    = (byte)(guildWarType == GuildWarType.Soccer ? 100 : 20),
            };

            targetGuildMaster.GuildWarContext = new GuildWarContext(guildWarType, score, GuildWarTeam.First, player);
            player.GuildWarContext            = new GuildWarContext(guildWarType, score, GuildWarTeam.Second, null);

            targetGuildMaster.ViewPlugIns.GetPlugIn <IShowGuildWarRequestPlugIn>()?.ShowRequest(guild.Name !, guildWarType);
            player.ViewPlugIns.GetPlugIn <IShowShowGuildWarRequestResultPlugIn>()?.ShowResult(GuildWarRequestResult.RequestSentToGuildMaster);
        }