SHARE
TWEET

Untitled

a guest Oct 20th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace WildArmsSimulator.Simulation
  2. {
  3.     public class PlayerDamageCalculator
  4.     {
  5.         public IBattleState BattleState { get; }
  6.         public PlayerDamageCalculator(IBattleState battleState)
  7.         {
  8.             BattleState = battleState;
  9.         }
  10.  
  11.         //If absorb or nullify, handle in battle engine logic
  12.         public int GetSpellDamage(int sor, int spellModifier, int targetMgr, int forceLevel, bool isWeakness, bool isResistant)
  13.         {
  14.             var damage = sor * spellModifier;
  15.             damage -= targetMgr;
  16.  
  17.             return CalculateVariance(damage, forceLevel);
  18.         }
  19.  
  20.         //TODO: Investigate weakness and resistance modifiers
  21.         public int GetRegularAttackDamage(int atp, int targetDfp, int forceLevel, bool isCritical, bool isHyper, bool isWeakness, bool isResistant)
  22.         {
  23.             var damage = atp * 2;
  24.             if (!isCritical)
  25.             {
  26.                 damage -= targetDfp;
  27.             }
  28.  
  29.             if (isHyper)
  30.             {
  31.                 damage *= 2;
  32.             }
  33.             return CalculateVariance(damage, forceLevel);
  34.         }
  35.  
  36.         public int GetArmAttackDamage(int armAtp, int level, int forceLevel, int targetDfp)
  37.         {
  38.             var damage = (int)((10 * (level * 1.5 + armAtp)) - targetDfp);
  39.             return CalculateVariance(damage, forceLevel);
  40.         }
  41.  
  42.         public int CalculateVariance(int baseDamage, int forceLevel)
  43.         {
  44.             var currentDamage = baseDamage;
  45.             currentDamage += GetRandomModifier(currentDamage);
  46.             if (forceLevel >= 1)
  47.             {
  48.                 currentDamage += GetForceModifier(currentDamage);
  49.             }
  50.             if (forceLevel >= 2)
  51.             {
  52.                 currentDamage += GetForceModifier(currentDamage);
  53.             }
  54.             if (forceLevel >= 3)
  55.             {
  56.                 currentDamage += GetForceModifier(currentDamage);
  57.             }
  58.             if (forceLevel >= 4)
  59.             {
  60.                 currentDamage += GetForceModifier(currentDamage);
  61.             }
  62.             return currentDamage;
  63.         }
  64.        
  65.         private int GetRandomModifier(int baseDamage)
  66.         {
  67.             var randomDamage = BattleState.Rng.Next((int)(baseDamage * .1) * -1, (int)(baseDamage * .1));
  68.             return randomDamage;
  69.         }
  70.  
  71.         private int GetForceModifier(int baseDamage)
  72.         {
  73.             var randomDamage = BattleState.Rng.Next(0, (int)(baseDamage * .1));
  74.             return randomDamage;
  75.         }
  76.  
  77.     }
  78. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top