Added support for volatile status effects including confusion and flinching. Also, all elements are now supported.

This commit is contained in:
James Daly
2019-06-03 22:46:09 -04:00
parent 34cd67c36f
commit ce81ab2079
12 changed files with 355 additions and 155 deletions

View File

@@ -60,6 +60,7 @@ abstract class Move extends MoveTurn {
val crit: Int
val status: StatusTemplate
val drain: Fraction
val effect: Secondary
val selfEffect: Secondary
val secondary: Secondary
// boosts
@@ -97,6 +98,9 @@ abstract class Move extends MoveTurn {
}
applyBoosts(target, boosts)
applyStatus(target, status)
if (effect != null) {
applyEffect(target, effect)
}
if (selfEffect != null) {
applyEffect(user, selfEffect)
}
@@ -104,7 +108,6 @@ abstract class Move extends MoveTurn {
applyEffect(target, secondary)
}
// TODO : Support moves
// TODO : Multiparty
} else {
println("Missed!")
@@ -155,18 +158,12 @@ abstract class Move extends MoveTurn {
def applyEffect(target: Monster, effect: Secondary)(implicit rng: Random) {
applyBoosts(target, effect.boosts)
applyStatus(target, effect.status)
applyStatus(target, effect.volatile)
}
def applyStatus(target: Monster, status: StatusTemplate)(implicit rng: Random) {
if (target.isAlive && status != null) {
if (target.status == None) {
// apply status
val s = status.build
target.status = Some(s)
s.onStart(target)
} else {
println("But it failed!")
}
target += status.build
}
}
@@ -204,6 +201,7 @@ case class MoveToken(
val status: String,
val self: SecondaryToken,
val secondary: SecondaryToken,
val volatileStatus: String,
val drain: Fraction,
val recoil: Fraction,
@JsonScalaEnumeration(classOf[TargetType]) val target: Target = Target.Normal,
@@ -212,6 +210,7 @@ case class MoveToken(
def instantiate() = {
val token = this
val effectToken = SecondaryToken(100, Map(), null, token.volatileStatus, null)
new Move {
val name = token.name
val desc = token.shortDesc
@@ -228,6 +227,7 @@ case class MoveToken(
val crit = token.critRatio
val status = if (token.status != null) Status(token.status) else null
val drain = if (token.drain != null) token.drain else if (token.recoil != null) -token.recoil else 0.frac
val effect = effectToken.instantiate()
val selfEffect = if (token.self != null) token.self.instantiate() else null
val secondary = if (token.secondary != null) token.secondary.instantiate() else null
}