Basic functionality of buttons completed, think all I have to do now is to find a way to break the code when the user wins, loses or runs away.
This commit is contained in:
72
.idea/workspace.xml
generated
72
.idea/workspace.xml
generated
@@ -1,7 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3114a2b9-4919-4fdf-8fd9-d03b60109ce4" name="Default Changelist" comment="" />
|
<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" />
|
||||||
|
</list>
|
||||||
<ignored path="$PROJECT_DIR$/out/" />
|
<ignored path="$PROJECT_DIR$/out/" />
|
||||||
<ignored path="C:\Users\Harkamal Randhawa\IdeaProjects\TaipanClone\.idea\shelf/" />
|
<ignored path="C:\Users\Harkamal Randhawa\IdeaProjects\TaipanClone\.idea\shelf/" />
|
||||||
<ignored path="$PROJECT_DIR$/.idea/shelf/" />
|
<ignored path="$PROJECT_DIR$/.idea/shelf/" />
|
||||||
@@ -16,8 +18,20 @@
|
|||||||
<file pinned="false" current-in-tab="true">
|
<file pinned="false" current-in-tab="true">
|
||||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
|
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="199">
|
<state relative-caret-position="255">
|
||||||
<caret line="331" lean-forward="true" selection-start-line="331" selection-end-line="331" />
|
<caret line="17" column="35" selection-start-line="17" selection-start-column="35" selection-end-line="17" selection-end-column="35" />
|
||||||
|
<folding>
|
||||||
|
<element signature="imports" expanded="true" />
|
||||||
|
</folding>
|
||||||
|
</state>
|
||||||
|
</provider>
|
||||||
|
</entry>
|
||||||
|
</file>
|
||||||
|
<file pinned="false" current-in-tab="false">
|
||||||
|
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
|
||||||
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
|
<state relative-caret-position="483">
|
||||||
|
<caret line="665" column="1" selection-start-line="665" selection-start-column="1" selection-end-line="665" selection-end-column="1" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="imports" expanded="true" />
|
<element signature="imports" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
@@ -46,8 +60,8 @@
|
|||||||
<file pinned="false" current-in-tab="false">
|
<file pinned="false" current-in-tab="false">
|
||||||
<entry file="file://$PROJECT_DIR$/src/Player.java">
|
<entry file="file://$PROJECT_DIR$/src/Player.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="89">
|
<state relative-caret-position="120">
|
||||||
<caret line="8" column="29" lean-forward="true" selection-start-line="8" selection-start-column="29" selection-end-line="8" selection-end-column="29" />
|
<caret line="8" column="29" selection-start-line="8" selection-start-column="29" selection-end-line="8" selection-end-column="29" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
@@ -116,9 +130,9 @@
|
|||||||
<option value="$PROJECT_DIR$/src/TaipanShop.java" />
|
<option value="$PROJECT_DIR$/src/TaipanShop.java" />
|
||||||
<option value="$PROJECT_DIR$/src/main.java" />
|
<option value="$PROJECT_DIR$/src/main.java" />
|
||||||
<option value="$PROJECT_DIR$/src/Travel.java" />
|
<option value="$PROJECT_DIR$/src/Travel.java" />
|
||||||
<option value="$PROJECT_DIR$/src/ShipWarfare.java" />
|
|
||||||
<option value="$PROJECT_DIR$/src/Player.java" />
|
<option value="$PROJECT_DIR$/src/Player.java" />
|
||||||
<option value="$PROJECT_DIR$/src/ShipWarfareGUI.java" />
|
<option value="$PROJECT_DIR$/src/ShipWarfareGUI.java" />
|
||||||
|
<option value="$PROJECT_DIR$/src/ShipWarfare.java" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@@ -134,6 +148,7 @@
|
|||||||
<foldersAlwaysOnTop value="true" />
|
<foldersAlwaysOnTop value="true" />
|
||||||
</navigator>
|
</navigator>
|
||||||
<panes>
|
<panes>
|
||||||
|
<pane id="PackagesPane" />
|
||||||
<pane id="ProjectPane">
|
<pane id="ProjectPane">
|
||||||
<subPane>
|
<subPane>
|
||||||
<expand>
|
<expand>
|
||||||
@@ -151,7 +166,6 @@
|
|||||||
</subPane>
|
</subPane>
|
||||||
</pane>
|
</pane>
|
||||||
<pane id="Scope" />
|
<pane id="Scope" />
|
||||||
<pane id="PackagesPane" />
|
|
||||||
</panes>
|
</panes>
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">
|
<component name="PropertiesComponent">
|
||||||
@@ -267,6 +281,8 @@
|
|||||||
<workItem from="1552199842131" duration="998000" />
|
<workItem from="1552199842131" duration="998000" />
|
||||||
<workItem from="1552201459117" duration="275000" />
|
<workItem from="1552201459117" duration="275000" />
|
||||||
<workItem from="1552203562938" duration="2174000" />
|
<workItem from="1552203562938" duration="2174000" />
|
||||||
|
<workItem from="1552207404121" duration="54000" />
|
||||||
|
<workItem from="1552210170594" duration="72000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="This should fix the ShipWarfare file and bring it up to date with the rest of the file.">
|
<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>
|
<created>1550458470138</created>
|
||||||
@@ -429,17 +445,31 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1552205678080</updated>
|
<updated>1552205678080</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="24" />
|
<task id="LOCAL-00024" summary="Fixed the loot system a bit">
|
||||||
|
<created>1552207442784</created>
|
||||||
|
<option name="number" value="00024" />
|
||||||
|
<option name="presentableId" value="LOCAL-00024" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1552207442785</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00025" summary="Completely ruined shipWarfare with a previous edit, fixed it and added a better loot feature for peasant ships">
|
||||||
|
<created>1552210228514</created>
|
||||||
|
<option name="number" value="00025" />
|
||||||
|
<option name="presentableId" value="LOCAL-00025" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1552210228514</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="26" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TimeTrackingManager">
|
<component name="TimeTrackingManager">
|
||||||
<option name="totallyTimeSpent" value="62514000" />
|
<option name="totallyTimeSpent" value="62640000" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ToolWindowManager">
|
<component name="ToolWindowManager">
|
||||||
<frame x="48" y="23" width="1189" height="652" extended-state="0" />
|
<frame x="48" y="23" width="1189" height="652" extended-state="0" />
|
||||||
<editor active="true" />
|
<editor active="true" />
|
||||||
<layout>
|
<layout>
|
||||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24934612" />
|
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2580645" />
|
||||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||||
<window_info id="Image Layers" order="2" />
|
<window_info id="Image Layers" order="2" />
|
||||||
<window_info id="Designer" order="3" />
|
<window_info id="Designer" order="3" />
|
||||||
@@ -536,7 +566,6 @@
|
|||||||
<ignored-roots>
|
<ignored-roots>
|
||||||
<path value="$PROJECT_DIR$" />
|
<path value="$PROJECT_DIR$" />
|
||||||
</ignored-roots>
|
</ignored-roots>
|
||||||
<MESSAGE value="This should fix the project repository once and for all." />
|
|
||||||
<MESSAGE value="This should fix the ShipWarfare file and bring it up to date with the rest of the file." />
|
<MESSAGE value="This should fix the ShipWarfare file and bring it up to date with the rest of the file." />
|
||||||
<MESSAGE value="Created Core class" />
|
<MESSAGE value="Created Core class" />
|
||||||
<MESSAGE value="Fixed the setters to be greater than 0" />
|
<MESSAGE value="Fixed the setters to be greater than 0" />
|
||||||
@@ -560,7 +589,9 @@
|
|||||||
<MESSAGE value="ShipWarfare fight button coming along nicely" />
|
<MESSAGE value="ShipWarfare fight button coming along nicely" />
|
||||||
<MESSAGE value="Shipwarfare fight button GUI almost complete" />
|
<MESSAGE value="Shipwarfare fight button GUI almost complete" />
|
||||||
<MESSAGE value="Fixed numOfShips method for ShipWarfareGUI" />
|
<MESSAGE value="Fixed numOfShips method for ShipWarfareGUI" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Fixed numOfShips method for ShipWarfareGUI" />
|
<MESSAGE value="Fixed the loot system a bit" />
|
||||||
|
<MESSAGE value="Completely ruined shipWarfare with a previous edit, fixed it and added a better loot feature for peasant ships" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Completely ruined shipWarfare with a previous edit, fixed it and added a better loot feature for peasant ships" />
|
||||||
</component>
|
</component>
|
||||||
<component name="editorHistoryManager">
|
<component name="editorHistoryManager">
|
||||||
<entry file="uml://JAVA/ShipWarfare">
|
<entry file="uml://JAVA/ShipWarfare">
|
||||||
@@ -639,30 +670,25 @@
|
|||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/src/Player.java">
|
<entry file="file://$PROJECT_DIR$/src/Player.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="89">
|
<state relative-caret-position="120">
|
||||||
<caret line="8" column="29" lean-forward="true" selection-start-line="8" selection-start-column="29" selection-end-line="8" selection-end-column="29" />
|
<caret line="8" column="29" selection-start-line="8" selection-start-column="29" selection-end-line="8" selection-end-column="29" />
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
|
<entry file="file://$PROJECT_DIR$/src/ShipWarfareGUI.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="92">
|
<state relative-caret-position="483">
|
||||||
<caret line="206" column="28" selection-end-line="662" selection-end-column="1" />
|
<caret line="665" column="1" selection-start-line="665" selection-start-column="1" selection-end-line="665" selection-end-column="1" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="imports" expanded="true" />
|
<element signature="imports" expanded="true" />
|
||||||
<element signature="e#762#793#0" expanded="true" />
|
|
||||||
<element signature="e#1354#1355#0" expanded="true" />
|
|
||||||
<element signature="e#1382#1383#0" expanded="true" />
|
|
||||||
<element signature="e#17505#17506#0" expanded="true" />
|
|
||||||
<element signature="e#17543#17544#0" expanded="true" />
|
|
||||||
</folding>
|
</folding>
|
||||||
</state>
|
</state>
|
||||||
</provider>
|
</provider>
|
||||||
</entry>
|
</entry>
|
||||||
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
|
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
|
||||||
<provider selected="true" editor-type-id="text-editor">
|
<provider selected="true" editor-type-id="text-editor">
|
||||||
<state relative-caret-position="199">
|
<state relative-caret-position="255">
|
||||||
<caret line="331" lean-forward="true" selection-start-line="331" selection-end-line="331" />
|
<caret line="17" column="35" selection-start-line="17" selection-start-column="35" selection-end-line="17" selection-end-column="35" />
|
||||||
<folding>
|
<folding>
|
||||||
<element signature="imports" expanded="true" />
|
<element signature="imports" expanded="true" />
|
||||||
</folding>
|
</folding>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//Remember you deleted userAttacks = true, you might need it later
|
||||||
|
|
||||||
import javafx.animation.PathTransition;
|
import javafx.animation.PathTransition;
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
@@ -368,6 +370,17 @@ public class ShipWarfareGUI extends Application {
|
|||||||
continueToFight.setVisible(false);
|
continueToFight.setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public void completeWipe() {
|
||||||
|
title.setVisible(false);
|
||||||
|
chooseFightOrRun.setVisible(false);
|
||||||
|
runAwayOrLeft.setVisible(false);
|
||||||
|
shipsRemaining.setVisible(false);
|
||||||
|
HPLeft.setVisible(false);
|
||||||
|
gunsLeftOrTaken.setVisible(false);
|
||||||
|
continueToFight.setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -382,11 +395,19 @@ public class ShipWarfareGUI extends Application {
|
|||||||
int chanceOfEnemyRun = 0;
|
int chanceOfEnemyRun = 0;
|
||||||
int hitCounter = 0;
|
int hitCounter = 0;
|
||||||
int missCounter = 0;
|
int missCounter = 0;
|
||||||
boolean gunFrustration = false;
|
boolean gunFrustration = true;
|
||||||
//runAwayOrLeft.setVisible(false);
|
|
||||||
|
title.setVisible(true);
|
||||||
|
chooseFightOrRun.setVisible(true);
|
||||||
|
report.setVisible(true);
|
||||||
|
runAwayOrLeft.setVisible(true);
|
||||||
|
shipsRemaining.setVisible(true);
|
||||||
|
HPLeft.setVisible(true);
|
||||||
|
gunsLeftOrTaken.setVisible(true);
|
||||||
|
continueToFight.setVisible(true);
|
||||||
|
|
||||||
runAwayOrLeft.setText("No ships ran away");
|
runAwayOrLeft.setText("No ships ran away");
|
||||||
|
|
||||||
Scanner userInput = new Scanner(System.in);
|
|
||||||
Random randomValue = new Random();
|
Random randomValue = new Random();
|
||||||
int exitValue = 0;
|
int exitValue = 0;
|
||||||
|
|
||||||
@@ -412,8 +433,9 @@ public class ShipWarfareGUI extends Application {
|
|||||||
} else {
|
} else {
|
||||||
//continue;
|
//continue;
|
||||||
}
|
}
|
||||||
|
}if(userAttacks==true) {
|
||||||
|
report.setText(String.format("Report: Ships hit: %d, Shots missed: %d", hitCounter, missCounter));
|
||||||
}
|
}
|
||||||
report.setText(String.format("Report: Ships hit: %d, Shots missed: %d", hitCounter, missCounter));
|
|
||||||
} else {
|
} else {
|
||||||
report.setText("We don't have any guns!!!");
|
report.setText("We don't have any guns!!!");
|
||||||
|
|
||||||
@@ -432,11 +454,18 @@ public class ShipWarfareGUI extends Application {
|
|||||||
|
|
||||||
|
|
||||||
setNumOfPeasantShips(numOfPeasantShips - howMuchRun);
|
setNumOfPeasantShips(numOfPeasantShips - howMuchRun);
|
||||||
if (howMuchRun > 0) {
|
if (userAttacks == true) {
|
||||||
runAwayOrLeft.setText(String.format("Cowards! %d ships ran away %s! ", howMuchRun, player.getName()));
|
if (howMuchRun > 0) {
|
||||||
//runAwayOrLeft.setVisible(true);
|
runAwayOrLeft.setText(String.format("Cowards! %d ships ran away %s! ", howMuchRun, player.getName()));
|
||||||
|
//runAwayOrLeft.setVisible(true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
runAwayOrLeft.setText(String.format("Escaped %d of them %s! ", howMuchRun, player.getName()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
runAwayOrLeft.setText("None chose to flee!");
|
report.setText((String.format("Escaped %d of them %s!", howMuchRun,player.getName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -490,10 +519,10 @@ public class ShipWarfareGUI extends Application {
|
|||||||
|
|
||||||
if (exitValue == 1) {
|
if (exitValue == 1) {
|
||||||
wipe();
|
wipe();
|
||||||
chooseFightOrRun.setText(String.format("Ayy We won! We survived at %d%% ship status!", player.getHP()));
|
chooseFightOrRun.setText(String.format("Ayy! We won and survived at %d%% ship status!", player.getHP()));
|
||||||
calculateLoot = (startingPeasantShips *100) + randomValue.nextInt(startingPeasantShips) *200;
|
calculateLoot = (startingPeasantShips *100) + randomValue.nextInt(startingPeasantShips) *200;
|
||||||
player.setMoney(player.getMoney() + calculateLoot);
|
player.setMoney(player.getMoney() + calculateLoot);
|
||||||
report.setText(String.format("We got $%,d! ", calculateLoot));
|
report.setText(String.format("Our firm has earned $%,d in loot! ", calculateLoot));
|
||||||
return true;
|
return true;
|
||||||
} else if (exitValue == 2) {
|
} else if (exitValue == 2) {
|
||||||
player.gameOver();
|
player.gameOver();
|
||||||
@@ -638,19 +667,27 @@ public class ShipWarfareGUI extends Application {
|
|||||||
runButton.setOnAction(new EventHandler<ActionEvent>() {
|
runButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
|
chooseFightOrRun.setText("Ayy captain we will try to run!");
|
||||||
counter++;
|
counter++;
|
||||||
if (counter == 1) {
|
|
||||||
chooseFightOrRun.setText("Ohh, Run ehh?");
|
if (runFromShips() == false) {
|
||||||
|
title.setVisible(false);
|
||||||
|
chooseFightOrRun.setVisible(false);
|
||||||
|
report.setText(("Couldn't run away"));
|
||||||
|
try {
|
||||||
|
destroyPeasantShipsOrEscape();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
completeWipe();
|
||||||
|
report.setText("Phew! Got away safely");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (counter == 2) {
|
|
||||||
System.out.println("You pressed the button twice.");
|
|
||||||
fightButton.setVisible(false);
|
|
||||||
runButton.setVisible(false);
|
|
||||||
fightButton.setDisable(true);
|
|
||||||
runButton.setDisable(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user