Skip to content

Commit

Permalink
Merge pull request #142 from ElisaTronetti/develop
Browse files Browse the repository at this point in the history
Handle of negative number in attempt escape probability
  • Loading branch information
Tale152 committed Oct 8, 2021
2 parents ae695aa + ade302e commit cd26543
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ object BattleController {

private def escapeCondition: Boolean = {
val enemy: Enemy = storyModel.currentStoryNode.enemy.get
Random.nextInt(escapeChance - (storyModel.player.properties.modifiedStat(StatName.Intelligence).value -
enemy.properties.modifiedStat(StatName.Dexterity).value)) == 0
val escapeBaseValue: Int = escapeChance - (
storyModel.player.properties.modifiedStat(StatName.Intelligence).value -
enemy.properties.modifiedStat(StatName.Dexterity).value)

Random.nextInt(if (escapeBaseValue > 0) escapeBaseValue else 1) == 0
}

private def escapeFailed(): Unit = {
Expand Down

0 comments on commit cd26543

Please sign in to comment.