Added a builder for elements and made the buttons and damage bursts reflect the elemental color
This commit is contained in:
parent
11b03b02d2
commit
4d456d7e5d
1
Builder/.gitignore
vendored
Normal file
1
Builder/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/bin/
|
63
Builder/src/fmon/builder/App.fxml
Normal file
63
Builder/src/fmon/builder/App.fxml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?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.SeparatorMenuItem?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
|
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fmon.builder.App">
|
||||||
|
<children>
|
||||||
|
<MenuBar VBox.vgrow="NEVER">
|
||||||
|
<menus>
|
||||||
|
<Menu mnemonicParsing="false" text="File">
|
||||||
|
<items>
|
||||||
|
<MenuItem mnemonicParsing="false" text="New" />
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#open" text="Open…" />
|
||||||
|
<Menu mnemonicParsing="false" text="Open Recent" />
|
||||||
|
<SeparatorMenuItem mnemonicParsing="false" />
|
||||||
|
<MenuItem mnemonicParsing="false" text="Close" />
|
||||||
|
<MenuItem mnemonicParsing="false" text="Save" />
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#saveAs" 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 fx:id="pane" maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
||||||
|
<children>
|
||||||
|
<Label alignment="CENTER" layoutX="155.0" layoutY="177.0" style=" " text="Drag components from Library here…" textAlignment="CENTER" textFill="#9f9f9f" wrapText="false">
|
||||||
|
<font>
|
||||||
|
<Font size="18.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
54
Builder/src/fmon/builder/App.scala
Normal file
54
Builder/src/fmon/builder/App.scala
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package fmon.builder
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
import javafx.fxml.FXML
|
||||||
|
import javafx.fxml.FXMLLoader
|
||||||
|
import javafx.fxml.JavaFXBuilderFactory
|
||||||
|
import javafx.scene.{control => jfxsc, layout => jfxsl}
|
||||||
|
|
||||||
|
import scalafx.Includes._
|
||||||
|
import scalafx.stage.FileChooser
|
||||||
|
import FileChooser.ExtensionFilter
|
||||||
|
|
||||||
|
trait Savable {
|
||||||
|
def saveTo(file: File): Unit
|
||||||
|
def openFrom(file: File): Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
class App {
|
||||||
|
@FXML var pane: jfxsl.Pane = _
|
||||||
|
|
||||||
|
var builder: Savable = _
|
||||||
|
|
||||||
|
|
||||||
|
def open(): Unit = {
|
||||||
|
val fileChooser = new FileChooser {
|
||||||
|
title = "Open Resource File"
|
||||||
|
extensionFilters ++= Seq(
|
||||||
|
new ExtensionFilter("YAML Files", "*.yaml"),
|
||||||
|
new ExtensionFilter("All Files", "*.*")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val selectedFile = fileChooser.showOpenDialog(null)
|
||||||
|
if (selectedFile != null) {
|
||||||
|
builder openFrom selectedFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def saveAs(): Unit = {
|
||||||
|
val fileChooser = new FileChooser {
|
||||||
|
title = "Open Resource File"
|
||||||
|
extensionFilters ++= Seq(
|
||||||
|
new ExtensionFilter("YAML Files", "*.yaml"),
|
||||||
|
new ExtensionFilter("All Files", "*.*")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val selectedFile = fileChooser.showSaveDialog(null)
|
||||||
|
if (selectedFile != null) {
|
||||||
|
builder saveTo selectedFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
Builder/src/fmon/builder/ElementBuilder.fxml
Normal file
93
Builder/src/fmon/builder/ElementBuilder.fxml
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ColorPicker?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.ListView?>
|
||||||
|
<?import javafx.scene.control.Separator?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fmon.builder.ElementBuilder">
|
||||||
|
<left>
|
||||||
|
<VBox BorderPane.alignment="CENTER">
|
||||||
|
<children>
|
||||||
|
<ListView fx:id="elements" prefWidth="200.0" />
|
||||||
|
<HBox prefHeight="0.0" prefWidth="200.0">
|
||||||
|
<children>
|
||||||
|
<Button fx:id="add" mnemonicParsing="false" onAction="#addElement" text="+" />
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</left>
|
||||||
|
<center>
|
||||||
|
<VBox prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
|
||||||
|
<children>
|
||||||
|
<GridPane>
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Label text="Element Name:" />
|
||||||
|
<ColorPicker fx:id="bgColor" onAction="#updateBg" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
|
<Label text="Background Color:" GridPane.rowIndex="1" />
|
||||||
|
<Label text="Text Color:" GridPane.rowIndex="2" />
|
||||||
|
<ColorPicker fx:id="textColor" onAction="#updateFont" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
|
<Label text="Symbol:" GridPane.rowIndex="3" />
|
||||||
|
<Label text="Example" GridPane.rowIndex="4" />
|
||||||
|
<Button fx:id="button" mnemonicParsing="false" text="Button" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||||
|
<TextField fx:id="name" onAction="#updateName" promptText="Element" GridPane.columnIndex="1" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
<Separator prefHeight="0.0" prefWidth="400.0" />
|
||||||
|
<GridPane prefHeight="252.0" prefWidth="400.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="155.0" minHeight="10.0" prefHeight="38.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="186.0" minHeight="10.0" prefHeight="186.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="26.0" minHeight="0.0" prefHeight="26.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Label text="Immune" />
|
||||||
|
<Label text="Resist" GridPane.columnIndex="2" />
|
||||||
|
<Label text="Normal" GridPane.columnIndex="4" />
|
||||||
|
<Label text="Weak" GridPane.columnIndex="6" />
|
||||||
|
<ListView fx:id="immuneView" prefHeight="200.0" prefWidth="200.0" GridPane.columnSpan="2" GridPane.rowIndex="1" />
|
||||||
|
<ListView fx:id="resistView" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="1" />
|
||||||
|
<ListView fx:id="normalView" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="4" GridPane.columnSpan="2" GridPane.rowIndex="1" />
|
||||||
|
<ListView fx:id="weakView" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="6" GridPane.columnSpan="2" GridPane.rowIndex="1" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#immune2Resist" text="->" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#resist2Immune" text="<-" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#resist2Normal" text="->" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#normal2Resist" text="<-" GridPane.columnIndex="4" GridPane.rowIndex="2" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#normal2Weak" text="->" GridPane.columnIndex="5" GridPane.rowIndex="2" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#weak2Normal" text="<-" GridPane.columnIndex="6" GridPane.rowIndex="2" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
</children>
|
||||||
|
</VBox>
|
||||||
|
</center>
|
||||||
|
</BorderPane>
|
227
Builder/src/fmon/builder/ElementBuilder.scala
Normal file
227
Builder/src/fmon/builder/ElementBuilder.scala
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
package fmon.builder
|
||||||
|
|
||||||
|
import java.io._
|
||||||
|
|
||||||
|
import javafx.application.Application
|
||||||
|
import javafx.fxml.FXML
|
||||||
|
import javafx.fxml.FXMLLoader
|
||||||
|
import javafx.fxml.JavaFXBuilderFactory
|
||||||
|
import javafx.scene.{control => jfxsc, Parent, Scene}
|
||||||
|
import javafx.stage.Stage
|
||||||
|
|
||||||
|
import scalafx.Includes._
|
||||||
|
import scalafx.beans.property._
|
||||||
|
import scalafx.collections.ObservableBuffer
|
||||||
|
import scalafx.scene.control._
|
||||||
|
import scalafx.scene.paint.Color
|
||||||
|
import scalafx.scene.layout._
|
||||||
|
|
||||||
|
import org.yaml.snakeyaml.nodes._
|
||||||
|
import org.yaml.snakeyaml.nodes.Tag
|
||||||
|
import org.yaml.snakeyaml.constructor._
|
||||||
|
import org.yaml.snakeyaml.representer._
|
||||||
|
|
||||||
|
import fmon.stat.Element
|
||||||
|
import fmon.util.YamlHelper
|
||||||
|
|
||||||
|
import TableColumn._
|
||||||
|
|
||||||
|
class ObsElement(name_ : String, bgColor_ : Color = Color.Gray, fontColor_ : Color = Color.Black) {
|
||||||
|
val name = new StringProperty(this, "name", name_)
|
||||||
|
val bgColor = new ObjectProperty[Color](this, "bgColor", bgColor_)
|
||||||
|
val fontColor = new ObjectProperty[Color](this, "fontColor", fontColor_)
|
||||||
|
|
||||||
|
val immune = new ObservableBuffer[ObsElement]()
|
||||||
|
val resist = new ObservableBuffer[ObsElement]()
|
||||||
|
val normal = new ObservableBuffer[ObsElement]()
|
||||||
|
val weak = new ObservableBuffer[ObsElement]()
|
||||||
|
|
||||||
|
def asElement = {
|
||||||
|
def toMap(buffer: ObservableBuffer[ObsElement], mult: Double) = {
|
||||||
|
buffer.map(e => (e.name(), mult)).toMap
|
||||||
|
}
|
||||||
|
val effect = toMap(immune, 0.0) ++ toMap(resist, 0.5) ++ toMap(normal, 1.0) ++ toMap(weak, 2.0)
|
||||||
|
new Element(name(), bgColor(), fontColor(), effect)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def toString = name()
|
||||||
|
}
|
||||||
|
|
||||||
|
class ColorRepresenter extends Representer {
|
||||||
|
representers.put(classOf[Color], new ColorRepresent)
|
||||||
|
|
||||||
|
class ColorRepresent extends Represent {
|
||||||
|
override def representData(data: AnyRef): Node = {
|
||||||
|
val color = data.asInstanceOf[Color]
|
||||||
|
representScalar(new Tag("!color"), color.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ColorConstructor extends Constructor {
|
||||||
|
yamlConstructors.put(new Tag("!color"), new ConstructColor)
|
||||||
|
|
||||||
|
class ConstructColor extends AbstractConstruct {
|
||||||
|
override def construct(node: Node): AnyRef = {
|
||||||
|
val string = constructScalar(node.asInstanceOf[ScalarNode])
|
||||||
|
return Color.valueOf(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ElementBuilder extends Savable {
|
||||||
|
@FXML var elements: jfxsc.ListView[ObsElement] = _
|
||||||
|
@FXML var add: jfxsc.Button = _
|
||||||
|
//@FXML var matchups: jfxsc.TableView[ObsElement] = _
|
||||||
|
var elementList = ObservableBuffer[ObsElement]()
|
||||||
|
|
||||||
|
@FXML var immuneView: jfxsc.ListView[ObsElement] = _
|
||||||
|
@FXML var resistView: jfxsc.ListView[ObsElement] = _
|
||||||
|
@FXML var normalView: jfxsc.ListView[ObsElement] = _
|
||||||
|
@FXML var weakView: jfxsc.ListView[ObsElement] = _
|
||||||
|
|
||||||
|
@FXML var name: jfxsc.TextField = _
|
||||||
|
@FXML var bgColor: jfxsc.ColorPicker = _
|
||||||
|
@FXML var textColor: jfxsc.ColorPicker = _
|
||||||
|
@FXML var button: jfxsc.Button = _
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
def initialize(): Unit = {
|
||||||
|
elements.items = elementList
|
||||||
|
elementList ++= Seq(new ObsElement("Fire"), new ObsElement("Water"), new ObsElement("Leaf"))
|
||||||
|
elements.selectionModel().selectedIndex.onChange(selectionChange)
|
||||||
|
elements.selectionModel().selectFirst()
|
||||||
|
|
||||||
|
elementList.foreach(e => elementList.foreach(f => e.normal += f))
|
||||||
|
}
|
||||||
|
|
||||||
|
def selectionChange(): Unit = {
|
||||||
|
val element = elementList(elements.selectionModel().selectedIndex())
|
||||||
|
name.text = element.name()
|
||||||
|
bgColor.value = element.bgColor()
|
||||||
|
textColor.value = element.fontColor()
|
||||||
|
|
||||||
|
immuneView.items = element.immune
|
||||||
|
resistView.items = element.resist
|
||||||
|
normalView.items = element.normal
|
||||||
|
weakView.items = element.weak
|
||||||
|
updateFont()
|
||||||
|
}
|
||||||
|
|
||||||
|
def updateName(): Unit = {
|
||||||
|
button.text = name.text()
|
||||||
|
setChanges()
|
||||||
|
}
|
||||||
|
|
||||||
|
def updateBg(): Unit = {
|
||||||
|
updateFont()
|
||||||
|
}
|
||||||
|
|
||||||
|
def updateFont(): Unit = {
|
||||||
|
val bg = bgColor.value().toString().replaceFirst("0x", "#")
|
||||||
|
val color = textColor.value().toString().replaceFirst("0x", "#")
|
||||||
|
button.style = s"-fx-background-color: ${bg}; -fx-text-fill: ${color}"
|
||||||
|
setChanges()
|
||||||
|
}
|
||||||
|
|
||||||
|
def setChanges(): Unit = {
|
||||||
|
val element = elementList(elements.selectionModel().selectedIndex())
|
||||||
|
element.name.value = name.text()
|
||||||
|
element.bgColor.value = bgColor.value()
|
||||||
|
element.fontColor.value = textColor.value()
|
||||||
|
elements.refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
def addElement(): Unit = {
|
||||||
|
elementList += new ObsElement("New Element")
|
||||||
|
println(elements.items().size())
|
||||||
|
}
|
||||||
|
|
||||||
|
def immune2Resist(): Unit = {
|
||||||
|
val items = immuneView.selectionModel().getSelectedItems
|
||||||
|
resistView.items() ++= items
|
||||||
|
immuneView.items() --= items
|
||||||
|
}
|
||||||
|
|
||||||
|
def resist2Immune(): Unit = {
|
||||||
|
val items = resistView.selectionModel().getSelectedItems
|
||||||
|
immuneView.items() ++= items
|
||||||
|
resistView.items() --= items
|
||||||
|
}
|
||||||
|
|
||||||
|
def resist2Normal(): Unit = {
|
||||||
|
val items = resistView.selectionModel().getSelectedItems
|
||||||
|
normalView.items() ++= items
|
||||||
|
resistView.items() --= items
|
||||||
|
}
|
||||||
|
|
||||||
|
def normal2Resist(): Unit = {
|
||||||
|
val items = normalView.selectionModel().getSelectedItems
|
||||||
|
resistView.items() ++= items
|
||||||
|
normalView.items() --= items
|
||||||
|
}
|
||||||
|
|
||||||
|
def normal2Weak(): Unit = {
|
||||||
|
val items = normalView.selectionModel().getSelectedItems
|
||||||
|
weakView.items() ++= items
|
||||||
|
normalView.items() --= items
|
||||||
|
}
|
||||||
|
|
||||||
|
def weak2Normal(): Unit = {
|
||||||
|
val items = weakView.selectionModel().getSelectedItems
|
||||||
|
normalView.items() ++= items
|
||||||
|
weakView.items() --= items
|
||||||
|
}
|
||||||
|
|
||||||
|
override def saveTo(file: File): Unit = {
|
||||||
|
val elementMap = elementList.map(e => (e.name(), e.asElement)).toMap
|
||||||
|
YamlHelper.writeMap(new FileOutputStream(file), elementMap)
|
||||||
|
}
|
||||||
|
|
||||||
|
override def openFrom(file: File): Unit = {
|
||||||
|
val elementMap = YamlHelper.extractMap[Element](new FileInputStream(file))
|
||||||
|
val es = elementMap.values.map(e => new ObsElement(e.name, e.bgColor, e.fontColor)).toSeq
|
||||||
|
es.foreach(eo => es.foreach(fo => {
|
||||||
|
val e = elementMap(eo.name())
|
||||||
|
val f = elementMap(fo.name())
|
||||||
|
val mult = e <-- f
|
||||||
|
if (mult < 0.1) {
|
||||||
|
eo.immune += fo
|
||||||
|
} else if (mult < 0.75) {
|
||||||
|
eo.resist += fo
|
||||||
|
} else if (mult < 1.25) {
|
||||||
|
eo.normal += fo
|
||||||
|
} else {
|
||||||
|
eo.weak += fo
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
elementList.clear()
|
||||||
|
elementList ++= es
|
||||||
|
elements.selectionModel().selectFirst()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ElementBuilder {
|
||||||
|
class EBA extends Application {
|
||||||
|
override def start(primaryStage: Stage): Unit = {
|
||||||
|
val frameLoader = new FXMLLoader(getClass.getResource("App.fxml"))
|
||||||
|
val root: Parent = frameLoader.load()
|
||||||
|
val controller = frameLoader.getController[App]()
|
||||||
|
|
||||||
|
val builderLoader = new FXMLLoader(getClass.getResource("ElementBuilder.fxml"))
|
||||||
|
val builder: Parent = builderLoader.load()
|
||||||
|
val builderController = builderLoader.getController[ElementBuilder]()
|
||||||
|
|
||||||
|
controller.pane.children = builder
|
||||||
|
controller.builder = builderController
|
||||||
|
|
||||||
|
val scene: Scene = new Scene(root)
|
||||||
|
primaryStage.setScene(scene)
|
||||||
|
primaryStage.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
Application.launch(classOf[EBA], args: _*)
|
||||||
|
}
|
||||||
|
}
|
@ -97,7 +97,7 @@ class BattleUI extends SignalConsumer {
|
|||||||
numPlaying += 1
|
numPlaying += 1
|
||||||
def helper = {
|
def helper = {
|
||||||
val r = 25
|
val r = 25
|
||||||
val color = Color.AliceBlue
|
val color = element.bgColor
|
||||||
val center = findCenter(target)
|
val center = findCenter(target)
|
||||||
|
|
||||||
val circle = new Circle {
|
val circle = new Circle {
|
||||||
|
@ -5,6 +5,7 @@ import javafx.scene.{control => jfxsc}
|
|||||||
|
|
||||||
import scalafx.Includes._
|
import scalafx.Includes._
|
||||||
import scalafx.scene.control._
|
import scalafx.scene.control._
|
||||||
|
import scalafx.scene.paint.Color
|
||||||
|
|
||||||
import fmon.stat.Move
|
import fmon.stat.Move
|
||||||
|
|
||||||
@ -19,10 +20,16 @@ class MoveButton {
|
|||||||
move = mv
|
move = mv
|
||||||
moveName.text = mv.name
|
moveName.text = mv.name
|
||||||
moveUses.text = s"${move.pp}/${move.pp}"
|
moveUses.text = s"${move.pp}/${move.pp}"
|
||||||
|
moveBtn.style = s"-fx-background-color: ${colorString(mv.element.bgColor)}; -fx-text-fill: ${colorString(mv.element.fontColor)}"
|
||||||
this.callback = callback
|
this.callback = callback
|
||||||
}
|
}
|
||||||
|
|
||||||
def moveActivate(): Unit = {
|
def moveActivate(): Unit = {
|
||||||
callback(move)
|
callback(move)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def colorString(color: Color): String = {
|
||||||
|
val s = color.toString()
|
||||||
|
s"#${s.split("x")(1)}"
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,15 +2,15 @@ package fmon.stat
|
|||||||
|
|
||||||
import scala.io.Source
|
import scala.io.Source
|
||||||
|
|
||||||
|
import scalafx.scene.paint.Color
|
||||||
|
|
||||||
import fmon.util.YamlHelper
|
import fmon.util.YamlHelper
|
||||||
|
|
||||||
case class Element(val name : String, val effect : Map[String, Double]) {
|
case class Element(val name : String, val bgColor: Color, val fontColor: Color, val effect : Map[String, Double]) {
|
||||||
|
|
||||||
def -->(other : Element) = {
|
def -->(other : Element) = other <-- this
|
||||||
effect.getOrElse(other.name, 1.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
def <--(other : Element) = other --> this
|
def <--(other : Element) = effect.getOrElse(other.name, 1.0)
|
||||||
|
|
||||||
override def toString = name
|
override def toString = name
|
||||||
}
|
}
|
||||||
|
@ -1,174 +1,523 @@
|
|||||||
Bug:
|
---
|
||||||
effect:
|
|
||||||
Dark: 2.0
|
|
||||||
Fairy: 0.5
|
|
||||||
Fighting: 0.5
|
|
||||||
Fire: 0.5
|
|
||||||
Flying: 0.5
|
|
||||||
Ghost: 0.5
|
|
||||||
Grass: 2.0
|
|
||||||
Poison: 0.5
|
|
||||||
Psychic: 2.0
|
|
||||||
Steel: 0.5
|
|
||||||
name: Bug
|
|
||||||
Dark:
|
|
||||||
effect:
|
|
||||||
Dark: 0.5
|
|
||||||
Fairy: 0.5
|
|
||||||
Fighting: 0.5
|
|
||||||
Ghost: 2.0
|
|
||||||
Psychic: 2.0
|
|
||||||
name: Dark
|
|
||||||
Dragon:
|
|
||||||
effect:
|
|
||||||
Dragon: 2.0
|
|
||||||
Fairy: 0.0
|
|
||||||
Steel: 0.5
|
|
||||||
name: Dragon
|
|
||||||
Electric:
|
|
||||||
effect:
|
|
||||||
Dragon: 0.5
|
|
||||||
Electric: 0.5
|
|
||||||
Flying: 2.0
|
|
||||||
Grass: 0.5
|
|
||||||
Ground: 0.0
|
|
||||||
Water: 2.0
|
|
||||||
name: Electric
|
|
||||||
Fairy:
|
|
||||||
effect:
|
|
||||||
Dark: 2.0
|
|
||||||
Dragon: 2.0
|
|
||||||
Fighting: 2.0
|
|
||||||
Fire: 0.5
|
|
||||||
Poison: 0.5
|
|
||||||
Steel: 0.5
|
|
||||||
name: Fairy
|
|
||||||
Fighting:
|
|
||||||
effect:
|
|
||||||
Bug: 0.5
|
|
||||||
Dark: 2.0
|
|
||||||
Fairy: 0.5
|
|
||||||
Flying: 0.5
|
|
||||||
Ghost: 0.0
|
|
||||||
Ice: 2.0
|
|
||||||
Normal: 2.0
|
|
||||||
Poison: 0.5
|
|
||||||
Psychic: 0.5
|
|
||||||
Rock: 2.0
|
|
||||||
Steel: 2.0
|
|
||||||
name: Fighting
|
|
||||||
Fire:
|
|
||||||
effect:
|
|
||||||
Bug: 2.0
|
|
||||||
Dragon: 0.5
|
|
||||||
Fire: 0.5
|
|
||||||
Grass: 2.0
|
|
||||||
Ice: 2.0
|
|
||||||
Rock: 0.5
|
|
||||||
Steel: 2.0
|
|
||||||
Water: 0.5
|
|
||||||
name: Fire
|
|
||||||
Flying:
|
|
||||||
effect:
|
|
||||||
Bug: 2.0
|
|
||||||
Electric: 0.5
|
|
||||||
Fighting: 2.0
|
|
||||||
Grass: 2.0
|
|
||||||
Rock: 0.5
|
|
||||||
Steel: 0.5
|
|
||||||
name: Flying
|
|
||||||
Ghost:
|
|
||||||
effect:
|
|
||||||
Dark: 0.5
|
|
||||||
Ghost: 2.0
|
|
||||||
Normal: 0.0
|
|
||||||
Psychic: 2.0
|
|
||||||
name: Ghost
|
|
||||||
Grass:
|
|
||||||
effect:
|
|
||||||
Bug: 0.5
|
|
||||||
Dragon: 0.5
|
|
||||||
Fire: 0.5
|
|
||||||
Flying: 0.5
|
|
||||||
Grass: 0.5
|
|
||||||
Ground: 2.0
|
|
||||||
Poison: 0.5
|
|
||||||
Rock: 2.0
|
|
||||||
Steel: 0.5
|
|
||||||
Water: 2.0
|
|
||||||
name: Grass
|
|
||||||
Ground:
|
|
||||||
effect:
|
|
||||||
Bug: 0.5
|
|
||||||
Electric: 2.0
|
|
||||||
Fire: 2.0
|
|
||||||
Flying: 0.0
|
|
||||||
Grass: 0.5
|
|
||||||
Poison: 2.0
|
|
||||||
Rock: 2.0
|
|
||||||
Steel: 2.0
|
|
||||||
name: Ground
|
|
||||||
Ice:
|
|
||||||
effect:
|
|
||||||
Dragon: 2.0
|
|
||||||
Fire: 0.5
|
|
||||||
Flying: 2.0
|
|
||||||
Grass: 2.0
|
|
||||||
Ground: 2.0
|
|
||||||
Ice: 0.5
|
|
||||||
Steel: 0.5
|
|
||||||
Water: 0.5
|
|
||||||
name: Ice
|
|
||||||
Normal:
|
Normal:
|
||||||
|
name: "Normal"
|
||||||
|
bgColor:
|
||||||
|
red: 0.501960813999176
|
||||||
|
green: 0.501960813999176
|
||||||
|
blue: 0.501960813999176
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
effect:
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 1.0
|
||||||
Ghost: 0.0
|
Ghost: 0.0
|
||||||
Rock: 0.5
|
Ice: 1.0
|
||||||
Steel: 0.5
|
Water: 1.0
|
||||||
name: Normal
|
Fighting: 2.0
|
||||||
Poison:
|
Ground: 1.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 1.0
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 1.0
|
||||||
|
Dark: 1.0
|
||||||
|
Electric:
|
||||||
|
name: "Electric"
|
||||||
|
bgColor:
|
||||||
|
red: 0.9019607901573181
|
||||||
|
green: 0.9019607901573181
|
||||||
|
blue: 0.3019607961177826
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
effect:
|
effect:
|
||||||
Fairy: 2.0
|
Normal: 1.0
|
||||||
Ghost: 0.5
|
Electric: 0.5
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 0.5
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 1.0
|
||||||
|
Ground: 2.0
|
||||||
|
Steel: 0.5
|
||||||
|
Bug: 1.0
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 1.0
|
||||||
|
Dark: 1.0
|
||||||
|
Poison:
|
||||||
|
name: "Poison"
|
||||||
|
bgColor:
|
||||||
|
red: 0.6000000238418579
|
||||||
|
green: 0.4000000059604645
|
||||||
|
blue: 0.6000000238418579
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 0.5
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 0.5
|
||||||
|
Ground: 2.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 0.5
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 0.5
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 2.0
|
||||||
|
Grass: 0.5
|
||||||
|
Dark: 1.0
|
||||||
|
Rock:
|
||||||
|
name: "Rock"
|
||||||
|
bgColor:
|
||||||
|
red: 0.6000000238418579
|
||||||
|
green: 0.4000000059604645
|
||||||
|
blue: 0.0
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 0.5
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 0.5
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 0.5
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 2.0
|
||||||
|
Fighting: 2.0
|
||||||
|
Ground: 2.0
|
||||||
|
Steel: 2.0
|
||||||
|
Bug: 1.0
|
||||||
|
Fire: 0.5
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
Grass: 2.0
|
Grass: 2.0
|
||||||
Ground: 0.5
|
Dark: 1.0
|
||||||
|
Flying:
|
||||||
|
name: "Flying"
|
||||||
|
bgColor:
|
||||||
|
red: 0.7019608020782471
|
||||||
|
green: 0.6000000238418579
|
||||||
|
blue: 1.0
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 2.0
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 2.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 2.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 0.5
|
||||||
|
Ground: 0.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 0.5
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 0.5
|
||||||
|
Dark: 1.0
|
||||||
|
Ghost:
|
||||||
|
name: "Ghost"
|
||||||
|
bgColor:
|
||||||
|
red: 0.501960813999176
|
||||||
|
green: 0.3019607961177826
|
||||||
|
blue: 0.501960813999176
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 0.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 0.5
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 2.0
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 0.0
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 0.5
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 1.0
|
||||||
|
Dark: 2.0
|
||||||
|
Ice:
|
||||||
|
name: "Ice"
|
||||||
|
bgColor:
|
||||||
|
red: 0.7019608020782471
|
||||||
|
green: 0.9019607901573181
|
||||||
|
blue: 0.9019607901573181
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 2.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 0.5
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 2.0
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 2.0
|
||||||
|
Bug: 1.0
|
||||||
|
Fire: 2.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 1.0
|
||||||
|
Dark: 1.0
|
||||||
|
Water:
|
||||||
|
name: "Water"
|
||||||
|
bgColor:
|
||||||
|
red: 0.501960813999176
|
||||||
|
green: 0.6000000238418579
|
||||||
|
blue: 1.0
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 2.0
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 0.5
|
||||||
|
Water: 0.5
|
||||||
|
Fighting: 1.0
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 0.5
|
||||||
|
Bug: 1.0
|
||||||
|
Fire: 0.5
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 2.0
|
||||||
|
Dark: 1.0
|
||||||
|
Fighting:
|
||||||
|
name: "Fighting"
|
||||||
|
bgColor:
|
||||||
|
red: 0.800000011920929
|
||||||
|
green: 0.20000000298023224
|
||||||
|
blue: 0.20000000298023224
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 0.5
|
||||||
|
Flying: 2.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 1.0
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 0.5
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 2.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 2.0
|
||||||
|
Grass: 1.0
|
||||||
|
Dark: 0.5
|
||||||
|
Ground:
|
||||||
|
name: "Ground"
|
||||||
|
bgColor:
|
||||||
|
red: 0.9019607901573181
|
||||||
|
green: 0.7019608020782471
|
||||||
|
blue: 0.3019607961177826
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 0.0
|
||||||
Poison: 0.5
|
Poison: 0.5
|
||||||
Rock: 0.5
|
Rock: 0.5
|
||||||
Steel: 0.0
|
Flying: 1.0
|
||||||
name: Poison
|
Ghost: 1.0
|
||||||
Psychic:
|
|
||||||
effect:
|
|
||||||
Dark: 0.0
|
|
||||||
Fighting: 2.0
|
|
||||||
Poison: 2.0
|
|
||||||
Psychic: 0.5
|
|
||||||
Steel: 0.5
|
|
||||||
name: Psychic
|
|
||||||
Rock:
|
|
||||||
effect:
|
|
||||||
Bug: 2.0
|
|
||||||
Fighting: 0.5
|
|
||||||
Fire: 2.0
|
|
||||||
Flying: 2.0
|
|
||||||
Ground: 0.5
|
|
||||||
Ice: 2.0
|
Ice: 2.0
|
||||||
Steel: 0.5
|
Water: 2.0
|
||||||
name: Rock
|
Fighting: 1.0
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 1.0
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 2.0
|
||||||
|
Dark: 1.0
|
||||||
Steel:
|
Steel:
|
||||||
|
name: "Steel"
|
||||||
|
bgColor:
|
||||||
|
red: 0.800000011920929
|
||||||
|
green: 0.800000011920929
|
||||||
|
blue: 0.800000011920929
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
effect:
|
effect:
|
||||||
Electric: 0.5
|
Normal: 0.5
|
||||||
Fairy: 2.0
|
Electric: 1.0
|
||||||
Fire: 0.5
|
Poison: 0.0
|
||||||
Ice: 2.0
|
Rock: 0.5
|
||||||
Rock: 2.0
|
Flying: 0.5
|
||||||
Steel: 0.5
|
Ghost: 1.0
|
||||||
Water: 0.5
|
Ice: 0.5
|
||||||
name: Steel
|
Water: 1.0
|
||||||
Water:
|
Fighting: 2.0
|
||||||
effect:
|
|
||||||
Dragon: 0.5
|
|
||||||
Fire: 2.0
|
|
||||||
Grass: 0.5
|
|
||||||
Ground: 2.0
|
Ground: 2.0
|
||||||
|
Steel: 0.5
|
||||||
|
Bug: 0.5
|
||||||
|
Fire: 2.0
|
||||||
|
Fairy: 0.5
|
||||||
|
Dragon: 0.5
|
||||||
|
Psychic: 0.5
|
||||||
|
Grass: 0.5
|
||||||
|
Dark: 1.0
|
||||||
|
Bug:
|
||||||
|
name: "Bug"
|
||||||
|
bgColor:
|
||||||
|
red: 0.7019608020782471
|
||||||
|
green: 0.9019607901573181
|
||||||
|
blue: 0.7019608020782471
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 1.0
|
||||||
Rock: 2.0
|
Rock: 2.0
|
||||||
|
Flying: 2.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 0.5
|
||||||
|
Ground: 0.5
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 1.0
|
||||||
|
Fire: 2.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 0.5
|
||||||
|
Dark: 1.0
|
||||||
|
Fire:
|
||||||
|
name: "Fire"
|
||||||
|
bgColor:
|
||||||
|
red: 0.9019607901573181
|
||||||
|
green: 0.501960813999176
|
||||||
|
blue: 0.3019607961177826
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 2.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 0.5
|
||||||
|
Water: 2.0
|
||||||
|
Fighting: 1.0
|
||||||
|
Ground: 2.0
|
||||||
|
Steel: 0.5
|
||||||
|
Bug: 0.5
|
||||||
|
Fire: 0.5
|
||||||
|
Fairy: 0.5
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 0.5
|
||||||
|
Dark: 1.0
|
||||||
|
Fairy:
|
||||||
|
name: "Fairy"
|
||||||
|
bgColor:
|
||||||
|
red: 0.9019607901573181
|
||||||
|
green: 0.7019608020782471
|
||||||
|
blue: 0.800000011920929
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 2.0
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 0.5
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 2.0
|
||||||
|
Bug: 0.5
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 0.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 1.0
|
||||||
|
Dark: 0.5
|
||||||
|
Dragon:
|
||||||
|
name: "Dragon"
|
||||||
|
bgColor:
|
||||||
|
red: 0.4000000059604645
|
||||||
|
green: 0.20000000298023224
|
||||||
|
blue: 0.4000000059604645
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 0.5
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 2.0
|
||||||
Water: 0.5
|
Water: 0.5
|
||||||
name: Water
|
Fighting: 1.0
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 1.0
|
||||||
|
Fire: 0.5
|
||||||
|
Fairy: 2.0
|
||||||
|
Dragon: 2.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 0.5
|
||||||
|
Dark: 1.0
|
||||||
|
Psychic:
|
||||||
|
name: "Psychic"
|
||||||
|
bgColor:
|
||||||
|
red: 1.0
|
||||||
|
green: 0.501960813999176
|
||||||
|
blue: 0.501960813999176
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 2.0
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 0.5
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 2.0
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 0.5
|
||||||
|
Grass: 1.0
|
||||||
|
Dark: 2.0
|
||||||
|
Grass:
|
||||||
|
name: "Grass"
|
||||||
|
bgColor:
|
||||||
|
red: 0.6000000238418579
|
||||||
|
green: 0.800000011920929
|
||||||
|
blue: 0.6000000238418579
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 0.5
|
||||||
|
Poison: 2.0
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 2.0
|
||||||
|
Ghost: 1.0
|
||||||
|
Ice: 2.0
|
||||||
|
Water: 0.5
|
||||||
|
Fighting: 1.0
|
||||||
|
Ground: 0.5
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 2.0
|
||||||
|
Fire: 2.0
|
||||||
|
Fairy: 1.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 1.0
|
||||||
|
Grass: 0.5
|
||||||
|
Dark: 1.0
|
||||||
|
Dark:
|
||||||
|
name: "Dark"
|
||||||
|
bgColor:
|
||||||
|
red: 0.3019607961177826
|
||||||
|
green: 0.3019607961177826
|
||||||
|
blue: 0.3019607961177826
|
||||||
|
fontColor:
|
||||||
|
red: 0.0
|
||||||
|
green: 0.0
|
||||||
|
blue: 0.0
|
||||||
|
effect:
|
||||||
|
Normal: 1.0
|
||||||
|
Electric: 1.0
|
||||||
|
Poison: 1.0
|
||||||
|
Rock: 1.0
|
||||||
|
Flying: 1.0
|
||||||
|
Ghost: 0.5
|
||||||
|
Ice: 1.0
|
||||||
|
Water: 1.0
|
||||||
|
Fighting: 2.0
|
||||||
|
Ground: 1.0
|
||||||
|
Steel: 1.0
|
||||||
|
Bug: 2.0
|
||||||
|
Fire: 1.0
|
||||||
|
Fairy: 2.0
|
||||||
|
Dragon: 1.0
|
||||||
|
Psychic: 0.0
|
||||||
|
Grass: 1.0
|
||||||
|
Dark: 0.5
|
||||||
|
@ -1,20 +1,55 @@
|
|||||||
package fmon.util
|
package fmon.util
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.core._
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind._
|
||||||
|
import com.fasterxml.jackson.databind.ser._
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.StdSerializer
|
||||||
|
import com.fasterxml.jackson.databind.deser._
|
||||||
|
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
|
||||||
|
import com.fasterxml.jackson.databind.module.SimpleModule
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode
|
||||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
|
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
|
||||||
import com.fasterxml.jackson.module.scala.DefaultScalaModule
|
import com.fasterxml.jackson.module.scala.DefaultScalaModule
|
||||||
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
|
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
|
||||||
|
|
||||||
import java.io.InputStream
|
import scalafx.scene.paint.Color
|
||||||
|
|
||||||
|
import java.io.{InputStream, OutputStream}
|
||||||
|
|
||||||
import scala.io.Source
|
import scala.io.Source
|
||||||
|
|
||||||
import fmon.util._
|
import fmon.util._
|
||||||
|
|
||||||
|
class ColorSerializer extends StdSerializer[Color](classOf[Color]) {
|
||||||
|
override def serialize(color: Color, jgen: JsonGenerator, serializer: SerializerProvider): Unit = {
|
||||||
|
jgen.writeStartObject()
|
||||||
|
jgen.writeFieldName("red")
|
||||||
|
jgen.writeNumber(color.red)
|
||||||
|
jgen.writeFieldName("green")
|
||||||
|
jgen.writeNumber(color.green)
|
||||||
|
jgen.writeFieldName("blue")
|
||||||
|
jgen.writeNumber(color.blue)
|
||||||
|
jgen.writeEndObject()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ColorDeserializer extends StdDeserializer[Color](classOf[Color]) {
|
||||||
|
override def deserialize(jp: JsonParser, ctxt: DeserializationContext): Color = {
|
||||||
|
val node = jp.getCodec.readTree[JsonNode](jp)
|
||||||
|
val red = node.get("red").asDouble()
|
||||||
|
val green = node.get("green").asDouble()
|
||||||
|
val blue = node.get("blue").asDouble()
|
||||||
|
Color.color(red, green, blue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object YamlHelper {
|
object YamlHelper {
|
||||||
val mapper = new ObjectMapper(new YAMLFactory()) with ScalaObjectMapper
|
val mapper = new ObjectMapper(new YAMLFactory()) with ScalaObjectMapper
|
||||||
mapper.registerModule(DefaultScalaModule)
|
mapper.registerModule(DefaultScalaModule)
|
||||||
|
val module = new SimpleModule()
|
||||||
|
module.addSerializer(classOf[Color], new ColorSerializer)
|
||||||
|
module.addDeserializer(classOf[Color], new ColorDeserializer)
|
||||||
|
mapper.registerModule(module)
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
|
|
||||||
def extract[T](text : String)(implicit m : Manifest[T]) : T = {
|
def extract[T](text : String)(implicit m : Manifest[T]) : T = {
|
||||||
@ -50,4 +85,8 @@ object YamlHelper {
|
|||||||
def extractMap[T](source : InputStream)(implicit m: Manifest[T]) : Map[String, T] = {
|
def extractMap[T](source : InputStream)(implicit m: Manifest[T]) : Map[String, T] = {
|
||||||
mapper.readValue[Map[String, T]](source)
|
mapper.readValue[Map[String, T]](source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def writeMap[T](source: OutputStream, items: Map[String, T])(implicit m: Manifest[T]) = {
|
||||||
|
mapper.writeValue(source, items)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user