Example #1
0
        public static async Task GameOver(PlayerGameContext winner, PlayerGameContext loser)
        {
            var kb = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardHide();

            winner.User.AddWin();
            winner.User.status = User.Status.Default;
            await winner.SendAsync(lang => lang.GameFinished, kb);

            await winner.SendAsync(lang => GetWinMessage(winner, loser, lang));

            await winner.SendAsync(lang => GetMessageForMe(lang, winner.hero));

            await winner.SendAsync(lang => GetMessageForEnemy(lang, loser.hero));

            loser.User.AddLose();
            loser.User.status = User.Status.Default;
            await loser.SendAsync(lang => lang.GameFinished, kb);

            await loser.SendAsync(lang => GetWinMessage(winner, loser, lang));

            await loser.SendAsync(lang => GetMessageForMe(lang, loser.hero));

            await loser.SendAsync(lang => GetMessageForEnemy(lang, winner.hero));

            await winner.User.Sender.SendPhotoWithText(lang => lang.GetAds(), "http://cdn1.savepice.ru/uploads/2017/6/18/f3a68821810058281cb2e19aa0dd1bc0-full.png");

            await loser.User.Sender.SendPhotoWithText(lang => lang.GetAds(), "http://cdn1.savepice.ru/uploads/2017/6/18/f3a68821810058281cb2e19aa0dd1bc0-full.png");
        }
Example #2
0
        private static string GetWinMessage(PlayerGameContext winner, PlayerGameContext loser, User.Text lang)
        {
            string[] msg =
            {
                $"{winner.User.Name} ({winner.hero.Name}) {lang.HasWonThisBattle}!",
                $"{loser.User.Name} ({loser.hero.Name}) {lang.HasLostThisBattle}!",
                $"{winner.User.lang.Result}:",
            };

            return(string.Join("\n", msg));
        }
Example #3
0
        public Game(User user_one, User user_two, Telegram.Bot.TelegramBotClient _bot)
        {
            bot = _bot;
            IGameID++;
            GameID = IGameID;

            user_one.ActiveGameID = GameID;
            user_one.status       = User.Status.GameConfirming;


            user_two.ActiveGameID = GameID;
            user_two.status       = User.Status.GameConfirming;

            isWorking = true;

            var player_one_context = new PlayerGameContext(user_one, bot);
            var player_two_context = new PlayerGameContext(user_two, bot);

            player_one_controller = new PlayerController(player_one_context, player_two_context, this);
            player_two_controller = new PlayerController(player_two_context, player_one_context, this);
        }
Example #4
0
        private async void SetAttackerAndExcepter(PlayerGameContext attacker, PlayerGameContext excepter)
        {
            attacker.User.LastMoveTime = Main.Time;
            excepter.User.LastMoveTime = Main.Time;
            attacker.User.status       = User.Status.Attacking;
            excepter.User.status       = User.Status.Excepting;

            await attacker.SendAsync(lang => lang.YourEnemyMessage + ": " + excepter.User.Name);

            await excepter.SendAsync(lang => lang.YourEnemyMessage + ": " + attacker.User.Name);

            //Временно вызывается из game
            await SendHeroesStates();

            await attacker.SendAsync(lang => lang.FirstAttackNotify);

            await excepter.SendAsync(lang => lang.EnemyFirstAttackNotify);

            IHero temp = attacker.hero;

            await attacker.SendAsync(lang => attacker.hero.GetMessageAbilitesList(lang));

            await excepter.SendAsync(lang => lang.WaitingForAnotherPlayerAction);
        }
Example #5
0
 public PlayerController(PlayerGameContext player, PlayerGameContext enemyPlayer, Game game)
 {
     this.player      = player;
     this.enemyPlayer = enemyPlayer;
     this.game        = game;
 }