| 1 | package com.takenoko.actions.tile; | |
| 2 | ||
| 3 | import com.takenoko.actions.Action; | |
| 4 | import com.takenoko.actions.ActionResult; | |
| 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.tile.Tile; | |
| 10 | import com.takenoko.vector.PositionVector; | |
| 11 | import java.util.Objects; | |
| 12 | ||
| 13 | /** This class represents the action of placing a tile on the board. */ | |
| 14 | @ActionAnnotation(ActionType.FORCED) | |
| 15 | public class PlaceTileAction implements Action { | |
| 16 | protected final Tile tile; | |
| 17 | private final PositionVector positionVector; | |
| 18 | ||
| 19 | /** | |
| 20 | * Constructor for the PlaceTileAction class. | |
| 21 | * | |
| 22 | * @param tile the tile to place | |
| 23 | * @param positionVector the position vector where to place the tile | |
| 24 | */ | |
| 25 | public PlaceTileAction(Tile tile, PositionVector positionVector) { | |
| 26 | this.tile = tile; | |
| 27 | this.positionVector = positionVector; | |
| 28 | } | |
| 29 | ||
| 30 | /** | |
| 31 | * Place the tile on the board and display a message. | |
| 32 | * | |
| 33 | * @param board the board | |
| 34 | * @param botManager the bot manager | |
| 35 | * @return the action result | |
| 36 | */ | |
| 37 | @Override | |
| 38 | public ActionResult execute(Board board, BotManager botManager) { | |
| 39 |
1
1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → KILLED |
botManager.displayMessage( |
| 40 | botManager.getName() + " placed " + tile + " at " + positionVector); | |
| 41 |
1
1. execute : negated conditional → KILLED |
if (!board.placeTile(tile, positionVector).isEmpty()) { |
| 42 |
1
1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → KILLED |
botManager.displayMessage(tile.getColor() + " bamboo grew at " + positionVector); |
| 43 | botManager | |
| 44 | .getSingleBotStatistics() | |
| 45 |
1
1. execute : removed call to com/takenoko/stats/SingleBotStatistics::updateTilesPlacedCounter → KILLED |
.updateTilesPlacedCounter(board.getTileAt(positionVector).getColor()); |
| 46 |
1
1. execute : removed call to com/takenoko/stats/SingleBotStatistics::updateActions → KILLED |
botManager.getSingleBotStatistics().updateActions(getClass().getSimpleName()); |
| 47 | } | |
| 48 |
1
1. execute : replaced return value with null for com/takenoko/actions/tile/PlaceTileAction::execute → KILLED |
return new ActionResult(1); |
| 49 | } | |
| 50 | ||
| 51 | @Override | |
| 52 | public boolean equals(Object o) { | |
| 53 |
2
1. equals : replaced boolean return with false for com/takenoko/actions/tile/PlaceTileAction::equals → NO_COVERAGE 2. equals : negated conditional → TIMED_OUT |
if (this == o) return true; |
| 54 |
3
1. equals : negated conditional → TIMED_OUT 2. equals : negated conditional → TIMED_OUT 3. equals : replaced boolean return with true for com/takenoko/actions/tile/PlaceTileAction::equals → TIMED_OUT |
if (o == null || getClass() != o.getClass()) return false; |
| 55 | PlaceTileAction that = (PlaceTileAction) o; | |
| 56 |
2
1. equals : negated conditional → TIMED_OUT 2. equals : replaced boolean return with true for com/takenoko/actions/tile/PlaceTileAction::equals → TIMED_OUT |
return Objects.equals(tile, that.tile) |
| 57 |
1
1. equals : negated conditional → TIMED_OUT |
&& Objects.equals(positionVector, that.positionVector); |
| 58 | } | |
| 59 | ||
| 60 | @Override | |
| 61 | public int hashCode() { | |
| 62 |
1
1. hashCode : replaced int return with 0 for com/takenoko/actions/tile/PlaceTileAction::hashCode → TIMED_OUT |
return Objects.hash(tile, positionVector); |
| 63 | } | |
| 64 | } | |
Mutations | ||
| 39 |
1.1 |
|
| 41 |
1.1 |
|
| 42 |
1.1 |
|
| 45 |
1.1 |
|
| 46 |
1.1 |
|
| 48 |
1.1 |
|
| 53 |
1.1 2.2 |
|
| 54 |
1.1 2.2 3.3 |
|
| 56 |
1.1 2.2 |
|
| 57 |
1.1 |
|
| 62 |
1.1 |