[ all classes ]
[ it.polimi.ingsw.model ]
Coverage Summary for Class: GodPoseidon (it.polimi.ingsw.model)
Class | Class, % | Method, % | Line, % |
---|---|---|---|
GodPoseidon | 100% (1/ 1) | 100% (3/ 3) | 100% (20/ 20) |
1 package it.polimi.ingsw.model;
2
3 class GodPoseidon extends GodDecorator {
4
5 /**
6 * Count build times
7 */
8 int count = 0;
9
10 /**
11 * Unmoved worker's position
12 */
13 int[] position = new int[2];
14
15 /**
16 * God Poseidon's class
17 *
18 * @param godPower God's power
19 */
20 public GodPoseidon(GodInterface godPower) {
21 super(godPower);
22 }
23
24 /**
25 * Get event
26 *
27 * @param events event to be updated
28 * @param map board situation at the moment
29 * @param actions action of the event
30 */
31 @Override
32 public void getEvent(Event[] events, Cell[][] map, Action[][][] actions) {
33 if (godPower.getCurrentPlayer().equals(godPower.getName())) {
34 if (events[0].equals(Event.BUILD) && count > 0) {
35 setAction(map, actions, position);
36 count--;
37 } else if (events[0] == Event.ZERO) {
38 count = 3;
39 for (int i = 0; i < 25; i++) {
40 if ((map[i / 5][i % 5].getBlock().getTypeBlock().equals(TypeBlock.WORKER) && map[i / 5][i % 5].getSize() == 1
41 && map[i / 5][i % 5].getBlock().getOwner().equals(godPower.getName()))
42 && (i / 5 != godPower.getPositionWorker()[0] || i % 5 != godPower.getPositionWorker()[1])) {
43 position[0] = i / 5;
44 position[1] = i % 5;
45 break;
46 }
47 }
48 }
49 }
50
51 }
52
53 /**
54 * Set god's special move/build action (God Power) if possible
55 *
56 * @param map Current board
57 * @param actions List of possible actions
58 * @param positionWorker unmoved worker's position
59 */
60 private void setAction(Cell[][] map, Action[][][] actions, int[] positionWorker) {
61 build(map, actions, positionWorker);
62 }
63 }