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

Class Method, % Line, %
GodHephaestus 100% (3/ 3) 100% (40/ 40)
GodHephaestus$1 100% (1/ 1) 100% (1/ 1)
total 100% (4/ 4) 100% (41/ 41)


1 package it.polimi.ingsw.model; 2  3 class GodHephaestus 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 = new int[2]; 14  15  /** 16  * God Hephaestus's class 17  * @param godPower God's power 18  */ 19  public GodHephaestus(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  if (events[0] == Event.ZERO) { 33  position = null; 34  godPower.activate(true); 35  } else if (godPower.getStatus()) { 36  if (events[0].equals(Event.MOVE)) { 37  for (int i = 0; i < 5; i++) { 38  for (int j = 0; j < 5; j++) { 39  size[i][j] = map[i][j].getSize(); 40  } 41  position = new int[2]; 42  } 43  } else if (events[0].equals(Event.BUILD) && position != null) { 44  godPower.activate(false); 45  for (int i = 0; i < 25; i++) { 46  if (map[i / 5][i % 5].getSize() > size[i / 5][i % 5]) { 47  position[0] = i / 5; 48  position[1] = i % 5; 49  break; 50  } 51  } 52  setAction(map, actions); 53  } 54  } 55  } 56  } 57  58  /** 59  * Set god's special move/build action (God Power) if possible 60  * @param map Current board 61  * @param actions List of possible actions 62  */ 63  private void setAction(Cell[][] map, Action[][][] actions) { 64  if (map[position[0]][position[1]].getSize() < 3) { 65  int i = position[0]; 66  int j = position[1]; 67  TypeBlock typeBlock = null; 68  int[] destination = new int[2]; 69  switch (map[i][j].getBlock(map[i][j].getSize() - 1).getTypeBlock()) { 70  case LEVEL1: 71  typeBlock = TypeBlock.LEVEL2; 72  destination[0] = i; 73  destination[1] = j; 74  ((Build) actions[i][j][1]).set(true, typeBlock, destination); 75  break; 76  case LEVEL2: 77  typeBlock = TypeBlock.LEVEL3; 78  destination[0] = i; 79  destination[1] = j; 80  ((Build) actions[i][j][1]).set(true, typeBlock, destination); 81  break; 82  default: 83  break; 84  } 85  } 86  } 87 }