Fixed some of the code related with Liu Yuen and fixed some of the javadocing
This commit is contained in:
@@ -31,6 +31,7 @@ public class Player implements Serializable {
|
|||||||
private int armsPrice = 160;
|
private int armsPrice = 160;
|
||||||
private int generalPrice = 8;
|
private int generalPrice = 8;
|
||||||
private int isPriceChanged = 0;
|
private int isPriceChanged = 0;
|
||||||
|
private boolean attackingShips = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* default constructor for player
|
* default constructor for player
|
||||||
@@ -84,6 +85,7 @@ public class Player implements Serializable {
|
|||||||
this.armsPrice = player.armsPrice;
|
this.armsPrice = player.armsPrice;
|
||||||
this.generalPrice = player.generalPrice;
|
this.generalPrice = player.generalPrice;
|
||||||
this.isPriceChanged = player.isPriceChanged;
|
this.isPriceChanged = player.isPriceChanged;
|
||||||
|
this.attackingShips = player.attackingShips;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,13 +103,30 @@ public class Player implements Serializable {
|
|||||||
*
|
*
|
||||||
* @param cargoSpace takes an int that is greater than 0 as an argument
|
* @param cargoSpace takes an int that is greater than 0 as an argument
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setCargoSpace(int cargoSpace) {
|
public void setCargoSpace(int cargoSpace) {
|
||||||
if (cargoSpace > 0) {
|
if (cargoSpace > 0) {
|
||||||
this.cargoSpace = cargoSpace;
|
this.cargoSpace = cargoSpace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getter method for the instance variable attackingShips.
|
||||||
|
*
|
||||||
|
* @return returns the instance variable attackingShips
|
||||||
|
*/
|
||||||
|
public boolean getAttackingShips() {
|
||||||
|
return attackingShips;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setter method for the instance variable attackingShips.
|
||||||
|
*
|
||||||
|
* @param attackingShips takes an int that is greater than 0 as an argument
|
||||||
|
*/
|
||||||
|
public void setAttackingShips(boolean attackingShips) {
|
||||||
|
this.attackingShips = attackingShips;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getter method for the instance variable retire.
|
* getter method for the instance variable retire.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 2019-03-19
|
* 2019-03-19
|
||||||
* Authors:
|
* Authors: Harkamal Randhawa
|
||||||
* Random Event GUI class generates random events that occur during travel, such as fixing your ship,
|
* Random Event GUI class generates random events that occur during travel, such as fixing your ship,
|
||||||
* liu yen asking for money and to purchase a gun.
|
* liu yen asking for money and to purchase a gun.
|
||||||
*/
|
*/
|
||||||
@@ -126,6 +126,8 @@ public class RandomEventGUI extends Player{
|
|||||||
|
|
||||||
/*Pick a random number dictating the events that could happen.
|
/*Pick a random number dictating the events that could happen.
|
||||||
* 1: New gun for player
|
* 1: New gun for player
|
||||||
|
* 2: Paying Liu Yuen
|
||||||
|
* 3: Repairing the Ship
|
||||||
*/
|
*/
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
int randGenNum = rand.nextInt(3) + 1;
|
int randGenNum = rand.nextInt(3) + 1;
|
||||||
@@ -133,17 +135,18 @@ public class RandomEventGUI extends Player{
|
|||||||
//Buy Guns
|
//Buy Guns
|
||||||
if (randGenNum == 1) {
|
if (randGenNum == 1) {
|
||||||
itemPrice = (int) ((getPlayer().getMoney() * 0.1) + 10);
|
itemPrice = (int) ((getPlayer().getMoney() * 0.1) + 10);
|
||||||
sellingItemLabel.setText("Would you like to pay $" + itemPrice + " for a gun?");
|
sellingItemLabel.setText("A vender is selling a gun for $" + itemPrice + " for a gun?");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//Liu Yuen
|
//Liu Yuen
|
||||||
if (randGenNum == 2) {
|
if (randGenNum == 2) {
|
||||||
itemPrice = (int) ((getPlayer().getMoney() * 0.1) + 10);
|
itemPrice = (int) ((getPlayer().getMoney() * 0.1) + 10);
|
||||||
sellingItemLabel.setText("Liu Yuen asks $" + itemPrice + " in donation to the temple of Tin Hau, the Sea Goddess");
|
sellingItemLabel.setText("Liu Yuen asks $" + itemPrice + " in donation to the temple of Tin Hau, the Sea Goddess");
|
||||||
|
setAttackingShips(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//Ship Repair
|
//Ship Repair
|
||||||
if (randGenNum == 3 && getHP() != 100) {
|
if (randGenNum == 3 && getHP() < 101) {
|
||||||
itemPrice = (int) ((100 - getPlayer().getHP()) * 10 + 10);
|
itemPrice = (int) ((100 - getPlayer().getHP()) * 10 + 10);
|
||||||
sellingItemLabel.setText("Mc Henry from the Hong Kong shipyard has arrived, would be willing to repair your ship for $" + itemPrice);
|
sellingItemLabel.setText("Mc Henry from the Hong Kong shipyard has arrived, would be willing to repair your ship for $" + itemPrice);
|
||||||
break;
|
break;
|
||||||
@@ -159,7 +162,7 @@ public class RandomEventGUI extends Player{
|
|||||||
taipanShopGUI.initializeShop(stage);
|
taipanShopGUI.initializeShop(stage);
|
||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
if((eventNumber == 3 && getPlayer().getHP() == 100)){
|
if((eventNumber == 3 && getPlayer().getHP() >= 100)){
|
||||||
TaipanShopGUI taipanShopGUI = new TaipanShopGUI(getPlayer());
|
TaipanShopGUI taipanShopGUI = new TaipanShopGUI(getPlayer());
|
||||||
taipanShopGUI.initializeShop(stage);
|
taipanShopGUI.initializeShop(stage);
|
||||||
stage.show();
|
stage.show();
|
||||||
@@ -182,7 +185,7 @@ public class RandomEventGUI extends Player{
|
|||||||
|
|
||||||
//Liu Yuen
|
//Liu Yuen
|
||||||
if (eventNumber == 2) {
|
if (eventNumber == 2) {
|
||||||
//MAKE LIU YUEN CHANCE BASICALLY 0
|
setAttackingShips(false);
|
||||||
setMoney(getPlayer().getMoney() - itemPrice);
|
setMoney(getPlayer().getMoney() - itemPrice);
|
||||||
|
|
||||||
TaipanShopGUI taipanShopGUI = new TaipanShopGUI(getPlayer());
|
TaipanShopGUI taipanShopGUI = new TaipanShopGUI(getPlayer());
|
||||||
@@ -207,14 +210,13 @@ public class RandomEventGUI extends Player{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//If the no button is clicked then it skips to the location screen you wanted to go to.
|
//If the no button is clicked then it skips to the location screen you wanted to go to.
|
||||||
noButton.setOnAction(event -> {
|
noButton.setOnAction(event -> {
|
||||||
TaipanShopGUI taipanShopGUI = new TaipanShopGUI(getPlayer());
|
TaipanShopGUI taipanShopGUI = new TaipanShopGUI(getPlayer());
|
||||||
taipanShopGUI.initializeShop(stage);
|
taipanShopGUI.initializeShop(stage);
|
||||||
stage.show();
|
stage.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
//Creates the scene and window
|
//Creates the scene and window
|
||||||
Scene root = new Scene(borderPane, 600, 480);
|
Scene root = new Scene(borderPane, 600, 480);
|
||||||
root.getStylesheets().add("styleguide.css");
|
root.getStylesheets().add("styleguide.css");
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ public class TravelGUI extends Player{
|
|||||||
|
|
||||||
//Continues on to either shop or shipwarfare
|
//Continues on to either shop or shipwarfare
|
||||||
continueButton.setOnAction(event -> {
|
continueButton.setOnAction(event -> {
|
||||||
if(peasantShipScene){
|
if(peasantShipScene && getAttackingShips()){
|
||||||
ShipWarfareGUI ship = new ShipWarfareGUI(getPlayer());
|
ShipWarfareGUI ship = new ShipWarfareGUI(getPlayer());
|
||||||
try {
|
try {
|
||||||
ship.initializeShip(stage);
|
ship.initializeShip(stage);
|
||||||
|
|||||||
Reference in New Issue
Block a user