From f8132c6a4f50636b081f3caad383d331662166b4 Mon Sep 17 00:00:00 2001 From: niangaoa Date: Sun, 18 Dec 2022 20:24:03 +0800 Subject: [PATCH] 1.0 --- .../Ctrller/BSSGameCtrl.java | 107 ++++++++---------- .../GameContro/DataSave.java | 6 - .../GameContro/GameData.java | 9 -- 3 files changed, 46 insertions(+), 76 deletions(-) diff --git a/src/main/java/com/niangaoa/BusinessSimulator/Ctrller/BSSGameCtrl.java b/src/main/java/com/niangaoa/BusinessSimulator/Ctrller/BSSGameCtrl.java index 8693b3b..cc4dde5 100644 --- a/src/main/java/com/niangaoa/BusinessSimulator/Ctrller/BSSGameCtrl.java +++ b/src/main/java/com/niangaoa/BusinessSimulator/Ctrller/BSSGameCtrl.java @@ -14,6 +14,8 @@ import java.io.IOException; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.ResourceBundle; public class BSSGameCtrl implements Initializable { @@ -38,31 +40,32 @@ public class BSSGameCtrl implements Initializable { @FXML private Button read; - public Text have1 = new Text(); @FXML - public Text have2 = new Text(); + private Text have1; @FXML - public Text have3 = new Text(); + public Text have2; @FXML - public Text have4 = new Text(); + private Text have3; @FXML - public Text have5 = new Text(); + private Text have4; @FXML - public Text have6 = new Text(); + private Text have5; @FXML - public Text have7 = new Text(); + private Text have6; @FXML - public Text have8 = new Text(); + private Text have7; @FXML - public Text have9 = new Text(); + private Text have8; @FXML - public Text have10 = new Text(); + private Text have9; @FXML - public Text have11 = new Text(); + private Text have10; @FXML - public Text have12 = new Text(); + private Text have11; @FXML - public Text Health = new Text(); + private Text have12; + @FXML + private Text Health; @FXML @@ -127,7 +130,7 @@ public class BSSGameCtrl implements Initializable { private Button sell12; @FXML - public Text money = new Text(); + public Text money; @FXML @@ -145,17 +148,12 @@ public class BSSGameCtrl implements Initializable { private int daySet = 1; @FXML - private Pane pane = new Pane(); - + private Pane pane; - BuySell buySell = new BuySell(); + private final List gameDataList = new ArrayList<>(); + private final BuySell buySell = new BuySell(); public GameData gameData = new GameData(); - - public BSSGameCtrl() { - } - - @FXML private void onMapChick() throws IOException { new BSSMap().start(new Stage()); @@ -168,7 +166,6 @@ private void onSleep() { Health.setText(String.valueOf(healthSet)); } - @FXML private void onBuy1() { buySell.onBuy(gameData.moneyData.get(0), 1, have1); @@ -218,67 +215,55 @@ private void onBuy11() { private void onBuy12() { buySell.onBuy(gameData.moneyData.get(11), 1,have12); } - @FXML private void onSell1() { buySell.onSell(gameData.moneyData.get(0), 1, have1); } - @FXML private void onSell2() { buySell.onSell(gameData.moneyData.get(1), 1, have2); } - @FXML private void onSell3() { buySell.onSell(gameData.moneyData.get(2), 1, have3); } - @FXML private void onSell4() { buySell.onSell(gameData.moneyData.get(3), 1, have4); } - @FXML private void onSell5() { buySell.onSell(gameData.moneyData.get(4), 10, have5); } - @FXML private void onSell6() { buySell.onSell(gameData.moneyData.get(5), 1, have6); } - @FXML private void onSell7() { buySell.onSell(gameData.moneyData.get(6), 2, have7); } - @FXML private void onSell8() { buySell.onSell(gameData.moneyData.get(7), 1, have8); } - @FXML private void onSell9() { buySell.onSell(gameData.moneyData.get(8), 1, have9); } - @FXML private void onSell10() { buySell.onSell(gameData.moneyData.get(9), 1, have10); } - @FXML private void onSell11() { buySell.onSell(gameData.moneyData.get(10), 1, have11); } - @FXML private void onSell12() { buySell.onSell(gameData.moneyData.get(11), 5, have12); } - //分-------------------------------------割-------------------------------------线 + @FXML private void onRead() { } @@ -287,7 +272,6 @@ private void onRead() { private void onWrite() { } - @Override public void initialize(URL location, ResourceBundle resources) { { @@ -306,7 +290,6 @@ public void initialize(URL location, ResourceBundle resources) { gameData.addCssByArray(gameData.buyList, "btn", "btn-default"); } - { gameData.addButtonToSellArray(sell1); gameData.addButtonToSellArray(sell2); @@ -323,6 +306,29 @@ public void initialize(URL location, ResourceBundle resources) { gameData.addCssByArray(gameData.sellList, "btn", "btn-warning"); } + { + addGameData(have1.getText()); + addGameData(have2.getText()); + addGameData(have3.getText()); + addGameData(have4.getText()); + addGameData(have5.getText()); + addGameData(have6.getText()); + addGameData(have7.getText()); + addGameData(have8.getText()); + addGameData(have9.getText()); + addGameData(have10.getText()); + addGameData(have11.getText()); + addGameData(have12.getText()); + addGameData(money.getText()); + addGameData(Health.getText()); + addGameData(honor.getText()); + addGameData(storage.getText()); + addGameData(thinking.getText()); + addGameData(tired.getText()); + addGameData(level.getText()); + addGameData(xp.getText()); + addGameData(hunger.getText()); + } day.setText(String.valueOf(daySet)); int moneySet = 50000000; money.setText(String.valueOf(moneySet)); @@ -330,28 +336,7 @@ public void initialize(URL location, ResourceBundle resources) { buySell.setMoney(money); buySell.setStorage(storage); } - - public void addTextToArray() { - gameData.addGameData(have1.getText()); - gameData.addGameData(have2.getText()); - gameData.addGameData(have3.getText()); - gameData.addGameData(have4.getText()); - gameData.addGameData(have5.getText()); - gameData.addGameData(have6.getText()); - gameData.addGameData(have7.getText()); - gameData.addGameData(have8.getText()); - gameData.addGameData(have9.getText()); - gameData.addGameData(have10.getText()); - gameData.addGameData(have11.getText()); - gameData.addGameData(have12.getText()); - gameData.addGameData(money.getText()); - gameData.addGameData(Health.getText()); - gameData.addGameData(honor.getText()); - gameData.addGameData(storage.getText()); - gameData.addGameData(thinking.getText()); - gameData.addGameData(tired.getText()); - gameData.addGameData(level.getText()); - gameData.addGameData(xp.getText()); - gameData.addGameData(hunger.getText()); + private void addGameData(String gameData) { + gameDataList.add(gameData); } } diff --git a/src/main/java/com/niangaoa/BusinessSimulator/GameContro/DataSave.java b/src/main/java/com/niangaoa/BusinessSimulator/GameContro/DataSave.java index 3d8b08b..b1cd925 100644 --- a/src/main/java/com/niangaoa/BusinessSimulator/GameContro/DataSave.java +++ b/src/main/java/com/niangaoa/BusinessSimulator/GameContro/DataSave.java @@ -1,11 +1,5 @@ package com.niangaoa.BusinessSimulator.GameContro; -import com.niangaoa.BusinessSimulator.Ctrller.BSSGameCtrl; public class DataSave { - public static void main(String[] args) { - BSSGameCtrl BSSGameCtrl = new BSSGameCtrl(); - BSSGameCtrl.addTextToArray(); - System.out.println(BSSGameCtrl.gameData.gameDataList.get(0)); - } } diff --git a/src/main/java/com/niangaoa/BusinessSimulator/GameContro/GameData.java b/src/main/java/com/niangaoa/BusinessSimulator/GameContro/GameData.java index 974be34..6fa3b69 100644 --- a/src/main/java/com/niangaoa/BusinessSimulator/GameContro/GameData.java +++ b/src/main/java/com/niangaoa/BusinessSimulator/GameContro/GameData.java @@ -10,7 +10,6 @@ public class GameData { public List moneyData = new ArrayList<>(); public List