| 1 | package com.takenoko.actors; | |
| 2 | ||
| 3 | import com.takenoko.engine.Board; | |
| 4 | import com.takenoko.layers.bamboo.LayerBambooStack; | |
| 5 | import com.takenoko.vector.PositionVector; | |
| 6 | import com.takenoko.vector.Vector; | |
| 7 | import java.util.HashMap; | |
| 8 | import java.util.Map; | |
| 9 | import java.util.stream.Stream; | |
| 10 | ||
| 11 | /** Gardener class. The gardener is an actor that can move on the board. */ | |
| 12 | public class Gardener extends Actor { | |
| 13 | ||
| 14 | /** | |
| 15 | * Constructor for the Gardener class. | |
| 16 | * | |
| 17 | * @param position the position of the gardener | |
| 18 | */ | |
| 19 | public Gardener(PositionVector position) { | |
| 20 | super(position); | |
| 21 | } | |
| 22 | ||
| 23 | /** Constructor for the Gardener class. Instantiate the gardener at the origin. */ | |
| 24 | public Gardener() { | |
| 25 | this(new PositionVector(0, 0, 0)); | |
| 26 | } | |
| 27 | ||
| 28 | /** | |
| 29 | * @return a string explaining where the gardener is on the board | |
| 30 | */ | |
| 31 | public String positionMessage() { | |
| 32 |
1
1. positionMessage : replaced return value with "" for com/takenoko/actors/Gardener::positionMessage → KILLED |
return "The gardener is at " + this.getPositionVector(); |
| 33 | } | |
| 34 | ||
| 35 | public Map<PositionVector, LayerBambooStack> afterMove(Board board) { | |
| 36 | Map<PositionVector, LayerBambooStack> growBambooMap = new HashMap<>(); | |
| 37 | ||
| 38 | Stream.concat( | |
| 39 | this.getPositionVector().getNeighbors().stream(), | |
| 40 | Stream.of(this.getPositionVector())) | |
| 41 | .map(Vector::toPositionVector) | |
| 42 | .filter(board::isTile) | |
| 43 | .filter( | |
| 44 | v -> | |
| 45 |
2
1. lambda$afterMove$0 : replaced boolean return with false for com/takenoko/actors/Gardener::lambda$afterMove$0 → KILLED 2. lambda$afterMove$0 : replaced boolean return with true for com/takenoko/actors/Gardener::lambda$afterMove$0 → KILLED |
board.getTileAt(v) |
| 46 | .getColor() | |
| 47 | .equals( | |
| 48 | board.getTileAt(this.getPositionVector()) | |
| 49 | .getColor())) | |
| 50 | .filter(board::isBambooGrowableAt) | |
| 51 |
1
1. afterMove : removed call to java/util/stream/Stream::forEach → KILLED |
.forEach( |
| 52 | v -> { | |
| 53 | board.growBamboo(v); | |
| 54 | growBambooMap.put(v, board.getBambooAt(v)); | |
| 55 | }); | |
| 56 |
1
1. afterMove : replaced return value with Collections.emptyMap for com/takenoko/actors/Gardener::afterMove → KILLED |
return growBambooMap; |
| 57 | } | |
| 58 | ||
| 59 | public Gardener copy() { | |
| 60 |
1
1. copy : replaced return value with null for com/takenoko/actors/Gardener::copy → KILLED |
return new Gardener(this.getPosition()); |
| 61 | } | |
| 62 | } | |
Mutations | ||
| 32 |
1.1 |
|
| 45 |
1.1 2.2 |
|
| 51 |
1.1 |
|
| 56 |
1.1 |
|
| 60 |
1.1 |