Esempio n. 1
0
        public void PlayCard(GeneralistProto proto, ref Player player)
        {
            Card card;

            if (this.isWaited != CGame.Types.Cmd.Card)
            {
                PlayerSession.BeginSend(ref player, "It's not the time to put a contract up.");
                return;
            }
            if (!HisTurn(ref player))
            {
                PlayerSession.BeginSend(ref player, "Please wait your turn to do a contract.");
                return;
            }

            try {
                card = GetCard(proto, ref player);
            } catch (Exception e) {
                PlayerSession.BeginSend(ref player, e.Message);
                return;
            }

            foreach (PlayedCard toplay in turn)
            {
                if (player.Name.Equals(toplay.player.Name))
                {
                    toplay.card = card;
                }
            }

            Broadcast(player.Name + " played: " + Card._names[(int)card.face] + " " + Card._colors[(int)card.color]);
            player.hand.Remove(card);

            Player tmp;

            if (hasToPlay < 3)
            {
                hasToPlay += 1;
                tmp        = GetToPlay();
                PlayerSession.BeginSend(ref tmp, "It's your turn to play a card.");
            }
            else
            {
                hasToPlay = 0;
                ConcludeTurn();
                if (blue.player1.hand.Count == 0)
                {
                    Broadcast("This hand is over, a new one will begin soon");
                    Reset();
                    if (IsOver())
                    {
                        return;
                    }
                    Broadcast("Your card has been redistribute");
                    isWaited = CGame.Types.Cmd.Contract;
                    return;
                }
                tmp = GetToPlay();
                PlayerSession.BeginSend(ref tmp, "It's your turn to play a card");
            }
        }
Esempio n. 2
0
        public void Contract(GeneralistProto proto, ref Player player)
        {
            if (this.isWaited != CGame.Types.Cmd.Contract)
            {
                PlayerSession.BeginSend(ref player, "It's not the time to put a contract up.");
                return;
            }
            if (!HisTurn(ref player))
            {
                PlayerSession.BeginSend(ref player, "Please wait your turn to do a contract.");
                return;
            }
            PlayerSession.BeginSend(ref player, "We are taking into count your contract");
            try {
                Contract contract = getFromCmd(ref player, proto);
                try {
                    NewContract(ref player, ref contract);
                    Broadcast(player.Name + " has put a contract on " + _contracts[(int)contract.type] + " of value " + contract.scale);
                } catch (Exception e) {
                    PlayerSession.BeginSend(ref player, e.Message);
                    return;
                }
            } catch (Exception e) {
                System.Console.Error.WriteLine(e.Message);
                if (proto.Gamecmd.Value.Split(' ')[0].Equals("Coinche"))
                {
                    if (_contract == null)
                    {
                        PlayerSession.BeginSend(ref player, "You can't put a coinche, if there is not existing contract");
                        return;
                    }
                    if (_contract.team == player.Team && _contract.coinche != 2)
                    {
                        PlayerSession.BeginSend(ref player, "You can't put a coinche on your team contract");
                        return;
                    }
                    _contract.coinche *= 2;
                    Broadcast(player.Name + " has put a coinche on the actual contract");
                }
                else if (proto.Gamecmd.Value.Split(' ')[0].Equals("Pass"))
                {
                    Broadcast(player.Name + " has pass this turn");
                }
                else
                {
                    PlayerSession.BeginSend(ref player, "Unrecognized contract");
                    return;
                }
            }
            Player tmp;


            if (hasToPlay < 3)
            {
                hasToPlay += 1;
                tmp        = GetToPlay();
                PlayerSession.BeginSend(ref tmp, "It's your turn to put a contract.");
            }
            else
            {
                if (_contract == null)
                {
                    NextTurn();
                    return;
                }
                hasToPlay = 0;
                Broadcast("The contract turn is now over, first turn of game can start");
                tmp = GetToPlay();
                PlayerSession.BeginSend(ref tmp, "It's your turn to play a card");
                isWaited = CGame.Types.Cmd.Card;
            }
        }