1 | package com.takenoko.bot.unitary; | |
2 | ||
3 | import com.takenoko.actions.improvement.DrawImprovementAction; | |
4 | import com.takenoko.bot.PriorityBot; | |
5 | import com.takenoko.engine.Board; | |
6 | import com.takenoko.engine.BotState; | |
7 | import com.takenoko.engine.History; | |
8 | import com.takenoko.layers.tile.ImprovementType; | |
9 | import java.util.Map; | |
10 | import java.util.Objects; | |
11 | ||
12 | /** | |
13 | * This bot will draw improvement if there is less than the number of improvement in the inventory. | |
14 | */ | |
15 | public class SmartDrawImprovement extends PriorityBot { | |
16 | private final Map<ImprovementType, Integer> improvementMap; | |
17 | ||
18 | /** | |
19 | * @param improvementMap the map of improvement and the number of improvement to draw. | |
20 | */ | |
21 | public SmartDrawImprovement(Map<ImprovementType, Integer> improvementMap) { | |
22 | this.improvementMap = improvementMap; | |
23 | } | |
24 | ||
25 | @Override | |
26 | protected void fillAction(Board board, BotState botState, History history) { | |
27 |
1
1. fillAction : removed call to java/util/Map::forEach → KILLED |
improvementMap.forEach( |
28 | (improvementType, integer) -> { | |
29 |
2
1. lambda$fillAction$0 : changed conditional boundary → KILLED 2. lambda$fillAction$0 : negated conditional → KILLED |
if (botState.getInventory().getImprovementCount(improvementType) < integer) { |
30 |
1
1. lambda$fillAction$0 : removed call to com/takenoko/bot/unitary/SmartDrawImprovement::addActionWithPriority → KILLED |
this.addActionWithPriority( |
31 | new DrawImprovementAction(improvementType), integer); | |
32 | } | |
33 | }); | |
34 | } | |
35 | ||
36 | @Override | |
37 | public boolean equals(Object o) { | |
38 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with false for com/takenoko/bot/unitary/SmartDrawImprovement::equals → NO_COVERAGE |
if (this == o) return true; |
39 |
3
1. equals : negated conditional → NO_COVERAGE 2. equals : negated conditional → NO_COVERAGE 3. equals : replaced boolean return with true for com/takenoko/bot/unitary/SmartDrawImprovement::equals → NO_COVERAGE |
if (o == null || getClass() != o.getClass()) return false; |
40 |
2
1. equals : negated conditional → NO_COVERAGE 2. equals : replaced boolean return with true for com/takenoko/bot/unitary/SmartDrawImprovement::equals → NO_COVERAGE |
if (!super.equals(o)) return false; |
41 | SmartDrawImprovement that = (SmartDrawImprovement) o; | |
42 |
2
1. equals : replaced boolean return with false for com/takenoko/bot/unitary/SmartDrawImprovement::equals → NO_COVERAGE 2. equals : replaced boolean return with true for com/takenoko/bot/unitary/SmartDrawImprovement::equals → NO_COVERAGE |
return Objects.equals(improvementMap, that.improvementMap); |
43 | } | |
44 | ||
45 | @Override | |
46 | public int hashCode() { | |
47 |
1
1. hashCode : replaced int return with 0 for com/takenoko/bot/unitary/SmartDrawImprovement::hashCode → NO_COVERAGE |
return Objects.hash(super.hashCode(), improvementMap); |
48 | } | |
49 | } | |
Mutations | ||
27 |
1.1 |
|
29 |
1.1 2.2 |
|
30 |
1.1 |
|
38 |
1.1 2.2 |
|
39 |
1.1 2.2 3.3 |
|
40 |
1.1 2.2 |
|
42 |
1.1 2.2 |
|
47 |
1.1 |