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

Class Class, % Method, % Line, %
GodStandard 100% (1/ 1) 100% (3/ 3) 100% (48/ 48)


1 package it.polimi.ingsw.model; 2  3 class GodStandard extends GodDecorator { 4  5  /** 6  * Boolean value for moved or built 7  */ 8  private boolean status; 9  10  /** 11  * Count player's actions 12  * If count == 2, player can end his turn (unless gods'powers say otherwise) 13  */ 14  private int count = 0; 15  16  /** 17  * *God* Standard's class 18  * @param godPower God's power 19  */ 20  public GodStandard(GodInterface godPower) { 21  super(godPower); 22  } 23  24  /** 25  * Get event 26  * @param events event to be updated 27  * @param map board situation at the moment 28  * @param actions action of the event 29  */ 30  @Override 31  public void getEvent(Event[] events, Cell[][] map, Action[][][] actions) { 32  if (events[0] == Event.ONE || events[0] == Event.TWO || events[0] == Event.THREE) { 33  if (godPower.getPlayerStatus() == StatusPlayer.WIN) { 34  return; 35  } 36  godPower.setStatusPlayer(StatusPlayer.LOSE); 37  godPower.setLastGod(God.STANDARD); 38  if (count == 0) { 39  for (int i = 0; i < 25; i++) { 40  if (actions[i / 5][i % 5][0].getStatus()) { 41  godPower.setStatusPlayer(StatusPlayer.GAMING); 42  break; 43  44  } 45  } 46  } else { 47  for (int i = 0; i < 25; i++) { 48  if (actions[i / 5][i % 5][1].getStatus() || (actions[i / 5][i % 5][2].getStatus())) { 49  godPower.setStatusPlayer(StatusPlayer.GAMING); 50  break; 51  } 52  } 53  } 54  if (count == 2 && (events[0] == Event.ONE || events[0] == Event.THREE || godPower.getPlayerStatus().equals(StatusPlayer.LOSE))) { 55  godPower.setStatusPlayer(StatusPlayer.IDLE); 56  godPower.setLastGod(God.STANDARD); 57  if (events[0] == Event.ONE) { 58  count = 0; 59  } 60  } 61  return; 62  } 63  64  int[] position = godPower.getPositionWorker(); 65  if (events[0] == Event.ZERO) { 66  status = false; 67  count = 0; 68  setAction(map, actions); 69  } else if (events[0].equals(Event.MOVE)) { 70  if (count == 0) { 71  count = 1; 72  } 73  status = true; 74  if (events[1].equals(Event.UP)) { 75  if (map[position[0]][position[1]].getSize() == 4) { 76  if (godPower.getLastGod().equals(God.STANDARD)) { 77  godPower.setStatusPlayer(StatusPlayer.WIN); 78  } 79  } 80  setAction(map, actions); 81  82  } else { 83  setAction(map, actions); 84  } 85  } else { 86  if (count == 1) { 87  count = 2; 88  } else if (count == 0) { 89  status = false; 90  setAction(map, actions); 91  } 92  } 93  94  } 95  96  /** 97  * Set god's special move/build action (God Power) if possible 98  * @param map Current board 99  * @param actions List of possible actions 100  */ 101  private void setAction(Cell[][] map, Action[][][] actions) { 102  if (!status) { 103  move(map, actions, godPower.getPositionWorker()); 104  } else { 105  build(map, actions, godPower.getPositionWorker()); 106  } 107  } 108 } 109  110