예제 #1
0
        void HandleChallengePlayerMessage(ChallengePlayer message)
        {
            ServerPlayer challenger = GetPlayerBySecret(message.Secret);
            ServerPlayer challenged = GetPlayerById(message.ChallengedId);

            if (challenger == challenged)
            {
                return;
            }

            foreach (Challenge chal in _challenges)
            {
                if (chal.Challenger == challenger || chal.Challenged == challenged || chal.Challenger == challenged || chal.Challenged == challenger)
                {
                    return;
                }
            }

            var challenge = new Challenge(challenger, challenged);

            _challenges.Add(challenge);

            BaseServer.SendTo(challenged.NetPlayer, new Messages.Challenge(challenger.Id, challenged.Id));
        }