Пример #1
0
        private static void ChooseContractHandler(PacketHeader header, Connection connection, byte[] info)
        {
            ContractRequest contract;

            using (MemoryStream stream = new MemoryStream(info))
            {
                contract = Serializer.Deserialize <ContractRequest>(stream);
            }

            Promise  promise  = AskUser.AskPromise(contract);
            GameMode gameMode = GameMode.ClassicClover;

            if (promise != Promise.Passe && promise != Promise.Coinche &&
                promise != Promise.ReCoinche)
            {
                gameMode = AskUser.AskGameMode();
            }

            if (!Lobby.IsGameStarted)
            {
                return;
            }
            using (MemoryStream streamResp = new MemoryStream())
            {
                ContractResponse resp = new ContractResponse
                {
                    Promise  = promise,
                    GameMode = gameMode
                };
                Serializer.Serialize(streamResp, resp);
                connection.SendObject("ChooseContractResp", streamResp.ToArray());
                Console.WriteLine("Response sent !");
            }
        }
Пример #2
0
        private static void GiveCardHandler(PacketHeader header, Connection connection, byte[] info)
        {
            int choice = AskUser.AskCard(Program.clientInfos.GetCards());

            if (!Lobby.IsGameStarted)
            {
                return;
            }

            using (var stream = new MemoryStream())
            {
                PlayCard card = new PlayCard
                {
                    CardValue = Program.clientInfos.GetCardType(choice),
                    CardColor = Program.clientInfos.GetCardColor(choice)
                };
                Program.clientInfos.PlayCard(choice);
                Serializer.Serialize(stream, card);
                connection.SendObject("GiveCard", stream.ToArray());
                Console.WriteLine("Card sent !");
            }
        }