예제 #1
0
        public void ExchangeTest()
        {
            Player p1 = new Player("fn1", "ln1", 1);
            Player p2 = new Player("fn2", "ln2", 2);

            var exc = new PlayerExchange(p1, p2, 12, 24);

            Assert.AreEqual(p1, exc.PlayerOut);
            Assert.AreEqual(p2, exc.PlayerIn);
            Assert.AreEqual(12, exc.HomePoints);
            Assert.AreEqual(24, exc.GuestPoints);
        }
예제 #2
0
        public static void ProcessExchangeAcceptRequest(WorldClient Client)
        {
            if (!Client.IsGameAction(GameActionTypeEnum.BASIC_REQUEST))
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            if (!(Client.GetBaseRequest() is ExchangeRequest))
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }
            if (Client == Client.GetBaseRequest().Requester)
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }

            if (Client.GetBaseRequest().Accept())
            {
                Client.EndGameAction(GameActionTypeEnum.BASIC_REQUEST);

                var Trader = Client.GetBaseRequest().Requester;

                Client.SetBaseRequest(null);
                Trader.SetBaseRequest(null);

                var Exchange       = new PlayerExchange(Client, Trader);
                var ExchangeAction = new GameExchange(Client.Character, Exchange);

                Client.SetExchange(Exchange);
                Trader.SetExchange(Exchange);

                Client.AddGameAction(ExchangeAction);
                Trader.AddGameAction(ExchangeAction);

                var Message = new ExchangeCreateMessage(ExchangeTypeEnum.EXCHANGE_PLAYER);

                Client.Send(Message);
                Trader.Send(Message);

                return;
            }

            Client.Send(new BasicNoOperationMessage());
        }