1 | package com.takenoko.objective; | |
2 | ||
3 | import com.takenoko.engine.Board; | |
4 | import com.takenoko.engine.BotState; | |
5 | import com.takenoko.shape.*; | |
6 | import java.util.List; | |
7 | import java.util.Objects; | |
8 | ||
9 | public class PatternObjective extends Objective { | |
10 | private final Pattern pattern; | |
11 | ||
12 | public PatternObjective(Pattern pattern, int points) { | |
13 | super(ObjectiveType.SHAPE, ObjectiveState.NOT_ACHIEVED, points); | |
14 | this.pattern = pattern; | |
15 | } | |
16 | ||
17 | @Override | |
18 | public void verify(Board board, BotState botState) { | |
19 |
1
1. verify : negated conditional → KILLED |
if (!pattern.match(board).isEmpty()) { |
20 | state = ObjectiveState.ACHIEVED; | |
21 | } | |
22 | } | |
23 | ||
24 | @Override | |
25 | public void reset() { | |
26 | state = ObjectiveState.NOT_ACHIEVED; | |
27 | } | |
28 | ||
29 | @Override | |
30 | public boolean equals(Object o) { | |
31 |
2
1. equals : negated conditional → KILLED 2. equals : replaced boolean return with false for com/takenoko/objective/PatternObjective::equals → KILLED |
if (this == o) return true; |
32 |
3
1. equals : negated conditional → KILLED 2. equals : negated conditional → KILLED 3. equals : replaced boolean return with true for com/takenoko/objective/PatternObjective::equals → KILLED |
if (o == null || getClass() != o.getClass()) return false; |
33 | PatternObjective objective = (PatternObjective) o; | |
34 |
2
1. equals : replaced boolean return with false for com/takenoko/objective/PatternObjective::equals → KILLED 2. equals : replaced boolean return with true for com/takenoko/objective/PatternObjective::equals → KILLED |
return pattern.equals(objective.pattern); |
35 | } | |
36 | ||
37 | @Override | |
38 | public int hashCode() { | |
39 |
1
1. hashCode : replaced int return with 0 for com/takenoko/objective/PatternObjective::hashCode → KILLED |
return Objects.hash(pattern); |
40 | } | |
41 | ||
42 | public PatternObjective copy() { | |
43 | PatternObjective objective = new PatternObjective(pattern, getPoints()); | |
44 | objective.state = state; | |
45 |
1
1. copy : replaced return value with null for com/takenoko/objective/PatternObjective::copy → KILLED |
return objective; |
46 | } | |
47 | ||
48 | public List<Shape> getShapeToCompletePatternObjective(Board board) { | |
49 |
1
1. getShapeToCompletePatternObjective : replaced return value with Collections.emptyList for com/takenoko/objective/PatternObjective::getShapeToCompletePatternObjective → TIMED_OUT |
return pattern.getShapesToCompletePatternObjective(board); |
50 | } | |
51 | ||
52 | @Override | |
53 | public float getCompletion(Board board, BotState botState) { | |
54 | throw new UnsupportedOperationException(); | |
55 | } | |
56 | ||
57 | @Override | |
58 | public String toString() { | |
59 |
1
1. toString : replaced return value with "" for com/takenoko/objective/PatternObjective::toString → TIMED_OUT |
return "Pattern Objective <" + pattern.toString() + ">"; |
60 | } | |
61 | ||
62 | /** | |
63 | * Return the pattern of the objective. | |
64 | * | |
65 | * @return the pattern of the objective | |
66 | */ | |
67 | public Pattern getPattern() { | |
68 |
1
1. getPattern : replaced return value with null for com/takenoko/objective/PatternObjective::getPattern → KILLED |
return pattern; |
69 | } | |
70 | } | |
Mutations | ||
19 |
1.1 |
|
31 |
1.1 2.2 |
|
32 |
1.1 2.2 3.3 |
|
34 |
1.1 2.2 |
|
39 |
1.1 |
|
45 |
1.1 |
|
49 |
1.1 |
|
59 |
1.1 |
|
68 |
1.1 |