コード例 #1
0
 public void Add(IBattleEntity entity)
 {
     lock (actorlock) {
         actors.Add(entity);
         if (actors.Count == 2)
         {
             messages?.Create().BattleActor(actors[0], true).Text(" encounters a ").BattleActor(actors[1], true).Text(".").Send();
             actor = RNG.XORShift64.NextInt(2);
         }
     }
 }
コード例 #2
0
ファイル: FoldCommand.cs プロジェクト: telmengedar/StreamRC
        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();
        }
コード例 #3
0
        public override void ExecuteCommand(IChatChannel channel, StreamCommand command)
        {
            BlackJackGame game = blackjack.GetGame(command.Service, command.User);

            if (game == null)
            {
                SendMessage(channel, command.User, "There is active black jack game. Start another one with !bj <bet>");
                return;
            }

            game.PlayerBoards[game.ActiveBoard].Board += game.Stack.Pop();

            int value = logic.Evaluate(game.PlayerBoards[game.ActiveBoard].Board);

            RPGMessageBuilder message = messages.Create();

            message.User(game.PlayerID).Text(" has ");
            foreach (Card card in game.PlayerBoards[game.ActiveBoard].Board)
            {
                message.Image(images.GetCardUrl(card), $"{card} ");
            }
            message.Text(". ");

            if (value > 21)
            {
                message.Text("Bust!");
                game.PlayerBoards.RemoveAt(game.ActiveBoard);
            }
            else
            {
                message.Text($"({value}). ");
                if (value == 21)
                {
                    ++game.ActiveBoard;
                }
            }


            if (game.PlayerBoards.Count == 0)
            {
                message.Text(" All hands are busted.").ShopKeeper().Text(" laughs at you.");
                blackjack.RemoveGame(game.PlayerID);
            }
            else
            {
                if (game.ActiveBoard >= game.PlayerBoards.Count)
                {
                    message.Text(" All hands have been played.");
                    logic.PlayoutDealer(game, message, playermodule, images);
                    blackjack.RemoveGame(game.PlayerID);
                }
            }
            message.Send();
        }
コード例 #4
0
        public override void ExecuteCommand(IChatChannel channel, StreamCommand command)
        {
            BlackJackGame game = blackjack.GetGame(command.Service, command.User);

            if (game == null)
            {
                SendMessage(channel, command.User, "There is no active black jack game. Start another one with !bj <bet>");
                return;
            }

            ++game.ActiveBoard;

            RPGMessageBuilder message = messages.Create();

            message.User(game.PlayerID).Text(" is satisfied.");
            if (game.ActiveBoard >= game.PlayerBoards.Count)
            {
                message.Text(" All hands have been played.");
                logic.PlayoutDealer(game, message, playermodule, images);
                blackjack.RemoveGame(game.PlayerID);
            }
            else
            {
                if (game.PlayerBoards[game.ActiveBoard].Board.Count == 1)
                {
                    game.PlayerBoards[game.ActiveBoard].Board += game.Stack.Pop();
                }

                message.Text(" Next hand is ");
                foreach (Card card in game.PlayerBoards[game.ActiveBoard].Board)
                {
                    message.Image(images.GetCardUrl(card), $"{card} ");
                }

                int value = logic.Evaluate(game.PlayerBoards[game.ActiveBoard].Board);
                message.Text($"({value}). ");
                logic.CheckSplit(game.PlayerBoards[game.ActiveBoard].Board, message);
            }
            message.Send();
        }
コード例 #5
0
        public void TakeOff(string service, string channel, string username, string itemorslotname)
        {
            User   user   = context.GetModule <UserModule>().GetExistingUser(service, username);
            Player player = context.GetModule <PlayerModule>().GetExistingPlayer(service, username);

            if (player == null)
            {
                throw new Exception($"Player for '{service}/{username}' does not exist.");
            }

            Item item = context.GetModule <ItemModule>().GetItem(itemorslotname);

            if (item == null)
            {
                EquipmentSlot slot;
                try
                {
                    slot = (EquipmentSlot)Enum.Parse(typeof(EquipmentSlot), itemorslotname, true);
                }
                catch (Exception) {
                    context.GetModule <StreamModule>().SendMessage(service, channel, username, $"'{itemorslotname}' is not an item or slotname.");
                    return;
                }

                TakeOffSlot(service, channel, username, player.UserID, slot);
                return;
            }

            EquipmentItem currentequipment = context.Database.LoadEntities <EquipmentItem>().Where(i => i.PlayerID == player.UserID && i.ItemID == item.ID).Execute().FirstOrDefault();

            if (currentequipment == null)
            {
                context.GetModule <StreamModule>().SendMessage(service, channel, username, $"You don't have equipped any '{item.Name}'.");
            }
            else
            {
                context.GetModule <InventoryModule>().AddItem(player.UserID, item.ID, 1, true);
                context.Database.Delete <EquipmentItem>().Where(i => i.PlayerID == player.UserID && i.Slot == currentequipment.Slot).Execute();

                messagemodule.Create().User(user).Text(" took off the ").Item(item, 0).Text(" from the ").EquipmentSlot(currentequipment.Slot).Text(".").Send();
                EquipmentChanged?.Invoke(player.UserID, currentequipment.Slot);
            }
        }
コード例 #6
0
 public void Initialize()
 {
     messages.Create().User(user).Text(" has seen Fortuna throwing kisses.").Send();
 }
コード例 #7
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();
        }
コード例 #8
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();
        }
コード例 #9
0
 public void Initialize()
 {
     cooldown = GetCooldown();
     messages.Create().BattleActor(target).Text(" was ").Color(AdventureColors.Poison).Text($"Poisoned ({Level})").Reset().Text(".").Send();
 }
コード例 #10
0
 public void Initialize()
 {
     messages.Create().User(user).Text(" feels as graceful as a cat.").Send();
 }
コード例 #11
0
 public void Initialize()
 {
     messages.Create().User(user).Text(" is getting ideas about all and everything.").Send();
 }
コード例 #12
0
 public void Initialize()
 {
     cooldown = 5.0;
     messages.Create().BattleActor(target).Text($" got a {(Level >= 5 ? "nasty diverse manifold" : "fecal")} infection.").Send();
 }
コード例 #13
0
 public void WearOff()
 {
     messages.Create().Text("The armor of ").User(userid).Text(" doesn't smell like pee anymore.").Send();
 }
コード例 #14
0
 public void Initialize()
 {
     messages.Create().User(user).Text(" is growing some muscles.").Send();
 }
コード例 #15
0
        public override void ExecuteCommand(IChatChannel channel, StreamCommand command)
        {
            BlackJackGame game = blackjack.GetGame(command.Service, command.User);

            if (game == null)
            {
                SendMessage(channel, command.User, "There is no active black jack game. Start another one with !bj <bet>");
                return;
            }

            if (!logic.IsSplitPossible(game.PlayerBoards[game.ActiveBoard].Board))
            {
                SendMessage(channel, command.User, "A split is not possible on the current hand.");
                return;
            }

            int bet = game.PlayerBoards[game.ActiveBoard].Bet;

            if (bet > playermodule.GetPlayerGold(game.PlayerID))
            {
                SendMessage(channel, command.User, "You don't have enough gold to split the hand.");
                return;
            }

            playermodule.UpdateGold(game.PlayerID, -bet);

            game.PlayerBoards.Add(new BlackJackBoard {
                Bet   = bet,
                Board = new Board(game.PlayerBoards[game.ActiveBoard].Board[1])
            });

            game.PlayerBoards[game.ActiveBoard].Board = game.PlayerBoards[game.ActiveBoard].Board.ChangeCard(1, game.Stack.Pop());

            RPGMessageBuilder message = messages.Create();

            message.User(game.PlayerID).Text(" current hand is ");
            foreach (Card card in game.PlayerBoards[game.ActiveBoard].Board)
            {
                message.Image(images.GetCardUrl(card), $"{card} ");
            }
            int value = logic.Evaluate(game.PlayerBoards[game.ActiveBoard].Board);

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

            while (value == 21 || (game.ActiveBoard < game.PlayerBoards.Count && game.PlayerBoards[game.ActiveBoard].Board[0].Rank == CardRank.Ace))
            {
                ++game.ActiveBoard;
                if (game.ActiveBoard >= game.PlayerBoards.Count)
                {
                    message.Text(" All hands are played.");
                    logic.PlayoutDealer(game, message, playermodule, images);
                    value = 0;
                }
                else
                {
                    if (game.PlayerBoards[game.ActiveBoard].Board.Count == 0)
                    {
                        game.PlayerBoards[game.ActiveBoard].Board += game.Stack.Pop();
                    }

                    message.User(game.PlayerID).Text(" next hand is ");
                    foreach (Card card in game.PlayerBoards[0].Board)
                    {
                        message.Image(images.GetCardUrl(card), $"{card} ");
                    }
                    value = logic.Evaluate(game.PlayerBoards[game.ActiveBoard].Board);
                    message.Text($"({value}). ");
                }
            }

            if (value > 0)
            {
                logic.CheckSplit(game.PlayerBoards[game.ActiveBoard].Board, message);
            }

            message.Send();
        }
コード例 #16
0
 public void Initialize()
 {
     cooldown = GetCooldown();
     messages.Create().BattleActor(target).Text(" got infected with the ").Color(AdventureColors.Plaque).Text($"Plaque Lv{Level}").Reset().Send();
 }
コード例 #17
0
        public override void ExecuteCommand(IChatChannel channel, StreamCommand command) {
            VideoPokerGame game = pokermodule.GetGame(command.Service, command.User);
            long userid = playermodule.GetPlayer(command.Service, command.User).UserID;
            HandEvaluation evaluation;

            if (game == null) {
                if(command.Arguments.Length == 0) {
                    SendMessage(channel, command.User, "You have to specify a bet amount");
                    return;
                }

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

                if (bet > playermodule.GetPlayerGold(userid)) {
                    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;
                }

                game = pokermodule.CreateGame(command.Service, command.User, bet);
                game.IsMaxBet = bet == maxbet;
                game.Deck.Shuffle();
                for(int i = 0; i < 5; ++i)
                    game.Hand += game.Deck.Pop();

                RPGMessageBuilder message = messagemodule.Create();
                message.User(userid).Text(" has ");
                foreach(Card card in game.Hand)
                    message.Image(imagemodule.GetCardUrl(card), $"{card} ");

                evaluation = HandEvaluator.Evaluate(game.Hand);
                message.Text($"({evaluation})").Send();
            }
            else {
                RPGMessageBuilder message = messagemodule.Create();

                if(command.Arguments.Length > 0) {
                    int redraw = 0;
                    foreach(string argument in command.Arguments) {
                        if(argument.All(c => char.IsDigit(c))) {
                            int index = int.Parse(argument);
                            if(index < 1 || index > 5) {
                                SendMessage(channel, command.User, $"{index} is not a valid slot to redraw");
                                return;
                            }
                            redraw |= 1 << (index - 1);
                        }
                        else if(argument.ToLower() == "all") {
                            redraw |= 31;
                        }
                        else {
                            int index = game.Hand.IndexOf(c => c.ToString().ToLower() == argument.ToLower());
                            if(index == -1) {
                                SendMessage(channel, command.User, $"{argument} points not to a card in your hand");
                                return;
                            }
                            redraw |= 1 << index;
                        }
                    }

                    int cards = 0;
                    for(int i = 0; i < 5; ++i) {
                        if((redraw & (1 << i)) != 0) {
                            game.Hand = game.Hand.ChangeCard(i, game.Deck.Pop());
                            ++cards;
                        }
                    }
                    message.User(userid).Text($" is redrawing {cards} cards. ");
                    foreach (Card card in game.Hand)
                        message.Image(imagemodule.GetCardUrl(card), $"{card} ");

                    evaluation = HandEvaluator.Evaluate(game.Hand);
                    message.Text($"({evaluation}).");
                }
                else {
                    evaluation = HandEvaluator.Evaluate(game.Hand);
                    message.User(userid).Text(" is satisfied with the hand.");
                }

                int multiplicator = GetMultiplicator(evaluation, game.IsMaxBet);
                if(multiplicator == 0)
                    message.Text(" ").ShopKeeper().Text(" laughs about that shitty hand.");
                else {
                    int payout = game.Bet * multiplicator;
                    playermodule.UpdateGold(userid, payout);
                    message.Text(" Payout is ").Gold(payout);
                }

                message.Send();
                pokermodule.RemoveGame(command.Service, command.User);
            }
        }
コード例 #18
0
        public override void ExecuteCommand(IChatChannel channel, StreamCommand command) {
            BlackJackGame existing = blackjack.GetGame(command.Service, command.User);
            if(existing != null) {
                SendMessage(channel, command.User, "There is already a game running for you.");
                return;
            }

            if(command.Arguments.Length == 0) {
                SendMessage(channel, command.User, "You have to specify a bet amount");
                return;
            }

            long userid = playermodule.GetPlayer(command.Service, command.User).UserID;

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

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

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

            BlackJackGame game = blackjack.StartGame(command.Service, command.User);
            game.Stack.Shuffle();

            game.DealerBoard += game.Stack.Pop();

            game.PlayerBoards = new List<BlackJackBoard>();
            game.PlayerBoards.Add(new BlackJackBoard() {
                Bet = bet
            });
            game.PlayerBoards[0].Board += game.Stack.Pop();
            game.PlayerBoards[0].Board += game.Stack.Pop();

            playermodule.UpdateGold(game.PlayerID, -bet);

            RPGMessageBuilder message = messages.Create();
            message.User(userid).Text(" has ");
            foreach(Card card in game.PlayerBoards[0].Board)
                message.Image(images.GetCardUrl(card), $"{card} ");
            message.Text(".");

            int value = logic.Evaluate(game.PlayerBoards[0].Board);
            if(value == 21) {
                message.Text("Black Jack!");
                int winnings = (int)(game.PlayerBoards[0].Bet * 2.5);
                message.Text("Winnings: ").Gold(winnings);
                playermodule.UpdateGold(userid, winnings);
                blackjack.RemoveGame(userid);
            }
            else {
                message.Text($"({value}). ");
                message.ShopKeeper().Text(" shows ");
                foreach (Card card in game.DealerBoard)
                    message.Image(images.GetCardUrl(card), $"{card} ");
                message.Text($"({logic.Evaluate(game.DealerBoard)}). ");

                logic.CheckSplit(game.PlayerBoards[0].Board, message);
            }

            message.Send();
        }