Super broken but fight button is in progress for shipwarfare
This commit is contained in:
95
.idea/workspace.xml
generated
95
.idea/workspace.xml
generated
@@ -3,6 +3,8 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3114a2b9-4919-4fdf-8fd9-d03b60109ce4" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/TaipanClone/ShipWarfare.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/TaipanClone/ShipWarfare.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/ShipWarfareGUI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ShipWarfareGUI.java" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
<ignored path="C:\Users\Harkamal Randhawa\IdeaProjects\TaipanClone\.idea\shelf/" />
|
||||
@@ -27,21 +29,21 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2580">
|
||||
<caret line="172" column="5" selection-start-line="172" selection-start-column="5" selection-end-line="172" selection-end-column="5" />
|
||||
<state relative-caret-position="135">
|
||||
<caret line="399" column="97" selection-start-line="399" selection-start-column="92" selection-end-line="399" selection-end-column="97" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#1150#1151#0" expanded="true" />
|
||||
<element signature="e#1178#1179#0" expanded="true" />
|
||||
<element signature="e#1208#1209#0" expanded="true" />
|
||||
<element signature="e#1236#1237#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="135">
|
||||
@@ -84,10 +86,6 @@
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>GetGuns</find>
|
||||
<find>set</find>
|
||||
<find>TaipanShop</find>
|
||||
<find>shop()</find>
|
||||
<find>shop</find>
|
||||
<find>being</find>
|
||||
<find>label0</find>
|
||||
@@ -100,7 +98,6 @@
|
||||
<find>setNumOfP</find>
|
||||
<find>setUs</find>
|
||||
<find>starting</find>
|
||||
<find>destro</find>
|
||||
<find>numOfpeasantShips</find>
|
||||
<find>startingPeasantShips</find>
|
||||
<find>startingLittyShips</find>
|
||||
@@ -114,6 +111,11 @@
|
||||
<find>numOfLittyShips</find>
|
||||
<find>delay</find>
|
||||
<find>Hp</find>
|
||||
<find>shipwarfare</find>
|
||||
<find>destroyPeasa</find>
|
||||
<find>destr</find>
|
||||
<find>destro</find>
|
||||
<find>hitco</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>HP</replace>
|
||||
@@ -137,9 +139,9 @@
|
||||
<option value="$PROJECT_DIR$/src/TaipanShop.java" />
|
||||
<option value="$PROJECT_DIR$/src/main.java" />
|
||||
<option value="$PROJECT_DIR$/src/Travel.java" />
|
||||
<option value="$PROJECT_DIR$/src/ShipWarfareGUI.java" />
|
||||
<option value="$PROJECT_DIR$/src/Player.java" />
|
||||
<option value="$PROJECT_DIR$/src/ShipWarfare.java" />
|
||||
<option value="$PROJECT_DIR$/src/ShipWarfareGUI.java" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@@ -155,7 +157,6 @@
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
@@ -172,6 +173,7 @@
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
<pane id="PackagesPane" />
|
||||
</panes>
|
||||
</component>
|
||||
@@ -179,7 +181,7 @@
|
||||
<property name="ChangesTree.GroupingKeys" value="" />
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="aspect.path.notification.shown" value="true" />
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1552182988336" />
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1552187991754" />
|
||||
<property name="extract.method.default.visibility" value="private" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/../GitHub/Cpsc233" />
|
||||
<property name="project.structure.last.edited" value="Project" />
|
||||
@@ -199,7 +201,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Application.main">
|
||||
<component name="RunManager" selected="Application.ShipWarfareGUI">
|
||||
<configuration name="Game" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="Game" />
|
||||
<module name="TaipanClone" />
|
||||
@@ -244,8 +246,8 @@
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Application.main" />
|
||||
<item itemvalue="Application.ShipWarfareGUI" />
|
||||
<item itemvalue="Application.main" />
|
||||
<item itemvalue="Application.TaipanShop" />
|
||||
<item itemvalue="Application.Game" />
|
||||
<item itemvalue="Application.ShipWarfare" />
|
||||
@@ -279,6 +281,8 @@
|
||||
<workItem from="1552183247090" duration="42000" />
|
||||
<workItem from="1552183350012" duration="132000" />
|
||||
<workItem from="1552183501892" duration="5000" />
|
||||
<workItem from="1552187010251" duration="1043000" />
|
||||
<workItem from="1552195875453" duration="55000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="This should fix the ShipWarfare file and bring it up to date with the rest of the file.">
|
||||
<created>1550458470138</created>
|
||||
@@ -399,17 +403,24 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1552181667376</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="18" />
|
||||
<task id="LOCAL-00018" summary="Please find error">
|
||||
<created>1552187032139</created>
|
||||
<option name="number" value="00018" />
|
||||
<option name="presentableId" value="LOCAL-00018" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1552187032139</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="19" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="57306000" />
|
||||
<option name="totallyTimeSpent" value="58404000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="48" y="23" width="1189" height="652" extended-state="0" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.21621622" />
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.22319093" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info id="Image Layers" order="2" />
|
||||
<window_info id="Designer" order="3" />
|
||||
@@ -418,7 +429,7 @@
|
||||
<window_info id="Favorites" order="6" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" weight="0.32922733" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.4482143" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.9357143" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
@@ -524,7 +535,8 @@
|
||||
<MESSAGE value="Made ShipWarfare easier to access by ShipWarfareGUI" />
|
||||
<MESSAGE value="Missed one statement that I needed to encapsulate" />
|
||||
<MESSAGE value="Messed up player by setting money to 1000" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Messed up player by setting money to 1000" />
|
||||
<MESSAGE value="Please find error" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Please find error" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="uml://JAVA/ShipWarfare">
|
||||
@@ -579,6 +591,13 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/javafx-src.zip!/com/sun/glass/ui/InvokeLaterDispatcher.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="140">
|
||||
<caret line="110" column="19" selection-start-line="110" selection-start-column="19" selection-end-line="110" selection-end-column="19" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="5025">
|
||||
@@ -589,15 +608,17 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/main.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2580">
|
||||
<caret line="172" column="5" selection-start-line="172" selection-start-column="5" selection-end-line="172" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#1150#1151#0" expanded="true" />
|
||||
<element signature="e#1178#1179#0" expanded="true" />
|
||||
</folding>
|
||||
<state relative-caret-position="135">
|
||||
<caret line="9" column="4" selection-end-line="55" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/Start.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="15">
|
||||
<caret line="1" column="13" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -611,17 +632,15 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/Start.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="15">
|
||||
<caret line="1" column="13" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main.java">
|
||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="135">
|
||||
<caret line="9" column="4" selection-end-line="55" />
|
||||
<caret line="399" column="97" selection-start-line="399" selection-start-column="92" selection-end-line="399" selection-end-column="97" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#1208#1209#0" expanded="true" />
|
||||
<element signature="e#1236#1237#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
||||
Binary file not shown.
@@ -29,16 +29,22 @@ import static javafx.application.Application.launch;
|
||||
public class ShipWarfareGUI extends Application {
|
||||
|
||||
|
||||
private Player player = new Player();
|
||||
private ShipWarfare shipWarfare = new ShipWarfare(player);
|
||||
private Player player = new Player();
|
||||
private ShipWarfare shipWarfare = new ShipWarfare(player);
|
||||
private HBox hBox;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Button fightButton;
|
||||
private Button runButton;
|
||||
private VBox vBox;
|
||||
private Label label1;
|
||||
private Label label;
|
||||
private VBox vBox0;
|
||||
private Label label0;
|
||||
private Label title;
|
||||
private Label chooseFightOrRun;
|
||||
private Label report;
|
||||
private Label runAwayOrLeft;
|
||||
private Label shipsRemaining;
|
||||
private Label HPLeft;
|
||||
private Label gunsLeftOrTaken;
|
||||
private Label continueToFight;
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
@@ -53,14 +59,6 @@ public class ShipWarfareGUI extends Application {
|
||||
private int howMuchRun = 0;
|
||||
private String pirateName = "Liu Yen";
|
||||
|
||||
/**
|
||||
* Class Constructor that takes in a type player as a parameter
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public ShipWarfareGUI(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter method for player
|
||||
@@ -88,15 +86,13 @@ public class ShipWarfareGUI extends Application {
|
||||
Scanner userResponse = new Scanner(System.in);
|
||||
setNumOfPeasantShips(numOfShips());
|
||||
|
||||
System.out.printf("By Golly! We have $%,d and are being attacked by %d Merchant ships\nCurrently our ship status is %d%%\n", player.getMoney(), numOfPeasantShips, player.getHP());
|
||||
|
||||
title.setText(String.format("By Golly! We have $%,d and are being attacked by %d Merchant ships\nCurrently our ship status is %d%%\n", player.getMoney(), numOfPeasantShips, player.getHP()));
|
||||
fightOrRunMessage();
|
||||
while (true) {
|
||||
String response = userResponse.nextLine();
|
||||
if (response.equalsIgnoreCase("f")) {
|
||||
userAttacks = true;
|
||||
System.out.println("Ohh, fight ehh?");
|
||||
delayForSeconds(1);
|
||||
boolean winOrLose = destroyPeasantShipsOrEscape();
|
||||
if (winOrLose == true) {
|
||||
break;
|
||||
@@ -147,7 +143,6 @@ public class ShipWarfareGUI extends Application {
|
||||
break;
|
||||
} else {
|
||||
System.out.println("Phew! Got away safely");
|
||||
delayForSeconds(2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -263,13 +258,10 @@ public class ShipWarfareGUI extends Application {
|
||||
break;
|
||||
}
|
||||
System.out.println("Got eem");
|
||||
delayForSeconds(1);
|
||||
} else if (hitOrMiss == 2) {
|
||||
System.out.printf("ARRG! We missed %s\n", player.getName());
|
||||
delayForSeconds(1);
|
||||
} else {
|
||||
System.out.println("Darn! Their fleet tanked our attack");
|
||||
delayForSeconds(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +271,6 @@ public class ShipWarfareGUI extends Application {
|
||||
}
|
||||
} else {
|
||||
System.out.printf("%s! We don't have any GUNS!!!!\n",player.getName());
|
||||
delayForSeconds(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +297,6 @@ public class ShipWarfareGUI extends Application {
|
||||
|
||||
System.out.printf("%d ships remaining\n", numOfLittyShips);
|
||||
System.out.println("Oh no, they are taking the offensive!");
|
||||
delayForSeconds(1);
|
||||
//Computer volley
|
||||
int takeGunChance = randomValue.nextInt(4) + 1;
|
||||
if (takeGunChance == 1 && player.getGuns() > 0) {
|
||||
@@ -320,7 +310,6 @@ public class ShipWarfareGUI extends Application {
|
||||
break;
|
||||
}
|
||||
System.out.printf("EEK, our current ship status is %d%% \n", player.getHP());
|
||||
delayForSeconds(1);
|
||||
if (userAttacks == false) {
|
||||
userAttacks = true;
|
||||
}
|
||||
@@ -331,10 +320,8 @@ public class ShipWarfareGUI extends Application {
|
||||
if (response.equalsIgnoreCase("r")) {
|
||||
if (runFromShips() == false) {
|
||||
System.out.println("Couldn't run away");
|
||||
delayForSeconds(1);
|
||||
} else {
|
||||
System.out.println("Phew! Got away safely");
|
||||
delayForSeconds(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -345,11 +332,9 @@ public class ShipWarfareGUI extends Application {
|
||||
|
||||
if (exitValue == 1) {
|
||||
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
|
||||
delayForSeconds(1);
|
||||
calculateLoot = (randomValue.nextInt(startingLittyShips) + startingLittyShips) * 300;
|
||||
player.setMoney(player.getMoney() + calculateLoot);
|
||||
System.out.printf("We got $%,d!\n", calculateLoot);
|
||||
delayForSeconds(2);
|
||||
return true;
|
||||
} else if (exitValue == 2) {
|
||||
player.gameOver();
|
||||
@@ -357,7 +342,6 @@ public class ShipWarfareGUI extends Application {
|
||||
return true;
|
||||
} else if (exitValue == 3) {
|
||||
System.out.printf("We made it out at %d%% ship status!\n", player.getHP());
|
||||
delayForSeconds(2);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -371,11 +355,23 @@ public class ShipWarfareGUI extends Application {
|
||||
* @throws Exception in case of errors due to the delay
|
||||
*/
|
||||
|
||||
public void wipe(){
|
||||
title.setVisible(false);
|
||||
runAwayOrLeft.setVisible(false);
|
||||
shipsRemaining.setVisible(false);
|
||||
HPLeft.setVisible(false);
|
||||
gunsLeftOrTaken.setVisible(false);
|
||||
continueToFight.setVisible(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean destroyPeasantShipsOrEscape() throws Exception {
|
||||
int calculateLoot = 0;
|
||||
int chanceOfEnemyRun = 0;
|
||||
int hitCounter=0;
|
||||
int missCounter=0;
|
||||
boolean gunFrustration= false;
|
||||
|
||||
|
||||
Scanner userInput = new Scanner(System.in);
|
||||
@@ -396,10 +392,8 @@ public class ShipWarfareGUI extends Application {
|
||||
break;
|
||||
}
|
||||
hitCounter++;
|
||||
delayForSeconds(1);
|
||||
} else {
|
||||
missCounter++;
|
||||
delayForSeconds(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -407,11 +401,10 @@ public class ShipWarfareGUI extends Application {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
label1.setText(String.format("Report:\nShips we hit: %d\nShots missed: %d", hitCounter,missCounter));
|
||||
report.setText(String.format("Report: Ships we hit: %d Shots missed: %d", hitCounter,missCounter));
|
||||
}
|
||||
else{
|
||||
label1.setText("We don't have any guns!!!");
|
||||
delayForSeconds(1);
|
||||
report.setText("We don't have any guns!!!");
|
||||
|
||||
}
|
||||
|
||||
@@ -429,23 +422,20 @@ public class ShipWarfareGUI extends Application {
|
||||
|
||||
setNumOfPeasantShips(numOfPeasantShips - howMuchRun);
|
||||
if (userAttacks == true) {
|
||||
System.out.printf("Ahhh, %d ships ran away %s!\n", howMuchRun, player.getName());
|
||||
runAwayOrLeft.setText(String.format("Ahhh, %d ships ran away %s!\n", howMuchRun, player.getName()));
|
||||
} else {
|
||||
System.out.printf("Escaped %d of them!\n", howMuchRun);
|
||||
runAwayOrLeft.setText(String.format("Escaped %d of them!\n", howMuchRun));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.printf("%d ships remaining\n", numOfPeasantShips);
|
||||
delayForSeconds(1);
|
||||
System.out.println("Oh no, they are taking the offensive!");
|
||||
delayForSeconds(1);
|
||||
shipsRemaining.setText(String.format("%d ships remaining and they look angry!\n", numOfPeasantShips));
|
||||
//Computer volley
|
||||
int takeGunChance = randomValue.nextInt(4) + 1;
|
||||
if (takeGunChance == 1 && player.getGuns() > 0) {
|
||||
player.setGuns(player.getGuns() - 1);
|
||||
System.out.println("Dang it! They destroyed one of our guns");
|
||||
gunFrustration=true;
|
||||
} else {
|
||||
player.setHP(player.getHP() - (1 + randomValue.nextInt(10)));
|
||||
}
|
||||
@@ -453,42 +443,53 @@ public class ShipWarfareGUI extends Application {
|
||||
exitValue = 2;
|
||||
break;
|
||||
}
|
||||
System.out.printf("EEK, our current ship status is %d%% \n", player.getHP());
|
||||
delayForSeconds(1);
|
||||
if(gunFrustration==true){
|
||||
gunsLeftOrTaken.setText(String.format("Dang it! We only have %d guns left", player.getGuns()));
|
||||
}
|
||||
else{
|
||||
gunsLeftOrTaken.setText(String.format("We still have %d guns left", player.getGuns()));
|
||||
}
|
||||
|
||||
HPLeft.setText(String.format("EEK, our current ship status is %d%% \n", player.getHP()));
|
||||
if (userAttacks == false) {
|
||||
userAttacks = true;
|
||||
}
|
||||
|
||||
System.out.printf("Shall we continue to fight? Enter \"f\" to fight, and \"r\" to run (We have %d gun(s) left)\n", player.getGuns());
|
||||
continueToFight.setText(String.format("Shall we continue to fight? (Click the fight button or the run button)\n", player.getGuns()));
|
||||
|
||||
if (runButton.isPressed()) {
|
||||
|
||||
String response = userInput.nextLine();
|
||||
if (response.equalsIgnoreCase("r")) {
|
||||
if (runFromShips() == false) {
|
||||
System.out.println("Couldn't run away");
|
||||
wipe();
|
||||
chooseFightOrRun.setText("Couldn't run away");
|
||||
} else {
|
||||
exitValue = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if(fightButton.isPressed()){
|
||||
title.setText("AYYYYYYYYYYY");
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (exitValue == 1) {
|
||||
System.out.printf("\nGot eem\nVictory!\nIt appears we have defeated the enemy fleet and made it out at %d%% ship status\n", player.getHP());
|
||||
delayForSeconds(1);
|
||||
calculateLoot = (randomValue.nextInt(startingPeasantShips) + startingPeasantShips) * 100;
|
||||
player.setMoney(player.getMoney() + calculateLoot);
|
||||
System.out.printf("We got $%,d!", calculateLoot);
|
||||
delayForSeconds(2);
|
||||
return true;
|
||||
} else if (exitValue == 2) {
|
||||
player.gameOver();
|
||||
return true;
|
||||
} else if (exitValue == 3) {
|
||||
System.out.printf("We made it out at %d%% ship status!\n", player.getHP());
|
||||
delayForSeconds(2);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -521,7 +522,7 @@ public class ShipWarfareGUI extends Application {
|
||||
|
||||
|
||||
public void setLabel1(String sysOut) {
|
||||
label1.setText(sysOut);
|
||||
report.setText(sysOut);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -533,7 +534,7 @@ public class ShipWarfareGUI extends Application {
|
||||
*/
|
||||
|
||||
public void start(Stage stage) throws Exception {
|
||||
shipWarfare.setNumOfPeasantShips(shipWarfare.numOfShips());
|
||||
setNumOfPeasantShips(numOfShips());
|
||||
|
||||
|
||||
BorderPane BorderPane = new BorderPane();
|
||||
@@ -543,13 +544,19 @@ public class ShipWarfareGUI extends Application {
|
||||
gridPane.setVgap(5.0);
|
||||
|
||||
hBox = new HBox();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
fightButton = new Button();
|
||||
runButton = new Button();
|
||||
vBox = new VBox();
|
||||
label1 = new Label();
|
||||
label = new Label();
|
||||
vBox0 = new VBox();
|
||||
label0 = new Label();
|
||||
title = new Label();
|
||||
chooseFightOrRun = new Label();
|
||||
report = new Label();
|
||||
runAwayOrLeft = new Label();
|
||||
shipsRemaining = new Label();
|
||||
HPLeft = new Label();
|
||||
gunsLeftOrTaken = new Label();
|
||||
continueToFight = new Label();
|
||||
|
||||
|
||||
|
||||
BorderPane.setPrefHeight(400.0);
|
||||
BorderPane.setPrefWidth(600.0);
|
||||
@@ -558,16 +565,22 @@ public class ShipWarfareGUI extends Application {
|
||||
hBox.setPrefWidth(200.0);
|
||||
hBox.setSpacing(10.0);
|
||||
|
||||
button1.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
button1.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
|
||||
button1.setId("Button1");
|
||||
button1.setMnemonicParsing(false);
|
||||
button1.setText("Fight");
|
||||
title.setAlignment(javafx.geometry.Pos.TOP_CENTER);
|
||||
title.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
|
||||
title.setId("Label1");
|
||||
title.setText(String.format("%d ships attacking. Would you like to Fight or Run?",numOfPeasantShips));
|
||||
title.setPadding(new Insets(6.0, 0.0, 0.0, 0.0));
|
||||
|
||||
button2.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
button2.setId("Button2");
|
||||
button2.setMnemonicParsing(false);
|
||||
button2.setText("Run");
|
||||
fightButton.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
fightButton.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
|
||||
fightButton.setId("Button1");
|
||||
fightButton.setMnemonicParsing(false);
|
||||
fightButton.setText("Fight");
|
||||
|
||||
runButton.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
runButton.setId("Button2");
|
||||
runButton.setMnemonicParsing(false);
|
||||
runButton.setText("Run");
|
||||
BorderPane.setBottom(hBox);
|
||||
|
||||
BorderPane.setAlignment(vBox, javafx.geometry.Pos.CENTER);
|
||||
@@ -576,76 +589,45 @@ public class ShipWarfareGUI extends Application {
|
||||
vBox.setPrefWidth(100.0);
|
||||
vBox.setSpacing(20.0);
|
||||
|
||||
label1.setAlignment(javafx.geometry.Pos.TOP_CENTER);
|
||||
label1.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
|
||||
label1.setId("Label1");
|
||||
label1.setPadding(new Insets(6.0, 0.0, 0.0, 0.0));
|
||||
report.setAlignment(javafx.geometry.Pos.TOP_CENTER);
|
||||
report.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
|
||||
report.setId("Label1");
|
||||
report.setPadding(new Insets(6.0, 0.0, 0.0, 0.0));
|
||||
vBox.setPadding(new Insets(0.0, 0.0, 10.0, 0.0));
|
||||
BorderPane.setTop(vBox);
|
||||
BorderPane.setPadding(new Insets(6.0, 0.0, 0.0, 0.0));
|
||||
vBox0.setAlignment(javafx.geometry.Pos.TOP_CENTER);
|
||||
vBox0.setPrefHeight(200.0);
|
||||
vBox0.setPrefWidth(100.0);
|
||||
vBox0.setSpacing(5.0);
|
||||
|
||||
hBox.getChildren().add(button1);
|
||||
hBox.getChildren().add(button2);
|
||||
vBox.getChildren().add(label1);
|
||||
vBox.getChildren().add(label);
|
||||
vBox0.getChildren().add(label0);
|
||||
vBox.getChildren().add(vBox0);
|
||||
int calculateLoot = 0;
|
||||
int chanceOfEnemyRun = 0;
|
||||
hBox.getChildren().add(fightButton);
|
||||
hBox.getChildren().add(runButton);
|
||||
vBox.getChildren().add(title);
|
||||
vBox.getChildren().add(chooseFightOrRun);
|
||||
vBox.getChildren().add(report);
|
||||
vBox.getChildren().add(runAwayOrLeft);
|
||||
vBox.getChildren().add(shipsRemaining);
|
||||
vBox.getChildren().add(HPLeft);
|
||||
vBox.getChildren().add(gunsLeftOrTaken);
|
||||
vBox.getChildren().add(continueToFight);
|
||||
|
||||
|
||||
//label1.setText(String.format("By Golly! We have $%,d and are being attacked by %d Merchant ships\nCurrently our ship status is %d%%\n", player.getMoney(), shipWarfare.getNumOfPeasantShips(), player.getHP()));
|
||||
label.setText("What would you like to do?");
|
||||
|
||||
|
||||
|
||||
//report.setText(String.format("By Golly! We have $%,d and are being attacked by %d Merchant ships\nCurrently our ship status is %d%%\n", player.getMoney(), shipWarfare.getNumOfPeasantShips(), player.getHP()));
|
||||
|
||||
|
||||
//Fight
|
||||
button1.setOnAction(new EventHandler<ActionEvent>() {
|
||||
fightButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
public void handle(ActionEvent event) {
|
||||
counter++;
|
||||
if (counter == 1) {
|
||||
|
||||
label.setText("Ohh, Fight ehh?");
|
||||
chooseFightOrRun.setText("Ohh, Fight ehh?");
|
||||
try {
|
||||
destroyPeasantShipsOrEscape();
|
||||
}
|
||||
catch(Exception e){
|
||||
|
||||
int hitCounter=0;
|
||||
int missCounter=0;
|
||||
|
||||
Random randomValue = new Random();
|
||||
int exitValue = 0;
|
||||
while (exitValue == 0) {
|
||||
if (player.getGuns() > 0) {
|
||||
|
||||
for (int j = 0; j < player.getGuns(); j++) {
|
||||
if (userAttacks == true) {
|
||||
int hitOrMiss = randomValue.nextInt(2) + 1;
|
||||
if (hitOrMiss == 2) {
|
||||
numOfPeasantShips--;
|
||||
if (numOfPeasantShips <= 0) {
|
||||
exitValue = 1;
|
||||
break;
|
||||
}
|
||||
hitCounter++;
|
||||
delayForSeconds(1);
|
||||
} else {
|
||||
missCounter++;
|
||||
delayForSeconds(1);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
label1.setText(String.format("Report:\nShips we hit: %d\nShots missed: %d", hitCounter, missCounter));
|
||||
} else {
|
||||
label1.setText("We don't have any guns!!!");
|
||||
delayForSeconds(1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -653,30 +635,30 @@ public class ShipWarfareGUI extends Application {
|
||||
}
|
||||
if (counter == 2) {
|
||||
System.out.println("You pressed the button twice.");
|
||||
button1.setVisible(false);
|
||||
button2.setVisible(false);
|
||||
button1.setDisable(true);
|
||||
button2.setDisable(true);
|
||||
fightButton.setVisible(false);
|
||||
runButton.setVisible(false);
|
||||
fightButton.setDisable(true);
|
||||
runButton.setDisable(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Flee
|
||||
button2.setOnAction(new EventHandler<ActionEvent>() {
|
||||
runButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
counter++;
|
||||
if (counter == 1) {
|
||||
label1.setText("Ohh, Run ehh?");
|
||||
chooseFightOrRun.setText("Ohh, Run ehh?");
|
||||
|
||||
|
||||
}
|
||||
if (counter == 2) {
|
||||
System.out.println("You pressed the button twice.");
|
||||
button1.setVisible(false);
|
||||
button2.setVisible(false);
|
||||
button1.setDisable(true);
|
||||
button2.setDisable(true);
|
||||
fightButton.setVisible(false);
|
||||
runButton.setVisible(false);
|
||||
fightButton.setDisable(true);
|
||||
runButton.setDisable(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user