1 | package com.takenoko.actions.actors; | |
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.layers.bamboo.LayerBambooStack; | |
10 | import com.takenoko.vector.PositionVector; | |
11 | import java.util.Map; | |
12 | import java.util.Objects; | |
13 | ||
14 | /** Action to move a gardener. */ | |
15 | @ActionAnnotation(ActionType.DEFAULT) | |
16 | public class MoveGardenerAction implements DefaultAction { | |
17 | private final PositionVector relativePositionVector; | |
18 | ||
19 | /** | |
20 | * Constructor for the MoveGardenerAction class. | |
21 | * | |
22 | * @param relativePositionVector the position vector to move the Gardener | |
23 | */ | |
24 | public MoveGardenerAction(PositionVector relativePositionVector) { | |
25 | this.relativePositionVector = relativePositionVector; | |
26 | } | |
27 | ||
28 | public static boolean canBePlayed(Board board) { | |
29 |
2
1. canBePlayed : negated conditional → KILLED 2. canBePlayed : replaced boolean return with true for com/takenoko/actions/actors/MoveGardenerAction::canBePlayed → KILLED |
return !board.getTilesWithoutPond().isEmpty(); |
30 | } | |
31 | ||
32 | /** | |
33 | * Move the Gardener with a vector on the board and display a message. | |
34 | * | |
35 | * @param board the board | |
36 | * @param botManager the bot manager | |
37 | * @return the action result | |
38 | */ | |
39 | @Override | |
40 | public ActionResult execute(Board board, BotManager botManager) { | |
41 | // move the Gardener | |
42 | ||
43 | Map<PositionVector, LayerBambooStack> bambooStacks = | |
44 | board.moveGardener(relativePositionVector); | |
45 |
1
1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT |
botManager.displayMessage( |
46 | botManager.getName() | |
47 | + " moved the gardener" | |
48 | + " with " | |
49 | + relativePositionVector | |
50 | + " to position " | |
51 | + board.getGardenerPosition()); | |
52 | ||
53 |
1
1. execute : negated conditional → TIMED_OUT |
if (bambooStacks.isEmpty()) { |
54 |
1
1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT |
botManager.displayMessage("Gardener didn't plant any bamboo"); |
55 | } | |
56 | ||
57 |
1
1. execute : removed call to java/util/Map::forEach → KILLED |
bambooStacks.forEach( |
58 | (positionVector, layerBambooStack) -> { | |
59 |
1
1. lambda$execute$0 : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT |
botManager.displayMessage( |
60 | "Gardener planted bamboo at " | |
61 | + positionVector | |
62 | + ", the stack is now " | |
63 | + layerBambooStack.getBambooCount() | |
64 | + "high"); | |
65 | botManager | |
66 | .getSingleBotStatistics() | |
67 |
1
1. lambda$execute$0 : removed call to com/takenoko/stats/SingleBotStatistics::updatePlantedBambooCounter → KILLED |
.updatePlantedBambooCounter( |
68 | board.getTileAt(positionVector).getColor(), | |
69 | layerBambooStack.getBambooCount()); | |
70 | }); | |
71 |
1
1. execute : removed call to com/takenoko/stats/SingleBotStatistics::updateActions → KILLED |
botManager.getSingleBotStatistics().updateActions(this.getClass().getSimpleName()); |
72 | ||
73 |
1
1. execute : replaced return value with null for com/takenoko/actions/actors/MoveGardenerAction::execute → KILLED |
return new ActionResult(1); |
74 | } | |
75 | ||
76 | @Override | |
77 | public boolean equals(Object o) { | |
78 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with false for com/takenoko/actions/actors/MoveGardenerAction::equals → NO_COVERAGE |
if (this == o) return true; |
79 |
3
1. equals : negated conditional → NO_COVERAGE 2. equals : negated conditional → NO_COVERAGE 3. equals : replaced boolean return with true for com/takenoko/actions/actors/MoveGardenerAction::equals → NO_COVERAGE |
if (o == null || getClass() != o.getClass()) return false; |
80 | MoveGardenerAction that = (MoveGardenerAction) o; | |
81 |
2
1. equals : replaced boolean return with false for com/takenoko/actions/actors/MoveGardenerAction::equals → NO_COVERAGE 2. equals : replaced boolean return with true for com/takenoko/actions/actors/MoveGardenerAction::equals → NO_COVERAGE |
return Objects.equals(relativePositionVector, that.relativePositionVector); |
82 | } | |
83 | ||
84 | @Override | |
85 | public int hashCode() { | |
86 |
1
1. hashCode : replaced int return with 0 for com/takenoko/actions/actors/MoveGardenerAction::hashCode → SURVIVED |
return Objects.hash(relativePositionVector); |
87 | } | |
88 | } | |
Mutations | ||
29 |
1.1 2.2 |
|
45 |
1.1 |
|
53 |
1.1 |
|
54 |
1.1 |
|
57 |
1.1 |
|
59 |
1.1 |
|
67 |
1.1 |
|
71 |
1.1 |
|
73 |
1.1 |
|
78 |
1.1 2.2 |
|
79 |
1.1 2.2 3.3 |
|
81 |
1.1 2.2 |
|
86 |
1.1 |