Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
niangaonb committed Dec 18, 2022
1 parent 34932cb commit f8132c6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 76 deletions.
107 changes: 46 additions & 61 deletions src/main/java/com/niangaoa/BusinessSimulator/Ctrller/BSSGameCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -127,7 +130,7 @@ public class BSSGameCtrl implements Initializable {
private Button sell12;

@FXML
public Text money = new Text();
public Text money;


@FXML
Expand All @@ -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<String> 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());
Expand All @@ -168,7 +166,6 @@ private void onSleep() {
Health.setText(String.valueOf(healthSet));
}


@FXML
private void onBuy1() {
buySell.onBuy(gameData.moneyData.get(0), 1, have1);
Expand Down Expand Up @@ -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() {
}
Expand All @@ -287,7 +272,6 @@ private void onRead() {
private void onWrite() {
}


@Override
public void initialize(URL location, ResourceBundle resources) {
{
Expand All @@ -306,7 +290,6 @@ public void initialize(URL location, ResourceBundle resources) {

gameData.addCssByArray(gameData.buyList, "btn", "btn-default");
}

{
gameData.addButtonToSellArray(sell1);
gameData.addButtonToSellArray(sell2);
Expand All @@ -323,35 +306,37 @@ 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));
storage.setText(String.valueOf(3000));
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);
}
}
Original file line number Diff line number Diff line change
@@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class GameData {
public List<Integer> moneyData = new ArrayList<>();
public List<Button> buyList = new ArrayList<>();
public List<Button> sellList = new ArrayList<>();
public List<String> gameDataList = new ArrayList<>();

public GameData() {
moneyData.add(3000);
Expand Down Expand Up @@ -41,12 +40,4 @@ public void addCssByArray(@NotNull List<Button> buttonArrary, String css1, Strin
b.getStyleClass().addAll(css1, css2);
}
}

public void addGameData(String gameData) {
this.gameDataList.add(gameData);
}

public List<String> getGameDataList() {
return gameDataList;
}
}

0 comments on commit f8132c6

Please sign in to comment.