diff --git a/FakeMon/src/fmon/Game.scala b/FakeMon/src/fmon/Game.scala
index d913120..e940abc 100644
--- a/FakeMon/src/fmon/Game.scala
+++ b/FakeMon/src/fmon/Game.scala
@@ -54,7 +54,6 @@ class Game extends Application {
val party2 = new Party(p2, new MonsterPtr(Monster.generate("Wild Mon", p2, 500, form2, movepool2)), IndexedSeq(
Monster.generate("Sideboard Mon", p2, 500, form2, movepool2)
))
- println(form1.xpCurve)
val engine = new BattleEngine(party1, party2)
controller.setEngine(engine)
diff --git a/FakeMon/src/fmon/battle/BattleEngine.scala b/FakeMon/src/fmon/battle/BattleEngine.scala
index dddd789..454249b 100644
--- a/FakeMon/src/fmon/battle/BattleEngine.scala
+++ b/FakeMon/src/fmon/battle/BattleEngine.scala
@@ -43,7 +43,7 @@ class BattleEngine(val player: Party, val enemy: Party)(implicit val reader: Sig
val replace = enemy.pollReplacement(player)
enemy.switchIn(replace)
} else {
- println(s"${enemy.trainer} has lost!")
+ this ! Message(s"${enemy.trainer} has lost!")
}
}
}
diff --git a/FakeMon/src/fmon/battle/BattleUI.scala b/FakeMon/src/fmon/battle/BattleUI.scala
index 67ac895..6aff388 100644
--- a/FakeMon/src/fmon/battle/BattleUI.scala
+++ b/FakeMon/src/fmon/battle/BattleUI.scala
@@ -15,17 +15,12 @@ import fmon.stat._
import fmon.stat.Statistic._
class BattleUI extends SignalConsumer {
- @FXML var usName: jfxsc.Label = _
- @FXML var usLv: jfxsc.Label = _
- @FXML var usHealth: jfxsc.Label = _
- @FXML var usHealthBar: jfxsc.ProgressBar = _
- @FXML var themName: jfxsc.Label = _
- @FXML var themLv: jfxsc.Label = _
- @FXML var themHealth: jfxsc.Label = _
- @FXML var themHealthBar: jfxsc.ProgressBar = _
@FXML var buttonPane: javafx.scene.layout.VBox = _
@FXML var messages: jfxsc.TextArea = _
+ @FXML var playerMonController: InfoWidget = _
+ @FXML var enemyMonController: InfoWidget = _
+
private var engine: BattleEngine = _
def setEngine(engine: BattleEngine): Unit = {
@@ -35,19 +30,12 @@ class BattleUI extends SignalConsumer {
def updateUI(): Unit = {
val player = engine.player.lead
- usName.text = player.name
- usLv.text = s"Lv. ${player.level}"
- usHealth.text = s"${player.hp}/${player.maxhp}"
- usHealthBar.progress = player.hp.toDouble / player.maxhp
-
val enemy = engine.enemy.lead
- themName.text = enemy.name
- themLv.text = s"Lv. ${enemy.level}"
- themHealth.text = s"${enemy.hp}/${enemy.maxhp}"
- themHealthBar.progress = enemy.hp.toDouble / enemy.maxhp
-
val buttons = player.base.moves.map(move => loadMoveButton(move))
buttonPane.children = buttons
+
+ playerMonController.update(player)
+ enemyMonController.update(enemy)
}
def onMove(move: Move): Unit = {
diff --git a/FakeMon/src/fmon/battle/InfoWidget.fxml b/FakeMon/src/fmon/battle/InfoWidget.fxml
new file mode 100644
index 0000000..06ddec5
--- /dev/null
+++ b/FakeMon/src/fmon/battle/InfoWidget.fxml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FakeMon/src/fmon/battle/InfoWidget.scala b/FakeMon/src/fmon/battle/InfoWidget.scala
new file mode 100644
index 0000000..1e46c9b
--- /dev/null
+++ b/FakeMon/src/fmon/battle/InfoWidget.scala
@@ -0,0 +1,30 @@
+package fmon.battle
+
+import javafx.fxml.FXML
+import javafx.scene.{control => jfxsc}
+
+import scalafx.Includes._
+import scalafx.scene.control._
+
+import fmon.stat.Monster
+import fmon.stat._
+
+class InfoWidget extends javafx.scene.layout.GridPane {
+ @FXML var name: jfxsc.Label = _
+ @FXML var status: jfxsc.Label = _
+ @FXML var health: jfxsc.Label = _
+ @FXML var healthBar: jfxsc.ProgressBar = _
+
+ def update(mon: Monster): Unit = {
+ name.text = mon.name
+ mon.status match {
+ case Some(s) => status.text = s.name
+ case None => status.text = s"Lv. ${mon.level}"
+ }
+
+ health.text = s"${mon.hp}/${mon.maxhp}"
+ val percent = mon.hp \\ mon.maxhp
+ healthBar.progress = percent.toDouble
+ // TODO : Change bar color
+ }
+}
\ No newline at end of file
diff --git a/FakeMon/src/fmon/battle/battle.fxml b/FakeMon/src/fmon/battle/battle.fxml
index e37421d..9bf7d70 100644
--- a/FakeMon/src/fmon/battle/battle.fxml
+++ b/FakeMon/src/fmon/battle/battle.fxml
@@ -1,21 +1,15 @@
-
-
-
-
-
-
@@ -75,70 +69,14 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/FakeMon/src/fmon/stat/Ability.scala b/FakeMon/src/fmon/stat/Ability.scala
index 0182d47..98b40bf 100644
--- a/FakeMon/src/fmon/stat/Ability.scala
+++ b/FakeMon/src/fmon/stat/Ability.scala
@@ -61,8 +61,11 @@ object Ability {
private val helper = """
implicit val gen = rng
implicit val signalConsumer = reader
+ def msg(text: String): Unit = {
+ reader ! Message(text)
+ }
def trigger {
- reader ! Message(s"[${mon}'s ${self}]")
+ msg(s"[${mon}'s ${self}]")
}
def effect = EffectSource(mon, self)
"""
diff --git a/FakeMon/src/fmon/stat/Monster.scala b/FakeMon/src/fmon/stat/Monster.scala
index 11a0f2b..6564aeb 100644
--- a/FakeMon/src/fmon/stat/Monster.scala
+++ b/FakeMon/src/fmon/stat/Monster.scala
@@ -41,7 +41,7 @@ class Monster(val base : StorageMon) {
def statuses = volatile ++ status
- def cureStatus() {
+ def cureStatus()(implicit reader: SignalConsumer, rng: Random) {
status.map(_.onEnd(this))
status = None
}
@@ -54,11 +54,11 @@ class Monster(val base : StorageMon) {
status = Some(s)
s.onStart(this, source)
} else {
- println("But it failed!")
+ reader ! Message("But it failed!")
}
}
- def -=(s : Status) = {
+ def -=(s : Status)(implicit reader: SignalConsumer, rng: Random) = {
if (s.effectType == EffectType.Volatile) {
s.onEnd(this)
volatile = volatile.filterNot(_.name == s.name)
@@ -67,13 +67,13 @@ class Monster(val base : StorageMon) {
}
}
- def applyBoost(s : Stat, boost : Int, effect: EffectSource) {
+ def applyBoost(s : Stat, boost : Int, effect: EffectSource)(implicit reader: SignalConsumer, rng: Random) {
val modified = boosts.getOrElse(s, 0) + boost
boosts = boosts.updated(s, Math.min(MaxBoost, Math.max(-MaxBoost, modified)))
if (boost > 0) {
- println(s"$this's $s rose!")
+ reader ! Message(s"$this's $s rose!")
} else if (boost < 0) {
- println(s"$this's $s fell!")
+ reader ! Message(s"$this's $s fell!")
}
}
diff --git a/FakeMon/src/fmon/stat/Move.scala b/FakeMon/src/fmon/stat/Move.scala
index 542e3f8..3b253fc 100644
--- a/FakeMon/src/fmon/stat/Move.scala
+++ b/FakeMon/src/fmon/stat/Move.scala
@@ -174,7 +174,7 @@ abstract class Move extends MoveTurn {
}
}
- def applyBoosts(target: Monster, boosts: Map[Stat, Int], source: Monster) {
+ def applyBoosts(target: Monster, boosts: Map[Stat, Int], source: Monster)(implicit read: SignalConsumer, rng: Random) {
if (target.isAlive) {
boosts.foreach {
case (s, b) => {
diff --git a/FakeMon/src/fmon/stat/Status.scala b/FakeMon/src/fmon/stat/Status.scala
index 630b9dc..a29251d 100644
--- a/FakeMon/src/fmon/stat/Status.scala
+++ b/FakeMon/src/fmon/stat/Status.scala
@@ -19,7 +19,7 @@ object EffectType extends Enumeration {
case "ability" => AbilityEffect
case "item" => ItemEffect
case "move" => MoveEffect
- case "status" => NonVolatile
+ case "status" | "Status" | "nonvolatile" => NonVolatile
case "volatile" => Volatile
case "weather" => Weather
case _ => default
@@ -49,14 +49,14 @@ class Status(template: StatusTemplate) extends Effect {
// val id
def effectType = template.effectType
def onStart(mon: Monster, source: EffectSource)(implicit reader: SignalConsumer, rng: Random) = template.onStart(this, mon, source, reader, rng)
- def onEnd(mon: Monster) = template.onEnd(this, mon)
+ def onEnd(mon: Monster)(implicit reader: SignalConsumer, rng: Random) = template.onEnd(this, mon, reader, rng)
def onModifyStat(mon: Monster, stat: Stat) = template.onModifyStat(this, mon, stat)
// val onBeforeMovePriority : Int
def onBeforeMove(mon: Monster, move: MoveTurn, target: Monster)(implicit reader: SignalConsumer, rng: Random) = template.onBeforeMove(this, mon, move, target, reader, rng)
// val onModifyMove
// val onHit
def onResidualOrder = template.onResidualOrder
- def onResidual(mon: Monster) = template.onResidual(this, mon)
+ def onResidual(mon: Monster)(implicit reader: SignalConsumer, rng: Random) = template.onResidual(this, mon, reader, rng)
// val onSwitchIn
val intData: MutMap[String, Int] = MutMap[String, Int]()
@@ -70,14 +70,14 @@ abstract class StatusTemplate {
// val id
val effectType: EffectType
val onStart: (Status, Monster, EffectSource, SignalConsumer, Random) => Unit
- val onEnd: (Status, Monster) => Unit
+ val onEnd: (Status, Monster, SignalConsumer, Random) => Unit
val onModifyStat: (Status, Monster, Stat) => Fraction
// val onBeforeMovePriority : Int
val onBeforeMove: (Status, Monster, MoveTurn, Monster, SignalConsumer, Random) => Boolean
// val onModifyMove
// val onHit
val onResidualOrder: Int
- val onResidual: (Status, Monster) => Unit
+ val onResidual: (Status, Monster, SignalConsumer, Random) => Unit
// val onSwitchIn
def build = new Status(this)
@@ -135,7 +135,7 @@ object Status {
}
"""
- def compileOnStart(code: String): (Status, Monster, EffectSource, SignalConsumer, Random ) => Unit = {
+ def compileOnStart(code: String): (Status, Monster, EffectSource, SignalConsumer, Random) => Unit = {
if (code == null) {
(_, _, _, _, _) => ()
} else {
@@ -154,21 +154,22 @@ object Status {
}
}
- def compileOnEnd(code: String): (Status, Monster) => Unit = {
+ def compileOnEnd(code: String): (Status, Monster, SignalConsumer, Random) => Unit = {
if (code == null) {
- (_, _) => ()
+ (_, _, _, _) => ()
} else {
val tree = tb.parse(
s"""
|$header
- |def onStart(self:Status, mon: Monster) = {
+ |def onStart(self:Status, mon: Monster, reader: SignalConsumer, rng: Random) = {
+ | $helpers
| $code
|}
onStart _
""".stripMargin)
val f = tb.compile(tree)
val wrapper = f()
- wrapper.asInstanceOf[(Status, Monster) => Unit]
+ wrapper.asInstanceOf[(Status, Monster, SignalConsumer, Random) => Unit]
}
}
@@ -210,14 +211,15 @@ object Status {
}
}
- def compileOnResidual(code: String): (Status, Monster) => Unit = {
+ def compileOnResidual(code: String): (Status, Monster, SignalConsumer, Random) => Unit = {
if (code == null) {
- (_, _) => ()
+ (_, _, _, _) => ()
} else {
val tree = tb.parse(
s"""
|$header
- |def onResidual(self: Status, mon: Monster) = {
+ |def onResidual(self: Status, mon: Monster, reader: SignalConsumer, rng: Random) = {
+ | $helpers
| $code
|}
|onResidual _
@@ -225,7 +227,7 @@ object Status {
val f = tb.compile(tree)
val wrapper = f()
- wrapper.asInstanceOf[(Status, Monster) => Unit]
+ wrapper.asInstanceOf[(Status, Monster, SignalConsumer, Random) => Unit]
}
}
}
\ No newline at end of file
diff --git a/FakeMon/src/fmon/stat/data/abilities.yaml b/FakeMon/src/fmon/stat/data/abilities.yaml
index 2fc83b0..ba3fdbb 100644
--- a/FakeMon/src/fmon/stat/data/abilities.yaml
+++ b/FakeMon/src/fmon/stat/data/abilities.yaml
@@ -16,7 +16,7 @@ aftermath:
onAfterDamage: |-
if ((source != null) && (source != mon) && (move != null) && move.flags("contact") && !mon.isAlive) {
trigger
- println(s"$source is damaged in the aftermath!")
+ msg(s"$source is damaged in the aftermath!")
source.takeDamage(source(Hp) / 4);
}
onAfterDamageOrder: 1
@@ -31,6 +31,7 @@ flamebody:
onAfterDamage: |-
if (move != null && move.flags("contact")) {
if (rng.chance(3, 10)) {
+ trigger
source.addStatus(Status("brn"), EffectSource(mon, self))
}
}
@@ -59,7 +60,7 @@ innardsout:
onAfterDamage: |-
if (source != null && source != mon && move != null /* && move.effectType === 'Move'*/ && !mon.isAlive) {
trigger
- println(s"$source is damaged in the aftermath!")
+ msg(s"$source is damaged in the aftermath!")
source.takeDamage(damage)//, source, target);
}
onAfterDamageOrder: 1
@@ -76,7 +77,7 @@ ironbarbs:
onAfterDamage: |-
if (source != null && source != mon && move != null && move.flags("contact")) {
trigger
- println(s"Pointed barbs dug into $source!")
+ msg(s"Pointed barbs dug into $source!")
source.takeDamage(source(Hp) / 8)//, source, target)
}
onAfterDamageOrder: 1
@@ -90,6 +91,7 @@ poisonpoint:
onAfterDamage: |-
if (move != null && move.flags("contact")) {
if (rng.chance(3, 10)) {
+ trigger
source.addStatus(Status("psn"), EffectSource(mon, self))
}
}
@@ -105,7 +107,7 @@ roughskin:
onAfterDamage: |-
if (source != null && source != mon && move != null && move.flags("contact")) {
trigger
- println(s"$source is damaged by rough skin!")
+ msg(s"$source is damaged by rough skin!")
source.takeDamage(source(Hp) / 8)//, source, target)
}
onAfterDamageOrder: 1
@@ -131,6 +133,7 @@ static:
onAfterDamage: |-
if (move != null && move.flags("contact")) {
if (rng.chance(3, 10)) {
+ trigger
source.addStatus(Status("par"), EffectSource(mon, self))
}
}
@@ -143,10 +146,8 @@ tanglinghair:
num: 221
onAfterDamage: |-
if (move != null && move.flags("contact")) {
- //this.add('-ability', target, 'Tangling Hair');
trigger
source.applyBoost(Speed, -1, effect)
- //this.boost({'spe': -1}, source, target, null, true);
}
rating: 2.5
shortDesc: Pokemon making contact with this Pokemon have their Speed lowered by
@@ -160,10 +161,8 @@ weakarmor:
num: 133
onAfterDamage: |-
if (move.category == Physical) {
- //this.boost({'def': -1, 'spe': 2}, target, target);
trigger
mon.applyBoost(PDef, -1)
- trigger
mon.applyBoost(Speed, +2)
}
rating: 1
diff --git a/FakeMon/src/fmon/stat/data/statuses.yaml b/FakeMon/src/fmon/stat/data/statuses.yaml
index 6f0e145..346e28c 100644
--- a/FakeMon/src/fmon/stat/data/statuses.yaml
+++ b/FakeMon/src/fmon/stat/data/statuses.yaml
@@ -10,24 +10,13 @@ brn:
1.frac
}
onStart: |
- if (!source.isMove) {
- print(s"[${source.mon}'s ${source.effect}]")
- }
msg(s"${mon} was burned!")
- /*
- if (sourceEffect && sourceEffect.id === 'flameorb') {
- target.status = Status('brn', '[from] 'item': Flame Orb');
- } else if (sourceEffect && sourceEffect.effectType === 'Ability') {
- target.status = Status('brn', '[from] 'ability': ' + sourceEffect.name, '[of] ' + source);
- } else {
- target.status = Status('brn');
- }*/
onEnd: |
- println(s"${mon} was healed of its burn.")
+ msg(s"${mon} was healed of its burn.")
onResidualOrder: 9
onResidual: |
mon.takeDamage(mon(Hp) / 16);
- println(s"${mon} was hurt by its burn!")
+ msg(s"${mon} was hurt by its burn!")
confusion:
id: confusion
@@ -39,7 +28,7 @@ confusion:
mon -= self
true
} else {
- println(s"${mon} is confused!")
+ msg(s"${mon} is confused!")
if (rng.chance(1, 3)) {
// confusion damage
val maxDmg = (2 * mon.level / 5 + 2) * 40 * mon(PAtk) / (mon(PDef) * 50) + 2
@@ -63,15 +52,9 @@ confusion:
}));
*/
onBeforeMovePriority: 3
- onEnd: println(s"${mon} snapped out of its confusion.")
+ onEnd: msg(s"${mon} snapped out of its confusion.")
onStart: |-
msg(s"${mon} was confused!")
- /*
- if (sourceEffect && sourceEffect.id === 'lockedmove') {
- this.add('-start', target, 'confusion', '[fatigue]');
- } else {
- this.add('-start', target, 'confusion');
- }*/
self.intData("time") = rng.nextInt(2, 6);
par:
@@ -80,19 +63,9 @@ par:
num: 0
effectType: 'Status'
onStart: |
- if (!source.isMove) {
- print(s"[${source.mon}'s ${source.effect}]")
- }
- println(s"${mon} was paralyzed!")
- /*
- if (sourceEffect && sourceEffect.effectType === 'Ability') {
- this.add('-status', target, 'par', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
- } else {
- this.add('-status', target, 'par');
- }
- */
+ msg(s"${mon} was paralyzed!")
onEnd: |
- println(s"${mon} is no longer paralyzed!")
+ msg(s"${mon} is no longer paralyzed!")
onModifyStat: |
if (stat == Speed /* && !mon.hasAbility('quickfeet') */) {
1 \\ 2
@@ -114,21 +87,12 @@ slp:
num: 0
effectType: 'Status'
onStart: |
- println(s"${mon} fell asleep!")
- /*
- if (sourceEffect && sourceEffect.effectType === 'Ability') {
- this.add('-status', target, 'slp', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
- } else if (sourceEffect && sourceEffect.effectType === 'Move') {
- this.add('-status', target, 'slp', '[from] move: ' + sourceEffect.name);
- } else {
- this.add('-status', target, 'slp');
- }
- */
+ msg(s"${mon} fell asleep!")
// 1-3 turns
self.intData("startTime") = rng.nextInt(2, 5)
self.intData("time") = self.intData("startTime")
onEnd: |
- println(s"${mon} woke up!")
+ msg(s"${mon} woke up!")
onBeforeMovePriority: 10
onBeforeMove: |
/*
@@ -141,7 +105,7 @@ slp:
mon.cureStatus();
true
} else {
- println(s"${mon} is fast asleep.")
+ msg(s"${mon} is fast asleep.")
!move.flags("sleepUsable")
}
@@ -151,7 +115,7 @@ flinch:
name: flinch
num: 0
onBeforeMove: |-
- println(s"${mon} flinched!")
+ msg(s"${mon} flinched!")
false
onBeforeMovePriority: 8
onResidualOrder: 13
@@ -168,7 +132,7 @@ frz:
mon.cureStatus()
true
} else {
- println(s"${mon} is completely frozen!")
+ msg(s"${mon} is completely frozen!")
false
}
onBeforeMovePriority: 10
@@ -177,19 +141,9 @@ frz:
target.cureStatus()
}
onStart: |-
- println(s"${mon} was frozen solid!")
- /*
- if (sourceEffect && sourceEffect.effectType === 'Ability') {
- target.status = Status('frz', '[from] 'ability': ' + sourceEffect.name, '[of] ' + source);
- } else {
- target.status = Status('frz');
- }
- if (target.template.species === 'Shaymin-Sky' && target.baseTemplate.baseSpecies === 'Shaymin') {
- target.formeChange('Shaymin', this.effect, true);
- }
- */
+ msg(s"${mon} was frozen solid!")
onEnd: |-
- println(s"${mon} thawed out.")
+ msg(s"${mon} thawed out.")
onModifyMove: |
if (move.flags("defrost")) {
mon.cureStatus()
@@ -201,20 +155,13 @@ psn:
num: 0
effectType: 'Status'
onStart: |
- println(s"${mon} was poisoned!")
- /*
- if (sourceEffect && sourceEffect.effectType === 'Ability') {
- this.add('-status', target, 'psn', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
- } else {
- this.add('-status', target, 'psn');
- }
- */
+ msg(s"${mon} was poisoned!")
oneEnd: |
- println(s"${mon} was cured of its poison.")
+ msg(s"${mon} was cured of its poison.")
onResidualOrder: 9
onResidual: |
mon.takeDamage(mon(Hp) / 8);
- println(s"${mon} was damaged by poison!")
+ msg(s"${mon} was damaged by poison!")
tox:
name: 'tox'
@@ -222,16 +169,8 @@ tox:
num: 0
effectType: 'Status'
onStart: |
- println(s"${mon} was baddly poisoned!")
+ msg(s"${mon} was baddly poisoned!")
self.intData("stage") = 0;
- /*
- if (sourceEffect && sourceEffect.id === 'toxicorb') {
- this.add('-status', target, 'tox', '[from] item: Toxic Orb');
- } else if (sourceEffect && sourceEffect.effectType === 'Ability') {
- this.add('-status', target, 'tox', '[from] ability: ' + sourceEffect.name, '[of] ' + source);
- } else {
- this.add('-status', target, 'tox');
- }*/
onSwitchIn: |
this.effectData.stage = 0;
onResidualOrder: 9
@@ -240,4 +179,4 @@ tox:
self.intData("stage") += 1
}
mon.takeDamage(self.intData("stage") \\ 16 * mon(Hp));
- println(s"${mon} was damaged by poison!")
+ msg(s"${mon} was damaged by poison!")
diff --git a/FakeMon/src/fmon/util/Fraction.scala b/FakeMon/src/fmon/util/Fraction.scala
index e0c22c9..3ac38a1 100644
--- a/FakeMon/src/fmon/util/Fraction.scala
+++ b/FakeMon/src/fmon/util/Fraction.scala
@@ -9,6 +9,8 @@ case class Fraction(val num : Int, val denom : Int) extends Ordered[Fraction] {
override def compare(f : Fraction) : Int = {
(num * f.denom) compare (f.num * denom)
}
+
+ def toDouble = 1.0 * num / denom
}
class IntFraction(val x : Int) extends AnyVal {