コード例 #1
0
        [PacketHandler(RealmServerOpCode.GuildWaveRegisterRequest)] //4402
        public static void GuildWaveRegisterRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position += 2;
            packet.ReadByte();                  //{Type act}
            var difficulty = packet.ReadByte(); //{Difficulty}

            Asda2GuildWave guildWave = Asda2GuildWaveMgr.GetGuildWaveForId((int)client.ActiveCharacter.GuildId);

            /* if (guildWave.IsInProgress)
             * {
             *   GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.Fail);
             *   return;
             * }*/
            if (guildWave == null)
            {
                if (client.ActiveCharacter.Guild.WaveLimit >= CharacterFormulas.GetWaveLimit(client.ActiveCharacter.Guild.Level))
                {
                    if (CharacterFormulas.GetWaveLimit(client.ActiveCharacter.Guild.Level) > 1)
                    {
                        GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.LimitDay);
                    }
                    else
                    {
                        GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.LimitOneDay);
                    }
                    return;
                }
                if (client.ActiveCharacter.Guild.Level < 2)
                {
                    GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.GuildLevel);
                }
                else
                {
                    guildWave = Asda2GuildWaveMgr.CreateGuildWave((int)client.ActiveCharacter.GuildId, difficulty, client.ActiveCharacter);
                    GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.Ok);
                    GuildWaveoOnResponseToRegisteredPlayers(guildWave.GuildId);
                }
            }
            else
            {
                if (guildWave.PlayersRegisteredCount < 20)
                {
                    if (guildWave.isPlayerRegistered(client.ActiveCharacter))
                    {
                        GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.AlreadyRegistered);
                    }
                    else
                    {
                        if (guildWave.IsInProgress)
                        {
                            GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.WaveInProgress);
                        }
                        else
                        {
                            guildWave.AddRegisteringPlayer(client.ActiveCharacter);
                            GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.Ok);
                            GuildWaveoOnResponseToRegisteredPlayers((int)client.ActiveCharacter.GuildId);
                        }
                    }
                }
                else
                {
                    GuildWaveRegisterResponse(client, GuildWaveRegisterStatus.Full);
                }
            }
        }