コード例 #1
0
ファイル: HumanPlayer.cs プロジェクト: manboygames/capsa
    protected override HandType PlayHand(bool newRound, bool requireLowestCard)
    {
        HandType handType = base.PlayHand(newRound, requireLowestCard);

        if (handType == HandType.Invalid)
        {
            //dont play if hand invalid
            return(HandType.Invalid);
        }

        uiManager.SetPlayerButtonsActive(false, newRound);

        var msg = new ClientPlayHandMsg();

        msg.cardDatas      = hand.PlayedHandData.ToArray();
        msg.handType       = handType;
        msg.remainingCards = hand.RemainingCards;
        msg.playingSet     = hand.PlayedHandData.Count == 5; //if hand is a set
        client.Send(ClientPlayHandMsg.msgID, msg);

        return(handType);
    }
コード例 #2
0
ファイル: BotPlayer.cs プロジェクト: manboygames/capsa
    protected override HandType PlayHand(bool newRound, bool requireLowestCard)
    {
        HandType handType = HandType.Invalid;

        List <CardData> tempHand = new List <CardData>();

        if (requireLowestCard)
        {
            Debug.Log(playerName + " is playing in first round");

            tempHand = BotFirstPlays();

            if (tempHand != null)
            {
                handType = HandEvaluator.EvaluateHand(tempHand);

                var msg = new ClientPlayHandMsg();
                msg.cardDatas      = tempHand.ToArray();
                msg.handType       = handType;
                msg.remainingCards = hand.RemainingCards;
                msg.playingSet     = tempHand.Count == 5; //if hand is a set
                client.Send(ClientPlayHandMsg.msgID, msg);

                return(HandEvaluator.EvaluateHand(tempHand));
            }
        }

        if (newRound)
        {
            Debug.Log(playerName + " is first player in new round");

            tempHand = BotPlays();

            if (tempHand != null)
            {
                hand.RemainingCards -= tempHand.Count;

                handType = HandEvaluator.EvaluateHand(tempHand);

                var msg = new ClientPlayHandMsg();
                msg.cardDatas      = tempHand.ToArray();
                msg.handType       = handType;
                msg.remainingCards = hand.RemainingCards;
                msg.playingSet     = tempHand.Count == 5; //if hand is a set
                client.Send(ClientPlayHandMsg.msgID, msg);

                return(handType);
            }
        }

        List <CardData> gameHand = gameManager.currentPlayedHand.ToDynList();

        int gameHandCount = gameHand.Count;

        if (hand.cardDatas.Count < gameHandCount)
        {
            //return invalid if amount of cards less than played hand in game
            return(HandType.Invalid);
        }

        tempHand = BotCounterPlays(gameHandCount);

        if (tempHand == null) //if bot has valid hand to play
        {
            //bot pass
            return(HandType.Invalid);
        }
        else
        {
            //send hand to server
            hand.RemainingCards -= tempHand.Count;

            handType = HandEvaluator.EvaluateHand(tempHand);

            var msg = new ClientPlayHandMsg();
            msg.cardDatas      = tempHand.ToArray();
            msg.handType       = handType;
            msg.remainingCards = hand.RemainingCards;
            msg.playingSet     = tempHand.Count == 5; //if hand is a set
            client.Send(ClientPlayHandMsg.msgID, msg);

            return(handType);
        }
    }