Incorporated a UI
This commit is contained in:
parent
273a79c9c6
commit
2805bbf1c7
4
FakeMon/info/Credits.txt
Normal file
4
FakeMon/info/Credits.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Images
|
||||
Aekashics
|
||||
http://www.akashics.moe/
|
||||
Battlers
|
@ -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()
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
54
FakeMon/src/fmon/battle/BattleUI.scala
Normal file
54
FakeMon/src/fmon/battle/BattleUI.scala
Normal file
@ -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
|
||||
}
|
||||
}
|
27
FakeMon/src/fmon/battle/MoveButton.scala
Normal file
27
FakeMon/src/fmon/battle/MoveButton.scala
Normal file
@ -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}")
|
||||
}
|
||||
}
|
143
FakeMon/src/fmon/battle/battle.fxml
Normal file
143
FakeMon/src/fmon/battle/battle.fxml
Normal file
@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Menu?>
|
||||
<?import javafx.scene.control.MenuBar?>
|
||||
<?import javafx.scene.control.MenuItem?>
|
||||
<?import javafx.scene.control.ProgressBar?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.control.SeparatorMenuItem?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<VBox prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fmon.battle.BattleUI">
|
||||
<children>
|
||||
<MenuBar VBox.vgrow="NEVER">
|
||||
<menus>
|
||||
<Menu mnemonicParsing="false" text="File">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" text="New" />
|
||||
<MenuItem mnemonicParsing="false" text="Open…" />
|
||||
<Menu mnemonicParsing="false" text="Open Recent" />
|
||||
<SeparatorMenuItem mnemonicParsing="false" />
|
||||
<MenuItem mnemonicParsing="false" text="Close" />
|
||||
<MenuItem mnemonicParsing="false" text="Save" />
|
||||
<MenuItem mnemonicParsing="false" text="Save As…" />
|
||||
<MenuItem mnemonicParsing="false" text="Revert" />
|
||||
<SeparatorMenuItem mnemonicParsing="false" />
|
||||
<MenuItem mnemonicParsing="false" text="Preferences…" />
|
||||
<SeparatorMenuItem mnemonicParsing="false" />
|
||||
<MenuItem mnemonicParsing="false" text="Quit" />
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Edit">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" text="Undo" />
|
||||
<MenuItem mnemonicParsing="false" text="Redo" />
|
||||
<SeparatorMenuItem mnemonicParsing="false" />
|
||||
<MenuItem mnemonicParsing="false" text="Cut" />
|
||||
<MenuItem mnemonicParsing="false" text="Copy" />
|
||||
<MenuItem mnemonicParsing="false" text="Paste" />
|
||||
<MenuItem mnemonicParsing="false" text="Delete" />
|
||||
<SeparatorMenuItem mnemonicParsing="false" />
|
||||
<MenuItem mnemonicParsing="false" text="Select All" />
|
||||
<MenuItem mnemonicParsing="false" text="Unselect All" />
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Help">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" text="About MyHelloApp" />
|
||||
</items>
|
||||
</Menu>
|
||||
</menus>
|
||||
</MenuBar>
|
||||
<AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<ImageView fitHeight="575.0" fitWidth="856.0" pickOnBounds="true">
|
||||
<image>
|
||||
<Image url="@images/scene01.jpg" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<ImageView fitHeight="250.0" fitWidth="250.0" layoutX="14.0" layoutY="279.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@images/Colossal%20Bat.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<ImageView fitHeight="250.0" fitWidth="250.0" layoutX="606.0" layoutY="87.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@images/Darkness%20Slime.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<GridPane layoutX="14.0" layoutY="502.0" prefHeight="59.0" prefWidth="200.0" style="-fx-background-color: lightgrey;">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="139.0" minWidth="10.0" prefWidth="139.0" />
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" maxWidth="95.0" minWidth="10.0" prefWidth="61.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="22.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="29.0" minHeight="10.0" prefHeight="18.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label fx:id="usName" text="Batty">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="usLv" text="Lv. 17" textAlignment="RIGHT" GridPane.columnIndex="1">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<ProgressBar fx:id="usHealthBar" prefHeight="24.0" prefWidth="200.0" progress="1.0" GridPane.columnSpan="2" GridPane.rowIndex="1" />
|
||||
<Label fx:id="usHealth" text="43/43" GridPane.rowIndex="2">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</GridPane>
|
||||
<GridPane layoutX="642.0" layoutY="14.0" prefHeight="59.0" prefWidth="200.0" style="-fx-background-color: lightgrey;">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="137.0" minWidth="10.0" prefWidth="137.0" />
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" maxWidth="95.0" minWidth="10.0" prefWidth="63.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="37.0" minHeight="10.0" prefHeight="22.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="29.0" minHeight="10.0" prefHeight="18.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label fx:id="themName" text="Slime">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="themLv" text="Lv. 17" textAlignment="RIGHT" GridPane.columnIndex="1">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<ProgressBar fx:id="themHealthBar" prefHeight="24.0" prefWidth="200.0" progress="1.0" GridPane.columnSpan="2" GridPane.rowIndex="1" />
|
||||
<Label fx:id="themHealth" text="43/43" GridPane.rowIndex="2">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</GridPane>
|
||||
<ScrollPane hbarPolicy="NEVER" layoutX="616.0" layoutY="344.0" prefHeight="200.0" prefWidth="200.0">
|
||||
<content>
|
||||
<VBox fx:id="buttonPane" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</VBox>
|
BIN
FakeMon/src/fmon/battle/images/Colossal Bat.png
Normal file
BIN
FakeMon/src/fmon/battle/images/Colossal Bat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
BIN
FakeMon/src/fmon/battle/images/Darkness Slime.png
Normal file
BIN
FakeMon/src/fmon/battle/images/Darkness Slime.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
FakeMon/src/fmon/battle/images/scene01.jpg
Normal file
BIN
FakeMon/src/fmon/battle/images/scene01.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 312 KiB |
25
FakeMon/src/fmon/battle/moveButton.fxml
Normal file
25
FakeMon/src/fmon/battle/moveButton.fxml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<Button fx:id="moveBtn" mnemonicParsing="false" onAction="#moveActivate" prefHeight="40.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fmon.battle.MoveButton">
|
||||
<graphic>
|
||||
<AnchorPane prefHeight="32.0" prefWidth="168.0">
|
||||
<children>
|
||||
<Label fx:id="moveName" text="Move" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="moveUses" alignment="CENTER_RIGHT" text="20/20" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</graphic>
|
||||
</Button>
|
@ -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]()
|
||||
|
Loading…
x
Reference in New Issue
Block a user