diff --git a/FakeMon/info/Credits.txt b/FakeMon/info/Credits.txt new file mode 100644 index 0000000..38e22f0 --- /dev/null +++ b/FakeMon/info/Credits.txt @@ -0,0 +1,4 @@ +Images +Aekashics + http://www.akashics.moe/ + Battlers \ No newline at end of file diff --git a/FakeMon/src/fmon/Game.scala b/FakeMon/src/fmon/Game.scala index 5c6f9bb..3b0cfeb 100644 --- a/FakeMon/src/fmon/Game.scala +++ b/FakeMon/src/fmon/Game.scala @@ -1,19 +1,20 @@ package fmon -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory -import com.fasterxml.jackson.module.scala.DefaultScalaModule +import javafx.application.Application +import javafx.fxml._ +import javafx.scene.{Scene, Parent} +import javafx.stage.Stage -import scala.reflect.runtime.universe._ -import scala.tools.reflect.ToolBox +import scalafx.Includes._ -import fmon.battle.BattleEngine +import fmon.battle.{BattleEngine, BattleUI} import fmon.stat._ case class Prop(url : Seq[String]) object Game { def main(args : Array[String]): Unit = { + /* implicit val rng = new scala.util.Random() val form1 = Form("Diabolo") val form2 = Form("Chanilla") @@ -29,5 +30,36 @@ object Game { val engine = new BattleEngine(party1, party2) engine.play() println(party1.lead.elements) + * */ + Application.launch(classOf[Game], args: _*) + } +} + +class Game extends Application { + override def start(primaryStage: Stage): Unit = { + val url = getClass.getResource("battle/battle.fxml") + val loader = new FXMLLoader(url) + val root: Parent = loader.load() + val controller = loader.getController[BattleUI]() + val scene: Scene = new Scene(root) + + implicit val rng = new scala.util.Random() + val form1 = Form("Diabolo") + val form2 = Form("Chanilla") + val movepool1 = IndexedSeq(Move("eruption"), Move("willowisp"), Move("thunderbolt"), Move("thunderwave")) + val movepool2 = IndexedSeq(Move("flail")) + val p1 = TrainerID("Jaeda", Gender.Female, 0) + val p2 = TrainerID("Wild Monster", Gender.Male, 0) + val party1 = new Party(p1, new MonsterPtr(Monster.generate("Allied Mon", p1, 500, form1, movepool1)), IndexedSeq()) + 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) + + primaryStage.setTitle("FakeMon Battle Simulator") + primaryStage.setScene(scene) + primaryStage.show() } } \ No newline at end of file diff --git a/FakeMon/src/fmon/battle/BattleEngine.scala b/FakeMon/src/fmon/battle/BattleEngine.scala index 7bd4966..e89d458 100644 --- a/FakeMon/src/fmon/battle/BattleEngine.scala +++ b/FakeMon/src/fmon/battle/BattleEngine.scala @@ -15,8 +15,14 @@ class BattleEngine(val player: Party, val enemy: Party)(implicit val rng: Random } } - def playTurn() = { + + + def playTurn(): Unit = { val playerAction = player.pollAction(enemy) + playTurn(playerAction) + } + + def playTurn(playerAction: Action): Unit = { val enemyAction = enemy.pollAction(player) val actions = Seq(playerAction, enemyAction) diff --git a/FakeMon/src/fmon/battle/BattleUI.scala b/FakeMon/src/fmon/battle/BattleUI.scala new file mode 100644 index 0000000..a4e5405 --- /dev/null +++ b/FakeMon/src/fmon/battle/BattleUI.scala @@ -0,0 +1,54 @@ +package fmon.battle + +import javafx.fxml.FXML +import javafx.fxml.FXMLLoader +import javafx.fxml.JavaFXBuilderFactory +import javafx.scene.{control => jfxsc} + +import scalafx.Includes._ +import scalafx.scene.Parent +import scalafx.scene.control._ +import scalafx.scene.layout._ + +import fmon.stat._ +import fmon.stat.Statistic._ + +class BattleUI { + @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 = _ + + private var engine: BattleEngine = _ + + def setEngine(engine: BattleEngine): 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 / 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 / enemy.maxhp + + val buttons = player.base.moves.map(move => loadMoveButton(move)) + buttonPane.children = buttons + } + + private def loadMoveButton(move: Move): Button = { + val fxmlLoader = new FXMLLoader(getClass.getResource("moveButton.fxml")) + fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory()) + val button = fxmlLoader.load[jfxsc.Button]() + val controller = fxmlLoader.getController[MoveButton]() + controller.setup(move) + button + } +} \ No newline at end of file diff --git a/FakeMon/src/fmon/battle/MoveButton.scala b/FakeMon/src/fmon/battle/MoveButton.scala new file mode 100644 index 0000000..8aa62c5 --- /dev/null +++ b/FakeMon/src/fmon/battle/MoveButton.scala @@ -0,0 +1,27 @@ +package fmon.battle + +import javafx.fxml.FXML +import javafx.scene.{control => jfxsc} + +import scalafx.Includes._ +import scalafx.scene.control._ + +import fmon.stat.Move + +class MoveButton { + @FXML var moveBtn: jfxsc.Button = _ + @FXML var moveName: jfxsc.Label = _ + @FXML var moveUses: jfxsc.Label = _ + private var move: Move = _ + + def setup(mv: Move): Unit = { + move = mv + moveName.text = mv.name + moveUses.text = s"${move.pp}/${move.pp}" + } + + def moveActivate(): Unit = { + println("We should take a turn here") + println(s"${moveBtn.width}") + } +} \ No newline at end of file diff --git a/FakeMon/src/fmon/battle/battle.fxml b/FakeMon/src/fmon/battle/battle.fxml new file mode 100644 index 0000000..dd88064 --- /dev/null +++ b/FakeMon/src/fmon/battle/battle.fxml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FakeMon/src/fmon/battle/images/Colossal Bat.png b/FakeMon/src/fmon/battle/images/Colossal Bat.png new file mode 100644 index 0000000..01b4e83 Binary files /dev/null and b/FakeMon/src/fmon/battle/images/Colossal Bat.png differ diff --git a/FakeMon/src/fmon/battle/images/Darkness Slime.png b/FakeMon/src/fmon/battle/images/Darkness Slime.png new file mode 100644 index 0000000..6ff62be Binary files /dev/null and b/FakeMon/src/fmon/battle/images/Darkness Slime.png differ diff --git a/FakeMon/src/fmon/battle/images/scene01.jpg b/FakeMon/src/fmon/battle/images/scene01.jpg new file mode 100644 index 0000000..5ff3dbf Binary files /dev/null and b/FakeMon/src/fmon/battle/images/scene01.jpg differ diff --git a/FakeMon/src/fmon/battle/moveButton.fxml b/FakeMon/src/fmon/battle/moveButton.fxml new file mode 100644 index 0000000..cdbbf90 --- /dev/null +++ b/FakeMon/src/fmon/battle/moveButton.fxml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/FakeMon/src/fmon/stat/Monster.scala b/FakeMon/src/fmon/stat/Monster.scala index 42d5514..1bf9cd9 100644 --- a/FakeMon/src/fmon/stat/Monster.scala +++ b/FakeMon/src/fmon/stat/Monster.scala @@ -12,6 +12,7 @@ class Monster(val base : StorageMon) { val stats = Statistic.buildMap(computeStat) var boosts = Statistic.buildMap(_ => 0) var hp = stats(Hp) + def maxhp = stats(Hp) var status : Option[Status] = None var volatile = Seq[Status]()