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

Class Class, % Method, % Line, %
GodPrometheus 100% (1/ 1) 100% (3/ 3) 100% (29/ 29)


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