Messages will now play when an ability triggers

This commit is contained in:
James Daly
2019-06-06 17:37:32 -04:00
parent d2ee6debf8
commit bebbf469db
6 changed files with 87 additions and 44 deletions

View File

@@ -21,8 +21,9 @@ object Target extends Enumeration {
}
class TargetType extends TypeReference[Target.type]
trait MoveTurn {
trait MoveTurn extends Effect {
def name: String
def effectType = EffectType.MoveEffect
def flags: Set[String]
def prior: Int
def target: Target
@@ -101,16 +102,16 @@ abstract class Move extends MoveTurn {
println(s"$target fainted!")
}
}
applyBoosts(target, boosts)
applyStatus(target, status)
applyBoosts(target, boosts, user)
applyStatus(target, user, status)
if (effect != null) {
applyEffect(target, effect)
applyEffect(target, user, effect)
}
if (selfEffect != null) {
applyEffect(user, selfEffect)
applyEffect(user, user, selfEffect)
}
if (secondary != null && rng.chance(secondary.chance.%%)) {
applyEffect(target, secondary)
applyEffect(target, user, secondary)
}
// TODO : Multiparty
@@ -160,24 +161,23 @@ 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 applyEffect(target: Monster, source: Monster, effect: Secondary)(implicit rng: Random) {
applyBoosts(target, effect.boosts, source)
applyStatus(target, source, effect.status)
applyStatus(target, source, effect.volatile)
}
def applyStatus(target: Monster, status: StatusTemplate)(implicit rng: Random) {
def applyStatus(target: Monster, user: Monster, status: StatusTemplate)(implicit rng: Random) {
if (target.isAlive && status != null) {
target += status.build
target.addStatus(status.build, EffectSource(user, this))
}
}
def applyBoosts(target: Monster, boosts: Map[Stat, Int]) {
def applyBoosts(target: Monster, boosts: Map[Stat, Int], source: Monster) {
if (target.isAlive) {
boosts.foreach {
case (s, b) => {
target.applyBoost(s, b)
target.applyBoost(s, b, EffectSource(source, this))
}
}
}