Skip to content

Commit 1b5cbc8

Browse files
committed
completely new approach to the project
1 parent 6cdf9ea commit 1b5cbc8

File tree

8 files changed

+349
-1079
lines changed

8 files changed

+349
-1079
lines changed

logs/logging

Lines changed: 0 additions & 414 deletions
Large diffs are not rendered by default.

src/entities/MasterThief.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,33 @@
77
import static utils.Utils.logger;
88

99
public class MasterThief extends Thief {
10-
boolean sentAnyAssaultParty;
1110

12-
public boolean sentAnyAssaultParty() {
13-
return sentAnyAssaultParty;
14-
}
15-
16-
public void sentAnyAssaultParty(boolean sentAnyAssaultParty) {
17-
this.sentAnyAssaultParty = sentAnyAssaultParty;
18-
}
11+
private int activeAssaultParties;
12+
private boolean[] hasCanvas;
1913

2014
public MasterThief(String threadName, int thiefID, Museum museum, ConcentrationSite concentrationSite, CollectionSite collectionSite, AssaultParty[] assaultParties) throws MemException {
2115
super(threadName, thiefID, museum, concentrationSite, collectionSite, assaultParties);
2216
setThiefState(MasterThiefStates.PLANNING_HEIST);
23-
sentAnyAssaultParty = false;
17+
activeAssaultParties = 0;
18+
hasCanvas = new boolean[N_ASSAULT_PARTIES];
19+
for (int i = 0; i < N_ASSAULT_PARTIES; i++)
20+
hasCanvas[i] = true;
21+
}
22+
23+
public int getActiveAssaultParties() {
24+
return activeAssaultParties;
25+
}
26+
27+
public void setActiveAssaultParties(int activeAssaultParties) {
28+
this.activeAssaultParties = activeAssaultParties;
29+
}
30+
31+
public boolean hasCanvas(int partyID) {
32+
return hasCanvas[partyID];
33+
}
34+
35+
public void hasCanvas(int partyID, boolean hasCanvas) {
36+
this.hasCanvas[partyID] = hasCanvas;
2437
}
2538

2639
@Override

src/entities/OrdinaryThief.java

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,24 @@
1111

1212
public class OrdinaryThief extends Thief {
1313
private AssaultParty party;
14-
private boolean canIMove;
15-
private int position;
1614
private int displacement;
17-
private int movesLeft;
1815
private boolean hasCanvas;
19-
public void joinParty(int partyID) {
20-
this.party = assaultParties[partyID];
21-
}
22-
23-
public AssaultParty getParty() {
24-
return party;
25-
}
16+
private Museum.Room[] rooms;
2617

27-
public boolean canMove() {
28-
return canIMove;
18+
public void setAssaultParty(int partyID) {
19+
party = assaultParties[partyID];
2920
}
3021

31-
public void canMove(boolean canIMove) {
32-
this.canIMove = canIMove;
33-
}
34-
35-
public int getPosition() {
36-
return position;
37-
}
38-
39-
public void setPosition(int position) {
40-
this.position = position;
22+
public void setRoomOfParty(int roomID) {
23+
party.setRoom(rooms[roomID]);
4124
}
4225

4326
public int getDisplacement() {
4427
return displacement;
4528
}
4629

47-
public int getMovesLeft() {
48-
return movesLeft;
49-
}
50-
51-
public void setMovesLeft(int movesLeft) {
52-
this.movesLeft = movesLeft;
53-
}
54-
55-
public void resetMovesLeft() {
56-
movesLeft = max(displacement, MAX_SEPARATION_LIMIT);
30+
public void setDisplacement(int displacement) {
31+
this.displacement = displacement;
5732
}
5833

5934
public boolean hasCanvas() {
@@ -68,16 +43,16 @@ public OrdinaryThief(String threadName, int thiefID, Museum museum, Concentratio
6843
super(threadName, thiefID, museum, concentrationSite, collectionSite, assaultParties);
6944
thiefState = OrdinaryThiefStates.CONCENTRATION_SITE;
7045
displacement = random(MIN_DISPLACEMENT, MAX_DISPLACEMENT);
71-
resetMovesLeft();
72-
canIMove = hasCanvas = false;
46+
hasCanvas = false;
47+
rooms = museum.getRooms();
7348
}
7449

7550
@Override
7651
public void run() {
7752
while (concentrationSite.amINeeded()) {
7853
concentrationSite.prepareExcursion();
7954
party.crawlIn();
80-
museum.rollACanvas(party.getId());
55+
museum.rollACanvas(party.getID());
8156
party.reverseDirection();
8257
party.crawlOut();
8358
collectionSite.handACanvas();

0 commit comments

Comments
 (0)