Ejemplo n.º 1
0
Archivo: IHero.cs Proyecto: y2k/Bot
        protected async Task <bool> CheckImmuneToMagic(IHero target)
        {
            if (target.HasImmuneToMagic)
            {
                await Sender.SendAsync(lang => lang.EnemyHasImmuneToMagic);

                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
Archivo: IHero.cs Proyecto: y2k/Bot
        public IHero(IHero _hero, Sender sender)
        {
            this.Sender = sender;

            string      name = _hero.Name;
            int         STR  = _hero.Strength;
            int         AGI  = _hero.Agility;
            int         INT  = _hero.Intelligence;
            MainFeature feat = _hero.Feature;

            this.Name = name;
            Init(STR, AGI, INT, feat);
        }
Ejemplo n.º 3
0
        public static string GetMessageForEnemy(User.Text playerLang, IHero enemyHero)
        {
            string[] lines =
            {
                playerLang.YourEnemyMessage,
                $"{playerLang.HeroNameMessage}: {enemyHero.Name}",
                $"{playerLang.HpText}: {Convert.ToInt32(enemyHero.HP)}/{Convert.ToInt32(enemyHero.MaxHP)} {smile_hp}",
                $"{playerLang.MpText}: {Convert.ToInt32(enemyHero.MP)}/{Convert.ToInt32(enemyHero.MaxMP)} {smile_mp}",
                $"{playerLang.DpsText}: {Convert.ToInt32(enemyHero.DPS)} {smile_dps}",
                $"{playerLang.ArmorText}: {Convert.ToInt32(enemyHero.Armor)} {smile_armor}",
                $"{enemyHero.GetEffects(playerLang)}"
            };

            return(string.Join("\n", lines));
        }
Ejemplo n.º 4
0
Archivo: IHero.cs Proyecto: y2k/Bot
        virtual public async Task <bool> Attack(IHero target)
        {
            float damage = 0.0f;

            var attakerMessages  = Sender.CreateMessageContainer();
            var excepterMessages = target.Sender.CreateMessageContainer();

            if (GetRandomNumber(1, 101) >= target.MissChance)
            {
                damage += this.DPS + this.AdditionalDamage;
                damage -= target.Armor;
                if (GetRandomNumber(1, 101) <= StunHitChance)
                {
                    target.StunCounter++;
                    damage += StunDamage;
                    attakerMessages.Add(lang => $"{lang.StunningHit}!");
                    excepterMessages.Add(lang => $"{lang.TheEnemyStunnedYou}");
                }
                if (GetRandomNumber(1, 101) <= CriticalHitChance)
                {
                    damage *= CriticalHitMultiplier;
                    attakerMessages.Add(lang => $"{lang.CriticalHit}!");
                    excepterMessages.Add(lang => lang.TheEnemyDealtCriticalDamageToYou);
                }
                attakerMessages.Add(lang => lang.GetAttackedMessageForAttacker(Convert.ToInt32(damage)));
                excepterMessages.Add(lang => lang.GetAttackedMessageForExcepter(Convert.ToInt32(damage)));
            }
            else
            {
                attakerMessages.Add(lang => lang.YouMissedTheEnemy);
                excepterMessages.Add(lang => lang.TheEnemyMissedYou);
            }

            target.GetDamage(damage);
            HP += (damage / 100 * HpStealPercent) + HpStealAdditional;

            await attakerMessages.SendAsync();

            await excepterMessages.SendAsync();

            return(true);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
Archivo: IHero.cs Proyecto: y2k/Bot
        virtual public async Task <bool> Heal(IHero excepter)
        {
            if (!await CheckSilence())
            {
                return(false);
            }
            if (!await CheckManaAndCD(HealPayMana, HealCountdown))
            {
                return(false);
            }
            HP += HealthRestore;
            MP += ManaRestore;

            HP = HP > MaxHP ? MaxHP : HP;
            MP = MP > MaxMP ? MaxMP : MP;

            HealCountdown = HealCountdownDefault;

            await Sender.SendAsync(lang => lang.GetMessageHpAndMpRestored(Convert.ToInt32(HealthRestore), Convert.ToInt32(ManaRestore)));

            await excepter.Sender.SendAsync(lang => lang.GetMessageEnemyHpAndMpRestored(Convert.ToInt32(HealthRestore), Convert.ToInt32(ManaRestore)));

            return(true);
        }
Ejemplo n.º 7
0
        public async Task <bool> UseAbility(int number)
        {
            User  user_attacker = player.User;
            User  user_excepter = enemyPlayer.User;
            IHero attacker      = player.hero;
            IHero excepter      = enemyPlayer.hero;

            bool finished = false;

            excepter.UpdatePerStep();

            switch (number)
            {
            case 1:
                if (await attacker.Attack(excepter))
                {
                    finished = true;
                }
                break;

            case 2:
                if (await attacker.Heal(excepter))
                {
                    finished = true;
                }
                break;

            case 3:
                if (await attacker.UseAbilityOne(excepter))
                {
                    finished = true;
                }
                break;

            case 4:
                if (await attacker.UseAbilityTwo(excepter))
                {
                    finished = true;
                }
                break;

            case 5:
                if (await attacker.UseAbilityThree(excepter))
                {
                    finished = true;
                }
                break;

            default:
                Console.WriteLine("Switch bug!");
                break;
            }

            if (finished)
            {
                //attacker.UpdatePerStep();
                user_attacker.LastMoveTime = Main.Time;
                user_excepter.LastMoveTime = Main.Time;
                attacker.Update();
                excepter.Update();

                if (Math.Floor(attacker.HP) <= 0.0f || Math.Floor(excepter.HP) <= 0.0f)
                {
                    if (Math.Floor(attacker.HP) <= 0.0f)
                    {
                        await GameOver(enemyPlayer, player);
                    }
                    else
                    {
                        await GameOver(player, enemyPlayer);
                    }

                    game.isWorking = false;
                    return(true);
                }

                await player.SendAsync(lang => $"{GetMessageForMe(lang, attacker)}\n\n{GetMessageForEnemy(lang, excepter)}");

                await enemyPlayer.SendAsync(lang => $"{GetMessageForMe(lang, excepter)}\n\n{GetMessageForEnemy(lang, attacker)}");

                if (excepter.StunCounter == 0 && !excepter.IsFullDisabled)
                {
                    user_attacker.status = User.Status.Excepting;
                    user_excepter.status = User.Status.Attacking;

                    await enemyPlayer.SendAsync(lang => excepter.GetMessageAbilitesList(lang), GetAbilitiesKeyboard());

                    await player.SendAsync(lang => lang.WaitingForAnotherPlayerAction, GetHideKeyboard());
                }
                else
                {
                    await player.SendAsync(lang => attacker.GetMessageAbilitesList(user_attacker.lang), GetAbilitiesKeyboard());
                }

                attacker.UpdateStunAndDisableDuration();
                excepter.UpdateStunAndDisableDuration();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
Archivo: IHero.cs Proyecto: y2k/Bot
 virtual public Task <bool> UseAbilityThree(IHero target)
 {
     return(Task.FromResult(false));
 }
Ejemplo n.º 9
0
Archivo: IHero.cs Proyecto: y2k/Bot
 protected void DisableFull(int time, IHero target)
 {
     target.IsFullDisabled      = true;
     target.FullDisableCounter += time;
 }
Ejemplo n.º 10
0
Archivo: IHero.cs Proyecto: y2k/Bot
 public void Silence(int time, IHero target)
 {
     target.IsSilenced      = true;
     target.SilenceCounter += time;
 }