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

Class Class, % Method, % Line, %
GodApollo 100% (1/ 1) 100% (3/ 3) 100% (22/ 22)


1 package it.polimi.ingsw.model; 2  3 class GodApollo extends GodDecorator { 4  /** 5  * God Artemis's class 6  * @param godPower God's power 7  */ 8  public GodApollo(GodInterface godPower) { 9  super(godPower); 10  } 11  12  /** 13  * Get event 14  * @param events event to be updated 15  * @param map board situation at the moment 16  * @param actions action of the event 17  */ 18  @Override 19  public void getEvent(Event[] events, Cell[][] map, Action[][][] actions) { 20  String namePlayer = godPower.getCurrentPlayer(); 21  if (events[0] == Event.ZERO && namePlayer.equals(godPower.getName())) { 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  String name = godPower.getName(); 36  Block block = null; 37  int[] destination = new int[2]; 38  39  for (int i = Math.max(0, position[0] - 1); (i <= Math.min(4, position[0] + 1)); i++) { 40  41  for (int j = Math.max(0, position[1] - 1); j <= Math.min(4, position[1] + 1); j++) { 42  block = map[i][j].getBlock(map[i][j].getSize()); 43  if (block.getTypeBlock().equals(TypeBlock.WORKER) 44  && map[i][j].getSize() <= map[position[0]][position[1]].getSize() + 1 45  && !block.getOwner().equals(name)) { 46  destination[0] = i; 47  destination[1] = j; 48  ((Swap) actions[i][j][0]).set(position, destination, destination, position, true); 49  } 50  } 51  } 52  } 53 }