Coverage Summary for Class: GodDemeter (it.polimi.ingsw.model)

Class Class, % Method, % Line, %
GodDemeter 100% (1/ 1) 100% (3/ 3) 100% (27/ 27)


1 package it.polimi.ingsw.model; 2  3 class GodDemeter extends GodDecorator { 4  5  /** 6  * Board size 7  */ 8  private int[][] size = new int[5][5]; 9  10  /** 11  * First build position 12  */ 13  private int[] position = null; 14  15  /** 16  * God GodDemeter's class 17  * @param godPower God's power 18  */ 19  public GodDemeter(GodInterface godPower) { 20  super(godPower); 21  } 22  23  /** 24  * Get event 25  * @param events event to be updated 26  * @param map board situation at the moment 27  * @param actions action of the event 28  */ 29  @Override 30  public void getEvent(Event[] events, Cell[][] map, Action[][][] actions) { 31  if (godPower.getCurrentPlayer().equals(godPower.getName())) { 32  33  if (events[0] == Event.ZERO) { 34  position = null; 35  godPower.activate(true); 36  } else if (godPower.getStatus()) { 37  if (events[0].equals(Event.MOVE)) { 38  for (int i = 0; i < 5; i++) { 39  for (int j = 0; j < 5; j++) { 40  size[i][j] = map[i][j].getSize(); 41  } 42  position = new int[2]; 43  } 44  } else if (events[0].equals(Event.BUILD) && position != null) { 45  godPower.activate(false); 46  for (int i = 0; i < 25; i++) { 47  if (map[i / 5][i % 5].getSize() > size[i / 5][i % 5]) { 48  position[0] = i / 5; 49  position[1] = i % 5; 50  break; 51  } 52  } 53  setAction(map, actions); 54  } 55  } 56  } 57  58  } 59  60  /** 61  * Set god's special move/build action (God Power) if possible 62  * @param map Current board 63  * @param actions List of possible actions 64  */ 65  private void setAction(Cell[][] map, Action[][][] actions) { 66  build(map,actions,godPower.getPositionWorker()); 67  actions[position[0]][position[1]][1].set(false); 68  actions[position[0]][position[1]][2].set(false); 69  } 70 }