Coverage Summary for Class: EffectTracker (it.polimi.ingsw.Model)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| EffectTracker | 100% (1/1) | 100% (13/13) | 100% (18/18) |
1 package it.polimi.ingsw.Model; 2 3 import it.polimi.ingsw.Misc.OptionalValue; 4 import it.polimi.ingsw.Model.Enums.PawnColour; 5 6 import java.io.Serial; 7 import java.io.Serializable; 8 9 /** 10 * {@link CharacterCard}s may impose some non immediate effects to resolve during the turn. This class aims to keep track of them 11 */ 12 public class EffectTracker implements Serializable { 13 @Serial 14 private static final long serialVersionUID = 135L; // convention: 1 for model, (01 -> 99) for objects 15 private OptionalValue<PawnColour> deniedPawnColour; 16 private boolean denyTowerInfluence; 17 private boolean increasedInfluence; 18 private boolean increasedMotherNatureMovement; 19 private boolean alternativeTeacherAssignment; 20 21 /** 22 * Constructor for the Tracker (all effects are disabled) 23 */ 24 public EffectTracker() { 25 this.reset(); 26 } 27 28 /** 29 * When called, this method will reset all effects to the disabled state. 30 */ 31 public void reset() { 32 this.deniedPawnColour = OptionalValue.empty(); 33 this.denyTowerInfluence = false; 34 this.increasedInfluence = false; 35 this.increasedMotherNatureMovement = false; 36 this.alternativeTeacherAssignment = false; 37 } 38 39 /** 40 * enables the increased influence flag 41 */ 42 public void enableIncreasedInfluence() { 43 this.increasedInfluence = true; 44 } 45 46 /** 47 * enables the denied tower influence flag 48 */ 49 public void enableDenyTowerInfluence() { 50 this.denyTowerInfluence = true; 51 } 52 53 /** 54 * enables the increased mother nature movement flag 55 */ 56 public void enableIncreasedMotherNatureMovement() { 57 this.increasedMotherNatureMovement = true; 58 } 59 60 /** 61 * enables the alternative teacher assignment algorithm flag 62 */ 63 public void enableAlternativeTeacherAssignment() { 64 this.alternativeTeacherAssignment = true; 65 } 66 67 /** 68 * @return value of the increased influence flag 69 */ 70 public boolean isInfluenceIncreased() { 71 return increasedInfluence; 72 } 73 74 /** 75 * @return value of the denied tower influence flag 76 */ 77 public boolean isTowerInfluenceDenied() { 78 return denyTowerInfluence; 79 } 80 81 /** 82 * @return value of the increased mother nature movement flag 83 */ 84 public boolean isMotherNatureMovementIncreased() { 85 return increasedMotherNatureMovement; 86 } 87 88 /** 89 * @return value of the alternative teacher assignment algorithm flag 90 */ 91 public boolean isAlternativeTeacherAssignmentEnabled() { 92 return alternativeTeacherAssignment; 93 } 94 95 /** 96 * @return true if the value of the denied {@link PawnColour} is set 97 */ 98 public boolean isPawnColourDenied() { 99 return deniedPawnColour.isPresent(); 100 } 101 102 /** 103 * @return the denied {@link PawnColour} wrapped in a {@link OptionalValue} 104 */ 105 public OptionalValue<PawnColour> getDeniedPawnColour() { 106 return deniedPawnColour; 107 } 108 109 /** 110 * sets the denied {@link PawnColour} 111 * 112 * @param pawnColour the {@link PawnColour} to be denied 113 */ 114 public void setDeniedPawnColour(PawnColour pawnColour) { 115 this.deniedPawnColour = OptionalValue.of(pawnColour); 116 } 117 }