Ejemplo n.º 1
0
        AvatarStatus Convert(CSVBattleStatus bs)
        {
            var ast = new AvatarStatus();

            ast.Name        = CreateName(bs);
            ast.Level       = bs.Level;
            ast.Rank        = bs.Rank;
            ast.PAtk        = bs.PAtk;
            ast.PDef        = bs.PDef;
            ast.MaxHp       = bs.MaxHp;
            ast.Avoid       = bs.Avoid;
            ast.Accuracy    = bs.Accuracy;
            ast.HPAuto      = bs.HPAuto;
            ast.TPAuto      = bs.TPAuto;
            ast.HPDrain     = bs.HPDrain;
            ast.HealUp      = bs.HealUp;
            ast.TPUp        = bs.TPUp;
            ast.TPReduction = bs.TPReduction;
            ast.MAtk        = bs.MAtk;
            ast.MDef        = bs.MDef;
            ast.PCri        = bs.PCri;
            ast.MCri        = bs.MCri;

            return(ast);
        }
Ejemplo n.º 2
0
        public static AttackResult Battle(AvatarStatus attack, AvatarStatus defence, int damage, uint flag)
        {
            var result = new AttackResult();

            if ((flag & AttackFlag.Psysical) != 0)
            {
                result.damage  = damage * 100 / (100 + defence.PDef);
                result.criRate = attack.PCri * 0.05f * Math.Max(attack.Level - defence.Level, 0);
            }
            else if ((flag & AttackFlag.Magic) != 0)
            {
                result.damage  = damage * 100 / (100 + defence.MDef);
                result.criRate = attack.MCri * 0.05f * Math.Max(attack.Level - defence.Level, 0);
            }

            int avoid = Math.Max(defence.Avoid - attack.Hit, 0);

            result.avoidRate = 100f * avoid / (100f + avoid);
            result.hpDrain   = result.damage * attack.HPDrain / (attack.HPDrain + defence.Level + 100);

            result.tpGain = 90 * (100 + attack.TPUp) / 100;

            if ((flag & AttackFlag.EnshuredHit) != 0)
            {
                result.avoidRate = 0;
            }
            if ((flag & AttackFlag.EnshuredCri) != 0)
            {
                result.criRate = 100;
            }
            if ((flag & AttackFlag.Invincible) != 0)
            {
                result.avoidRate = 100;
            }

            result.tpEnemyGain = (result.damage * 500 / defence.MaxHp) * (100 + defence.TPUp) / 100;

            return(result);
        }