Search in sources :

Example 1 with DraftPlayer

use of mage.game.draft.DraftPlayer in project mage by magefree.

the class TableController method endDraft.

public void endDraft(Draft draft) {
    if (!draft.isAbort()) {
        for (DraftPlayer player : draft.getPlayers()) {
            player.prepareDeck();
            tournament.getPlayer(player.getPlayer().getId()).setDeck(player.getDeck());
        }
    }
    // free the draft resources after draft step has ended
    tournament.clearDraft();
    tournament.nextStep();
}
Also used : DraftPlayer(mage.game.draft.DraftPlayer)

Example 2 with DraftPlayer

use of mage.game.draft.DraftPlayer in project mage by magefree.

the class DraftController method init.

private void init() {
    draft.addTableEventListener((Listener<TableEvent>) event -> {
        try {
            switch(event.getEventType()) {
                case UPDATE:
                    updateDraft();
                    break;
                case END:
                    endDraft();
                    break;
            }
        } catch (MageException ex) {
            logger.fatal("Table event listener error", ex);
        }
    });
    draft.addPlayerQueryEventListener((Listener<PlayerQueryEvent>) event -> {
        try {
            switch(event.getQueryType()) {
                case PICK_CARD:
                    pickCard(event.getPlayerId(), event.getMax());
                    break;
            }
        } catch (MageException ex) {
            logger.fatal("Table event listener error", ex);
        }
    });
    for (DraftPlayer player : draft.getPlayers()) {
        if (!player.getPlayer().isHuman()) {
            player.setJoined();
            logger.debug("player " + player.getPlayer().getId() + " has joined draft " + draft.getId());
        }
    }
    checkStart();
}
Also used : DraftPickView(mage.view.DraftPickView) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TableEvent(mage.game.events.TableEvent) Set(java.util.Set) UUID(java.util.UUID) MageException(mage.MageException) DraftPlayer(mage.game.draft.DraftPlayer) Player(mage.players.Player) ConcurrentMap(java.util.concurrent.ConcurrentMap) Logger(org.apache.log4j.Logger) PlayerQueryEvent(mage.game.events.PlayerQueryEvent) ManagerFactory(mage.server.managers.ManagerFactory) Entry(java.util.Map.Entry) Optional(java.util.Optional) Listener(mage.game.events.Listener) GameController(mage.server.game.GameController) Draft(mage.game.draft.Draft) DraftPlayer(mage.game.draft.DraftPlayer) TableEvent(mage.game.events.TableEvent) MageException(mage.MageException) PlayerQueryEvent(mage.game.events.PlayerQueryEvent)

Aggregations

DraftPlayer (mage.game.draft.DraftPlayer)2 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Set (java.util.Set)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 MageException (mage.MageException)1 Draft (mage.game.draft.Draft)1 Listener (mage.game.events.Listener)1 PlayerQueryEvent (mage.game.events.PlayerQueryEvent)1 TableEvent (mage.game.events.TableEvent)1 Player (mage.players.Player)1 GameController (mage.server.game.GameController)1 ManagerFactory (mage.server.managers.ManagerFactory)1 DraftPickView (mage.view.DraftPickView)1 Logger (org.apache.log4j.Logger)1