Fixed up last of the bug fixes, this should be it up until the interactive demo
This commit is contained in:
@@ -79,7 +79,7 @@ public class GameEndGUI extends Player {
|
||||
borderPane.setCenter(vBox);
|
||||
|
||||
//Calculating the netWorth of the Player
|
||||
GameEndLogic gameEndLogic = new GameEndLogic();
|
||||
GameEndLogic gameEndLogic = new GameEndLogic(getPlayer());
|
||||
netWorthInt = gameEndLogic.getNetWorth();
|
||||
|
||||
//Adding the labels to the character's stats to the VBox which will show up on the screen
|
||||
|
||||
@@ -2,6 +2,17 @@ package logic;
|
||||
|
||||
public class GameEndLogic extends Player{
|
||||
|
||||
|
||||
/**
|
||||
* Class Constructor that takes in a type player as a parameter
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public GameEndLogic(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
setPlayer(playerDummy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the networth of the player by the end of the game.
|
||||
* Calculation is based off the total guns and items bought throughout the game
|
||||
|
||||
@@ -36,10 +36,10 @@ public class StartLogic extends Player {
|
||||
* sets the player's money, bank, guns, hp, ad cargo space to max values.
|
||||
*/
|
||||
public void cheat() {
|
||||
setMoney(999999999);
|
||||
setBank(999999999);
|
||||
setGuns(999);
|
||||
setHP(99999999);
|
||||
setCargoSpace(99999999);
|
||||
setMoney(1000000);
|
||||
setBank(1000000);
|
||||
setGuns(1000000);
|
||||
setHP(1000000);
|
||||
setCargoSpace(100000000);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -20,17 +20,15 @@ public class GameEndText extends Player {
|
||||
*/
|
||||
public void gameEnd(){
|
||||
//Calculating the netWorth of the Player
|
||||
GameEndLogic gameEndLogic = new GameEndLogic();
|
||||
GameEndLogic gameEndLogic = new GameEndLogic(getPlayer());
|
||||
int netWorthInt = gameEndLogic.getNetWorth();
|
||||
|
||||
//Adding the labels to the character's stats to the VBox which will show up on the screen
|
||||
System.out.println(gameEndLogic.endGameText());
|
||||
|
||||
String[] strings = gameEndLogic.endGameStats(netWorthInt);
|
||||
//Updating the endgame stats of the player
|
||||
System.out.println(strings[0]);
|
||||
System.out.println(strings[1]);
|
||||
System.out.println(strings[2]);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,10 +26,11 @@ public class LoanSharkText extends Player {
|
||||
System.out.println("Would you like you get a (l)oan or (p)ay a debt?");
|
||||
|
||||
Scanner keyboard = new Scanner(System.in);
|
||||
String response = keyboard.nextLine();
|
||||
//Pay off loan
|
||||
if (keyboard.nextLine().equalsIgnoreCase("p")) {
|
||||
System.out.println("How much of your debt would you like to pay?");
|
||||
if (response.equalsIgnoreCase("p")) {
|
||||
try {
|
||||
System.out.println("How much of your debt would you like to pay?");
|
||||
int returnAsk = Integer.parseInt(keyboard.nextLine());
|
||||
//If the player enters a invalid number
|
||||
if (returnAsk > getDebt()) {
|
||||
@@ -56,9 +57,9 @@ public class LoanSharkText extends Player {
|
||||
}
|
||||
}
|
||||
//Ask for Loan
|
||||
else if (keyboard.nextLine().equalsIgnoreCase("l")) {
|
||||
System.out.println("How big of a loan would you like?");
|
||||
if (response.equalsIgnoreCase("l")) {
|
||||
try {
|
||||
System.out.println("How big of a loan would you like?");
|
||||
int loanAsk = Integer.parseInt(keyboard.nextLine());
|
||||
//If the player enters a valid number
|
||||
if (loanAsk <= 2 * (getMoney() - getDebt()) && loanAsk >= 0) {
|
||||
|
||||
@@ -23,59 +23,68 @@ public class StartText extends Player {
|
||||
* 2) guns and no cash/debt.
|
||||
*/
|
||||
public void start() {
|
||||
Scanner userInput = new Scanner(System.in);
|
||||
try{
|
||||
Scanner userInput = new Scanner(System.in);
|
||||
|
||||
//See if the player wants to load up a previous save
|
||||
System.out.println("Taipan, do you want to...\n\t1) load a save file?\n\t\t\t>> or <<\n\t2) make a new save file?");
|
||||
while (true) {
|
||||
int input = userInput.nextInt();
|
||||
//Will attempt to load the save if it's not empty
|
||||
if(input == 1){
|
||||
FileSaving saving = new FileSaving();
|
||||
if(saving.loadFile() != null){
|
||||
TaipanShopText taipanShopText = new TaipanShopText(saving.loadFile());
|
||||
taipanShopText.shop();
|
||||
//See if the player wants to load up a previous save
|
||||
System.out.println("Taipan, do you want to...\n\t1) load a save file?\n\t\t\t>> or <<\n\t2) make a new save file?");
|
||||
while (true) {
|
||||
int input = userInput.nextInt();
|
||||
//Will attempt to load the save if it's not empty
|
||||
if (input == 1) {
|
||||
FileSaving saving = new FileSaving();
|
||||
if (saving.loadFile() != null) {
|
||||
TaipanShopText taipanShopText = new TaipanShopText(saving.loadFile());
|
||||
taipanShopText.shop();
|
||||
} else {
|
||||
System.out.println("There are no previous saves!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
else{
|
||||
System.out.println("There are no previous saves!");
|
||||
//Just makes a new save
|
||||
else if (input == 2) {
|
||||
break;
|
||||
} else {
|
||||
System.out.println("Invalid input, please try again.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
//Just makes a new save
|
||||
else if(input == 2){
|
||||
break;
|
||||
}
|
||||
else{
|
||||
System.out.println("Invalid input, please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
//Asks the player about their firm name and what kind of start they want
|
||||
System.out.println("Taipan, \nWhat will you name your firm:");
|
||||
setName(userInput.nextLine());
|
||||
System.out.println("Do you want to start . . .\n\t1) With cash (and a debt)\n\t\t\t>> or <<\n\t" + "2) With five guns and no cash (But no debt!)?\n ");
|
||||
while (true) {
|
||||
int input = userInput.nextInt();
|
||||
StartLogic startLogic = new StartLogic(getPlayer());
|
||||
//If the player wants the money and debt starting
|
||||
if (input == 1) {
|
||||
startLogic.money_and_debt();
|
||||
break;
|
||||
}
|
||||
//If the player wants the gun start
|
||||
else if (input == 2) {
|
||||
startLogic.guns();
|
||||
break;
|
||||
//Asks the player about their firm name and what kind of start they want
|
||||
System.out.println("Taipan, \nWhat will you name your firm:");
|
||||
setName(userInput.nextLine());
|
||||
setName(userInput.nextLine());
|
||||
System.out.println("Do you want to start . . .\n\t1) With cash (and a debt)\n\t\t\t>> or <<\n\t" + "2) With five guns and no cash (But no debt!)?\n ");
|
||||
while (true) {
|
||||
int input = userInput.nextInt();
|
||||
StartLogic startLogic = new StartLogic(getPlayer());
|
||||
//If the player wants the money and debt starting
|
||||
if (input == 1) {
|
||||
startLogic.money_and_debt();
|
||||
setPlayer(startLogic.getPlayer());
|
||||
break;
|
||||
}
|
||||
//If the player wants the gun start
|
||||
else if (input == 2) {
|
||||
startLogic.guns();
|
||||
setPlayer(startLogic.getPlayer());
|
||||
break;
|
||||
}
|
||||
else {
|
||||
System.out.println("Invalid input, please try again.");
|
||||
}
|
||||
}
|
||||
// purely for testing purposes.
|
||||
else if (getName().equalsIgnoreCase("Vikram")) {
|
||||
StartLogic startLogic = new StartLogic(getPlayer());
|
||||
if (getName().equalsIgnoreCase("Vikram")) {
|
||||
startLogic.cheat();
|
||||
setPlayer(startLogic.getPlayer());
|
||||
}
|
||||
else {
|
||||
System.out.println("Invalid input, please try again.");
|
||||
}
|
||||
TaipanShopText taipanShopText = new TaipanShopText(startLogic.getPlayer());
|
||||
taipanShopText.shop();
|
||||
}
|
||||
catch (Exception e){
|
||||
StartText startText = new StartText(getPlayer());
|
||||
startText.start();
|
||||
}
|
||||
TaipanShopText taipanShopText = new TaipanShopText(getPlayer());
|
||||
taipanShopText.shop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,16 @@ public class TaipanShopText extends Player {
|
||||
public void retire(){
|
||||
setRetire(true);
|
||||
System.out.println("You win!");
|
||||
System.exit(0);
|
||||
GameEndText gameEndText = new GameEndText(getPlayer());
|
||||
gameEndText.gameEnd();
|
||||
setPlayer(gameEndText.getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* this method is evoked if the user has decided to travel elsewhere.
|
||||
*/
|
||||
public void travel(){
|
||||
setIsPriceChanged(1);
|
||||
TravelText travel = new TravelText(getPlayer());
|
||||
travel.travelTo();
|
||||
setPlayer(travel.getPlayer());
|
||||
@@ -105,13 +108,13 @@ public class TaipanShopText extends Player {
|
||||
setPlayer(logic.getPlayer());
|
||||
|
||||
boolean notDone = true;
|
||||
int caseNum;
|
||||
String optionText;
|
||||
int caseNum = 1;
|
||||
String optionText = "";
|
||||
|
||||
// first case is triggered if the user is at location one, and has less than $1 million net worth
|
||||
if (getLocation() == 1 && getBank()+getMoney()-getDebt() < 1000000) {
|
||||
caseNum = 1;
|
||||
optionText = " Visit Bank, Transfer Cargo, Get Loans,";
|
||||
optionText = " (V)isit Bank, (T)ransfer Cargo, (G)et Loans,";
|
||||
} // the second case is triggered if the user is at a location other than location one.
|
||||
else if(getLocation() != 1) {
|
||||
caseNum = 2;
|
||||
@@ -120,7 +123,7 @@ public class TaipanShopText extends Player {
|
||||
// worth that is greater than or equal to $1 million and is at location one.
|
||||
else{
|
||||
caseNum = 3;
|
||||
optionText = " Visit Bank, Transfer Cargo, Get Loans, Retire,";
|
||||
optionText = " (V)isit Bank, (T)ransfer Cargo, (G)et Loans, (R)etire,";
|
||||
}
|
||||
|
||||
Scanner input = new Scanner(System.in);
|
||||
@@ -144,7 +147,7 @@ public class TaipanShopText extends Player {
|
||||
// as long as the user does not enter a valid input, the code will run in a loop forever.
|
||||
while(notDone){
|
||||
printShop();
|
||||
System.out.printf("\nShall I Buy, Sell,%s or Quit Trading?\n", optionText);
|
||||
System.out.printf("\nShall I (B)uy, (S)ell,%s or (Q)uit Trading?\n", optionText);
|
||||
String response = input.next();
|
||||
if (response.equalsIgnoreCase("B")) {
|
||||
boolean notDone2 = true;
|
||||
@@ -167,7 +170,7 @@ public class TaipanShopText extends Player {
|
||||
loan();
|
||||
} // if the user wishes to quit trading, they may do so. Doing this breaks them out of the loop.
|
||||
else if (response.equalsIgnoreCase("Q") ) {
|
||||
System.out.println("1");
|
||||
setIsPriceChanged(1);
|
||||
travel();
|
||||
notDone = false;
|
||||
} // if the user wishes to retire and win the game, they may do so. Doing this breaks them out of the loop.
|
||||
|
||||
@@ -54,6 +54,9 @@ public class TravelText extends Player {
|
||||
traveling(keyboard, hasTraveled);
|
||||
} else {
|
||||
System.out.println(getName() + " the cargo is too heavy! We can't set sail!");
|
||||
TaipanShopText taipanShopText = new TaipanShopText(getPlayer());
|
||||
taipanShopText.shop();
|
||||
setPlayer(taipanShopText.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,14 +71,14 @@ public class TravelText extends Player {
|
||||
int tempInt;
|
||||
while (true) {
|
||||
System.out.println("\n" + getName() + ", do you wish to go to:\n");
|
||||
System.out.println("1) Hong Kong, 2) Shanghai, 3) Nagasaki,\n4) Saigon, 5) Manila, 6) Singapore, or 7) Batavia? or (Q)uit");
|
||||
System.out.println("1) Hong Kong, 2) Shanghai, 3) Nagasaki,\n4) Saigon, 5) Manila, 6) Singapore, or 7) Batavia?");
|
||||
|
||||
response = keyboard.nextLine();
|
||||
//Sends the player back to shop if they want to quit
|
||||
if(response.equalsIgnoreCase("Q")){
|
||||
TaipanShopText taipanShopText = new TaipanShopText(getPlayer());
|
||||
taipanShopText.shop();
|
||||
}
|
||||
//if(response.equalsIgnoreCase("Q")){
|
||||
// TaipanShopText taipanShopText = new TaipanShopText(getPlayer());
|
||||
// taipanShopText.shop();
|
||||
//}
|
||||
//Just in case the player types something that was not intended. It will refresh the question and ask it again
|
||||
try {
|
||||
tempInt = Integer.parseInt(response);
|
||||
|
||||
Reference in New Issue
Block a user