-
Notifications
You must be signed in to change notification settings - Fork 0
/
Criminal.java
135 lines (116 loc) · 6.33 KB
/
Criminal.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package com.intermediate.thegreatrobbery;
public class Criminal extends Person {
private Item[] ITEMS;
private boolean Arrested;
private boolean Escaped;
private String playerName;
public Criminal(final String NAME, final String NICKNAME, final int BIRTH_YEAR, final String EXPERT_IN) {
super(NAME, NICKNAME, BIRTH_YEAR, EXPERT_IN);
this.ITEMS = new Item[20];
this.Arrested = false;
this.Escaped = false;
this.playerName = getPlayerName();
}
public Criminal(Criminal criminal) {
super(criminal.getName(), criminal.getNickname(), criminal.getBirthYear(), criminal.getExpertIn());
this.ITEMS = new Item[20];
this.Arrested = false;
this.Escaped = false;
this.playerName = getPlayerName();
}
public String getPlayerName() {
return playerName;
}
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
public int getSuccessPercentage() {
return Utils.rangeFromZero((short) 100);
}
public boolean isArrested() {
return Arrested;
}
public void setArrested(boolean arrested) {
Arrested = arrested;
}
public boolean hasEscaped() {
return Escaped;
}
public void setEscaped(boolean hasEscaped) {
this.Escaped = hasEscaped;
}
public void runAway(){
this.setEscaped(true);
System.out.println(this.getName() + " decided it's time to bail. If there's anyone remaining, good luck!");
System.out.println("Their total loot was $" + this.getTotalValueForItems());
System.out.println("--------------------------------------------");
}
public void listHaulItems() {
byte itemIndex = 1;
String statusMessage = this.isArrested() ? "This were the items " + this.getName() + " had before being arrested: " :
" List of " + this.getName() + "'s stolen items: ";
System.out.println(statusMessage);
for (Item item : this.getItems()) {
if(item != null){
System.out.println(itemIndex + ". " + item);
itemIndex++;
}else{ break; }
}
System.out.println(this.getName() + "'s haul is equal to: $" + this.getTotalValueForItems());
}
public void printBioData() {
System.out.println("Criminal Person: ");
super.printBioData();
}
public void theft(String playerPrompt) {
int playerSuccessCheck = this.getSuccessPercentage();
boolean wasSuccessful;
String detectiveLocation = Assets.detectiveCurrentLocation = Assets.detective.randomLocationToCheck();
for (Building building : Assets.getCityBuildings()) {
if (building.getName().toLowerCase().equals(playerPrompt)) {
if (detectiveLocation.equals(building.getName())) {
wasSuccessful = playerSuccessCheck >= building.getSecurityPercentage() + Assets.detective.getSuccessPercentage();
building.setDetectivePresent(true);
} else
{
wasSuccessful = playerSuccessCheck >= building.getSecurityPercentage();
}
if (wasSuccessful) {
this.saveStolenItem(building, playerSuccessCheck);
} else {
Assets.detective.makeArrest(this, building);
System.out.println("The people from the " + building.getName() + " will be on higher alert now. Their security has been increased by a small amount.");
building.setSecurityPercentage(building.getSecurityPercentage() + 2);
}
}
}
}
public void saveStolenItem(Building building, int playerSuccessCheck) {
short randomItemIndex = Utils.rangeFromZero((short) (building.getItems().length - 1));
Item stolenItem = new Item(building.getItems()[randomItemIndex]);
if(!stolenItem.getNAME().equals("nothing")){
Utils.addItemsToCharacter(this, stolenItem);
}
if(building.isDetectivePresent()){
System.out.println("Despite detective's " + Assets.detective.getName() + " presence at the scene, " + this.getName() + " still managed to escape the scene.");
System.out.println(Assets.detective.getNickname() + " took a hit to their professional reliance, reducing their security check by 5%");
Assets.detective.setIncreasedSuccessPercentagePerRound(Assets.detective.getIncreasedSuccessPercentagePerRound() - 3);
}else {
System.out.println("While the theft at the " + building.getName() + " was taking place, detective " + Assets.detective.getName() + " was checking the " + Assets.detectiveCurrentLocation);
System.out.println(Assets.detective.getNickname() + " vowed to do better in the future. Their security check increases by 3%");
Assets.detective.setIncreasedSuccessPercentagePerRound(Assets.detective.getIncreasedSuccessPercentagePerRound() + 3);
}
System.out.println("------------------------------------------------------------------------------");
building.setDetectivePresent(false);
if(stolenItem.getNAME().equals("nothing")){
System.out.println(this.getName() + " decided that despite the chances, it would be too risk to hit the place. " +
this.getNickname() + " got away from the " + building.getName() + " with nothing. The success rate was: " + playerSuccessCheck +
"% against " + Utils.twoDecimals(building.getSecurityPercentage()) + "% from the " + building.getName());
}
System.out.println(this.getName() + " managed to get away from the " + building.getName() + " with " +
stolenItem.getNAME() + " worth $" + stolenItem.getValue() + ". " + this.getNickname() +
" success rate was: " + playerSuccessCheck +
"% against " + Utils.twoDecimals(building.getSecurityPercentage()) + "% from the " + building.getName());
System.out.println("------------------------------------------------------------------------------");
}
}