DrawImprovementAction.java

1
package com.takenoko.actions.improvement;
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.actions.weather.ChooseAndApplyWeatherAction;
8
import com.takenoko.engine.Board;
9
import com.takenoko.engine.BotManager;
10
import com.takenoko.layers.tile.ImprovementType;
11
import java.util.List;
12
import java.util.Objects;
13
14
/**
15
 * Action to draw an improvement from the deck. if the improvement is not available in the deck, the
16
 * bot can choose to and apply a weather instead.
17
 */
18
@ActionAnnotation(ActionType.FORCED)
19
public class DrawImprovementAction implements Action {
20
21
    final ImprovementType improvementType;
22
23
    public DrawImprovementAction(ImprovementType improvementType) {
24
        this.improvementType = improvementType;
25
    }
26
27
    @Override
28
    public ActionResult execute(Board board, BotManager botManager) {
29 1 1. execute : negated conditional → KILLED
        if (!board.hasImprovementInDeck(improvementType)) {
30 1 1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
            botManager.displayMessage("No more " + improvementType + " in the deck");
31 1 1. execute : replaced return value with null for com/takenoko/actions/improvement/DrawImprovementAction::execute → KILLED
            return new ActionResult(List.of(ChooseAndApplyWeatherAction.class), 0);
32
        }
33
        board.drawImprovement(improvementType);
34 1 1. execute : removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT
        botManager.displayMessage(botManager.getName() + " drew improvement " + improvementType);
35 1 1. execute : replaced return value with null for com/takenoko/actions/improvement/DrawImprovementAction::execute → KILLED
        return new ActionResult(
36
                List.of(ApplyImprovementAction.class, StoreImprovementAction.class), 0);
37
    }
38
39
    @Override
40
    public boolean equals(Object o) {
41 2 1. equals : negated conditional → TIMED_OUT
2. equals : replaced boolean return with false for com/takenoko/actions/improvement/DrawImprovementAction::equals → KILLED
        if (this == o) return true;
42 3 1. equals : replaced boolean return with true for com/takenoko/actions/improvement/DrawImprovementAction::equals → NO_COVERAGE
2. equals : negated conditional → KILLED
3. equals : negated conditional → KILLED
        if (o == null || getClass() != o.getClass()) return false;
43
        DrawImprovementAction that = (DrawImprovementAction) o;
44 2 1. equals : negated conditional → TIMED_OUT
2. equals : replaced boolean return with true for com/takenoko/actions/improvement/DrawImprovementAction::equals → TIMED_OUT
        return improvementType == that.improvementType;
45
    }
46
47
    @Override
48
    public int hashCode() {
49 1 1. hashCode : replaced int return with 0 for com/takenoko/actions/improvement/DrawImprovementAction::hashCode → TIMED_OUT
        return Objects.hash(improvementType);
50
    }
51
}

Mutations

29

1.1
Location : execute
Killed by : com.takenoko.actions.improvement.DrawImprovementActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.improvement.DrawImprovementActionTest]/[nested-class:TestApply]/[method:shouldReturnAnActionResultContainingChooseAndApplyWeatherActionIfNoImprovementCanBeDrawn()]
negated conditional → KILLED

30

1.1
Location : execute
Killed by : none
removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT

31

1.1
Location : execute
Killed by : com.takenoko.actions.improvement.DrawImprovementActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.improvement.DrawImprovementActionTest]/[nested-class:TestApply]/[method:shouldReturnAnActionResult()]
replaced return value with null for com/takenoko/actions/improvement/DrawImprovementAction::execute → KILLED

34

1.1
Location : execute
Killed by : none
removed call to com/takenoko/engine/BotManager::displayMessage → TIMED_OUT

35

1.1
Location : execute
Killed by : com.takenoko.actions.improvement.DrawImprovementActionTest.[engine:junit-jupiter]/[class:com.takenoko.actions.improvement.DrawImprovementActionTest]/[nested-class:TestApply]/[method:shouldReturnAnActionResultContainingApplyImprovementActionAndStoreImprovementActionIfAnImprovementIsDrawn()]
replaced return value with null for com/takenoko/actions/improvement/DrawImprovementAction::execute → KILLED

41

1.1
Location : equals
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : equals
Killed by : com.takenoko.bot.unitary.SmartDrawImprovementTest.[engine:junit-jupiter]/[class:com.takenoko.bot.unitary.SmartDrawImprovementTest]/[nested-class:FillAction]/[method:shouldDrawAnImprovementWhenThereIsLessThanImprovementInTheInventory()]
replaced boolean return with false for com/takenoko/actions/improvement/DrawImprovementAction::equals → KILLED

42

1.1
Location : equals
Killed by : com.takenoko.bot.unitary.SmartDrawImprovementTest.[engine:junit-jupiter]/[class:com.takenoko.bot.unitary.SmartDrawImprovementTest]/[nested-class:FillAction]/[method:shouldDrawAnImprovementWhenThereIsLessThanImprovementInTheInventory()]
negated conditional → KILLED

2.2
Location : equals
Killed by : com.takenoko.bot.unitary.SmartDrawImprovementTest.[engine:junit-jupiter]/[class:com.takenoko.bot.unitary.SmartDrawImprovementTest]/[nested-class:FillAction]/[method:shouldDrawAnImprovementWhenThereIsLessThanImprovementInTheInventory()]
negated conditional → KILLED

3.3
Location : equals
Killed by : none
replaced boolean return with true for com/takenoko/actions/improvement/DrawImprovementAction::equals → NO_COVERAGE

44

1.1
Location : equals
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : equals
Killed by : none
replaced boolean return with true for com/takenoko/actions/improvement/DrawImprovementAction::equals → TIMED_OUT

49

1.1
Location : hashCode
Killed by : none
replaced int return with 0 for com/takenoko/actions/improvement/DrawImprovementAction::hashCode → TIMED_OUT

Active mutators

Tests examined


Report generated by PIT 1.8.0