Skip to content

Package: VierGewinntMoveImpl

VierGewinntMoveImpl

nameinstructionbranchcomplexitylinemethod
VierGewinntMoveImpl(VierGewinntPosition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
applyTo(VierGewinntState, VierGewinntPlayer)
M: 0 C: 29
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
getPosition()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$applyTo$0(VierGewinntField)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$applyTo$1(VierGewinntPosition)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: package de.fhdw.gaming.ipspiel21.viergewinnt.core.domain.moves.impl;
2:
3: import de.fhdw.gaming.core.domain.GameException;
4: import de.fhdw.gaming.ipspiel21.viergewinnt.core.domain.VierGewinntPlayer;
5: import de.fhdw.gaming.ipspiel21.viergewinnt.core.domain.VierGewinntPosition;
6: import de.fhdw.gaming.ipspiel21.viergewinnt.core.domain.VierGewinntState;
7:
8: /**
9: * The Implementation of a VierGewinntMove.
10: *
11: * @author Robby Rabbitman
12: *
13: */
14: public class VierGewinntMoveImpl extends AbstractMove {
15:
16: /**
17: * Target position.
18: *
19: */
20: private final VierGewinntPosition position;
21:
22: /**
23: * Move with target position.
24: *
25: * @param position
26: */
27: public VierGewinntMoveImpl(final VierGewinntPosition position) {
28: super();
29: this.position = position;
30: }
31:
32: @Override
33: public void applyTo(final VierGewinntState state, final VierGewinntPlayer player) throws GameException {
34: if (state.getBoard().getAllPlayableFields().stream().map(field -> field.getPosition())
35:• .filter(p -> p.equals(this.getPosition())).findAny().isEmpty()) {
36: throw new GameException("Unvalid move");
37: } else {
38: state.getBoard().getFieldAt(this.getPosition()).changeState(player.getPlayerMark());
39: state.moveCompleted(this);
40: }
41: }
42:
43: @Override
44: public VierGewinntPosition getPosition() {
45: return this.position;
46: }
47:
48: }