Beispiel #1
0
        public void TestCardToHand()
        {
            System.Collections.Generic.List <Card> deck = new System.Collections.Generic.List <Card>();
            Card.Suits    suit = Card.Suits.Diamonds;
            Card.CardType typ  = Card.CardType.Five;
            Card          card = new Card(typ, suit);

            deck.Add(card);
            deck.Add(card);
            deck.Add(card);

            // Test the number of cards in the deck
            Assert.AreEqual(3, deck.Count);

            CardPlayer cardPlayer = new CardPlayer();

            //Test the number of cards on hand
            Assert.AreEqual(0, cardPlayer.HandValue);

            cardPlayer.addCardToHand();

            // Test the number of cards after play
            Assert.AreEqual(2, deck.Count);
            Assert.AreEqual(5, cardPlayer.HandValue);
        }
Beispiel #2
0
        public IEnumerator WinCards(CardPlayer player, params CardPanel[] cardPanels)
        {
            if (cardPanels == null || cardPanels.Length == 0)
            {
                yield break;
            }
            for (var i = cardPanels.Length - 1; i > 0; i--)
            {
                HoldPlace(cardPanels[i]);
            }

            yield return(null);

            var offset = Vector3.Scale(previewOffset, canvas.localScale);

            if (cardPanels.Length > 1)
            {
                cardPanels[0].Root.SetParent(cardPanels[1].Root);
            }

            for (var i = 1; i < cardPanels.Length - 1; i++)
            {
                yield return(TranslateWorld(cardPanels[i].Root, cardPanels[i + 1].Root.position + offset));

                cardPanels[i].Root.SetParent(cardPanels[i + 1].Root);
                SoundManager.Instance.PlayClip(SoundManager.Instance.CardFriction);
            }

            StartCoroutine(DeleteCards(player.Pivot, cardPanels));
        }
Beispiel #3
0
        private IEnumerator WinCard(CardPlayer winner, string playerId, CardPanel cardPanel, CardPanel[] wonPanels)
        {
            if (cardPanel == null)
            {
                if (wonPanels.Length > 1)
                {
                    CardManager.Instance.HoldPlace(cardPanel = wonPanels[0]);
                    yield return(CardManager.Instance.TranslateCard(cardPanel, wonPanels[1]));
                }
            }
            else
            {
                ColorManager.Instance.SetCardFocused(wonPanels);
                ColorManager.Instance.SetCardPlayed(cardPanel);
                cardPanel.Details.Player.RemoveCard(cardPanel);
                if (!cardPanel.IsRevealed)
                {
                    StartCoroutine(CardManager.Instance.TurnCard(cardPanel));
                }
                if (wonPanels.Length > 0)
                {
                    yield return(CardManager.Instance.TranslateCard(cardPanel, wonPanels[0]));
                }
            }


            if (PlayerExists(playerId))
            {
                Debug.Log(playerId + " - - - - - -");
            }
            var list = wonPanels.ToList();

            list.Insert(0, cardPanel);
            yield return(CardManager.Instance.WinCards(winner, list.ToArray()));
        }
Beispiel #4
0
        public void testInit()
        {
            _rollResultChances    = new Dictionary <int, double>();
            _invalidResultChances = new Dictionary <int, double>();

            //Initialize the rollChances
            _rollResultChances.Add(1, 0.0);
            _rollResultChances.Add(2, 0.2);
            _rollResultChances.Add(3, 0.3);
            _rollResultChances.Add(4, 0.5);
            _rollResultChances.Add(5, 0.0);
            _rollResultChances.Add(6, 0.2);

            _invalidResultChances.Add(7, 0.5);
            _invalidResultChances.Add(8, 0.2);
            _invalidResultChances.Add(9, 0.3);

            _cardPlayer = new CardPlayer("test first name", "test last name");
            _dicePlayerWithFixedChances       = new DicePlayer("test first name", "test last name", 4, 6);
            _dicePlayerWithRollChances        = new DicePlayer("Nick", "Taramas", _rollResultChances);
            _dicePlayerWithInvalidRollChances = new DicePlayer("Nick", "Taramas", _invalidResultChances);
            _cardDicePlayer = new CardDicePlayer("test first name", "test last name", _rollResultChances);

            _deckersMeeting = new DeckersMeeting();
        }
Beispiel #5
0
        /// <summary>
        /// Comparission of the values of each player at the end of the game, return a string with the result of the comparision.
        /// </summary>
        /// <param name="player1">Represent the Computer, an instance of CardPlayer object</param>
        /// <param name="player2">Represent the User, an instance of CardPlayer object</param>
        /// <returns></returns>
        public string CheckWinnerFinal(CardPlayer player1, CardPlayer player2)
        {
            var winneris = "NoWinner";

            var who = player1.MaxTotalHand().CompareTo((player2.MaxTotalHand() > 21) ? player2.MinTotalHand() :
                                                       player2.MaxTotalHand());

            if (who == 0)
            {
                winneris = string.Format("Have been a Tie to {0} ", player1.MaxTotalHand());
            }
            else if (who < 0)
            {
                winneris = string.Format("You Win!  {0} to {1} ",
                                         (player2.MaxTotalHand() > 21) ? player2.MinTotalHand() :
                                         player2.MaxTotalHand(),
                                         player1.MaxTotalHand());
            }
            else
            {
                winneris = string.Format("The Computer is the winner {0} to {1} ", player1.MaxTotalHand(),
                                         (player2.MaxTotalHand() > 21) ? player2.MinTotalHand() :
                                         player2.MaxTotalHand());
            }

            return(winneris);
        }
Beispiel #6
0
 public void RunGame()
 {
     InitializeGame();
     do
     {
         foreach (var player in players)
         {
             if (player.AmountOfMonies + 50 > 1)
             {
                 int initialBet = ConsoleIO.PromptForInt("Take Initial Bet", 1, player.AmountOfMonies + 50);
                 c.TakeInitialBet(player, initialBet);
             }
         }
         Console.WriteLine("You New Round...");
         for (int i = 0; i < players.Count; i++)
         {
             if (players[i].AmountOfMonies > -51)
             {
                 currentPlayer = players[i];
                 RunTurn();
             }
         }
         c.RunHouseTurn();
     } while (!c.IsGameOver);
 }
Beispiel #7
0
 void SetupPlayerCards(CardPlayer player)
 {
     for (int i = 0; i < player.Hand.Count; i++)
     {
         AbilityCard newCard = player.Hand.GetCard(i);
         _playerView.AddNewCard(newCard);
     }
 }
Beispiel #8
0
        public IEnumerator CardPlayed(CardPanel newPanel)
        {
            var oldPanel = CardManager.Instance.GetCards()
                           .Where(panel => panel.Card.number == newPanel.Card.number)
                           .OrderBy(panel => panel.Details.Index)
                           .FirstOrDefault();

            if (oldPanel)
            {
                var number = newPanel.Card.number;
                var groups = CardManager.Instance.GetCards().Where(panel => panel.Card.number >= number)
                             .OrderBy(panel => panel.Card.number)
                             .GroupBy(panel => panel.Card.number)
                             .TakeWhile(group => group.First().Card.number == number++);
                var cards = groups.Select(group => group.First()).ToList();
                cards.Insert(0, newPanel);
                var list = cards.ToArray();

                ColorManager.Instance.SetCardFocused(list);
                ColorManager.Instance.SetCardPlayed(newPanel);

                yield return(CardManager.Instance.TranslateCard(newPanel, oldPanel));

                StartNewMove();
                if (oldPanel.Details.Turn == newPanel.Details.Turn &&
                    oldPanel.Details.Index == newPanel.Details.Index - 1 &&
                    oldPanel.Details.Player is CardMainPlayer)
                {
                    yield return(SpecialMove(newPanel, oldPanel));

                    if (IsCompleted)
                    {
                        if (!_countDictionary.ContainsKey(oldPanel.Details.Player))
                        {
                            _countDictionary.Add(oldPanel.Details.Player, 0);
                        }
                        _countDictionary[oldPanel.Details.Player]++;
                    }
                }
                else
                {
                    SetCompleted(false);
                }

                if (!IsCompleted)
                {
                    _lastWinner = newPanel.Details.Player;
                    yield return(CardManager.Instance.WinCards(_lastWinner, list));

                    _lastWinner.ReportScore(list.Length);
                    yield break;
                }

                ColorManager.Instance.SetCardDefault(list);
            }

            yield return(CardManager.Instance.AddCard(newPanel));
        }
    public override void Draw(CardPlayer player)
    {
        base.Draw(player);

        if (DiscardEffect != null)
        {
            DiscardEffect.Activate(player);
        }
    }
Beispiel #10
0
        private static IEnumerator GameFinished(CardPlayer lastWinner, CardPlayer winner, CardPanel[] remainedCards)
        {
            if (remainedCards.Length > 1)
            {
                yield return(CardManager.Instance.TranslateCard(remainedCards[0], remainedCards[1]));
            }
            yield return(CardManager.Instance.WinCards(lastWinner, remainedCards));

            Debug.LogFormat("Winner : {0}, Score : {1}", winner.Name, winner.Score);
        }
    public override void Enter()
    {
        _player = StateMachine.PlayerController.CurrentPlayer;

        Debug.Log("Player Card Select");
        _input.PressedRight   += OnPressedRight;
        _input.PressedLeft    += OnPressedLeft;
        _input.PressedConfirm += OnPressedConfirm;

        Debug.Log("Initial Selected Card: " + _player.CurrentSelectedCard.Name);
    }
Beispiel #12
0
    public void AddToHand(NetworkIdentity id)
    {
        Card c = id.GetComponent <Card>();

        if (c != null)
        {
            c.gameObject.layer = CardPlayer.UnityTrashWorkaround(PlayerHandLayer);
            AddCard(c);
            c.SetState(CardState.OnHand);
        }
    }
Beispiel #13
0
    public override void Enter()
    {
        Debug.Log("PLAYER TURN");
        _player = _playerController.CurrentPlayer;

        // start player turn setup animation
        if (_playerStartRoutine != null)
        {
            StopCoroutine(_playerStartRoutine);
        }
        _playerStartRoutine = StartCoroutine(TurnStartRoutine());
    }
Beispiel #14
0
        public static int MissingCards(CardPlayer card)
        {
            var nbCardsCollect = 0;

            for (int i = card.Level.Value; i < card.MaxLevel; i++)
            {
                nbCardsCollect += CardNumber[i];
            }
            nbCardsCollect -= card.Count.Value;

            return(nbCardsCollect * -1);
        }
Beispiel #15
0
    public void Setup(CardGameSM gameController)
    {
        _playerController = gameController.PlayerController;

        _playerView.Setup(_playerController.Players[0], gameController.TargetController);
        //TODO simulate that player is 0 index, in this case. Fix in the future
        CardPlayer playerToSetup = _playerController.Players[0];

        if (playerToSetup.Hand.Count > 0)
        {
            SetupPlayerCards(playerToSetup);
        }
    }
    public override void Enter()
    {
        Debug.Log("ENEMY TURN");
        _player = _playerController.CurrentPlayer;

        Debug.Log("Enemy draws 2 cards");
        int cardsToDraw = StateMachine.CardDrawPerTurn;

        _player.DrawAbilityCard(_cardsToDraw, _abilityCardDeck);

        Debug.Log("...Enemy Thinking...");
        if (_enemyPauseRoutine != null)
        {
            StopCoroutine(_enemyPauseRoutine);
        }
        _enemyPauseRoutine = StartCoroutine(EnemyPauseRoutine(_botPauseDuration));
    }
    public void UpdateCards(CardPlayer human, CardPlayer enemy)
    {
        string playerCards = "";
        string enemyCards = "";

        foreach (Card c in human.Hand().CardList()) {
            playerCards += c.Value()+ " ";

        }

        foreach (Card c in enemy.Hand().CardList()) {
            enemyCards += c.Value()+ " ";

        }

        debugBody.text = playerCards + "\n" + enemyCards;
    }
Beispiel #18
0
        public void TestBuldDeck()
        {
            Deck deck = new Deck();


            deck.Builddeck();

            // Test total number of cards in new created deck
            Assert.AreEqual(52, deck.DeckList.Count);

            CardPlayer cardPlayer = new CardPlayer();

            cardPlayer.Hand = deck.DeckList;
            cardPlayer.getHandValue();

            // Test maximum number of points that can appear in any blackjack game
            Assert.AreEqual(340, cardPlayer.HandValue);
        }
Beispiel #19
0
        /// <summary>
        /// Comparission of the values of each player during the process of the game, return a string with the result of the comparision.
        /// </summary>
        /// <param name="player1">Represent the Computer, an instance of CardPlayer object</param>
        /// <param name="player2">Represent the User, an instance of CardPlayer object</param>
        /// <returns></returns>
        public string CheckWinner(CardPlayer player1, CardPlayer player2)
        {
            var winneris = "NoWinner";

            if (player1.MaxTotalHand() == 21 && player2.MaxTotalHand() == 21)
            {
                winneris = String.Format("Have been a Tie to {0} ", 21);
            }
            else if (player1.MaxTotalHand() == 21 || (player2.MaxTotalHand() > 21 && player2.MinTotalHand() > 21))
            {
                winneris = string.Format("The Computer is the winner {0} to {1} ", player1.MaxTotalHand(), player2.MaxTotalHand());
            }
            else if (player2.MaxTotalHand() == 21 || player2.MinTotalHand() == 21)
            {
                winneris = string.Format("You Win!  {0} to {1} ", 21, player1.MaxTotalHand());
            }

            return(winneris);
        }
Beispiel #20
0
    // Start is called before the first frame update
    private void Start()
    {
        PlayerStatistics.InitializeStatDictionary();
        Camera = Camera.main;
        if (isLocalPlayer)
        {
            LocalPlayer = this;


            //Got replaced by a non dynamic function BoardLogic.ClientRequestEndTurn()
            //DebugPanelInfo dpi = FindObjectOfType<DebugPanelInfo>();
            //if (dpi != null)
            //{
            //    dpi.RegisterEndTurn(EndTurn);
            //}
            CmdRequestClientID();
        }

        ServerPlayers.Add(this);
        //Debug.Log($"isLocalPlayer: {isLocalPlayer}\nIsClient: {isClient}\nIsServer: {isServer}");
    }
Beispiel #21
0
    void Start()
    {
        cardPlayer = GetComponent <CardPlayer>();
        p1.SetDeckAndEnemy(deck, p2); //Test
        p2.SetDeckAndEnemy(deck, p1); //Test

        if (Random.Range(0, 2) == 0)
        {
            p1Turn = true;
            p2.TakeNCards(2);
            p1.TakeNCards(2);
            p1.StartTurn();
        }
        else
        {
            p1Turn = false;
            p1.TakeNCards(2);
            p2.TakeNCards(2);
            p2.StartTurn();
        }
    }
Beispiel #22
0
        public void TestHandValue()
        {
            CardPlayer cardPlayer = new CardPlayer();

            System.Collections.Generic.List <Card> cards = new System.Collections.Generic.List <Card>();
            Card.Suits    suit = Card.Suits.Diamonds;
            Card.CardType typ  = Card.CardType.Five;
            Card          card = new Card(typ, suit);

            cards.Add(card);
            cards.Add(card);
            cards.Add(card);



            cardPlayer.Hand = cards;

            cardPlayer.getHandValue();

            // Test correctness of card counting
            Assert.AreEqual(15, cardPlayer.HandValue);
        }
Beispiel #23
0
    public void ServerEndTurn()
    {
        CurrentTurn++;
        if (CurrentTurn >= CardPlayer.ServerPlayers.Count)
        {
            CurrentTurn = 0;
        }

        CardPlayer current = CardPlayer.ServerPlayers[CurrentTurn];

        CurrentTurnClient = current.ClientID;

        Debug.Log("Next Turn Client ID: " + CurrentTurnClient + "\nTurnNumber: " + CurrentTurn);
        if (CardPlayer.LocalPlayer != null)
        {
            CardPlayer.LocalPlayer.EnableInteractions = CardPlayer.LocalPlayer.ClientID == CurrentTurnClient;
        }
        MapTransformInfo.Instance.SocketManager.SetTurn(CurrentTurnClient);
        RpcBroadcastEndTurn(CurrentTurnClient);

        current.DrawCard(1);         //Next player is drawing one card
    }
    private CardPlayer player2; // player2 assumed to be AI

    #endregion Fields

    #region Methods

    private void SetupGame()
    {
        cardGame = new CardGame ();

        if (typeOfPlayer1 == PlayerType.Blind) {
            player1 = new CardPlayerBlind (cardGame, player1IsAI, 0);
        } else if (typeOfPlayer1 == PlayerType.Reflect) {
            player1 = new CardPlayerReflect (cardGame, player1IsAI, 0);
        } else if (typeOfPlayer1 == PlayerType.Mutation) {
            player1 = new CardPlayerMutation (cardGame, player1IsAI, 0);
        }

        if (typeOfPlayer2 == PlayerType.Blind) {
            player2 = new CardPlayerBlind(cardGame, player2IsAI, 0);
        } else if (typeOfPlayer2 == PlayerType.Reflect) {
            player2 = new CardPlayerReflect (cardGame, player2IsAI, 0);
        } else if (typeOfPlayer2 == PlayerType.Mutation) {
            player2 = new CardPlayerMutation (cardGame, player2IsAI, 0);
        }

        cardGame.InitializeData (player1, player2);
    }
Beispiel #25
0
 private void Awake()
 {
     instance = this;
 }
Beispiel #26
0
 public void GameFinished(CardPlayer winner, CardPanel[] remainedCards)
 {
     StartCoroutine(GameFinished(_lastWinner, winner, remainedCards));
 }
 public void InitializeData(CardPlayer p1, CardPlayer p2)
 {
     player1 = p1;
     player2 = p2;
     player1SelectedCardList = new Hand ();
     player2SelectedCardList = new Hand ();
     player1LastSelectedCardList = new List<Card>();
     player2LastSelectedCardList = new List<Card>();
     InitializeGame ();
 }
 public void MutateOpponent(CardPlayer initiatingPlayer)
 {
     if (initiatingPlayer == player1) {
         player2.MutateHand();
     } else if (initiatingPlayer == player2) {
         player1.MutateHand();
     }
 }
    public void AdvancePhase(int phaseOverride = -1)
    {
        int player1Sum, player2Sum, difference, cardCount;

        if (phaseOverride != -1) {
            phase = phaseOverride;
        } else if (phase == 5) {
            phase = 0;
        } else {
            phase++;
        }

        if (phase == 0) {
            RefillHands ();
            SetupNewTurn ();
            currentActiveSuit = CommonUtils.RandomSuit();

            CheckPlayersForPowerUse();
            Debug.Log ("Current Suit: " + currentActiveSuit.ToString ());

            Debug.Log ("Phase 0: Player and AI Hands Set Up");

            currentActivePlayerForInput = 1;
            GetNextPlayerHand();
        } else if (phase == 1) {
            Debug.Log ("Phase 1: Player and AI Initiative Cards Selected");

            AdvancePhase ();
        } else if (phase == 2) {
            player1Sum = 0;
            cardCount = 0;
            foreach (Card card in player1SelectedCardList.CardList ()) {
                player1Sum += CommonUtils.SuitAdjustedValue(currentActiveSuit, card);
                cardCount++;
                player1.Hand ().RemoveCard (card);
            }
            if (player2.IsAI ()) {
                player2.ProcessInitiativePhaseResult(cardCount, player1Sum);
            }
            player1LastHandScore = player1Sum;
            SetPlayer1SelectedCardList(player1SelectedCardList.CardList());

            player2Sum = 0;
            cardCount = 0;
            foreach (Card card in player2SelectedCardList.CardList ()) {
                player2Sum += CommonUtils.SuitAdjustedValue(currentActiveSuit, card);
                cardCount++;
                player2.Hand ().RemoveCard (card);
            }
            if (player1.IsAI ()) {
                player1.ProcessInitiativePhaseResult(cardCount, player2Sum);
            }
            player2LastHandScore = player2Sum;
            SetPlayer2SelectedCardList(player2SelectedCardList.CardList());

            ClearSelectedCardsList();

            if (reflectStatus%2 == 1) {
                // @BUGFIX
                Debug.Log ("Reflect activated, scores swapped");
                int temp = player1Sum;
                player1Sum = player2Sum;
                player2Sum = temp;

                player1LastHandScore = player1Sum;
                player2LastHandScore = player2Sum;
            }
            reflectStatus = 0;

            if (player1Sum > player2Sum) {
                initiativeWinner = player1;
                if (player1.IsAI ()) {
                    player1.ProcessInitiativePhaseOutcome(true);
                }
                if (player2.IsAI ()) {
                    player2.ProcessInitiativePhaseOutcome(false);
                }

                Debug.Log ("Phase 2: Initiative Phase Result: " + Player1HandScore() + "-" + Player2HandScore() + ": Initiative won by " + InitiativeWinner ().Name ());
            } else if (player2Sum > player1Sum) {
                initiativeWinner = player2;
                if (player1.IsAI ()) {
                    player1.ProcessInitiativePhaseOutcome(false);
                }
                if (player2.IsAI ()) {
                    player2.ProcessInitiativePhaseOutcome(true);
                }
                Debug.Log ("Phase 2: Initiative Phase Result: " + Player1HandScore() + "-" + Player2HandScore() + ": Initiative won by " + InitiativeWinner ().Name ());
            } else {
                initiativeWinner = null;
                Debug.Log ("Phase 2: Initiative Phase Result: Initiative Phase Tied, Returning to Phase 0");
                GrowCards();
                RefillHands ();
                AdvancePhase (0);
            }

            if (initiativeWinner == player1) {
                player1.AddSuperBar(superBarGainOnInitiativeWin);
                Debug.Log (player1.Name () + " gains " + superBarGainOnInitiativeWin + " super for winning initiative");
            } else if (initiativeWinner == player2) {
                player2.AddSuperBar(superBarGainOnInitiativeWin);
                Debug.Log (player2.Name () + " gains " + superBarGainOnInitiativeWin + " super for winning initiative");
            }

            CheckPlayersForPowerUse();

            currentActivePlayerForInput = 1;
            GetNextPlayerHand();
        } else if (phase == 3) {
            Debug.Log ("Phase 3: Player and AI Damage Cards Selected");

            AdvancePhase ();
        } else if (phase == 4) {
            player1Sum = 0;
            cardCount = 0;
            foreach (Card card in player1SelectedCardList.CardList ()) {
                player1Sum += CommonUtils.SuitAdjustedValue(currentActiveSuit, card);
                cardCount++;
                player1.Hand ().RemoveCard (card);
            }
            if (player2.IsAI ()) {
                player2.ProcessDamagePhaseResult(cardCount, player1Sum);
            }
            player1LastHandScore = player1Sum;
            SetPlayer1SelectedCardList(player1SelectedCardList.CardList());

            player2Sum = 0;
            cardCount = 0;
            foreach (Card card in player2SelectedCardList.CardList ()) {
                player2Sum += CommonUtils.SuitAdjustedValue(currentActiveSuit, card);
                cardCount++;
                player2.Hand ().RemoveCard (card);
            }
            if (player1.IsAI ()) {
                player1.ProcessInitiativePhaseResult(cardCount, player1Sum);
            }
            player2LastHandScore = player2Sum;
            SetPlayer2SelectedCardList(player2SelectedCardList.CardList());

            ClearSelectedCardsList();

            if (reflectStatus%2 == 1) {
                // @BUG FIX
                Debug.Log ("Reflect activated, scores swapped");
                int temp = player1Sum;
                player1Sum = player2Sum;
                player2Sum = temp;

                player1LastHandScore = player1Sum;
                player2LastHandScore = player2Sum;
            }
            reflectStatus = 0;

            if (initiativeWinner == player1) {
                Debug.Log ("Phase 4: Automatic damage of " + automaticDamage + " applied to defender");
                player2.ApplyDamage(automaticDamage);

                if (player1Sum > player2Sum) {
                    difference = player1Sum - player2Sum;
                    Debug.Log ("Phase 4: Damage Resolution Result: " + Player1HandScore() + "-" + Player2HandScore() + ": " + player1.Name () + " deals " + difference + " damage to " + player2.Name ());
                    player2.ApplyDamage (difference);
                } else {
                    Debug.Log ("Phase 4: Damage Resolution Result: " + Player1HandScore() + "-" + Player2HandScore() + ": " + "Defense successful, no damage dealt");
                }
            } else if (initiativeWinner == player2) {
                Debug.Log ("Phase 4: Automatic damage of " + automaticDamage + " applied to defender");
                player1.ApplyDamage(automaticDamage);

                if (player2Sum > player1Sum) {
                    difference = player2Sum - player1Sum;
                    Debug.Log ("Phase 4: Damage Resolution Result: " + Player1HandScore() + "-" + Player2HandScore() + ": " + player2.Name () + " deals " + difference + " damage to " + player1.Name ());
                    player1.ApplyDamage (difference);
                } else {
                    Debug.Log ("Phase 4: Damage Resolution Result: " + Player1HandScore() + "-" + Player2HandScore() + ": " + "Defense successful, no damage dealt");
                }
            }

            if (player1.Health () <= 0) {
                AdvancePhase (6);
            } else if (player2.Health () <= 0) {
                AdvancePhase (7);
            } else {
                AdvancePhase ();
            }
        } else if (phase == 5) {
            GrowCards ();
            AddEndOfTurnSuperBarPoints();
            CheckPlayersForPowerUse();

            Debug.Log ("Phase 5: Grow Remaining Cards");
        } else if (phase == 6) {  // player 2 won
            Debug.Log ("Player 2 wins!");
        } else if (phase == 7) {  // player 1 won
            Debug.Log ("Player 1 wins!");
        }
    }
Beispiel #30
0
 private void Awake()
 {
     builder = CardPlayer.instance;
 }
Beispiel #31
0
 public CardDeck(CardPlayer card) : base(card.Name, card.Level, card.MaxLevel, card.Count, card.IconUrls)
 {
     Cards = CardHelper.MissingCards(card);
     IsMax = card.MaxLevel == card.Level;
 }
        public static void Main(string[] args)
        {
            string continuePlay;

            do
            {
                Console.WriteLine("Start/Continue Black Jack Game? (Y/N)");
                continuePlay = Console.ReadLine();
                Console.Clear();
                Console.WriteLine("New Game:.....\r\n");

                if (continuePlay.ToUpper() != "Y" && continuePlay.ToUpper() != "N")
                {
                    Console.WriteLine("!Wrong option, please type Y (yes) or N (no)...try again!");
                    continuePlay = "Y";
                }

                else if (continuePlay.ToUpper() == "Y")
                {
                    var ComputerPlayer = new CardPlayer()
                    {
                        Name = "Computer"
                    };
                    var UserPlayer = new CardPlayer()
                    {
                        Name = "User"
                    };
                    var currentGame = new BlackJackGame();
                    var winnerIs    = "NoWinner";

                    currentGame.InitPlayer(ComputerPlayer);
                    //For the production version do not to show the Computer cards.
                    //Console.WriteLine("Cards For: " + ComputerPlayer.Name + ComputerPlayer.showCards());
                    currentGame.InitPlayer(UserPlayer);
                    Console.WriteLine("\r\nCards For: " + UserPlayer.Name + "\r\n" +
                                      UserPlayer.showCards());
                    winnerIs = currentGame.CheckWinner(ComputerPlayer, UserPlayer);

                    var resp = "H";

                    while (resp.ToUpper() == "H" && winnerIs == "NoWinner")
                    {
                        Console.WriteLine("\r\nHit or Stand? ");
                        resp = Console.ReadLine();

                        if (resp.ToUpper() == "H")
                        {
                            //Provide more cards to the user Player
                            UserPlayer.RequestCard(currentGame.DeckBlackJack);
                            Console.WriteLine("\r\nCards For: " + UserPlayer.Name + "\r\n" +
                                              UserPlayer.showCards());
                            winnerIs = currentGame.CheckWinner(ComputerPlayer, UserPlayer);
                        }
                        else if (resp.ToUpper() == "S")
                        {
                            winnerIs = currentGame.CheckWinnerFinal(ComputerPlayer, UserPlayer);
                        }
                        else
                        {
                            Console.WriteLine("Wrong Choice, please use H (hit) or S (stand)...try again");
                            resp = "H";
                        }
                    }

                    if (winnerIs != "NoWinner")
                    {
                        Console.WriteLine("\r\n" + winnerIs);
                    }
                }
            } while (continuePlay.ToUpper() == "Y");

            Console.Clear();
            Console.WriteLine("\r\nThanks...Bye!,...hit Enter key for to close the window");
            Console.Read();
        }
Beispiel #33
0
 public CardManager(CardPlayer card, Coordinate coordinate)
 {
     this.currentCoordinate = coordinate;
     initPlayer(card);
 }
 /************************************************************************
  * Game State Transition Methods
  ************************************************************************/
 private void SetupGame()
 {
     cardGame = new CardGame ();
     player1 = new CardPlayerReflect (cardGame, false);
     player2 = new CardPlayerMutation (cardGame, true);
     cardGame.InitializeData (player1, player2);
 }
 public void PickCard(CardPlayer player)
 {
     player.PickCard(deck);
 }
Beispiel #36
0
    // 플카 초기화
    private void initPlayer(CardPlayer card)
    {
        initUnit(card);

        stat.Add("leadership", card.leadership);
    }
Beispiel #37
0
 public void CardsWon(CardPlayer player, params CardPanel[] cardPanels)
 {
     player.ReportScore(cardPanels.Length);
 }
 public void ReduceTimerOnOpponent(CardPlayer initiatingPlayer)
 {
     if (initiatingPlayer == player1) {
         if (player2CardSelectionTimerRushState == 2) {
             player2CardSelectionTimerRushState = 3;
         } else {
             player2CardSelectionTimerRushState = 1;
         }
     } else if (initiatingPlayer == player2) {
         if (player1CardSelectionTimerRushState == 2) {
             player1CardSelectionTimerRushState = 3;
         } else {
             player1CardSelectionTimerRushState = 1;
         }
     }
 }
Beispiel #39
0
 public override bool IsPlayerTurn(CardPlayer cardPlayer)
 {
     return(cardPlayer.Id.Equals(_currentPlayer));
 }
 /*
  * Powers
  */
 public void BlindOpponent(CardPlayer initiatingPlayer)
 {
     if (initiatingPlayer == player1) {
         player2.BlindPlayer();
     } else if (initiatingPlayer == player2) {
         player1.BlindPlayer();
     }
 }