Пример #1
0
        private void IncreaseStat()
        {
            var val = KrispyGenerator.Value();

            if (val >= 0 && val < 0.5)
            {
                MaxHP++; CurrentHP++;
            }
            else if (val >= 0.5 && val < 0.65)
            {
                Speed = Math.Max(Speed * 0.98, 0.00001);
            }
            else if (val >= 0.65 && val < 0.80)
            {
                MaxStamina++;
            }
            else if (val >= 0.80 && val < 0.92)
            {
                HitMaximum++;
            }
            else if (val >= 0.92)
            {
                if (HitMinimum++ >= HitMaximum)
                {
                    HitMaximum += 4;
                }
            }
        }
Пример #2
0
        public void GiveExp(bool didWin, int opponentLevel, int lengthOfBattle, IMessageChannel battleChannel)
        {
            var exp = Math.Max(
                (didWin ? 8 : 3) *
                Math.Max(opponentLevel - Level.Number, 0) * 5
                + 2 * lengthOfBattle - MaxStamina, 5) + KrispyGenerator.NumberBetween(5, 25);

            exp = (int)(exp * (1.0 + 0.1 * Tokens));
            IncreaseStats(exp / 10);
            ExpLevel += exp;
            CheckLevelIncreases(battleChannel);
        }
Пример #3
0
        public void WithDamage(Participant participant, int damage, int times = 1, int criticalTimes = 0)
        {
            string attacker = participant == Participant.Challenger ? ChallengerNN : DefenderNN,
                   defender = participant == Participant.Defender ? ChallengerNN : DefenderNN;

            if (times == 1)
            {
                WithCustom(string.Format(
                               KrispyGenerator.PickLine(KrispyLines.NinjaSingle),
                               attacker, defender) + " [" + damage + " damage]");
            }
            else
            {
                WithCustom(string.Format(
                               KrispyGenerator.PickLine(KrispyLines.NinjaMultiple),
                               attacker, defender, GetTimesMessage(times), times) + " [" + damage + " " +
                           (criticalTimes > 0 ? "CRITICAL" + (criticalTimes > 1 ? "x" + criticalTimes : "") : "damage") +
                           "]");
            }
        }
Пример #4
0
 public static NinjaSkillBase Random()
 {
     return(Skills[(int)(KrispyGenerator.Value() * Skills.Length)]);
 }
Пример #5
0
        public StepResult Step()
        {
            if (GameOver)
            {
                return(StepResult.Error);
            }

            Display.ResetDisplay();

            Challenger.CurrentStamina--;
            Defender.CurrentStamina--;

            bool challengerTired = Challenger.CurrentStamina <= 0,
                 defenderTired   = Defender.CurrentStamina <= 0;

            if (Challenger.CurrentStamina == 0)
            {
                Display.WithCustom(NinjaDisplay.Participant.Challenger,
                                   "{0} has become tired! He's not moving as fast as before...");
            }
            if (Defender.CurrentStamina == 0)
            {
                Display.WithCustom(NinjaDisplay.Participant.Defender,
                                   "{0} has become tired! He's not moving as fast as before...");
            }

            int challengerLastMovement = (int)(Timestep / (Challenger.Speed * (challengerTired ? 1.5 : 1))),
                defenderLastMovement   = (int)(Timestep / (Defender.Speed * (defenderTired ? 1.5 : 1)));

            Timestep++;
            int challengerMovement = (int)(Timestep / (Challenger.Speed * (challengerTired ? 1.5 : 1))),
                defenderMovement   = (int)(Timestep / (Defender.Speed * (defenderTired ? 1.5 : 1)));

            int challengerAttackTimes = challengerMovement - challengerLastMovement,
                defenderAttackTimes = defenderMovement - defenderLastMovement;
            int challengerDamage = 0, defenderDamage = 0;

            double challengerDodgeOdds = 0.03 + Challenger.Skills.CheckForLevel(0) * 0.05,
                   defenderDodgeOdds   = 0.03 + Defender.Skills.CheckForLevel(0) * 0.05;

            if (KrispyGenerator.Value() <= challengerDodgeOdds)
            {
                defenderAttackTimes = 0;
                Display.WithCustom(NinjaDisplay.Participant.Challenger,
                                   KrispyGenerator.PickLine(KrispyLines.NinjaDodges));
            }
            if (KrispyGenerator.Value() <= defenderDodgeOdds)
            {
                challengerAttackTimes = 0;
                Display.WithCustom(NinjaDisplay.Participant.Defender,
                                   KrispyGenerator.PickLine(KrispyLines.NinjaDodges));
            }

            int    challengerCriticalTimes = 0, defenderCriticalTimes = 0;
            double challengerCriticalOdds = 0.03 + Challenger.Skills.CheckForLevel(1) * 0.05,
                   defenderCriticalOdds   = 0.03 + Defender.Skills.CheckForLevel(1) * 0.05;

            double challengerDmgAmp = 1 + Challenger.Skills.CheckForLevel(5) * 0.3 *
                                      (1 - Challenger.CurrentHP / Challenger.MaxHP),
                   defenderDmgAmp = 1 + Defender.Skills.CheckForLevel(5) * 0.3 *
                                    (1 - Defender.CurrentHP / Defender.MaxHP);

            for (var a = 0; a < challengerAttackTimes; a++)
            {
                var dmg = KrispyGenerator.NumberBetween(Challenger.HitMinimum, Challenger.HitMaximum);
                if (KrispyGenerator.Value() <= challengerCriticalOdds)
                {
                    dmg *= 2; challengerCriticalTimes++;
                }
                dmg  = (int)(dmg * challengerDmgAmp);
                dmg -= Defender.Skills.CheckForLevel(4);
                challengerDamage   += dmg;
                Defender.CurrentHP -= dmg;
            }

            for (var a = 0; a < defenderAttackTimes; a++)
            {
                var dmg = KrispyGenerator.NumberBetween(Defender.HitMinimum, Defender.HitMaximum);
                if (KrispyGenerator.Value() <= defenderCriticalOdds)
                {
                    dmg *= 2; defenderCriticalTimes++;
                }
                dmg                   = (int)(dmg * defenderDmgAmp);
                dmg                  -= Challenger.Skills.CheckForLevel(4);
                defenderDamage       += dmg;
                Challenger.CurrentHP -= dmg;
            }

            if (challengerAttackTimes > 0 || defenderAttackTimes > 0)
            {
                if (challengerAttackTimes > 0)
                {
                    if (Challenger.Skills.SkillExists(6))
                    {
                        var skill = Challenger.Skills.GetSkill(6);
                        skill.ExtraData--;
                        if (skill.ExtraData <= 0)
                        {
                            skill.ExtraData      = skill.BaseSkill.DefaultData;
                            Challenger.CurrentHP =
                                Math.Min(Challenger.CurrentHP +
                                         KrispyGenerator.NumberBetween(skill.Level * 5, skill.Level * 10),
                                         Challenger.MaxHP);
                        }
                    }
                    Display.WithDamage(NinjaDisplay.Participant.Challenger, challengerDamage,
                                       challengerAttackTimes, challengerCriticalTimes);
                }
                if (defenderAttackTimes > 0)
                {
                    if (Defender.Skills.SkillExists(6))
                    {
                        var skill = Defender.Skills.GetSkill(6);
                        skill.ExtraData--;
                        if (skill.ExtraData <= 0)
                        {
                            skill.ExtraData    = skill.BaseSkill.DefaultData;
                            Defender.CurrentHP =
                                Math.Min(Defender.CurrentHP +
                                         KrispyGenerator.NumberBetween(skill.Level * 5, skill.Level * 10),
                                         Defender.MaxHP);
                        }
                    }
                    Display.WithDamage(NinjaDisplay.Participant.Defender, defenderDamage,
                                       defenderAttackTimes, defenderCriticalTimes);
                }

                bool challengerKO = Challenger.CurrentHP <= 0, defenderKO = Defender.CurrentHP <= 0;

                NinjaSkill challengerLastStand = Challenger.Skills.GetSkill(3),
                           defenderLastStand   = Defender.Skills.GetSkill(3);
                if (challengerKO && challengerLastStand != null && challengerLastStand.ExtraData > 0)
                {
                    Challenger.CurrentHP = (int)(Challenger.MaxHP * Challenger.Skills.CheckForLevel(3) * 0.05);
                    Display.WithCustom(NinjaDisplay.Participant.Challenger,
                                       "{0} survived a strong hit! They're on their last stand!");
                    challengerLastStand.ExtraData--;
                    challengerKO = false;
                }
                if (defenderKO && defenderLastStand != null && defenderLastStand.ExtraData > 0)
                {
                    Defender.CurrentHP = (int)(Defender.MaxHP * Defender.Skills.CheckForLevel(3) * 0.05);
                    Display.WithCustom(NinjaDisplay.Participant.Defender,
                                       "{0} survived a strong hit! They're on their last stand!");
                    defenderLastStand.ExtraData--;
                    defenderKO = false;
                }

                Display.WithHealthBar(Challenger.CurrentHP, Defender.CurrentHP, Challenger.MaxHP, Defender.MaxHP);

                if (challengerKO || defenderKO)
                {
                    int challengerXp = Challenger.ExpLevel, defenderXp = Defender.ExpLevel;
                    EndGame(defenderKO, challengerKO);
                    var challengerXpGained = Challenger.ExpLevel - challengerXp;
                    var defenderXpGained   = Defender.ExpLevel - defenderXp;
                    Display.WithExpGained(challengerXpGained, defenderXpGained);
                    Display.WithKOMessage(challengerKO, defenderKO);
                }
            }
            else
            {
                Display.WithHealthBar();
            }

            Display.UpdateDisplay().GetAwaiter().GetResult();
            if (GameOver)
            {
                return(StepResult.End);
            }
            if (challengerAttackTimes > 0 || defenderAttackTimes > 0)
            {
                return(StepResult.Exchange);
            }
            return(StepResult.Nothing);
        }