Added support for abilities including a bunch of abilities that have effects the the monster is hit. Better monster generation support has been added.
This commit is contained in:
@@ -12,7 +12,7 @@ import Statistic._
|
||||
import fmon.util._
|
||||
|
||||
object MoveType extends Enumeration {
|
||||
val Physical, Special, Status = Value
|
||||
val Physical, Special, Support, Other = Value
|
||||
}
|
||||
class MoveTypeType extends TypeReference[MoveType.type]
|
||||
|
||||
@@ -26,6 +26,7 @@ trait MoveTurn {
|
||||
def flags: Set[String]
|
||||
def prior: Int
|
||||
def target: Target
|
||||
def category: MoveType
|
||||
def useMove(user: Monster, target: Monster)(implicit rng: Random): Unit
|
||||
}
|
||||
|
||||
@@ -34,6 +35,7 @@ class SwitchOut(val party: Party, val replacement: Monster) extends MoveTurn {
|
||||
def flags = Set()
|
||||
def prior = +6
|
||||
def target = Target.Self
|
||||
def category = MoveType.Other
|
||||
|
||||
def useMove(user: Monster, target: Monster)(implicit rng: Random): Unit = {
|
||||
println(s"${party.trainer} withdrew $user!")
|
||||
@@ -47,7 +49,7 @@ class SwitchOut(val party: Party, val replacement: Monster) extends MoveTurn {
|
||||
abstract class Move extends MoveTurn {
|
||||
val name: String
|
||||
val desc: String
|
||||
val mvType: MoveType
|
||||
val category: MoveType
|
||||
val pow: Int
|
||||
val powCallback: (Monster, Monster) => Int
|
||||
val prior: Int
|
||||
@@ -89,6 +91,9 @@ abstract class Move extends MoveTurn {
|
||||
user.takeDamage(recoil)
|
||||
println(s"$user took $recoil damage from recoil!")
|
||||
}
|
||||
|
||||
target.base.ability.onAfterDamage(user, this, target, actualDmg)
|
||||
|
||||
if (!user.isAlive) {
|
||||
println(s"$user fainted!")
|
||||
}
|
||||
@@ -126,8 +131,8 @@ abstract class Move extends MoveTurn {
|
||||
}
|
||||
|
||||
def damageRoll(user: Monster, target: Monster)(implicit rng: Random) = {
|
||||
val atkStat = if (mvType == MoveType.Physical) PAtk else MAtk
|
||||
val defStat = if (mvType == MoveType.Physical) PDef else MDef
|
||||
val atkStat = if (category == MoveType.Physical) PAtk else MAtk
|
||||
val defStat = if (category == MoveType.Physical) PDef else MDef
|
||||
// TODO : Fixed damage
|
||||
val actualPow = if (powCallback != null) powCallback(user, target) else pow
|
||||
val baseDmg = (2 * user.level / 5 + 2) * actualPow * user(atkStat) / (target(defStat) * 50) + 2
|
||||
@@ -172,11 +177,7 @@ abstract class Move extends MoveTurn {
|
||||
boosts.foreach {
|
||||
case (s, b) => {
|
||||
target.applyBoost(s, b)
|
||||
if (b > 0) {
|
||||
println(s"$target's $s rose!")
|
||||
} else if (b < 0) {
|
||||
println(s"$target's $s fell!")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,7 +215,7 @@ case class MoveToken(
|
||||
new Move {
|
||||
val name = token.name
|
||||
val desc = token.shortDesc
|
||||
val mvType = category
|
||||
val category = token.category
|
||||
val pow = token.basePower.getOrElse(0)
|
||||
val powCallback = Move.compilePowCallback(token.basePowerCallback)
|
||||
val prior = token.priority
|
||||
@@ -236,7 +237,7 @@ case class MoveToken(
|
||||
|
||||
object Move {
|
||||
private var moves = Map[String, Move]()
|
||||
val tokens = YamlHelper.extractSeq[MoveToken](Source.fromInputStream(Move.getClass.getResourceAsStream("data/moves.yaml"))).map(t => (t.name, t)).toMap
|
||||
val tokens = YamlHelper.extractMap[MoveToken](Source.fromInputStream(Move.getClass.getResourceAsStream("data/moves.yaml")))
|
||||
|
||||
def apply(name: String): Move = {
|
||||
if (!moves.contains(name)) {
|
||||
@@ -250,8 +251,8 @@ object Move {
|
||||
val tb = runtimeMirror(getClass.getClassLoader).mkToolBox()
|
||||
val tree = tb.parse(
|
||||
s"""
|
||||
|import mon.stat.Monster
|
||||
|import mon.stat.Statistic._
|
||||
|import fmon.stat.Monster
|
||||
|import fmon.stat.Statistic._
|
||||
|def callback(user : Monster, target : Monster): Int = {
|
||||
| $code
|
||||
|}
|
||||
|
||||
Reference in New Issue
Block a user