Beispiel #1
0
        public override void ExecuteCommand(IChatChannel channel, StreamCommand command)
        {
            long       userid = playermodule.GetPlayer(command.Service, command.User).UserID;
            HoldemGame game   = casino.GetGame(userid);

            if (game == null)
            {
                SendMessage(channel, command.User, "You have no active holdem game. Use !holdem to start a new game.");
                return;
            }

            casino.RemoveGame(userid);

            RPGMessageBuilder message          = messagemodule.Create().User(userid).Text(" folds the hand. ");
            HandEvaluation    dealerevaluation = HandEvaluator.Evaluate(game.Board + game.DealerHand);
            HandEvaluation    playerevaluation = HandEvaluator.Evaluate(game.Board + game.PlayerHand);

            if (dealerevaluation < playerevaluation || dealerevaluation.Rank < HandRank.Pair || (dealerevaluation.Rank == HandRank.Pair && dealerevaluation.HighCard < CardRank.Four))
            {
                message.ShopKeeper().Text(" laughs and shows ");
                foreach (Card card in game.DealerHand)
                {
                    message.Image(cardimages.GetCardUrl(card), $"{card} ");
                }
                message.Text("while grabbing ").Gold(game.Pot);
            }
            else
            {
                message.ShopKeeper().Text(" gladly rakes in ").Gold(game.Pot);
            }
            message.Send();
        }
Beispiel #2
0
        public override void ExecuteCommand(IChatChannel channel, StreamCommand command)
        {
            long       userid = playermodule.GetPlayer(command.Service, command.User).UserID;
            HoldemGame game   = casino.GetGame(userid);

            if (game != null)
            {
                SendMessage(channel, command.User, "You are already active in a holdem game. Use !fold to fold your hand or !call to stay active in the game.");
                return;
            }

            int bet;

            if (command.Arguments.Length == 0)
            {
                bet = 1;
            }
            else
            {
                int.TryParse(command.Arguments[0], out bet);
            }

            if (bet <= 0)
            {
                SendMessage(channel, command.User, $"{command.Arguments[0]} is no valid bet");
                return;
            }

            int gold = playermodule.GetPlayerGold(userid);

            if (bet > 1 && bet > gold)
            {
                SendMessage(channel, command.User, "You can't bet more than you have.");
                return;
            }

            int maxbet = playermodule.GetLevel(userid) * 10;

            if (bet > maxbet)
            {
                SendMessage(channel, command.User, $"On your level you're only allowed to bet up to {maxbet} gold.");
                return;
            }

            // allow the player to play for one gold even if he has no gold
            if (gold > 0)
            {
                playermodule.UpdateGold(userid, -bet);
            }

            game = casino.CreateGame(userid, bet);

            game.Deck.Shuffle();

            game.PlayerHand += game.Deck.Pop();
            game.DealerHand += game.Deck.Pop();
            game.PlayerHand += game.Deck.Pop();
            game.DealerHand += game.Deck.Pop();

            game.Muck.Push(game.Deck.Pop());
            for (int i = 0; i < 3; ++i)
            {
                game.Board += game.Deck.Pop();
            }

            RPGMessageBuilder message = messagemodule.Create();

            message.Text("You have ");
            foreach (Card card in game.PlayerHand)
            {
                message.Image(imagemodule.GetCardUrl(card), $"{card} ");
            }
            message.Text(". The board shows ");
            foreach (Card card in game.Board)
            {
                message.Image(imagemodule.GetCardUrl(card), $"{card} ");
            }

            HandEvaluation evaluation = HandEvaluator.Evaluate(game.Board + game.PlayerHand);

            message.Text($" ({evaluation})").Send();
        }
Beispiel #3
0
        public override void ExecuteCommand(IChatChannel channel, StreamCommand command)
        {
            long       userid = playermodule.GetPlayer(command.Service, command.User).UserID;
            HoldemGame game   = casino.GetGame(userid);

            if (game == null)
            {
                SendMessage(channel, command.User, "You have no active holdem game. Use !holdem to start a new game.");
                return;
            }

            int bet = Math.Min(playermodule.GetPlayerGold(userid), game.Bet);

            if (bet > 0)
            {
                playermodule.UpdateGold(userid, -bet);
                game.Pot += bet;
            }

            game.Muck.Push(game.Deck.Pop());
            game.Board += game.Deck.Pop();

            RPGMessageBuilder message = messagemodule.Create();

            if (game.Board.Count == 5)
            {
                // showdown
                message.Text("Showdown! ");
            }

            message.Text("The board shows ");
            foreach (Card card in game.Board)
            {
                message.Image(cardimages.GetCardUrl(card), $"{card} ");
            }
            message.Text(". You have ");
            foreach (Card card in game.PlayerHand)
            {
                message.Image(cardimages.GetCardUrl(card), $"{card} ");
            }

            HandEvaluation evaluation = HandEvaluator.Evaluate(game.Board + game.PlayerHand);

            message.Text($" ({evaluation})");

            if (game.Board.Count == 5)
            {
                message.Text(". ").ShopKeeper().Text(" shows ");
                foreach (Card card in game.DealerHand)
                {
                    message.Image(cardimages.GetCardUrl(card), $"{card} ");
                }
                HandEvaluation dealerevaluation = HandEvaluator.Evaluate(game.Board + game.DealerHand);
                message.Text($" ({dealerevaluation}). ");

                int multiplier = 0;

                if (dealerevaluation.Rank < HandRank.Pair || (dealerevaluation.Rank == HandRank.Pair && dealerevaluation.HighCard < CardRank.Four))
                {
                    message.ShopKeeper().Text(" isn't qualified for a showdown.");
                    multiplier = GetMultiplier(evaluation.Rank);
                }
                else if (dealerevaluation > evaluation)
                {
                    message.ShopKeeper().Text(" wins the hand and ").Gold(game.Pot).Text(" laughing at your face.");
                }
                else if (dealerevaluation == evaluation)
                {
                    message.ShopKeeper().Text(" Has the same hand as you.");
                    multiplier = 1;
                }
                else
                {
                    message.Text(" You win the hand.");
                    multiplier = GetMultiplier(evaluation.Rank);
                }

                if (multiplier > 0)
                {
                    message.Text(" Payout is ").Gold(game.Pot * multiplier);
                    playermodule.UpdateGold(userid, game.Pot * multiplier);
                }

                casino.RemoveGame(userid);
            }

            message.Send();
        }