mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
initial drafting stuff
This commit is contained in:
parent
5679c2de15
commit
7bea472fff
13 changed files with 469 additions and 3 deletions
|
@ -321,6 +321,18 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean sendCardPick(UUID draftId, UUID cardId) {
|
||||
try {
|
||||
server.sendPlayerUUID(draftId, sessionId, cardId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean joinChat(UUID chatId, ChatPanel chat) {
|
||||
try {
|
||||
server.joinChat(chatId, sessionId, userName);
|
||||
|
@ -465,6 +477,18 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean startDraft(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
server.startDraft(sessionId, roomId, tableId);
|
||||
return true;
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
||||
try {
|
||||
server.submitDeck(sessionId, tableId, deck);
|
||||
|
|
|
@ -86,6 +86,10 @@ public interface Server extends Remote, CallbackServer {
|
|||
public void sendPlayerInteger(UUID gameId, UUID sessionId, Integer data) throws RemoteException, MageException;
|
||||
public void concedeGame(UUID gameId, UUID sessionId) throws RemoteException, MageException;
|
||||
|
||||
//draft methods
|
||||
public void startDraft(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException;
|
||||
public void sendCardPick(UUID draftId, UUID sessionId, UUID cardId) throws RemoteException, MageException;
|
||||
|
||||
//replay methods
|
||||
public void replayGame(UUID sessionId) throws RemoteException, MageException;
|
||||
public void stopReplay(UUID sessionId) throws RemoteException, MageException;
|
||||
|
|
|
@ -72,6 +72,7 @@ import mage.abilities.keyword.FirstStrikeAbility;
|
|||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.player.ai.simulators.CombatGroupSimulator;
|
||||
import mage.player.ai.simulators.CombatSimulator;
|
||||
import mage.player.ai.simulators.CreatureSimulator;
|
||||
|
@ -773,6 +774,12 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
table.fireSubmitDeckEvent(playerId, deck);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pickCard(List<Card> cards, Deck deck, Draft draft) {
|
||||
//TODO: improve this
|
||||
draft.addPick(playerId, cards.get(0).getId());
|
||||
}
|
||||
|
||||
protected Attackers getPotentialAttackers(Game game) {
|
||||
logger.fine("getAvailableAttackers");
|
||||
Attackers attackers = new Attackers();
|
||||
|
|
|
@ -32,8 +32,10 @@ import java.util.List;
|
|||
import mage.abilities.TriggeredAbilities;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.effects.ReplacementEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.choices.Choice;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.players.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -477,6 +479,11 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
table.fireSideboardEvent(playerId, deck);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pickCard(List<Card> cards, Deck deck, Draft draft) {
|
||||
draft.firePickCardEvent(playerId);
|
||||
}
|
||||
|
||||
protected void specialAction(Game game) {
|
||||
Map<UUID, SpecialAction> specialActions = game.getState().getSpecialActions().getControlledBy(playerId);
|
||||
game.fireGetChoiceEvent(playerId, name, specialActions.values());
|
||||
|
@ -543,8 +550,6 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public HumanPlayer copy() {
|
||||
return new HumanPlayer(this);
|
||||
|
|
|
@ -231,6 +231,23 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startDraft(final UUID sessionId, final UUID roomId, final UUID draftId) throws MageException {
|
||||
try {
|
||||
rmiExecutor.execute(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TableManager.getInstance().startMatch(sessionId, roomId, tableId);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChatMessage(final UUID chatId, final String userName, final String message) throws MageException {
|
||||
try {
|
||||
|
@ -456,6 +473,23 @@ public class ServerImpl extends RemoteServer implements Server {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCardPick(final UUID gameId, final UUID sessionId, final UUID cardPick) throws MageException {
|
||||
try {
|
||||
rmiExecutor.execute(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// GameManager.getInstance().sendPlayerUUID(gameId, sessionId, data);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void concedeGame(final UUID gameId, final UUID sessionId) throws MageException {
|
||||
try {
|
||||
|
|
54
Mage/src/mage/game/draft/Draft.java
Normal file
54
Mage/src/mage/game/draft/Draft.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.game.draft;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
import mage.MageItem;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.PlayerQueryEvent;
|
||||
import mage.game.events.TableEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public interface Draft extends MageItem, Serializable {
|
||||
|
||||
public void addPlayer(Player player);
|
||||
public void addPick(UUID playerId, UUID cardId);
|
||||
public void start();
|
||||
|
||||
public void addTableEventListener(Listener<TableEvent> listener);
|
||||
public void fireUpdatePlayersEvent();
|
||||
public void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener);
|
||||
public void firePickCardEvent(UUID playerId);
|
||||
|
||||
}
|
199
Mage/src/mage/game/draft/DraftImpl.java
Normal file
199
Mage/src/mage/game/draft/DraftImpl.java
Normal file
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.game.draft;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.game.events.Listener;
|
||||
import mage.game.events.PlayerQueryEvent;
|
||||
import mage.game.events.PlayerQueryEventSource;
|
||||
import mage.game.events.TableEvent;
|
||||
import mage.game.events.TableEvent.EventType;
|
||||
import mage.game.events.TableEventSource;
|
||||
import mage.players.Player;
|
||||
import mage.players.PlayerList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class DraftImpl<T extends DraftImpl<T>> implements Draft {
|
||||
|
||||
protected final UUID id;
|
||||
protected Map<UUID, DraftPlayer> players = new HashMap<UUID, DraftPlayer>();
|
||||
protected PlayerList table = new PlayerList();
|
||||
protected List<ExpansionSet> sets;
|
||||
protected int boosterNum = 0;
|
||||
|
||||
protected transient TableEventSource tableEventSource = new TableEventSource();
|
||||
protected transient PlayerQueryEventSource playerQueryEventSource = new PlayerQueryEventSource();
|
||||
|
||||
public DraftImpl(List<ExpansionSet> sets) {
|
||||
id = UUID.randomUUID();
|
||||
this.sets = sets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayer(Player player) {
|
||||
DraftPlayer draftPlayer = new DraftPlayer(player);
|
||||
players.put(draftPlayer.getId(), draftPlayer);
|
||||
table.add(draftPlayer.getId());
|
||||
}
|
||||
|
||||
protected void passLeft() {
|
||||
UUID startId = table.get(0);
|
||||
UUID currentId = startId;
|
||||
UUID nextId = table.getNext();
|
||||
DraftPlayer current = players.get(currentId);
|
||||
DraftPlayer next = players.get(nextId);
|
||||
List<Card> currentBooster = current.booster;
|
||||
while (true) {
|
||||
List<Card> nextBooster = next.booster;
|
||||
next.setBooster(currentBooster);
|
||||
if (nextId == startId)
|
||||
break;
|
||||
currentBooster = nextBooster;
|
||||
current = next;
|
||||
currentId = nextId;
|
||||
nextId = table.getNext();
|
||||
next = players.get(nextId);
|
||||
}
|
||||
}
|
||||
|
||||
protected void passRight() {
|
||||
UUID startId = table.get(0);
|
||||
UUID currentId = startId;
|
||||
UUID prevId = table.getPrevious();
|
||||
DraftPlayer current = players.get(currentId);
|
||||
DraftPlayer prev = players.get(prevId);
|
||||
List<Card> currentBooster = current.booster;
|
||||
while (true) {
|
||||
List<Card> prevBooster = prev.booster;
|
||||
prev.setBooster(currentBooster);
|
||||
if (prevId == startId)
|
||||
break;
|
||||
currentBooster = prevBooster;
|
||||
current = prev;
|
||||
currentId = prevId;
|
||||
prevId = table.getPrevious();
|
||||
prev = players.get(prevId);
|
||||
}
|
||||
}
|
||||
|
||||
protected void openBooster() {
|
||||
if (sets.size() < boosterNum) {
|
||||
for (DraftPlayer player: players.values()) {
|
||||
player.setBooster(sets.get(boosterNum).createBooster());
|
||||
}
|
||||
}
|
||||
boosterNum++;
|
||||
}
|
||||
|
||||
protected boolean pickCards() {
|
||||
for (DraftPlayer player: players.values()) {
|
||||
if (player.getBooster().size() == 0)
|
||||
return false;
|
||||
player.getPlayer().pickCard(player.getBooster(), player.getDeck(), this);
|
||||
player.setPicking();
|
||||
}
|
||||
while (!donePicking()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(DraftImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean donePicking() {
|
||||
for (DraftPlayer player: players.values()) {
|
||||
if (player.picking)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
while (boosterNum < sets.size()) {
|
||||
openBooster();
|
||||
while (pickCards()) {
|
||||
if (boosterNum % 2 == 1)
|
||||
passLeft();
|
||||
else
|
||||
passRight();
|
||||
fireUpdatePlayersEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTableEventListener(Listener<TableEvent> listener) {
|
||||
tableEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireUpdatePlayersEvent() {
|
||||
tableEventSource.fireTableEvent(EventType.UPDATE, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener) {
|
||||
playerQueryEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void firePickCardEvent(UUID playerId) {
|
||||
playerQueryEventSource.pickCard(playerId, "Pick card", players.get(playerId).booster);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPick(UUID playerId, UUID cardId) {
|
||||
DraftPlayer player = players.get(playerId);
|
||||
for (Card card: player.booster) {
|
||||
if (card.getId().equals(cardId)) {
|
||||
player.addPick(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
94
Mage/src/mage/game/draft/DraftPlayer.java
Normal file
94
Mage/src/mage/game/draft/DraftPlayer.java
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.game.draft;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class DraftPlayer {
|
||||
|
||||
protected UUID id;
|
||||
protected Player player;
|
||||
protected Deck deck;
|
||||
protected List<Card> booster;
|
||||
protected boolean picking;
|
||||
|
||||
public DraftPlayer(Player player) {
|
||||
id = UUID.randomUUID();
|
||||
this.player = player;
|
||||
this.deck = new Deck();
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Deck getDeck() {
|
||||
return deck;
|
||||
}
|
||||
|
||||
public void addPick(Card card) {
|
||||
deck.getSideboard().add(card);
|
||||
booster.remove(card);
|
||||
picking = false;
|
||||
}
|
||||
|
||||
public void openBooster(ExpansionSet set) {
|
||||
booster = set.createBooster();
|
||||
}
|
||||
|
||||
public void setBooster(List<Card> booster) {
|
||||
this.booster = booster;
|
||||
}
|
||||
|
||||
public List<Card> getBooster() {
|
||||
return booster;
|
||||
}
|
||||
|
||||
public void setPicking() {
|
||||
picking = true;
|
||||
}
|
||||
|
||||
public boolean isPicking() {
|
||||
return picking;
|
||||
}
|
||||
|
||||
}
|
|
@ -31,11 +31,13 @@ package mage.game.events;
|
|||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.TriggeredAbilities;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +47,7 @@ import mage.cards.Cards;
|
|||
public class PlayerQueryEvent extends EventObject implements ExternalEvent, Serializable {
|
||||
|
||||
public enum QueryType {
|
||||
ASK, CHOOSE, CHOOSE_ABILITY, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK
|
||||
ASK, CHOOSE, CHOOSE_ABILITY, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK, PICK_CARD
|
||||
}
|
||||
|
||||
private String message;
|
||||
|
@ -53,6 +55,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
private Set<String> choices;
|
||||
private Set<UUID> targets;
|
||||
private Cards cards;
|
||||
private List<Card> booster;
|
||||
private QueryType queryType;
|
||||
private UUID playerId;
|
||||
private boolean required;
|
||||
|
@ -73,6 +76,14 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
this.max = max;
|
||||
}
|
||||
|
||||
private PlayerQueryEvent(UUID playerId, String message, List<Card> booster, QueryType queryType) {
|
||||
super(playerId);
|
||||
this.queryType = queryType;
|
||||
this.message = message;
|
||||
this.playerId = playerId;
|
||||
this.booster = booster;
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent askEvent(UUID playerId, String message) {
|
||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false);
|
||||
}
|
||||
|
@ -116,6 +127,10 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
return new PlayerQueryEvent(playerId, message, null, null, null, cards, QueryType.LOOK, 0, 0, false);
|
||||
}
|
||||
|
||||
public static PlayerQueryEvent pickCard(UUID playerId, String message, List<Card> booster) {
|
||||
return new PlayerQueryEvent(playerId, message, booster, QueryType.PICK_CARD);
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
@ -148,6 +163,10 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
|||
return cards;
|
||||
}
|
||||
|
||||
public List<Card> getBooster() {
|
||||
return booster;
|
||||
}
|
||||
|
||||
public int getMin() {
|
||||
return min;
|
||||
}
|
||||
|
|
|
@ -30,10 +30,12 @@ package mage.game.events;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.TriggeredAbilities;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
|
||||
/**
|
||||
|
@ -93,4 +95,8 @@ public class PlayerQueryEventSource implements EventSource<PlayerQueryEvent>, Se
|
|||
dispatcher.fireEvent(PlayerQueryEvent.playXManaEvent(playerId, message));
|
||||
}
|
||||
|
||||
public void pickCard(UUID playerId, String message, List<Card> booster) {
|
||||
dispatcher.fireEvent(PlayerQueryEvent.pickCard(playerId, message, booster));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.UUID;
|
|||
import mage.cards.Cards;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.Game;
|
||||
import mage.game.draft.Draft;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -46,6 +47,7 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
|||
}
|
||||
|
||||
private Game game;
|
||||
private Draft draft;
|
||||
private EventType eventType;
|
||||
private String message;
|
||||
private Cards cards;
|
||||
|
@ -67,10 +69,21 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
|||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public TableEvent(EventType eventType, String message, Draft draft) {
|
||||
super(draft);
|
||||
this.draft = draft;
|
||||
this.message = message;
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
public Game getGame() {
|
||||
return game;
|
||||
}
|
||||
|
||||
public Draft getDraft() {
|
||||
return draft;
|
||||
}
|
||||
|
||||
public EventType getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
|||
import mage.cards.Cards;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.Game;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.events.TableEvent.EventType;
|
||||
|
||||
/**
|
||||
|
@ -52,6 +53,10 @@ public class TableEventSource implements EventSource<TableEvent>, Serializable {
|
|||
dispatcher.fireEvent(new TableEvent(eventType, message, null, game));
|
||||
}
|
||||
|
||||
public void fireTableEvent(EventType eventType, String message, Draft draft) {
|
||||
dispatcher.fireEvent(new TableEvent(eventType, message, draft));
|
||||
}
|
||||
|
||||
public void fireTableEvent(EventType eventType, String message, Cards cards, Game game) {
|
||||
dispatcher.fireEvent(new TableEvent(eventType, message, cards, game));
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import mage.filter.FilterAbility;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.Game;
|
||||
import mage.game.Table;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetAmount;
|
||||
|
@ -148,6 +149,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
public abstract void assignDamage(int damage, List<UUID> targets, UUID sourceId, Game game);
|
||||
public abstract int getAmount(int min, int max, String message, Game game);
|
||||
public abstract void sideboard(Table table, Deck deck);
|
||||
public abstract void pickCard(List<Card> cards, Deck deck, Draft draft);
|
||||
|
||||
public void declareAttacker(UUID attackerId, UUID defenderId, Game game);
|
||||
public void declareBlocker(UUID blockerId, UUID attackerId, Game game);
|
||||
|
|
Loading…
Add table
Reference in a new issue