Advertisement
Guest User

ewfd

a guest
Jan 20th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1.  
  2. int optimalDamage = 0;
  3. int minHealth = int.MinValue;
  4.  
  5. Creature bestTarget = null;
  6. List<Creature> killedCreatures = new List<Creature>();
  7.  
  8. foreach (var target in targets)
  9. {
  10. if (target.HealthPoints - CalculateActualDamage(target) <= 0)
  11. {
  12. killedCreatures.Add(target);
  13. }
  14. }
  15. if (killedCreatures.Count ==0)
  16. {
  17. foreach (var target in targets)
  18. {
  19. if (minHealth>target.HealthPoints - CalculateActualDamage(target))
  20. {
  21. minHealth = target.HealthPoints - CalculateActualDamage(target);
  22. bestTarget = target;
  23. }
  24. }
  25. }
  26. else
  27. {
  28. foreach (var target in targets)
  29. {
  30. if (optimalDamage < target.Damage)
  31. {
  32. optimalDamage = target.Damage;
  33. bestTarget = target;
  34. }
  35. }
  36. }
  37. return bestTarget;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement