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

io.leonis.subra.game.rule.PreparePenaltyRule 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 PreparePenaltyRule.
 *
 * @author Rimon Oz
 */
public class PreparePenaltyRule 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.PREPARE_PENALTY_BLUE)) {
      return Collections.singleton(TeamColor.BLUE);
    } else if (refereeSupplier.getReferee().getCommand()
        .equals(Command.PREPARE_PENALTY_YELLOW)) {
      return Collections.singleton(TeamColor.YELLOW);
    }
    return Collections.emptySet();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy