[ all classes ]
[ it.polimi.ingsw.model ]
Coverage Summary for Class: GodAtlas (it.polimi.ingsw.model)
Class | Class, % | Method, % | Line, % |
---|---|---|---|
GodAtlas | 100% (1/ 1) | 100% (3/ 3) | 100% (19/ 19) |
1 package it.polimi.ingsw.model;
2
3 class GodAtlas extends GodDecorator {
4
5 /**
6 * God Atlas's class
7 * @param godPower God's power
8 */
9 public GodAtlas(GodInterface godPower) {
10 super(godPower);
11 }
12
13 /**
14 * Get event
15 * @param events event to be updated
16 * @param map board situation at the moment
17 * @param actions action of the event
18 */
19 @Override
20 public void getEvent(Event[] events, Cell[][] map, Action[][][] actions) {
21 if (godPower.getCurrentPlayer().equals(godPower.getName()) && events[0].equals(Event.MOVE)) {
22 godPower.activate(true);
23 setAction(map, actions);
24 godPower.activate(false);
25 }
26 }
27
28 /**
29 * Set god's special move/build action (God Power) if possible
30 * @param map Current board
31 * @param actions List of possible actions
32 */
33 private void setAction(Cell[][] map, Action[][][] actions) {
34 int[] position = godPower.getPositionWorker();
35 int[] destination = new int[2];
36 TypeBlock typeBlock = null;
37 for (int i = Math.max(0, position[0] - 1); (i <= Math.min(4, position[0] + 1)); i++) {
38 for (int j = Math.max(0, position[1] - 1); j <= Math.min(4, position[1] + 1); j++) {
39 if (!map[i][j].getBlock(map[i][j].getSize() - 1).getTypeBlock().equals(TypeBlock.WORKER)
40 && !map[i][j].getBlock(map[i][j].getSize() - 1).getTypeBlock().equals(TypeBlock.DOME)) {
41 typeBlock = TypeBlock.DOME;
42 destination[0] = i;
43 destination[1] = j;
44 ((Build) actions[i][j][2]).set(true, typeBlock, destination);
45 }
46 }
47 }
48 }
49 }