Coverage Summary for Class: CharacterCardInput (it.polimi.ingsw.Model)
| Class | Class, % | Method, % | Branch, % | Line, % |
|---|---|---|---|---|
| CharacterCardInput | 100% (1/1) | 100% (8/8) | 100% (6/6) | 100% (12/12) |
1 package it.polimi.ingsw.Model; 2 3 import it.polimi.ingsw.Misc.OptionalValue; 4 import it.polimi.ingsw.Misc.Pair; 5 import it.polimi.ingsw.Model.Enums.PawnColour; 6 7 import java.io.Serial; 8 import java.io.Serializable; 9 import java.util.List; 10 11 /** 12 * Each {@link CharacterCard} can use many input parameters. This class serves as a way to group all possible inputs and 13 * edit them in a safe, coherent way. 14 */ 15 public class CharacterCardInput implements Serializable { 16 @Serial 17 private static final long serialVersionUID = 116L; // convention: 1 for model, (01 -> 99) for objects 18 private final PlayerBoard caller; 19 private Island targetIsland; 20 private PawnColour targetPawn; 21 private List<Pair<PawnColour, PawnColour>> targetPawnPairs; 22 23 /** 24 * Constructor for the base input of the card. 25 * 26 * @param caller each card requires the caller's {@link PlayerBoard} as an input. 27 */ 28 public CharacterCardInput(PlayerBoard caller) { 29 this.caller = caller; 30 } 31 32 /** 33 * @return the caller's {@link PlayerBoard} 34 */ 35 public PlayerBoard getCaller() { 36 return caller; 37 } 38 39 /** 40 * @return the {@link Island} set as a target. The value is wrapped in a {@link OptionalValue}, as the related input is not 41 * compulsory 42 */ 43 public OptionalValue<Island> getTargetIsland() { 44 if (this.targetIsland == null) return OptionalValue.empty(); 45 else return OptionalValue.of(targetIsland); 46 } 47 48 /** 49 * @param targetIsland the {@link Island} to set as a target 50 */ 51 public void setTargetIsland(Island targetIsland) { 52 this.targetIsland = targetIsland; 53 } 54 55 /** 56 * @return the {@link PawnColour} set as a target. The value is wrapped in a {@link OptionalValue}, as the related input is not 57 * compulsory 58 */ 59 public OptionalValue<PawnColour> getTargetPawn() { 60 if (this.targetPawn == null) return OptionalValue.empty(); 61 else return OptionalValue.of(targetPawn); 62 } 63 64 /** 65 * @param targetPawn the {@link PawnColour} to set as a target 66 */ 67 public void setTargetPawn(PawnColour targetPawn) { 68 this.targetPawn = targetPawn; 69 } 70 71 /** 72 * @return the the {@link List} of {@link Pair}s of {@link PawnColour} set as a target. 73 * The value is wrapped in a {@link OptionalValue}, as the related input is not 74 * compulsory 75 */ 76 public OptionalValue<List<Pair<PawnColour, PawnColour>>> getTargetPawnPairs() { 77 if (this.targetPawnPairs == null) return OptionalValue.empty(); 78 else return OptionalValue.of(targetPawnPairs); 79 } 80 81 /** 82 * Note: the convention of the {@link Pair} is to be verified through the card that requires the input. 83 * 84 * @param targetPawnPairs the {@link List} of {@link Pair}s of {@link PawnColour} to set as a target. 85 */ 86 public void setTargetPawnPairs(List<Pair<PawnColour, PawnColour>> targetPawnPairs) { 87 this.targetPawnPairs = targetPawnPairs; 88 } 89 }