//returns the damage the player will give opponnent public double Attack(UserPlayer player) { double hp = HitProbability(player); double damageDone = GetDamage() * GetRandomProbability(Convert.ToInt32((hp - (hp * .25))), Convert.ToInt32(hp)) / 100; return(damageDone / 100); }
private static Player SetPlayerAttributes(Player player, UserPlayer userPlayer) { player.Aggression = userPlayer.Aggression; player.Agility = userPlayer.Agility; player.Endurance = userPlayer.Endurance; player.Humor = userPlayer.Humor; player.TeamWork = userPlayer.TeamWork; player.Strength = userPlayer.Strength; return(player); }
public double HitProbability(UserPlayer player) { int remainingHealth = 100 - Health; double hp = (Agility * Rating * Strength * Math.Log(TeamWork) + Math.Sqrt(Humor)) / Agility * (Math.Log10(Aggression)); //Using the remaing health as the players energy //Enerrgy is used to determine if the player will produce maximum damage if (this.Injured) { //If player is injured the chances of getting maximum damage is reduced by 50% hp /= (GetRandomProbability(remainingHealth, 120)); hp *= player.GetPlayerAgility(); } else { hp /= (GetRandomProbability((remainingHealth < 50 ? remainingHealth : 50), 50)); hp *= player.GetPlayerAgility(); hp = hp < 75 ? (double)GetRandomProbability(Convert.ToInt32(hp), 100) : hp; } return(hp); }