Search in sources :

Example 1 with Action

use of mage.interfaces.Action in project mage by magefree.

the class GameController method createPlayerTimer.

/**
 * We create a timer that will run every 250 ms individually for a player
 * decreasing their internal game counter. Later on this counter is used to
 * get time left to play the whole match.
 * <p>
 * What we also do here is passing Action to PriorityTimer that is the
 * action that will be executed once game timer is over.
 *
 * @param playerId
 * @param count
 * @return
 */
private PriorityTimer createPlayerTimer(UUID playerId, int count) {
    final UUID initPlayerId = playerId;
    // run each 250 ms
    long delayMs = 250L;
    Action executeOnNoTimeLeft = () -> {
        game.timerTimeout(initPlayerId);
        logger.debug("Player has no time left to end the match: " + initPlayerId + ". Conceding.");
    };
    PriorityTimer timer = new PriorityTimer(count, delayMs, executeOnNoTimeLeft);
    timer.init(game.getId());
    timers.put(playerId, timer);
    return timer;
}
Also used : PlayerAction(mage.constants.PlayerAction) Action(mage.interfaces.Action) PriorityTimer(mage.utils.timer.PriorityTimer)

Aggregations

PlayerAction (mage.constants.PlayerAction)1 Action (mage.interfaces.Action)1 PriorityTimer (mage.utils.timer.PriorityTimer)1