| 1 | package com.takenoko.actions.improvement; | |
| 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.ActionCanBePlayedMultipleTimesPerTurn; | |
| 7 | import com.takenoko.actions.annotations.ActionType; | |
| 8 | import com.takenoko.engine.Board; | |
| 9 | import com.takenoko.engine.BotManager; | |
| 10 | import com.takenoko.engine.BotState; | |
| 11 | import com.takenoko.layers.tile.ImprovementType; | |
| 12 | import com.takenoko.vector.PositionVector; | |
| 13 | import java.util.Objects; | |
| 14 | ||
| 15 | /** Action to apply an improvement from the inventory. */ | |
| 16 | @ActionAnnotation(ActionType.DEFAULT) | |
| 17 | @ActionCanBePlayedMultipleTimesPerTurn | |
| 18 | public class ApplyImprovementFromInventoryAction extends ApplyImprovementAction | |
| 19 | implements DefaultAction { | |
| 20 | private final ImprovementType improvementType; | |
| 21 | ||
| 22 | public ApplyImprovementFromInventoryAction( | |
| 23 | ImprovementType improvementType, PositionVector positionVector) { | |
| 24 | super(positionVector); | |
| 25 | this.improvementType = improvementType; | |
| 26 | } | |
| 27 | ||
| 28 | @Override | |
| 29 | public ActionResult execute(Board board, BotManager botManager) { | |
| 30 |
1
1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT |
botManager.displayMessage( |
| 31 | botManager.getName() | |
| 32 | + " applied improvement " | |
| 33 | + improvementType | |
| 34 | + " at " | |
| 35 | + positionVector | |
| 36 | + " from inventory"); | |
| 37 |
1
1. execute : removed call to com/takenoko/inventory/Inventory::useImprovement → KILLED |
botManager.getInventory().useImprovement(improvementType); |
| 38 |
1
1. execute : removed call to com/takenoko/engine/Board::applyImprovement → KILLED |
board.applyImprovement(improvementType, positionVector); |
| 39 | ||
| 40 |
1
1. execute : replaced return value with null for com/takenoko/actions/improvement/ApplyImprovementFromInventoryAction::execute → KILLED |
return new ActionResult(0); |
| 41 | } | |
| 42 | ||
| 43 | public static boolean canBePlayed(Board board, BotState botState) { | |
| 44 |
2
1. canBePlayed : negated conditional → TIMED_OUT 2. canBePlayed : replaced boolean return with true for com/takenoko/actions/improvement/ApplyImprovementFromInventoryAction::canBePlayed → KILLED |
return botState.getInventory().hasImprovement() |
| 45 |
1
1. canBePlayed : negated conditional → KILLED |
&& !board.getAvailableImprovementPositions().isEmpty(); |
| 46 | } | |
| 47 | ||
| 48 | @Override | |
| 49 | public boolean equals(Object o) { | |
| 50 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with false for com/takenoko/actions/improvement/ApplyImprovementFromInventoryAction::equals → NO_COVERAGE |
if (this == o) return true; |
| 51 |
3
1. equals : negated conditional → NO_COVERAGE 2. equals : negated conditional → NO_COVERAGE 3. equals : replaced boolean return with true for com/takenoko/actions/improvement/ApplyImprovementFromInventoryAction::equals → NO_COVERAGE |
if (o == null || getClass() != o.getClass()) return false; |
| 52 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with true for com/takenoko/actions/improvement/ApplyImprovementFromInventoryAction::equals → NO_COVERAGE |
if (!super.equals(o)) return false; |
| 53 | ApplyImprovementFromInventoryAction that = (ApplyImprovementFromInventoryAction) o; | |
| 54 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with true for com/takenoko/actions/improvement/ApplyImprovementFromInventoryAction::equals → NO_COVERAGE |
return improvementType == that.improvementType; |
| 55 | } | |
| 56 | ||
| 57 | @Override | |
| 58 | public int hashCode() { | |
| 59 |
1
1. hashCode : replaced int return with 0 for com/takenoko/actions/improvement/ApplyImprovementFromInventoryAction::hashCode → TIMED_OUT |
return Objects.hash(super.hashCode(), improvementType); |
| 60 | } | |
| 61 | } | |
Mutations | ||
| 30 |
1.1 |
|
| 37 |
1.1 |
|
| 38 |
1.1 |
|
| 40 |
1.1 |
|
| 44 |
1.1 2.2 |
|
| 45 |
1.1 |
|
| 50 |
1.1 2.2 |
|
| 51 |
1.1 2.2 3.3 |
|
| 52 |
1.1 2.2 |
|
| 54 |
1.1 2.2 |
|
| 59 |
1.1 |