Esempio n. 1
0
        private void StartSpecificGame(User targetPlayer, string requestingPlayerId, string requestingPlayerName, string channel)
        {
            Channel       ChannelInfo    = APICalls.GetChannelInfo(channel);
            List <string> UsersInChannel = ChannelInfo.members.ToList();

            if (UsersInChannel.Contains(targetPlayer.id))
            {
                GameRound newRound = new GameRound {
                    PlayerOne      = requestingPlayerId,
                    PlayerTwo      = targetPlayer.id,
                    Channel        = channel,
                    PlayerSpecific = true
                };
                Sender.SendMessage(new RTMMessageOut {
                    channel = channel,
                    text    = $"{requestingPlayerName} wants to fist bump {targetPlayer.name}"
                });
                ConsoleMessenger.PrintSuccess($"New game started by {requestingPlayerId}");
                CurrentGames.Add(newRound);
            }
            else
            {
                Sender.SendMessage(new RTMMessageOut {
                    channel = channel,
                    text    = $"{targetPlayer.name} is not this channel"
                });
            }
        }
Esempio n. 2
0
 private void StartOpenGame(GameRound newRound, string playerName)
 {
     CurrentGames.Add(newRound);
     Sender.SendMessage(new RTMMessageOut {
         channel = newRound.Channel,
         text    = $"{playerName} is looking for a fistbump! \nType \"!FistBump\" to bump {playerName} back!"
     });
     ConsoleMessenger.PrintSuccess($"New game started by {playerName}");
 }
Esempio n. 3
0
 private bool OpenGameInProgress(string channel, out GameRound gameRound)
 {
     foreach (var game in CurrentGames)
     {
         if (!game.PlayerSpecific && game.Channel == channel)
         {
             gameRound = game;
             return(true);
         }
     }
     gameRound = null;
     return(false);
 }
Esempio n. 4
0
 private bool SpecificGameInProgress(User targetPlayer, string channel, out GameRound round)
 {
     foreach (var Game in CurrentGames.Where(x => x.PlayerSpecific && x.Channel == channel))
     {
         if (Game.PlayerTwo.Equals(targetPlayer.id))
         {
             round = Game;
             return(true);
         }
     }
     round = null;
     return(false);
 }
Esempio n. 5
0
 private void FinishGame(GameRound round, string requestingPlayerName = "", string requestingPlayerId = "")
 {
     if (!round.PlayerSpecific)
     {
         //finish open game
         round.PlayerTwo = requestingPlayerId;
         ArchiveGame(round);
         Sender.SendMessage(new RTMMessageOut {
             channel = round.Channel,
             text    = $"{requestingPlayerName} Fist bumped {Users.FindUser(round.PlayerOne).name} back!"
         });
         ConsoleMessenger.PrintSuccess("Game Finished");
     }
     else
     {
         //finish specific game
         ArchiveGame(round);
         Sender.SendMessage(new RTMMessageOut {
             channel = round.Channel,
             text    = $"{Users.FindUser(round.PlayerTwo).name} Fist bumped {Users.FindUser(round.PlayerOne).name} back!"
         });
     }
 }
Esempio n. 6
0
 private void ArchiveGame(GameRound round)
 {
     ArchivedGames.Add(round);
     CurrentGames.Remove(round);
 }