some changes...

This commit is contained in:
Vikram
2019-03-10 21:49:50 -06:00
parent 461171ff46
commit ffb77b14a0
7 changed files with 276 additions and 133 deletions

View File

@@ -1,5 +1,3 @@
import java.util.Scanner;
public class Player {
private String name = "Taipan";
@@ -444,20 +442,6 @@ public class Player {
public void gameOver(){
System.out.flush();
System.out.println("Game over");
}
public boolean playAgain(){
Scanner input = new Scanner(System.in);
System.out.println("Would you like to play again? Y/N");
while(true){
String response = input.nextLine();
if(response.equalsIgnoreCase("Y")){
return true;
}else if(response.equalsIgnoreCase("N")){
System.exit(0);
}else{
System.out.println("That is not a valid input.");
}
}
System.exit(0);
}
}

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();
}
@@ -779,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

@@ -423,16 +423,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;
}