| 1 | package com.takenoko.actions.objective; | |
| 2 | ||
| 3 | import com.takenoko.actions.ActionResult; | |
| 4 | import com.takenoko.actions.DefaultAction; | |
| 5 | import com.takenoko.actions.annotations.ActionAnnotation; | |
| 6 | import com.takenoko.actions.annotations.ActionType; | |
| 7 | import com.takenoko.engine.Board; | |
| 8 | import com.takenoko.engine.BotManager; | |
| 9 | import com.takenoko.engine.BotState; | |
| 10 | import com.takenoko.objective.ObjectiveType; | |
| 11 | import java.util.List; | |
| 12 | import java.util.Objects; | |
| 13 | ||
| 14 | /** This class is used to draw an objective card. */ | |
| 15 | @ActionAnnotation(ActionType.DEFAULT) | |
| 16 | public class DrawObjectiveAction implements DefaultAction { | |
| 17 | private final ObjectiveType objectiveType; | |
| 18 | ||
| 19 | /** | |
| 20 | * Constructor. The parameter is mandatory as it allows to choose which type of objective you | |
| 21 | * want. | |
| 22 | * | |
| 23 | * @param objectiveType objectiveType | |
| 24 | */ | |
| 25 | public DrawObjectiveAction(ObjectiveType objectiveType) { | |
| 26 | this.objectiveType = objectiveType; | |
| 27 | } | |
| 28 | ||
| 29 | @Override | |
| 30 | public ActionResult execute(Board board, BotManager botManager) { | |
| 31 |
1
1. execute : removed call to com/takenoko/engine/Board::drawObjective → KILLED |
board.drawObjective(objectiveType); |
| 32 |
1
1. execute : removed call to com/takenoko/engine/BotManager::addObjective → KILLED |
botManager.addObjective(board.peekObjectiveDeck()); |
| 33 |
1
1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT |
botManager.displayMessage( |
| 34 | botManager.getName() + " drew objective " + board.peekObjectiveDeck()); | |
| 35 |
1
1. execute : removed call to com/takenoko/stats/SingleBotStatistics::updateActions → KILLED |
botManager.getSingleBotStatistics().updateActions(getClass().getSimpleName()); |
| 36 |
1
1. execute : replaced return value with null for com/takenoko/actions/objective/DrawObjectiveAction::execute → KILLED |
return new ActionResult(List.of(DrawObjectiveAction.class), 1); |
| 37 | } | |
| 38 | ||
| 39 | public static boolean canBePlayed(Board board, BotState botState) { | |
| 40 |
3
1. canBePlayed : changed conditional boundary → KILLED 2. canBePlayed : negated conditional → KILLED 3. canBePlayed : replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::canBePlayed → KILLED |
return (botState.getObjectives().size()) < BotState.MAX_OBJECTIVES |
| 41 |
1
1. canBePlayed : negated conditional → KILLED |
&& !board.isObjectiveDeckEmpty(); |
| 42 | } | |
| 43 | ||
| 44 | /** | |
| 45 | * Get the objective type of the action | |
| 46 | * | |
| 47 | * @return ObjectiveType | |
| 48 | */ | |
| 49 | public ObjectiveType getObjectiveType() { | |
| 50 |
1
1. getObjectiveType : replaced return value with null for com/takenoko/actions/objective/DrawObjectiveAction::getObjectiveType → KILLED |
return objectiveType; |
| 51 | } | |
| 52 | ||
| 53 | @Override | |
| 54 | public boolean equals(Object o) { | |
| 55 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with false for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE |
if (this == o) return true; |
| 56 |
3
1. equals : negated conditional → NO_COVERAGE 2. equals : negated conditional → NO_COVERAGE 3. equals : replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE |
if (o == null || getClass() != o.getClass()) return false; |
| 57 | DrawObjectiveAction that = (DrawObjectiveAction) o; | |
| 58 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with true for com/takenoko/actions/objective/DrawObjectiveAction::equals → NO_COVERAGE |
return objectiveType == that.objectiveType; |
| 59 | } | |
| 60 | ||
| 61 | @Override | |
| 62 | public int hashCode() { | |
| 63 |
1
1. hashCode : replaced int return with 0 for com/takenoko/actions/objective/DrawObjectiveAction::hashCode → TIMED_OUT |
return Objects.hash(objectiveType); |
| 64 | } | |
| 65 | } | |
Mutations | ||
| 31 |
1.1 |
|
| 32 |
1.1 |
|
| 33 |
1.1 |
|
| 35 |
1.1 |
|
| 36 |
1.1 |
|
| 40 |
1.1 2.2 3.3 |
|
| 41 |
1.1 |
|
| 50 |
1.1 |
|
| 55 |
1.1 2.2 |
|
| 56 |
1.1 2.2 3.3 |
|
| 58 |
1.1 2.2 |
|
| 63 |
1.1 |