Skip to contentMethod: KopfundZahlundKanteKopfStrategy(KopfundZahlundKanteMoveFactory)
      1: package de.fhdw.gaming.ipspiel22.kopfundzahlundkante.strategy;
2: 
3: import java.util.Optional;
4: 
5: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.KopfundZahlundKantePlayer;
6: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.KopfundZahlundKanteState;
7: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.domain.KopfundZahlundKanteStrategy;
8: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.moves.KopfundZahlundKanteMove;
9: import de.fhdw.gaming.ipspiel22.kopfundzahlundkante.moves.factory.KopfundZahlundKanteMoveFactory;
10: 
11: /**
12:  * Implements {@link KopfundZahlundKanteStrategy} by always saying "Head".
13:  */
14: public final class KopfundZahlundKanteKopfStrategy implements KopfundZahlundKanteStrategy {
15: 
16:     /**
17:      * The factory for creating KopfundZahl moves.
18:      */
19:     private final KopfundZahlundKanteMoveFactory moveFactory;
20: 
21:     /**
22:      * Creates an {@link KopfundZahlundKanteKopfStrategy}.
23:      *
24:      * @param moveFactory The factory for creating KopfundZahl moves.
25:      */
26:     public KopfundZahlundKanteKopfStrategy(final KopfundZahlundKanteMoveFactory moveFactory) {
27:         this.moveFactory = moveFactory;
28:     }
29: 
30:     @Override
31:     public Optional<KopfundZahlundKanteMove> computeNextMove(final int gameId, final KopfundZahlundKantePlayer player,
32:             final KopfundZahlundKanteState state) {
33:         return Optional.of(this.moveFactory.createHeadMove());
34:     }
35: 
36:     @Override
37:     public String toString() {
38:         return KopfundZahlundKanteKopfStrategy.class.getSimpleName();
39:     }
40: }