All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.leonis.subra.game.rule.DirectFreeKickRule Maven / Gradle / Ivy

The newest version!
package io.leonis.subra.game.rule;

import io.leonis.subra.game.data.*;
import io.leonis.subra.game.data.Referee.Command;
import io.leonis.zosma.game.Rule;
import java.util.*;

/**
 * The Class DirectFreeKickRule.
 *
 * @author Rimon Oz
 */
public class DirectFreeKickRule implements Rule {

  @Override
  public boolean test(final Referee.Supplier refereeSupplier) {
    return !this.getViolators(refereeSupplier).isEmpty();
  }

  @Override
  public Set getViolators(final Referee.Supplier refereeSupplier) {
    if (refereeSupplier.getReferee().getCommand()
        .equals(Command.DIRECT_FREE_BLUE)) {
      return Collections.singleton(TeamColor.BLUE);
    } else if (refereeSupplier.getReferee().getCommand()
        .equals(Command.DIRECT_FREE_YELLOW)) {
      return Collections.singleton(TeamColor.YELLOW);
    }
    return Collections.emptySet();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy