예제 #1
0
파일: RPS_Player.cs 프로젝트: jhoak/Tableau
 public void selectCard(RPS_Card sCard) //called from the card
 {                                      //so only the former selection's deselect method needs to be called
     if (selectedCard != null)
     {
         selectedCard.deselect();
     }
     selectedCard = sCard;
 }
예제 #2
0
    RPS_Player find_winner()
    {
        /*RPS_Card[] chosenCards = new RPS_Card[numPlayers];
         * for(int i = 0; i < numPlayers; i++)
         * {
         *  chosenCards[i] = players[i].getCard();
         * } *///for >2 players

        //EditorUtility.DisplayDialog("Test!", "Player 1: " + player1.getCard().value() + "\nPlayer 2: " + player2.getCard().value(), "OK");

        RPS_Card c1 = player1.getCard();
        RPS_Card c2 = player2.getCard();

        if (c1 == null)
        {
            if (c2 == null)
            {
                return(null);
            }
            return(player2);
        }
        if (c2 == null)
        {
            return(player1);
        }
        if (c1.value().Equals(c2.value()))
        {
            return(null);
        }
        if (c1.beatsCard(c2))
        {
            return(player1);
        }



        //switch (c1.beatsCard(c2))
        //{

        //}

        return(player2);
    }
예제 #3
0
    public bool beatsCard(RPS_Card other)      //API function to be extended per game
    {
        if (other == null)
        {
            return(true);
        }

        string cVal = other.value();    //General API function

        //bool retVal=false;

        if (cardType.Equals("rock"))
        {
            return(cVal.Equals("scissors"));
        }
        else if (cardType.Equals("scissors"))
        {
            return(cVal.Equals("paper"));
        }
        return(cVal.Equals("rock"));
    }