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);
|
borderPane.setCenter(vBox);
|
||||||
|
|
||||||
//Calculating the netWorth of the Player
|
//Calculating the netWorth of the Player
|
||||||
GameEndLogic gameEndLogic = new GameEndLogic();
|
GameEndLogic gameEndLogic = new GameEndLogic(getPlayer());
|
||||||
netWorthInt = gameEndLogic.getNetWorth();
|
netWorthInt = gameEndLogic.getNetWorth();
|
||||||
|
|
||||||
//Adding the labels to the character's stats to the VBox which will show up on the screen
|
//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{
|
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.
|
* 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
|
* 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.
|
* sets the player's money, bank, guns, hp, ad cargo space to max values.
|
||||||
*/
|
*/
|
||||||
public void cheat() {
|
public void cheat() {
|
||||||
setMoney(999999999);
|
setMoney(1000000);
|
||||||
setBank(999999999);
|
setBank(1000000);
|
||||||
setGuns(999);
|
setGuns(1000000);
|
||||||
setHP(99999999);
|
setHP(1000000);
|
||||||
setCargoSpace(99999999);
|
setCargoSpace(100000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -20,17 +20,15 @@ public class GameEndText extends Player {
|
|||||||
*/
|
*/
|
||||||
public void gameEnd(){
|
public void gameEnd(){
|
||||||
//Calculating the netWorth of the Player
|
//Calculating the netWorth of the Player
|
||||||
GameEndLogic gameEndLogic = new GameEndLogic();
|
GameEndLogic gameEndLogic = new GameEndLogic(getPlayer());
|
||||||
int netWorthInt = gameEndLogic.getNetWorth();
|
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);
|
String[] strings = gameEndLogic.endGameStats(netWorthInt);
|
||||||
//Updating the endgame stats of the player
|
//Updating the endgame stats of the player
|
||||||
System.out.println(strings[0]);
|
System.out.println(strings[0]);
|
||||||
System.out.println(strings[1]);
|
System.out.println(strings[1]);
|
||||||
System.out.println(strings[2]);
|
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?");
|
System.out.println("Would you like you get a (l)oan or (p)ay a debt?");
|
||||||
|
|
||||||
Scanner keyboard = new Scanner(System.in);
|
Scanner keyboard = new Scanner(System.in);
|
||||||
|
String response = keyboard.nextLine();
|
||||||
//Pay off loan
|
//Pay off loan
|
||||||
if (keyboard.nextLine().equalsIgnoreCase("p")) {
|
if (response.equalsIgnoreCase("p")) {
|
||||||
System.out.println("How much of your debt would you like to pay?");
|
|
||||||
try {
|
try {
|
||||||
|
System.out.println("How much of your debt would you like to pay?");
|
||||||
int returnAsk = Integer.parseInt(keyboard.nextLine());
|
int returnAsk = Integer.parseInt(keyboard.nextLine());
|
||||||
//If the player enters a invalid number
|
//If the player enters a invalid number
|
||||||
if (returnAsk > getDebt()) {
|
if (returnAsk > getDebt()) {
|
||||||
@@ -56,9 +57,9 @@ public class LoanSharkText extends Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Ask for Loan
|
//Ask for Loan
|
||||||
else if (keyboard.nextLine().equalsIgnoreCase("l")) {
|
if (response.equalsIgnoreCase("l")) {
|
||||||
System.out.println("How big of a loan would you like?");
|
|
||||||
try {
|
try {
|
||||||
|
System.out.println("How big of a loan would you like?");
|
||||||
int loanAsk = Integer.parseInt(keyboard.nextLine());
|
int loanAsk = Integer.parseInt(keyboard.nextLine());
|
||||||
//If the player enters a valid number
|
//If the player enters a valid number
|
||||||
if (loanAsk <= 2 * (getMoney() - getDebt()) && loanAsk >= 0) {
|
if (loanAsk <= 2 * (getMoney() - getDebt()) && loanAsk >= 0) {
|
||||||
|
|||||||
@@ -23,59 +23,68 @@ public class StartText extends Player {
|
|||||||
* 2) guns and no cash/debt.
|
* 2) guns and no cash/debt.
|
||||||
*/
|
*/
|
||||||
public void start() {
|
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
|
//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?");
|
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) {
|
while (true) {
|
||||||
int input = userInput.nextInt();
|
int input = userInput.nextInt();
|
||||||
//Will attempt to load the save if it's not empty
|
//Will attempt to load the save if it's not empty
|
||||||
if(input == 1){
|
if (input == 1) {
|
||||||
FileSaving saving = new FileSaving();
|
FileSaving saving = new FileSaving();
|
||||||
if(saving.loadFile() != null){
|
if (saving.loadFile() != null) {
|
||||||
TaipanShopText taipanShopText = new TaipanShopText(saving.loadFile());
|
TaipanShopText taipanShopText = new TaipanShopText(saving.loadFile());
|
||||||
taipanShopText.shop();
|
taipanShopText.shop();
|
||||||
|
} else {
|
||||||
|
System.out.println("There are no previous saves!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else{
|
//Just makes a new save
|
||||||
System.out.println("There are no previous saves!");
|
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
|
//Asks the player about their firm name and what kind of start they want
|
||||||
System.out.println("Taipan, \nWhat will you name your firm:");
|
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 ");
|
setName(userInput.nextLine());
|
||||||
while (true) {
|
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 ");
|
||||||
int input = userInput.nextInt();
|
while (true) {
|
||||||
StartLogic startLogic = new StartLogic(getPlayer());
|
int input = userInput.nextInt();
|
||||||
//If the player wants the money and debt starting
|
StartLogic startLogic = new StartLogic(getPlayer());
|
||||||
if (input == 1) {
|
//If the player wants the money and debt starting
|
||||||
startLogic.money_and_debt();
|
if (input == 1) {
|
||||||
break;
|
startLogic.money_and_debt();
|
||||||
}
|
setPlayer(startLogic.getPlayer());
|
||||||
//If the player wants the gun start
|
break;
|
||||||
else if (input == 2) {
|
}
|
||||||
startLogic.guns();
|
//If the player wants the gun start
|
||||||
break;
|
else if (input == 2) {
|
||||||
|
startLogic.guns();
|
||||||
|
setPlayer(startLogic.getPlayer());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("Invalid input, please try again.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// purely for testing purposes.
|
// purely for testing purposes.
|
||||||
else if (getName().equalsIgnoreCase("Vikram")) {
|
StartLogic startLogic = new StartLogic(getPlayer());
|
||||||
|
if (getName().equalsIgnoreCase("Vikram")) {
|
||||||
startLogic.cheat();
|
startLogic.cheat();
|
||||||
|
setPlayer(startLogic.getPlayer());
|
||||||
}
|
}
|
||||||
else {
|
TaipanShopText taipanShopText = new TaipanShopText(startLogic.getPlayer());
|
||||||
System.out.println("Invalid input, please try again.");
|
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(){
|
public void retire(){
|
||||||
setRetire(true);
|
setRetire(true);
|
||||||
System.out.println("You win!");
|
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.
|
* this method is evoked if the user has decided to travel elsewhere.
|
||||||
*/
|
*/
|
||||||
public void travel(){
|
public void travel(){
|
||||||
|
setIsPriceChanged(1);
|
||||||
TravelText travel = new TravelText(getPlayer());
|
TravelText travel = new TravelText(getPlayer());
|
||||||
travel.travelTo();
|
travel.travelTo();
|
||||||
setPlayer(travel.getPlayer());
|
setPlayer(travel.getPlayer());
|
||||||
@@ -105,13 +108,13 @@ public class TaipanShopText extends Player {
|
|||||||
setPlayer(logic.getPlayer());
|
setPlayer(logic.getPlayer());
|
||||||
|
|
||||||
boolean notDone = true;
|
boolean notDone = true;
|
||||||
int caseNum;
|
int caseNum = 1;
|
||||||
String optionText;
|
String optionText = "";
|
||||||
|
|
||||||
// first case is triggered if the user is at location one, and has less than $1 million net worth
|
// 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) {
|
if (getLocation() == 1 && getBank()+getMoney()-getDebt() < 1000000) {
|
||||||
caseNum = 1;
|
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.
|
} // the second case is triggered if the user is at a location other than location one.
|
||||||
else if(getLocation() != 1) {
|
else if(getLocation() != 1) {
|
||||||
caseNum = 2;
|
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.
|
// worth that is greater than or equal to $1 million and is at location one.
|
||||||
else{
|
else{
|
||||||
caseNum = 3;
|
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);
|
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.
|
// as long as the user does not enter a valid input, the code will run in a loop forever.
|
||||||
while(notDone){
|
while(notDone){
|
||||||
printShop();
|
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();
|
String response = input.next();
|
||||||
if (response.equalsIgnoreCase("B")) {
|
if (response.equalsIgnoreCase("B")) {
|
||||||
boolean notDone2 = true;
|
boolean notDone2 = true;
|
||||||
@@ -167,7 +170,7 @@ public class TaipanShopText extends Player {
|
|||||||
loan();
|
loan();
|
||||||
} // if the user wishes to quit trading, they may do so. Doing this breaks them out of the loop.
|
} // if the user wishes to quit trading, they may do so. Doing this breaks them out of the loop.
|
||||||
else if (response.equalsIgnoreCase("Q") ) {
|
else if (response.equalsIgnoreCase("Q") ) {
|
||||||
System.out.println("1");
|
setIsPriceChanged(1);
|
||||||
travel();
|
travel();
|
||||||
notDone = false;
|
notDone = false;
|
||||||
} // if the user wishes to retire and win the game, they may do so. Doing this breaks them out of the loop.
|
} // 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);
|
traveling(keyboard, hasTraveled);
|
||||||
} else {
|
} else {
|
||||||
System.out.println(getName() + " the cargo is too heavy! We can't set sail!");
|
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;
|
int tempInt;
|
||||||
while (true) {
|
while (true) {
|
||||||
System.out.println("\n" + getName() + ", do you wish to go to:\n");
|
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();
|
response = keyboard.nextLine();
|
||||||
//Sends the player back to shop if they want to quit
|
//Sends the player back to shop if they want to quit
|
||||||
if(response.equalsIgnoreCase("Q")){
|
//if(response.equalsIgnoreCase("Q")){
|
||||||
TaipanShopText taipanShopText = new TaipanShopText(getPlayer());
|
// TaipanShopText taipanShopText = new TaipanShopText(getPlayer());
|
||||||
taipanShopText.shop();
|
// taipanShopText.shop();
|
||||||
}
|
//}
|
||||||
//Just in case the player types something that was not intended. It will refresh the question and ask it again
|
//Just in case the player types something that was not intended. It will refresh the question and ask it again
|
||||||
try {
|
try {
|
||||||
tempInt = Integer.parseInt(response);
|
tempInt = Integer.parseInt(response);
|
||||||
|
|||||||
Reference in New Issue
Block a user