Lots more work on implementing battling
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.Models;
|
||||
@@ -13,4 +14,20 @@ public interface IBattleRandom : IRandom
|
||||
/// chance.
|
||||
/// </summary>
|
||||
bool EffectChance(float chance, IExecutingMove executingMove, IPokemon target, byte hitNumber);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBattleRandom"/>
|
||||
public class BattleRandomImpl : RandomImpl, IBattleRandom
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool EffectChance(float chance, IExecutingMove executingMove, IPokemon target, byte hitNumber)
|
||||
{
|
||||
executingMove.RunScriptHook(script => script.ChangeEffectChance(executingMove, target, hitNumber, ref chance));
|
||||
target.RunScriptHook(script => script.ChangeIncomingEffectChance(executingMove, target, hitNumber, ref chance));
|
||||
if (chance > 100.0)
|
||||
return true;
|
||||
if (chance < 0.0)
|
||||
return false;
|
||||
return GetFloat() * 100.0 < chance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user