mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
draft stuff
This commit is contained in:
parent
2e13136101
commit
03e3be90d6
34 changed files with 1238 additions and 743 deletions
|
|
@ -37,6 +37,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
import mage.game.match.MatchType;
|
||||
import mage.server.game.DeckValidatorFactory;
|
||||
import mage.server.game.DraftFactory;
|
||||
import mage.server.game.GameFactory;
|
||||
import mage.server.game.PlayerFactory;
|
||||
import mage.server.util.ConfigSettings;
|
||||
|
|
@ -72,6 +73,9 @@ public class Main {
|
|||
for (GamePlugin plugin: config.getGameTypes()) {
|
||||
GameFactory.getInstance().addGameType(plugin.getName(), loadGameType(plugin), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getDraftTypes()) {
|
||||
DraftFactory.getInstance().addDraftType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
for (Plugin plugin: config.getPlayerTypes()) {
|
||||
PlayerFactory.getInstance().addPlayerType(plugin.getName(), loadPlugin(plugin));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,10 @@ public class Session {
|
|||
fireCallback(new ClientCallback("sideboard", new TableClientMessage(deck, tableId)));
|
||||
}
|
||||
|
||||
public void construct(final Deck deck, final UUID tableId) {
|
||||
fireCallback(new ClientCallback("construct", new TableClientMessage(deck, tableId)));
|
||||
}
|
||||
|
||||
public void watchGame(final UUID gameId) {
|
||||
fireCallback(new ClientCallback("watchGame", gameId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class DraftController {
|
|||
public void event(PlayerQueryEvent event) {
|
||||
switch (event.getQueryType()) {
|
||||
case PICK_CARD:
|
||||
pickCard(event.getPlayerId());
|
||||
pickCard(event.getPlayerId(), event.getMax());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -130,6 +130,7 @@ public class DraftController {
|
|||
return;
|
||||
}
|
||||
}
|
||||
draft.start();
|
||||
}
|
||||
|
||||
private boolean allJoined() {
|
||||
|
|
@ -186,9 +187,9 @@ public class DraftController {
|
|||
}
|
||||
}
|
||||
|
||||
private synchronized void pickCard(UUID playerId) {
|
||||
private synchronized void pickCard(UUID playerId, int timeout) {
|
||||
if (draftSessions.containsKey(playerId))
|
||||
draftSessions.get(playerId).pickCard(getDraftPickView(playerId));
|
||||
draftSessions.get(playerId).pickCard(getDraftPickView(playerId), timeout);
|
||||
}
|
||||
|
||||
private DraftView getDraftView() {
|
||||
|
|
@ -196,7 +197,7 @@ public class DraftController {
|
|||
}
|
||||
|
||||
private DraftPickView getDraftPickView(UUID playerId) {
|
||||
return new DraftPickView();
|
||||
return new DraftPickView(draft.getPlayer(playerId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@ public class DraftSession {
|
|||
}
|
||||
}
|
||||
|
||||
public void pickCard(final DraftPickView draftPickView) {
|
||||
public void pickCard(final DraftPickView draftPickView, int timeout) {
|
||||
if (!killed) {
|
||||
setupTimeout(20);
|
||||
setupTimeout(timeout);
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
if (session != null)
|
||||
session.fireCallback(new ClientCallback("draftPick", new DraftClientMessage(draftPickView)));
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import mage.Constants.RangeOfInfluence;
|
||||
import mage.Constants.TableState;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
|
|
@ -212,7 +213,13 @@ public class TableController {
|
|||
}
|
||||
|
||||
private Player createPlayer(String name, String playerType) {
|
||||
Player player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange());
|
||||
Player player;
|
||||
if (options == null) {
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, RangeOfInfluence.ALL);
|
||||
}
|
||||
else {
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange());
|
||||
}
|
||||
logger.info("Player created " + player.getId());
|
||||
return player;
|
||||
}
|
||||
|
|
@ -245,7 +252,6 @@ public class TableController {
|
|||
|
||||
public synchronized void startDraft(UUID sessionId) {
|
||||
if (sessionId.equals(this.sessionId) && table.getState() == TableState.STARTING) {
|
||||
draft.start();
|
||||
table.initDraft();
|
||||
DraftManager.getInstance().createDraftSession(draft, sessionPlayerMap, table.getId());
|
||||
SessionManager sessionManager = SessionManager.getInstance();
|
||||
|
|
@ -274,6 +280,16 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
|
||||
private void construct(UUID playerId, Deck deck) {
|
||||
SessionManager sessionManager = SessionManager.getInstance();
|
||||
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
|
||||
if (entry.getValue().equals(playerId)) {
|
||||
sessionManager.getSession(entry.getKey()).construct(deck, table.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void endGame() {
|
||||
UUID choosingPlayerId = match.getChooser();
|
||||
match.endGame();
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@
|
|||
<xs:element ref="server"/>
|
||||
<xs:element ref="playerTypes"/>
|
||||
<xs:element ref="gameTypes"/>
|
||||
<xs:element ref="draftTypes"/>
|
||||
<xs:element ref="deckTypes"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
|
||||
<xs:element name="server">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="serverAddress" type="xs:string" use="required"/>
|
||||
|
|
@ -23,26 +24,40 @@
|
|||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="plugin">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
<xs:attribute name="jar" type="xs:string"/>
|
||||
<xs:attribute name="className" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:complexType name="plugin">
|
||||
<xs:attribute name="name" type="xs:string"/>
|
||||
<xs:attribute name="jar" type="xs:string"/>
|
||||
<xs:attribute name="className" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="gamePlugin">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="plugin">
|
||||
<xs:attribute name="typeName" type="xs:string"/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:element name="playerTypes">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="plugin" maxOccurs="unbounded"/>
|
||||
<xs:element name="playerType" type="plugin" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
|
||||
<xs:element name="gameTypes">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="plugin" maxOccurs="unbounded"/>
|
||||
<xs:element name="gameType" type="gamePlugin" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="draftTypes">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="draftType" type="plugin" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
|
@ -50,7 +65,7 @@
|
|||
<xs:element name="deckTypes">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element ref="plugin" maxOccurs="unbounded"/>
|
||||
<xs:element name="deckType" type="plugin" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
|
|
|||
|
|
@ -92,6 +92,10 @@ public class ConfigSettings {
|
|||
return config.getGameTypes().getGameType();
|
||||
}
|
||||
|
||||
public List<Plugin> getDraftTypes() {
|
||||
return config.getDraftTypes().getDraftType();
|
||||
}
|
||||
|
||||
public List<Plugin> getDeckTypes() {
|
||||
return config.getDeckTypes().getDeckType();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<xs:element ref="server"/>
|
||||
<xs:element ref="playerTypes"/>
|
||||
<xs:element ref="gameTypes"/>
|
||||
<xs:element ref="draftTypes"/>
|
||||
<xs:element ref="deckTypes"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
|
@ -53,6 +54,14 @@
|
|||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="draftTypes">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="draftType" type="plugin" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<xs:element name="deckTypes">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue