Skip to content

Content of file C4GSTKopplung.java

package de.fhdw.gaming.ipspiel23.c4.gststrategy;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;

import de.fhdw.gaming.core.domain.Move;
import de.fhdw.gaming.core.domain.PlayerState;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4Player;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4Position;
import de.fhdw.gaming.ipspiel23.c4.domain.IC4State;
import de.fhdw.gaming.ipspiel23.c4.moves.factory.IC4MoveFactory;
import de.fhdw.gaming.ipspiel23.gst.domain.IKopplung;

/**
 * The C4-GST-Kopplung.
 */
public class C4GSTKopplung implements IKopplung<IC4Player, IC4State> {

    
    /**
First sentence should end with a period.

Since Checkstyle 3.2

Validates Javadoc comments to help ensure they are well formed. The following checks are performed:

  • Ensures the first sentence ends with proper punctuation (That is a period, question mark, or exclamation mark, by default). Javadoc automatically places the first sentence in the method summary table and index. Without proper punctuation the Javadoc may be malformed. All items eligible for the {@inheritDoc} tag are exempt from this requirement.
  • Check text for Javadoc statements that do not have any description. This includes both completely empty Javadoc, and Javadoc with only tags such as @param and @return.
  • Check text for incomplete HTML tags. Verifies that HTML tags have corresponding end tags and issues an "Unclosed HTML tag found:" error if not. An "Extra HTML tag found:" error is issued if an end tag is found without a previous open tag.
  • Check that a package Javadoc comment is well-formed (as described above) and NOT missing from any package-info.java files.
  • Check for allowed HTML tags. The list of allowed HTML tags is "a", "abbr", "acronym", "address", "area", "b", "bdo", "big", "blockquote", "br", "caption", "cite", "code", "colgroup", "dd", "del", "div", "dfn", "dl", "dt", "em", "fieldset", "font", "h1" to "h6", "hr", "i", "img", "ins", "kbd", "li", "ol", "p", "pre", "q", "samp", "small", "span", "strong", "sub", "sup", "table", "tbody", "td", "tfoot", "th", "thread", "tr", "tt", "u", "ul".

These checks were patterned after the checks made by the DocCheck doclet available from Sun. Note: Original Sun's DocCheck tool does not exist anymore.

* TODO: Strategy-Pattern */ private final SimpleC4GSTEvaluation evaluationStrategy; /** * The Movefactory. */ private final IC4MoveFactory moveFactory; /** * Ctr. * @param moveFactory */ public C4GSTKopplung(final IC4MoveFactory moveFactory) { this.moveFactory = moveFactory; this.evaluationStrategy = new SimpleC4GSTEvaluation(); } @Override public Optional<Collection<Move<IC4Player, IC4State>>> getPossibleMoves(final IC4State state) { // seems to work as intended final IC4Position[] positions = state.getBoard().getLegalPositions(); final Collection<Move<IC4Player, IC4State>> possibleMoves = new ArrayList<>(); for (final IC4Position position : positions) { possibleMoves.add(moveFactory.createMove(state.getCurrentPlayer(), position)); } // return Optional.of(possibleMoves); } @Override public Optional<Integer> evalState(final IC4State state) { return Optional.of(evaluationStrategy.evalC4State(state)); } @Override public Optional<IC4Player> getCurrentPlayer(final IC4State state) { return Optional.of(state.getCurrentPlayer()); } @Override public Optional<Boolean> getIsGameOver(final IC4State state) { return Optional.of(state.getPlayers().values().stream() .filter(p -> p.getState() == PlayerState.PLAYING) .findAny() .isEmpty() ); //return Optional.of(false); //return Optional.of(state.getPlayers().values() // .stream() // .filter(p -> p.getOutcome().get() > 0) // .count() > 0); } }