import { GetDEBUG } from "../../app" ; import { Ability , TargetMode } from "../ability" ; import { Perks } from "../perks" ; import { IParse , Text } from "../text" ; const RunAb = new Ability ( ) ; RunAb . name = "Run" ; RunAb . Short = ( ) => "Run away." ; RunAb . targetMode = TargetMode . Self ; RunAb . enabledCondition = ( encounter , caster ) => { return encounter . canRun ; } ; RunAb . CastInternal = ( encounter , caster ) => { const parse = { Name : caster . NameDesc ( ) , was : caster . plural ( ) ? "were" : "was" , y : caster . plural ( ) ? "y" : "ies" , } ; Text . Add ( "[Name] tr[y] to run away... " , parse ) ; Text . Flush ( ) ; if ( encounter . canRun ) { const runlevel = encounter . RunLevel ( ) ; let goal = caster . level / ( caster . level + runlevel ) ; if ( caster . HasPerk ( Perks . Fleetfoot ) ) { goal *= 1.5 ; } if ( ( Math . random ( ) < goal ) || GetDEBUG ( ) ) { encounter . onRun ( ) ; } else { Text . Add ( "but [was] unable to!" , parse ) ; Text . NL ( ) ; encounter . CombatTick ( ) ; } } else { Text . NL ( ) ; encounter . CombatTick ( ) ; } } ; export { RunAb } ;