Example #1
0
        private void DetermineRoundResult()
        {
            short defeatedPlayer = -1;

            // the round is a tie
            if (ChosenBluePiece.PieceType.Equals(ChosenRedPiece.PieceType))
            {
            }
            else
            {
                // check to see if blue is defeated
                foreach (var defeatablePiece in ChosenRedPiece.Defeats)
                {
                    // blue's chosen piece matches a defeatable piece of red's chosen piece
                    if (ChosenBluePiece.PieceType.Equals(defeatablePiece.PieceType))
                    {
                        defeatedPlayer = (short)VMEODWarGamePlayers.Blue;
                    }
                }
                // if blue is not defeated, check to see if red is defeated
                if (defeatedPlayer == -1)
                {
                    foreach (var defeatablePiece in ChosenBluePiece.Defeats)
                    {
                        // red's chosen piece matches a defeatable piece of blue's chosen piece
                        if (ChosenRedPiece.PieceType.Equals(defeatablePiece.PieceType))
                        {
                            defeatedPlayer = (short)VMEODWarGamePlayers.Red;
                        }
                    }
                }
            }
            // blue is defeated
            if (defeatedPlayer == 0)
            {
                Players[defeatedPlayer].Pieces.Remove(ChosenBluePiece);
                RedPlayerClient.Send("WarGame_Victory", new Byte[] { (byte)ChosenBluePiece.PieceType, (byte)ChosenRedPiece.PieceType });
                BluePlayerClient.Send("WarGame_Defeat", new Byte[] { (byte)ChosenBluePiece.PieceType, (byte)ChosenRedPiece.PieceType });
                ControllerClient.SendOBJEvent(new VMEODEvent((short)VMEODWarGameEvents.RoundOver, (short)VMEODWarGamePlayers.Red));
            }
            // red is defeated
            else if (defeatedPlayer == 1)
            {
                Players[defeatedPlayer].Pieces.Remove(ChosenRedPiece);
                BluePlayerClient.Send("WarGame_Victory", new Byte[] { (byte)ChosenBluePiece.PieceType, (byte)ChosenRedPiece.PieceType });
                RedPlayerClient.Send("WarGame_Defeat", new Byte[] { (byte)ChosenBluePiece.PieceType, (byte)ChosenRedPiece.PieceType });
                ControllerClient.SendOBJEvent(new VMEODEvent((short)VMEODWarGameEvents.RoundOver, (short)VMEODWarGamePlayers.Blue));
            }
            // round is a tie
            else
            {
                BluePlayerClient.Send("WarGame_Tie", new Byte[] { (byte)ChosenBluePiece.PieceType, (byte)ChosenRedPiece.PieceType });
                RedPlayerClient.Send("WarGame_Tie", new Byte[] { (byte)ChosenBluePiece.PieceType, (byte)ChosenRedPiece.PieceType });
                RoundMessageTimer.Start();
            }
            ChosenBluePiece = null;
            ChosenRedPiece  = null;
        }
Example #2
0
        private void SetPlayerPiece(int playerNumber, VMEODWarGamePiece chosenPiece)
        {
            if (playerNumber == (short)VMEODWarGamePlayers.Blue)
            {
                ChosenBluePiece = chosenPiece;
            }
            else
            {
                ChosenRedPiece = chosenPiece;
            }

            if ((ChosenBluePiece != null) && (ChosenRedPiece != null))
            {
                DetermineRoundResult();
            }
        }