示例#1
0
 public void sendRpslsRequest(string opp)
 {
     RockPaperScissorsLizardSpock rpsls = new RockPaperScissorsLizardSpock(name, opp, GameSituation.Connect);
     Packet packet = new Packet();
     packet.Flag = Flag.GameRequest;
     packet.Data = rpsls;
     Comm.OutgoingMessageHandler(packet);
 }
示例#2
0
 private void buttonGiveUp_Click(object sender, EventArgs e)
 {
     Packet packet = new Packet();
     packet.Flag = Flag.RPSLS;
     RockPaperScissorsLizardSpock rpsls = new RockPaperScissorsLizardSpock(name, opponent, GameSituation.Win);
     packet.Data = rpsls;
     OnRPSLSChoice(packet);
 }
示例#3
0
        private void buttonLizard_Click(object sender, EventArgs e)
        {
            Packet packet = new Packet();
            packet.Flag = Flag.RPSLS;
            RockPaperScissorsLizardSpock rpsls = new RockPaperScissorsLizardSpock(name, opponent, GameSituation.Normal);
            rpsls.YourHand = Hands.Lizard;
            packet.Data = rpsls;
            OnRPSLSChoice(packet);

            buttonRock.Enabled = false;
            buttonPaper.Enabled = false;
            buttonSpock.Enabled = false;
            buttonSiccors.Enabled = false;
        }
示例#4
0
        public override void GameCheck()
        {
            GameSituation situation = GameSituation.Normal;
            switch (ChosenHands[Players[0]])
            {
                case Hands.Rock:
                    switch (ChosenHands[Players[1]])
                    {
                        case Hands.Rock:
                            // TIE
                            situation = GameSituation.Tie;
                            break;
                        case Hands.Paper:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                        case Hands.Scissors:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                        case Hands.Lizard:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                        case Hands.Spock:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                    }
                    break;
                case Hands.Paper:
                    switch (ChosenHands[Players[1]])
                    {
                        case Hands.Rock:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                        case Hands.Paper:
                            // TIE
                            situation = GameSituation.Tie;
                            break;
                        case Hands.Scissors:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                        case Hands.Lizard:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                        case Hands.Spock:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                    }
                    break;
                case Hands.Scissors:
                    switch (ChosenHands[Players[1]])
                    {
                        case Hands.Rock:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                        case Hands.Paper:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                        case Hands.Scissors:
                            // TIE
                            situation = GameSituation.Tie;
                            break;
                        case Hands.Lizard:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                        case Hands.Spock:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                    }
                    break;
                case Hands.Lizard:
                    switch (ChosenHands[Players[1]])
                    {
                        case Hands.Rock:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                        case Hands.Paper:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                        case Hands.Scissors:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                        case Hands.Lizard:
                            // TIE
                            situation = GameSituation.Tie;
                            break;
                        case Hands.Spock:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                    }
                    break;
                case Hands.Spock:
                    switch (ChosenHands[Players[1]])
                    {
                        case Hands.Rock:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                        case Hands.Paper:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                        case Hands.Scissors:
                            // player 1 wins
                            situation = GameSituation.Win;
                            break;
                        case Hands.Lizard:
                            // player 2 wins
                            situation = GameSituation.Loss;
                            break;
                        case Hands.Spock:
                            // TIE
                            situation = GameSituation.Tie;
                            break;
                    }
                    break;
            }

            Packet packet = new Packet();
            packet.Flag = Flag.RPSLS;
            for (int i = 0; i < Players.Count; i++)
            {
                if (i == 1)
                {
                    if(situation == GameSituation.Win)
                        situation = GameSituation.Loss;
                    else if(situation == GameSituation.Loss)
                        situation = GameSituation.Win;
                }
                RockPaperScissorsLizardSpock g = new RockPaperScissorsLizardSpock(Players[i], Players[(i+1)%Players.Count], situation);
                g.YourHand = ChosenHands[Players[i]];
                g.OpponentHand = ChosenHands[Players[(i + 1)%2]];
                //g.YourHand = Rounds.Last()[Players[i]];
                //g.OpponentHand = Rounds.Last()[Players[(i+1)%Players.Count]];
                packet.Data = g;
                serverMain.SendResolvedGameSituation(Players[i], packet);

                if (situation == GameSituation.Win || situation == GameSituation.Tie || situation == GameSituation.Loss)
                {
                    serverMain.RemoveGame(this);
                }
            }
        }