コード例 #1
0
    public EvaluatedHand evaluateHand(List <Card> cards)
    {
        if (cards.Count <= 2)
        {
            return(null);
        }

        assert(cards);
        string goal   = "X:evaluate(X).";
        string result = UnityExtensionMethods.SolveForParsed(kB, goal).ToString();

        List <Card> EvaluatedCards = new List <Card> ();

        for (int i = 1; i < 6; i++)
        {
            string cardValue = "X:cardValue(X," + i.ToString() + ").";
            string cardSuit  = "Y:cardSuit(Y," + i.ToString() + ").";
            int    v         = int.Parse(UnityExtensionMethods.SolveForParsed(kB, cardValue).ToString());
            var    s         = UnityExtensionMethods.SolveForParsed(kB, cardSuit);
            EvaluatedCards.Add(new Card(v, s.ToString()));
        }

        string straightPotentialCase = "Y:straightPotential(Y).";
        int    straightPotential     = int.Parse(UnityExtensionMethods.SolveForParsed(kB, straightPotentialCase).ToString());

        string flushPotentialCase = "Y:flushPotential(Y).";
        int    flushPotential     = int.Parse(UnityExtensionMethods.SolveForParsed(kB, flushPotentialCase).ToString());

        EvaluatedHand evaluatedhand = new EvaluatedHand(result, EvaluatedCards, straightPotential, flushPotential);

        retract();
        return(evaluatedhand);
    }
コード例 #2
0
 protected int CompareKickers(EvaluatedHand otherHand)
 {
     for (int i = 0; i < kickers.Count; i++){
         int kickerComparison = ((Card)kickers[i]).CompareTo((Card)otherHand.kickers[i]);
         if (kickerComparison != 0){
             return kickerComparison;
         }
     }
     return 0;
 }
コード例 #3
0
 public int CompareTo(EvaluatedHand otherHand)
 {
     if (typeValue < otherHand.typeValue){
         return -1;
     } else if (typeValue > otherHand.typeValue){
         return 1;
     } else {
         return CompareCardValues(otherHand);
     }
 }
コード例 #4
0
 protected override int CompareCardValues(EvaluatedHand otherHand)
 {
     ThreeOfAKind otherThreeOfAKind = (ThreeOfAKind)otherHand;
     int threeOfAKindComparison = ((Card)threeOfAKind[0]).CompareTo((Card)otherThreeOfAKind.threeOfAKind[0]);
     if (threeOfAKindComparison != 0){
         return threeOfAKindComparison;
     } else {
         return CompareKickers(otherHand);
     }
 }
コード例 #5
0
 protected override int CompareCardValues(EvaluatedHand otherHand)
 {
     OnePair otherOnePair = (OnePair)otherHand;
     int pairComparison = ((Card)pair[0]).CompareTo((Card)otherOnePair.pair[0]);
     if (pairComparison != 0){
         return pairComparison;
     } else {
         return CompareKickers(otherHand);
     }
 }
コード例 #6
0
 protected override int CompareCardValues(EvaluatedHand otherHand)
 {
     FourOfAKind otherFourOfAKind = (FourOfAKind)otherHand;
     int fourOfAKindComparison = ((Card)fourOfAKind[0]).CompareTo((Card)otherFourOfAKind.fourOfAKind[0]);
     if (fourOfAKindComparison != 0){
         return fourOfAKindComparison;
     } else {
         return CompareKickers(otherHand);
     }
 }
コード例 #7
0
 protected override int CompareCardValues(EvaluatedHand otherHand)
 {
     FullHouse otherFullHouse = (FullHouse)otherHand;
     int threeOfAKindComparison = ((Card)threeOfAKind[0]).CompareTo((Card)otherFullHouse.threeOfAKind[0]);
     if (threeOfAKindComparison != 0){
         return threeOfAKindComparison;
     } else {
         int pairComparison = ((Card)pair[0]).CompareTo((Card)otherFullHouse.pair[0]);
         return pairComparison;
     }
 }
コード例 #8
0
    public void setHandEvaluated(EvaluatedHand evaluatedhand)
    {
        this.evaluatedhand = evaluatedhand;

        handStrength = HandStrengthEvaluater.Evaluate
                           (evaluatedhand.name, cards, evaluatedhand.Cards, gameManager.gameStatus()) / 100f;
        int rank = HandStrengthEvaluater.rank(evaluatedhand.name);

        handPotential = HandPotentialEvaluater.Evaluate
                            (rank, evaluatedhand.flushPotential, evaluatedhand.straightPotential, gameManager.gameStatus()) / 10f;

        ExecuteEvents.Execute <PlayerHandler> (Player.gameObject, null, (x, y) => x.HandIsEvaluated());
    }
コード例 #9
0
 public ShowDownStage(Board board, Pot pot, ArrayList players, PCPokerAction pcPlayer)
 {
     this.pot = pot;
     this.board = board;
     this.players = players;
     this.pcPlayer = pcPlayer;
     buttonPressed = false;
     winnerName = null;
     loserName = null;
     winningHand = null;
     losingHand = null;
     isDraw = false;
     showDownDone = false;
 }
コード例 #10
0
 protected override int CompareCardValues(EvaluatedHand otherHand)
 {
     TwoPair otherTwoPair = (TwoPair)otherHand;
     int pair1Comparison = ((Card)pair1[0]).CompareTo((Card)otherTwoPair.pair1[0]);
     if (pair1Comparison != 0){
         return pair1Comparison;
     } else {
         int pair2Comparison = ((Card)pair2[0]).CompareTo((Card)otherTwoPair.pair2[0]);
         if (pair2Comparison != 0){
             return pair2Comparison;
         } else {
             return CompareKickers(otherHand);
         }
     }
 }
コード例 #11
0
 protected abstract int CompareCardValues(EvaluatedHand otherHand);
コード例 #12
0
    private void InstanceDrawShowDownGUI(int potSize, string winnerName, string loserName, EvaluatedHand winningHand, EvaluatedHand losingHand, bool isDraw, bool mustQuit, ShowDownStage stage)
    {
        GUILayout.BeginArea(new Rect(showDownTopLeftCorner.x, showDownTopLeftCorner.y, 1000, 1000));
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        GUILayout.BeginVertical(backgroundStyle);
        if (!isDraw){
            GUILayout.Label(winnerName + " wins $" + potSize);
        } else {
            GUILayout.Label("It's a draw!");
        }
        DrawShowDownHand(winnerName, winningHand);
        DrawShowDownHand(loserName, losingHand);
        GUILayout.BeginHorizontal();
        if (!mustQuit){
            if (GUILayout.Button("Continue")){
                FModManager.StartEvent(FModLies.EVENTID_LIES_STARTMENU_MOUSECLICKED);
                stage.ContinuePressed();
            }
        }
        if (GUILayout.Button("Quit")){
            FModManager.StartEvent(FModLies.EVENTID_LIES_STARTMENU_MOUSECLICKED);
            stage.QuitPressed();
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();

        GUILayout.FlexibleSpace();
        GUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
コード例 #13
0
 private void DrawShowDownHand(string playerName, EvaluatedHand hand)
 {
     if (hand == null){
         Debug.LogError("PokerGUI.DrawShowDownHand(" + playerName + "null): ERROR: hand cannot  be null" );
         return;
     }
     GUILayout.BeginVertical();
     GUILayout.Label(playerName + ": " + hand.GetName());
     GUILayout.BeginHorizontal();
     foreach (Card card in hand.GetCardsInOrder()){
         //GUIStyle cardStyle = new GUIStyle();
         GUILayout.Label(card.GetTexture(), "showdown_card");
     }
     GUILayout.EndHorizontal();
     GUILayout.EndVertical();
 }
コード例 #14
0
    public bool UpdateStage()
    {
        if (!showDownDone){
            //showdown-ääni
            showDownDone = true;
            ArrayList participants = new ArrayList();
            foreach (PokerPlayer player in players){
                if (pot.IsIn(player)){
                    participants.Add(player);
                }
            }
            ArrayList winners = new ArrayList();
            foreach (PokerPlayer participant in participants){
                if (winners.Count == 0){
                    winners.Add(participant);
                } else if (participant.GetEvaluatedHand(board.GetCards()).CompareTo(
                        ((PokerPlayer)winners[0]).GetEvaluatedHand(board.GetCards())) > 0){
                    winners.Clear();
                    winners.Add(participant);
                } else if (participant.GetEvaluatedHand(board.GetCards()).CompareTo(
                        ((PokerPlayer)winners[0]).GetEvaluatedHand(board.GetCards())) == 0){
                    winners.Add(participant);
                }
            }

            PokerPlayer winner = null;
            PokerPlayer loser = null;
            if (winners.Count > 1){
                isDraw = true;
                winner = (PokerPlayer)winners[0];
                loser = (PokerPlayer)winners[1];
            } else {
                isDraw = false;
                winner = (PokerPlayer)winners[0];
                foreach (PokerPlayer player in players){
                    if (player != winner){
                        loser = player;
                    }
                }
            }
            winnerName = winner.GetName();
            loserName = loser.GetName();
            winningHand = winner.GetEvaluatedHand(board.GetCards());
            losingHand = loser.GetEvaluatedHand(board.GetCards());

            foreach (PokerPlayer sharer in winners){
                int share = pot.GetPotSize() / winners.Count;
                sharer.Win(share);
            }

            if (!isDraw){
                pcPlayer.SendPerception(winners.Contains(pcPlayer), pot.GetPotSize() - pot.GetHighestBet());
            }
        }
        return buttonPressed;
    }
コード例 #15
0
 protected override int CompareCardValues(EvaluatedHand otherHand)
 {
     return CompareKickers(otherHand);
 }
コード例 #16
0
 public void HandWinning(EvaluatedHand EvalHand)
 {
     HandType.text = EvalHand.name;
 }
コード例 #17
0
 public static void DrawShowDownGUI(int potSize, string winnerName, string loserName, EvaluatedHand winningHand, EvaluatedHand losingHand, bool isDraw, bool mustQuit, ShowDownStage stage)
 {
     instance.InstanceDrawShowDownGUI(potSize, winnerName, loserName, winningHand, losingHand, isDraw, mustQuit, stage);
 }