Example #1
0
        private void countScore()
        {
            int team1 = 0;
            int team2 = 0;

            foreach (Player i in players)
            {
                i.countScore();
                Network.SendAll(players, "Player " + i.getId() + " of the " + i.getTeam() + " team got " + i.getScore() + " points.");
                if (i.getTeam() == Team.FIRST)
                {
                    team1 += i.getScore();
                }
                else
                {
                    team2 += i.getScore();
                }
            }
            Network.SendAll(players, Team.FIRST + " team got " + team1 + " points.");
            Network.SendAll(players, Team.SECOND + " team got " + team2 + " points.");
            switch (bid.getStatus())
            {
            case Status.CAPOT:
                Network.SendAll(players, "The bid was capot by " + bid.getTeam() + " team.");
                if ((bid.getTeam() == Team.FIRST ? team2 : team1) != 0)
                {
                    Network.SendAll(players, bid.getTeam() + " failed their capot. " + (bid.getTeam() == Team.FIRST ? Team.SECOND : Team.FIRST) + " won.");
                }
                else
                {
                    Network.SendAll(players, bid.getTeam() + " achieved their capot. They won.");
                }
                break;

            case Status.COINCH:
                Network.SendAll(players, "The bid was a coinch by the " + bid.getTeam() + " team on a bet of " + bid.getAmount() + " points.");
                if ((bid.getTeam() == Team.FIRST ? team2 : team1) <= bid.getAmount())
                {
                    Network.SendAll(players, (bid.getTeam() == Team.FIRST ? Team.SECOND : Team.FIRST) + " failed their contract and " + bid.getTeam() + " conched. " + bid.getTeam() + " won.");
                }
                else
                {
                    Network.SendAll(players, (bid.getTeam() == Team.FIRST ? Team.SECOND : Team.FIRST) + " achieved their contract and " + bid.getTeam() + " conched. " + (bid.getTeam() == Team.FIRST ? Team.SECOND : Team.FIRST) + " won.");
                }
                break;

            case Status.SURCOINCH:
                Network.SendAll(players, "The bid was a surcoinch by the " + bid.getTeam() + " team on a bet of " + bid.getAmount() + " points.");
                if ((bid.getTeam() == Team.FIRST ? team1 : team2) < bid.getAmount())
                {
                    Network.SendAll(players, bid.getTeam() + " failed their contract and they surcoinched. " + (bid.getTeam() == Team.FIRST ? Team.SECOND : Team.FIRST) + " won.");
                }
                else
                {
                    Network.SendAll(players, bid.getTeam() + " achieved their contract and they surcoinched. " + bid.getTeam() + " won!");
                }
                break;

            case Status.AMOUNT:
                Network.SendAll(players, "The bid was " + bid.getAmount() + " points by the " + bid.getTeam() + " team.");
                if ((bid.getTeam() == Team.FIRST ? team1 : team2) >= bid.getAmount())
                {
                    Network.SendAll(players, bid.getTeam() + " managed to fulfill their contract. They won!");
                }
                else
                {
                    Network.SendAll(players, bid.getTeam() + " failed to fulfill their contract. " + (bid.getTeam() == Team.FIRST ? Team.SECOND : Team.FIRST) + " won!");
                }
                break;
            }
        }
Example #2
0
        public Bid auction(Bid bid)
        {
            int  n;
            bool end = false;

            if (bid.getAmount() != 0)
            {
                Network.SendPrivate(this, "The actual bill is " + bid.getAmount() + " " + bid.getSuit() + " from " + bid.getTeam() + " team.\n");
            }
            else
            {
                Network.SendPrivate(this, "You are the first one to bid!");
            }
            Network.SendPrivate(this, "Player " + id + " turn to bid:");
            while (!end)
            {
                string str = "What do you want to do? ";
                switch (bid.getStatus())
                {
                case Status.AMOUNT:
                    str += "1->bid ";
                    goto case Status.CAPOT;

                case Status.CAPOT:
                    str += "2->coinche ";
                    goto case Status.COINCH;

                case Status.COINCH:
                    if (bid.getStatus() == Status.COINCH)
                    {
                        str += "3->surcoinche ";
                    }
                    break;

                case Status.SURCOINCH:
                    Network.SendPrivate(this, "You can't bid anymore.");
                    passed = true;
                    return(bid);
                }
                if (bid.getStatus() == Status.AMOUNT)
                {
                    str += "4->capot ";
                }
                Network.SendPrivate(this, str + "5->pass");
                n   = WaitForMessage();
                end = true;
                switch (n)
                {
                case 1:
                    Network.SendPrivate(this, "What is the amount of your bid ? (>= " + (bid.getAmount() == 0 ? 80 : bid.getAmount() + 10) + ")");
                    if (!bid.setAmount(WaitForMessage()) || bid.getStatus() != Status.AMOUNT)
                    {
                        Network.SendPrivate(this, "Incorrect input");
                        end = false;
                        break;
                    }
                    Network.SendPrivate(this, "What is the suit ? (0->CLUB | 1->DIAMOND | 2->HEART | 3->SPADE)");
                    n = WaitForMessage();
                    if (n < 0 || n > 3)
                    {
                        Network.SendPrivate(this, "Incorrect input");
                        end = false;
                        break;
                    }
                    bid.setSuit(n);
                    bid.setTeam(this.team);
                    passed = false;
                    break;

                case 2:
                    if (bid.getStatus() != Status.AMOUNT && bid.getStatus() != Status.CAPOT)
                    {
                        Network.SendPrivate(this, "Incorrect input");
                        end = false;
                        break;
                    }
                    bid.setStatus(Status.COINCH);
                    passed = false;
                    break;

                case 3:
                    if (bid.getStatus() != Status.COINCH)
                    {
                        Network.SendPrivate(this, "Incorrect input");
                        end = false;
                        break;
                    }
                    bid.setStatus(Status.SURCOINCH);
                    passed = false;
                    break;

                case 4:
                    if (bid.getStatus() == Status.COINCH || bid.getStatus() == Status.SURCOINCH || bid.getStatus() == Status.CAPOT)
                    {
                        Network.SendPrivate(this, "Incorrect input");
                        end = false;
                        break;
                    }
                    bid.setStatus(Status.CAPOT);
                    bid.setTeam(team);
                    passed = false;
                    break;

                case 5:
                    passed = true;
                    break;

                default:
                    Network.SendPrivate(this, "Incorrect input");
                    end = false;
                    break;
                }
            }
            Network.SendPrivate(this, "Great!");
            return(bid);
        }