Fixed probability of ships running away

This commit is contained in:
KahootChampion
2019-03-10 12:00:00 -06:00
parent a07d633ff9
commit 42c4534f52
3 changed files with 46 additions and 33 deletions

64
.idea/workspace.xml generated
View File

@@ -2,7 +2,7 @@
<project version="4">
<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$/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/" />
@@ -15,7 +15,7 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
@@ -27,13 +27,15 @@
</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="483">
<caret line="665" column="1" selection-start-line="665" selection-start-column="1" selection-end-line="665" selection-end-column="1" />
<state relative-caret-position="244">
<caret line="485" column="20" lean-forward="true" selection-end-line="702" selection-end-column="1" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#18416#18417#0" expanded="true" />
<element signature="e#18454#18455#0" expanded="true" />
</folding>
</state>
</provider>
@@ -77,9 +79,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>numOfpeasantShips</find>
<find>startingPeasantShips</find>
<find>startingLittyShips</find>
<find>howMuchRun</find>
<find>pirateName</find>
<find>player</find>
@@ -107,6 +106,9 @@
<find>We survive</find>
<find>total of</find>
<find>int numOfShips</find>
<find>runFromShips()</find>
<find>dang it!</find>
<find>dang it</find>
</findStrings>
<replaceStrings>
<replace>HP</replace>
@@ -131,8 +133,8 @@
<option value="$PROJECT_DIR$/src/main.java" />
<option value="$PROJECT_DIR$/src/Travel.java" />
<option value="$PROJECT_DIR$/src/Player.java" />
<option value="$PROJECT_DIR$/src/ShipWarfareGUI.java" />
<option value="$PROJECT_DIR$/src/ShipWarfare.java" />
<option value="$PROJECT_DIR$/src/ShipWarfareGUI.java" />
</list>
</option>
</component>
@@ -283,6 +285,7 @@
<workItem from="1552203562938" duration="2174000" />
<workItem from="1552207404121" duration="54000" />
<workItem from="1552210170594" duration="72000" />
<workItem from="1552238757321" duration="742000" />
</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>
@@ -459,17 +462,24 @@
<option name="project" value="LOCAL" />
<updated>1552210228514</updated>
</task>
<option name="localTasksCounter" value="26" />
<task id="LOCAL-00026" summary="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.">
<created>1552238814974</created>
<option name="number" value="00026" />
<option name="presentableId" value="LOCAL-00026" />
<option name="project" value="LOCAL" />
<updated>1552238814974</updated>
</task>
<option name="localTasksCounter" value="27" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="62640000" />
<option name="totallyTimeSpent" value="63382000" />
</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.2580645" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26242372" />
<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" />
@@ -566,7 +576,6 @@
<ignored-roots>
<path value="$PROJECT_DIR$" />
</ignored-roots>
<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="Fixed the setters to be greater than 0" />
<MESSAGE value="Created Player class" />
@@ -591,7 +600,8 @@
<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" />
<MESSAGE value="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." />
<option name="LAST_COMMIT_MESSAGE" value="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." />
</component>
<component name="editorHistoryManager">
<entry file="uml://JAVA/ShipWarfare">
@@ -654,6 +664,16 @@
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ShopGUI" />
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<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>
<entry file="file://$PROJECT_DIR$/src/main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
@@ -677,20 +697,12 @@
</entry>
<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>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/ShipWarfare.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="35" selection-start-line="17" selection-start-column="35" selection-end-line="17" selection-end-column="35" />
<state relative-caret-position="244">
<caret line="485" column="20" lean-forward="true" selection-end-line="702" selection-end-column="1" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#18416#18417#0" expanded="true" />
<element signature="e#18454#18455#0" expanded="true" />
</folding>
</state>
</provider>

View File

@@ -223,7 +223,7 @@ public class ShipWarfareGUI extends Application {
}
/**
* One in two chance of running away
* One in 10 chance of running away
*
* @return true if the user is allowed to run, false if not, the "default" is false
*/
@@ -231,7 +231,7 @@ public class ShipWarfareGUI extends Application {
public boolean runFromShips() {
userAttacks = false;
Random randomValue = new Random();
int runSuccessChance = randomValue.nextInt(2) + 1;
int runSuccessChance = randomValue.nextInt(10) + 1;
if (runSuccessChance == 2) {
return true;
} else if (runSuccessChance == 1) {
@@ -459,10 +459,6 @@ public class ShipWarfareGUI extends Application {
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 {
report.setText((String.format("Escaped %d of them %s!", howMuchRun,player.getName())));
@@ -656,7 +652,8 @@ public class ShipWarfareGUI extends Application {
destroyPeasantShipsOrEscape();
} catch (Exception e) {
}
if (counter == 2) {
if (counter >= 2) {
title.setVisible(false);
}
@@ -685,6 +682,10 @@ public class ShipWarfareGUI extends Application {
}
if (counter>=2){
title.setVisible(false);
}