当前位置: 首页>>代码示例>>C#>>正文


C# IPlayer.increase_pot_by方法代码示例

本文整理汇总了C#中IPlayer.increase_pot_by方法的典型用法代码示例。如果您正苦于以下问题:C# IPlayer.increase_pot_by方法的具体用法?C# IPlayer.increase_pot_by怎么用?C# IPlayer.increase_pot_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPlayer的用法示例。


在下文中一共展示了IPlayer.increase_pot_by方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: determine_winner_from

        public void determine_winner_from(IPlayingPositions playing_positions, IPlayer player)
        {
            var dealers_hand = playing_positions.dealers_hand;
            
            dealers_hand.show_card_in_hole();

            foreach (var players_hand in playing_positions.players_hands())
            {
                if (players_hand.has_status_of(HandStatus.blackjack) && dealers_hand.has_status_of(HandStatus.blackjack))
                {
                    players_hand.change_state_to(HandStatus.push);
                }
                else if (players_hand.has_status_of(HandStatus.blackjack))
                {
                    players_hand.change_state_to(HandStatus.won);
                }
                else if (dealers_hand.has_status_of(HandStatus.blackjack))
                {
                    players_hand.change_state_to(HandStatus.lost);
                }
                else if (players_hand.has_status_of(HandStatus.soft_blackjack) &&
                         dealers_hand.has_status_of(HandStatus.soft_blackjack))
                {
                    players_hand.change_state_to(HandStatus.push);
                }
                else if (players_hand.has_status_of(HandStatus.soft_blackjack))
                {
                    players_hand.change_state_to(HandStatus.won);
                }
                else if (dealers_hand.has_status_of(HandStatus.soft_blackjack))
                {
                    players_hand.change_state_to(HandStatus.lost);
                }
                else if (players_hand.has_status_of(HandStatus.bust) && dealers_hand.has_status_of(HandStatus.bust))
                {
                    players_hand.change_state_to(HandStatus.push);
                }
                else if (players_hand.has_status_of(HandStatus.bust))
                {
                    players_hand.change_state_to(HandStatus.lost);
                }
                else if (dealers_hand.has_status_of(HandStatus.bust))
                {
                    players_hand.change_state_to(HandStatus.won);
                }
                else if (players_hand.has_status_of(HandStatus.stick))
                {
                    var player_score = _hand_scorer.calculate_score_for(players_hand);
                    var dealers_score = _hand_scorer.calculate_score_for(dealers_hand);

                    if (player_score > dealers_score)
                    {
                        players_hand.change_state_to(HandStatus.won);
                    }
                    else if (player_score < dealers_score)
                    {
                        players_hand.change_state_to(HandStatus.lost);
                    }
                    else if (player_score == dealers_score)
                    {
                        players_hand.change_state_to(HandStatus.push);
                    }
                }

                var chips_to_give_to_player = new Chips(0m);

                // Check if dealer has blackjack and that player took insurnace
                if (players_hand.has_taken_insurance() && dealers_hand.has_status_of(HandStatus.blackjack))
                {
                    var original_insurance_amount = players_hand.wager.halved();

                    var winnings = original_insurance_amount.mulitple_by_odds_of(2, 1);

                    chips_to_give_to_player = chips_to_give_to_player.add(original_insurance_amount.add(winnings));
                }

                if (players_hand.has_status_of(HandStatus.won))
                {
                    chips_to_give_to_player = chips_to_give_to_player.add(players_hand.wager.mulitple_by_odds_of(3, 2).add(players_hand.wager));
                    DomainEvents.raise(new HandResultEvent(string.Format("Hand {0} Won - you win {1}", players_hand.get_hand_letter(), chips_to_give_to_player.ToString())));
                    player.increase_pot_by(chips_to_give_to_player);                    
                }

                if (players_hand.has_status_of(HandStatus.push))
                {
                    chips_to_give_to_player = chips_to_give_to_player.add(players_hand.wager);
                    player.increase_pot_by(chips_to_give_to_player); 

                    DomainEvents.raise(new HandResultEvent(string.Format("Hand {0} tied with the dealer, you get {1}", players_hand.get_hand_letter(), chips_to_give_to_player.ToString())));                                                           
                }

                if (players_hand.has_status_of(HandStatus.lost))
                {
                    if (chips_to_give_to_player.contains_chips())
                    {
                        player.increase_pot_by(chips_to_give_to_player); 
                        DomainEvents.raise(new HandResultEvent(string.Format("Hand {0} lost, but you won insurance bet of {1}", players_hand.get_hand_letter(), chips_to_give_to_player.ToString())));
                    }
                    else
                    {
//.........这里部分代码省略.........
开发者ID:elbandit,项目名称:DDD-CQRS-Blackjack,代码行数:101,代码来源:AnnouceWinnerAction.cs


注:本文中的IPlayer.increase_pot_by方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。