| 1 | package com.takenoko.objective; | |
| 2 | ||
| 3 | import com.takenoko.engine.Board; | |
| 4 | import com.takenoko.engine.BotState; | |
| 5 | import com.takenoko.layers.tile.TileColor; | |
| 6 | import com.takenoko.vector.PositionVector; | |
| 7 | import java.util.EnumMap; | |
| 8 | import java.util.List; | |
| 9 | import java.util.Map; | |
| 10 | import java.util.Objects; | |
| 11 | ||
| 12 | /** The Panda objective. */ | |
| 13 | public class PandaObjective extends Objective { | |
| 14 | private final Map<TileColor, Integer> bambooTarget; | |
| 15 | ||
| 16 | public PandaObjective(Map<TileColor, Integer> bambooTarget, int points) { | |
| 17 | super(ObjectiveType.PANDA, ObjectiveState.NOT_ACHIEVED, points); | |
| 18 | this.bambooTarget = bambooTarget; | |
| 19 |
1
1. <init> : negated conditional → KILLED |
if (bambooTarget.isEmpty()) { |
| 20 | throw new IllegalArgumentException("The bamboo target cannot be empty"); | |
| 21 | } | |
| 22 | } | |
| 23 | ||
| 24 | public PandaObjective(PandaObjective pandaObjective) { | |
| 25 | super(pandaObjective.getType(), pandaObjective.getState(), pandaObjective.getPoints()); | |
| 26 | this.bambooTarget = new EnumMap<>(TileColor.class); | |
| 27 |
1
1. <init> : removed call to java/util/Map::putAll → NO_COVERAGE |
this.bambooTarget.putAll(pandaObjective.bambooTarget); |
| 28 | } | |
| 29 | ||
| 30 | @Override | |
| 31 | public void verify(Board board, BotState botState) { | |
| 32 | boolean matched = | |
| 33 | bambooTarget.entrySet().stream() | |
| 34 | .allMatch( | |
| 35 | entry -> | |
| 36 |
1
1. lambda$verify$0 : replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$verify$0 → KILLED |
botState.getInventory().getBambooCount(entry.getKey()) |
| 37 |
2
1. lambda$verify$0 : changed conditional boundary → KILLED 2. lambda$verify$0 : negated conditional → KILLED |
>= entry.getValue()); |
| 38 |
1
1. verify : negated conditional → KILLED |
if (matched) { |
| 39 | state = ObjectiveState.ACHIEVED; | |
| 40 | } else state = ObjectiveState.NOT_ACHIEVED; | |
| 41 | } | |
| 42 | ||
| 43 | @Override | |
| 44 | public void reset() { | |
| 45 | state = ObjectiveState.NOT_ACHIEVED; | |
| 46 | } | |
| 47 | ||
| 48 | @Override | |
| 49 | public Objective copy() { | |
| 50 |
1
1. copy : replaced return value with null for com/takenoko/objective/PandaObjective::copy → NO_COVERAGE |
return new PandaObjective(this); |
| 51 | } | |
| 52 | ||
| 53 | @Override | |
| 54 | public float getCompletion(Board board, BotState botState) { | |
| 55 |
1
1. getCompletion : replaced float return with 0.0f for com/takenoko/objective/PandaObjective::getCompletion → KILLED |
return bambooTarget.entrySet().stream() |
| 56 | .map( | |
| 57 | entry -> | |
| 58 |
1
1. lambda$getCompletion$1 : replaced Float return value with 0 for com/takenoko/objective/PandaObjective::lambda$getCompletion$1 → KILLED |
(float) |
| 59 | botState.getInventory() | |
| 60 | .getBambooCount(entry.getKey()) | |
| 61 |
1
1. lambda$getCompletion$1 : Replaced float division with multiplication → TIMED_OUT |
/ entry.getValue()) |
| 62 | .reduce(0f, Float::sum) | |
| 63 |
1
1. getCompletion : Replaced float division with multiplication → KILLED |
/ bambooTarget.size(); |
| 64 | } | |
| 65 | ||
| 66 | public List<PositionVector> getWhereToEatToComplete(Board board, BotState botState) { | |
| 67 |
1
1. getWhereToEatToComplete : replaced return value with Collections.emptyList for com/takenoko/objective/PandaObjective::getWhereToEatToComplete → KILLED |
return board.getTiles().entrySet().stream() |
| 68 | .filter( | |
| 69 | positionVectorTileEntry -> | |
| 70 |
2
1. lambda$getWhereToEatToComplete$3 : replaced boolean return with false for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$3 → KILLED 2. lambda$getWhereToEatToComplete$3 : replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$3 → KILLED |
bambooTarget.entrySet().stream() |
| 71 | .anyMatch( | |
| 72 | entry -> | |
| 73 |
2
1. lambda$getWhereToEatToComplete$2 : negated conditional → KILLED 2. lambda$getWhereToEatToComplete$2 : replaced boolean return with true for com/takenoko/objective/PandaObjective::lambda$getWhereToEatToComplete$2 → KILLED |
board.isBambooEatableAt( |
| 74 | positionVectorTileEntry | |
| 75 | .getKey()) | |
| 76 | && positionVectorTileEntry | |
| 77 | .getValue() | |
| 78 | .getColor() | |
| 79 |
1
1. lambda$getWhereToEatToComplete$2 : negated conditional → KILLED |
== entry.getKey() |
| 80 | && botState.getInventory() | |
| 81 | .getBambooCount( | |
| 82 | entry | |
| 83 | .getKey()) | |
| 84 |
2
1. lambda$getWhereToEatToComplete$2 : changed conditional boundary → KILLED 2. lambda$getWhereToEatToComplete$2 : negated conditional → KILLED |
< entry.getValue())) |
| 85 | .map(Map.Entry::getKey) | |
| 86 | .toList(); | |
| 87 | } | |
| 88 | ||
| 89 | @Override | |
| 90 | public boolean equals(Object o) { | |
| 91 |
2
1. equals : negated conditional → TIMED_OUT 2. equals : replaced boolean return with false for com/takenoko/objective/PandaObjective::equals → KILLED |
if (this == o) return true; |
| 92 |
3
1. equals : replaced boolean return with true for com/takenoko/objective/PandaObjective::equals → TIMED_OUT 2. equals : negated conditional → KILLED 3. equals : negated conditional → KILLED |
if (o == null || getClass() != o.getClass()) return false; |
| 93 | PandaObjective that = (PandaObjective) o; | |
| 94 |
2
1. equals : replaced boolean return with true for com/takenoko/objective/PandaObjective::equals → TIMED_OUT 2. equals : replaced boolean return with false for com/takenoko/objective/PandaObjective::equals → KILLED |
return Objects.equals(bambooTarget, that.bambooTarget); |
| 95 | } | |
| 96 | ||
| 97 | @Override | |
| 98 | public int hashCode() { | |
| 99 |
1
1. hashCode : replaced int return with 0 for com/takenoko/objective/PandaObjective::hashCode → TIMED_OUT |
return Objects.hash(bambooTarget); |
| 100 | } | |
| 101 | ||
| 102 | @Override | |
| 103 | public String toString() { | |
| 104 |
1
1. toString : replaced return value with "" for com/takenoko/objective/PandaObjective::toString → TIMED_OUT |
return "Panda Objective <" + bambooTarget + " high>"; |
| 105 | } | |
| 106 | ||
| 107 | public Map<TileColor, Integer> getBambooTarget() { | |
| 108 |
1
1. getBambooTarget : replaced return value with Collections.emptyMap for com/takenoko/objective/PandaObjective::getBambooTarget → TIMED_OUT |
return new EnumMap<>(bambooTarget); |
| 109 | } | |
| 110 | } | |
Mutations | ||
| 19 |
1.1 |
|
| 27 |
1.1 |
|
| 36 |
1.1 |
|
| 37 |
1.1 2.2 |
|
| 38 |
1.1 |
|
| 50 |
1.1 |
|
| 55 |
1.1 |
|
| 58 |
1.1 |
|
| 61 |
1.1 |
|
| 63 |
1.1 |
|
| 67 |
1.1 |
|
| 70 |
1.1 2.2 |
|
| 73 |
1.1 2.2 |
|
| 79 |
1.1 |
|
| 84 |
1.1 2.2 |
|
| 91 |
1.1 2.2 |
|
| 92 |
1.1 2.2 3.3 |
|
| 94 |
1.1 2.2 |
|
| 99 |
1.1 |
|
| 104 |
1.1 |
|
| 108 |
1.1 |