Merge remote-tracking branch 'origin/master'

This commit is contained in:
2019-03-10 22:11:07 -06:00
9 changed files with 293 additions and 134 deletions

View File

@@ -1,5 +1,3 @@
import java.util.Scanner;
public class Player {
private String name = "Taipan";

View File

@@ -140,16 +140,14 @@ public class StartGUI {
String response = nameField.getText();
// purely for testing purposes.
if (player.getName().equalsIgnoreCase("Vikram")) {
if (response.equalsIgnoreCase("Vikram")) {
player.setMoney(999999999);
player.setBank(999999999);
player.setGuns(999);
player.setGuns(0);
player.setHP(99999999);
player.setCargoSpace(99999999);
}
else{
setFirm(response);
player.setCargoSpace(Integer.MAX_VALUE);
}
setFirm(response);
TaipanShopGUI shop = new TaipanShopGUI(player);
shop.initializeShop(stage);

View File

@@ -1,6 +1,65 @@
import java.util.Random;
import java.util.Scanner;
public class TaipanShop {
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class TaipanShop extends Application {
public static void main(String args[]){
launch(args);
}
public void start(Stage stage){
stage.setTitle("Shop");
GridPane grid = new GridPane();
grid.setPadding(new Insets(10,10,10,10));
grid.setVgap(20);
grid.setHgap(20);
grid.add(new Label("Firm: "+ player.getName()), 2, 0);
HBox warehouse = new HBox();
warehouse.setSpacing(20);
int itemsInWarehouse = player.getwOpium()+player.getwGeneral()+player.getwArms()+player.getwSilk();
Label ware1 = new Label("Warehouse\n\tOpium\n\tSilk\n\tArms\n\tGeneral");
Label ware2 = new Label("\n"+player.getwOpium()+"\n"+player.getwSilk()+"\n"+player.getwArms()+"\n"+player.getwGeneral());
Label ware3 = new Label("\nIn use:\n " + itemsInWarehouse + "\nVacant:\n " + (10000 - itemsInWarehouse));
warehouse.getChildren().addAll(ware1, ware2, new Label(), ware3);
HBox inventory = new HBox();
inventory.setSpacing(20);
int itemsInInventory = player.getCargoSpace()-player.getSilkHeld()-player.getOpiumHeld()-player.getGeneralHeld()-player.getArmsHeld();
Label inv1 = new Label("Hold "+itemsInInventory+"\n\tOpium\n\tSilk\n\tArms\n\tGeneral");
Label inv2 = new Label("\n"+player.getOpiumHeld()+"\n"+player.getSilkHeld()+"\n"+player.getArmsHeld()+"\n"+player.getGeneralHeld());
Label inv3 = new Label("Guns "+player.getGuns());
inventory.getChildren().addAll(inv1, inv2, new Label(), inv3);
String location;
switch(player.getLocation()){
case 1: location = "Hong Kong"; break;
case 2: location = "Shanghai"; break;
case 3: location = "Nagasaki"; break;
case 4: location = "Saigon"; break;
case 5: location = "Manila"; break;
case 6: location = "Singapore"; break;
case 7: location = "Batavia"; break;
default: location = "Error"; break;
}
grid.add(warehouse, 1, 1);
grid.add(inventory, 1, 2);
grid.add(new Label("\n\n\n Location\n"+location),3, 1 );
grid.add(new Label("Debt\n"+player.getDebt()), 3, 2);
Scene root = new Scene(grid, 600, 480);
stage.setResizable(false);
stage.setScene(root);
stage.show();
}
private Player player;
private int opiumPrice = 16000;

View File

@@ -491,7 +491,7 @@ public class TaipanShopGUI {
bankButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
bankGUI bank = new bankGUI();
bankGUI bank = new bankGUI(getPlayer());
bank.initializeBank(stage);
stage.show();
}
@@ -520,7 +520,7 @@ public class TaipanShopGUI {
loanButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
loanSharkGUI loan = new loanSharkGUI();
loanSharkGUI loan = new loanSharkGUI(getPlayer());
loan.initializeLoanShark(stage);
stage.show();
}
@@ -754,6 +754,7 @@ public class TaipanShopGUI {
stage.setResizable(false);
stage.setScene(root);
buttonSetup("reset");
updatePrices();
defaultTextOut();
updateStage();
@@ -778,16 +779,19 @@ public class TaipanShopGUI {
public String shipStatusString(){
String shipStatus;
switch(player.getHP()){
case 100: shipStatus = "Mint Condition"; break;
case 80: shipStatus = "Great"; break;
case 70: shipStatus = "Good"; break;
case 60: shipStatus = "Acceptable"; break;
case 50: shipStatus = "Tolerable"; break;
case 30: shipStatus = "Damaged"; break;
case 10: shipStatus = "Poor"; break;
case 1: shipStatus = "Extremely Poor"; break;
default: shipStatus = "Sinking"; break;
switch(player.getHP()/10){
case 10: shipStatus = "Mint Condition"; break;
case 9: shipStatus = "Near Perfect"; break;
case 8: shipStatus = "Great"; break;
case 7: shipStatus = "Good"; break;
case 6: shipStatus = "Acceptable"; break;
case 5: shipStatus = "Tolerable"; break;
case 4: shipStatus = "Needs Repair"; break;
case 3: shipStatus = "Damaged"; break;
case 2: shipStatus = "Indangered"; break;
case 1: shipStatus = "Near Sinking"; break;
case 0: shipStatus = "Sinking"; break;
default: shipStatus = "Invincible"; break;
}
return shipStatus;
}

View File

@@ -427,16 +427,19 @@ public class TravelGUI{
public String shipStatusString(){
String shipStatus;
switch(player.getHP()){
case 100: shipStatus = "Mint Condition"; break;
case 80: shipStatus = "Great"; break;
case 70: shipStatus = "Good"; break;
case 60: shipStatus = "Acceptable"; break;
case 50: shipStatus = "Tolerable"; break;
case 30: shipStatus = "Damaged"; break;
case 10: shipStatus = "Poor"; break;
case 1: shipStatus = "Extremely Poor"; break;
default: shipStatus = "Sinking"; break;
switch(player.getHP()/10){
case 10: shipStatus = "Mint Condition"; break;
case 9: shipStatus = "Near Perfect"; break;
case 8: shipStatus = "Great"; break;
case 7: shipStatus = "Good"; break;
case 6: shipStatus = "Acceptable"; break;
case 5: shipStatus = "Tolerable"; break;
case 4: shipStatus = "Needs Repair"; break;
case 3: shipStatus = "Damaged"; break;
case 2: shipStatus = "Indangered"; break;
case 1: shipStatus = "Near Sinking"; break;
case 0: shipStatus = "Sinking"; break;
default: shipStatus = "Invincible"; break;
}
return shipStatus;
}

View File

@@ -12,7 +12,7 @@ import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class bankGUI{
private Player player = new Player();
private Player player;
/**
* setter method that takes in a Player object as an argument.
*
@@ -36,19 +36,19 @@ public class bankGUI{
*
//* @param player object of the class Player
*/
//public bankGUI(Player player){
// Player playerDummy = new Player(player);
// this.player = playerDummy;
//}
public bankGUI(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public Stage initializeBank(Stage primaryStage) {
primaryStage.setTitle("Bank");
//Declaring each Layout
BorderPane brdr1 = new BorderPane();
HBox hbx1 = new HBox(10);
HBox hbx2 = new HBox(10);
VBox vbx1 = new VBox(10);
HBox hbx1 = new HBox(30);
HBox hbx2 = new HBox(30);
VBox vbx1 = new VBox(30);
//Declaring all Variables
Label l1 = new Label("Player: " + player.getName());
@@ -88,11 +88,11 @@ public class bankGUI{
brdr1.setTop(vbx1);
// Set the event handler when the deposit button is clicked
boolean keepGoing = true;
b1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
int withdraw = Integer.parseInt(txtField1.getText());
System.out.println(withdraw);
if(withdraw <= player.getBank()){
player.setMoney(withdraw + player.getMoney());
player.setBank(player.getBank()-withdraw);
@@ -111,6 +111,7 @@ public class bankGUI{
@Override
public void handle(ActionEvent event) {
int deposit = Integer.parseInt(txtField1.getText());
System.out.println(deposit);
if(deposit <= player.getMoney()){
player.setBank(deposit + player.getBank());
player.setMoney(player.getMoney()-deposit);
@@ -146,7 +147,7 @@ public class bankGUI{
public void start(Stage primaryStage) {
bankGUI bank = new bankGUI();
bankGUI bank = new bankGUI(player);
bank.initializeBank(primaryStage);
primaryStage.show();
}

View File

@@ -12,7 +12,7 @@ import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class loanSharkGUI{
private Player player = new Player();
private Player player;
/**
* setter method that takes in a Player object as an argument.
*
@@ -36,10 +36,10 @@ public class loanSharkGUI{
*
//* @param player object of the class Player
*/
//public loanSharkGUI(Player player){
// Player playerDummy = new Player(player);
// this.player = playerDummy;
//}
public loanSharkGUI(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public Stage initializeLoanShark(Stage primaryStage) {
primaryStage.setTitle("Loan Shark");
@@ -151,7 +151,7 @@ public class loanSharkGUI{
public void start(Stage primaryStage) {
loanSharkGUI loan = new loanSharkGUI();
loanSharkGUI loan = new loanSharkGUI(player);
loan.initializeLoanShark(primaryStage);
primaryStage.show();
}