Coverage Summary for Class: Card02 (it.polimi.ingsw.Model)
| Class | Class, % | Method, % | Branch, % | Line, % |
|---|---|---|---|---|
| Card02 | 100% (1/1) | 100% (4/4) | 50% (1/2) | 100% (8/8) |
1 package it.polimi.ingsw.Model; 2 3 import it.polimi.ingsw.Exceptions.Input.InputValidationException; 4 import it.polimi.ingsw.Misc.OptionalValue; 5 import it.polimi.ingsw.Model.Enums.PawnColour; 6 7 import java.io.Serial; 8 import java.util.Map; 9 10 /** 11 * EFFECT: During this turn, you take control of any 12 * number of Professors even if you have the same 13 * number of Students as the player who currently controls them. 14 */ 15 public class Card02 extends StatelessEffect { 16 @Serial 17 private static final long serialVersionUID = 104L; // convention: 1 for model, (01 -> 99) for objects 18 19 public Card02(Model ctx) { 20 super(2, 2, ctx); 21 } 22 23 /** 24 * Refer to: {@link CharacterCard#overridableCheckInput(CharacterCardInput)} for further information 25 * 26 * @param input No extra parameters required 27 */ 28 @Override 29 public OptionalValue<InputValidationException> overridableCheckInput(CharacterCardInput input) { 30 return OptionalValue.empty(); 31 } 32 33 /** 34 * Refer to: {@link CharacterCard#unsafeApplyEffect(CharacterCardInput)} for further information 35 */ 36 @Override 37 protected void unsafeApplyEffect(CharacterCardInput input) { 38 Map<PawnColour, PlayerBoard> teachers = this.context.getTeachers(); 39 PlayerBoard me = input.getCaller(); 40 41 this.context.getMutableEffects().enableAlternativeTeacherAssignment(); 42 teachers.forEach((teacherColour, teacherOwner) -> { 43 if (teacherOwner.getDiningRoomCount(teacherColour) == me.getDiningRoomCount(teacherColour)) 44 this.context.setTeacher(teacherColour, me); 45 }); 46 } 47 48 }