mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
UI: added test card render modes dialog (available from debug menu);
This commit is contained in:
parent
e1514e0d49
commit
051c3c4ac0
6 changed files with 559 additions and 223 deletions
|
@ -16,6 +16,14 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDebugTestModalDialogActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="menuDebugTestCardRenderModesDialog">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Test Card Render Modes"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="menuDebugTestCardRenderModesDialogActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</NonVisualComponents>
|
||||
|
|
|
@ -827,6 +827,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
|
||||
popupDebug = new javax.swing.JPopupMenu();
|
||||
menuDebugTestModalDialog = new javax.swing.JMenuItem();
|
||||
menuDebugTestCardRenderModesDialog = new javax.swing.JMenuItem();
|
||||
desktopPane = new MageJDesktop();
|
||||
mageToolbar = new javax.swing.JToolBar();
|
||||
btnPreferences = new javax.swing.JButton();
|
||||
|
@ -857,6 +858,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
});
|
||||
popupDebug.add(menuDebugTestModalDialog);
|
||||
|
||||
menuDebugTestCardRenderModesDialog.setText("Test Card Render Modes");
|
||||
menuDebugTestCardRenderModesDialog.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
menuDebugTestCardRenderModesDialogActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
popupDebug.add(menuDebugTestCardRenderModesDialog);
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(1024, 768));
|
||||
|
||||
|
@ -995,16 +1004,16 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 838, Short.MAX_VALUE)
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 838, Short.MAX_VALUE)
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2, 2, 2)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2, 2, 2)
|
||||
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
|
@ -1079,6 +1088,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
popupDebug.show(evt.getComponent(), 0, evt.getComponent().getHeight());
|
||||
}//GEN-LAST:event_btnDebugMouseClicked
|
||||
|
||||
private void menuDebugTestCardRenderModesDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuDebugTestCardRenderModesDialogActionPerformed
|
||||
final TestCardRenderDialog dialog = new TestCardRenderDialog();
|
||||
dialog.showDialog();
|
||||
}//GEN-LAST:event_menuDebugTestCardRenderModesDialogActionPerformed
|
||||
|
||||
public void downloadImages() {
|
||||
DownloadPicturesService.startDownload();
|
||||
}
|
||||
|
@ -1328,6 +1342,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
private javax.swing.JToolBar.Separator jSeparatorImages;
|
||||
private javax.swing.JToolBar.Separator jSeparatorSymbols;
|
||||
private javax.swing.JToolBar mageToolbar;
|
||||
private javax.swing.JMenuItem menuDebugTestCardRenderModesDialog;
|
||||
private javax.swing.JMenuItem menuDebugTestModalDialog;
|
||||
private javax.swing.JPopupMenu popupDebug;
|
||||
private javax.swing.JToolBar.Separator separatorDebug;
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="578" max="32767" attributes="0"/>
|
||||
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="cardArea1" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="88" max="32767" attributes="0"/>
|
||||
<Component id="cardArea1" min="-2" pref="327" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="buttonCancel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Close"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="mage.client.cards.CardArea" name="cardArea1">
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
|
@ -0,0 +1,223 @@
|
|||
package mage.client.dialog;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardGraphicInfo;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameImpl;
|
||||
import mage.game.match.MatchType;
|
||||
import mage.game.mulligan.Mulligan;
|
||||
import mage.game.mulligan.VancouverMulligan;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.players.Player;
|
||||
import mage.players.StubPlayer;
|
||||
import mage.view.CardsView;
|
||||
import mage.view.PermanentView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class TestCardRenderDialog extends MageDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class);
|
||||
|
||||
public TestCardRenderDialog() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
this.setModal(false);
|
||||
getRootPane().setDefaultButton(buttonCancel);
|
||||
|
||||
// windows settings
|
||||
MageFrame.getDesktop().remove(this);
|
||||
if (this.isModal()) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.MODAL_LAYER);
|
||||
} else {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||
}
|
||||
this.makeWindowCentered();
|
||||
|
||||
// Close on "ESC"
|
||||
registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void onCancel() {
|
||||
this.removeDialog();
|
||||
}
|
||||
|
||||
private PermanentView createCard(Game game, UUID controllerId, String code, String cardNumber, int damage) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
|
||||
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
|
||||
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(),
|
||||
new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
|
||||
Card card = CardImpl.createCard(cardInfo.getClassName(), testSet);
|
||||
|
||||
PermanentCard perm = new PermanentCard(card, controllerId, game);
|
||||
if (damage > 0) {
|
||||
perm.damage(damage, null, game);
|
||||
}
|
||||
PermanentView cardView = new PermanentView(perm, card, controllerId, game);
|
||||
cardView.setInViewerOnly(true);
|
||||
|
||||
return cardView;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
buttonCancel = new javax.swing.JButton();
|
||||
cardArea1 = new mage.client.cards.CardArea();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
buttonCancel.setText("Close");
|
||||
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButton1.setText("jButton1");
|
||||
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton1ActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 578, Short.MAX_VALUE)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(cardArea1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jButton1)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jButton1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
|
||||
.addComponent(cardArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
|
||||
onCancel();
|
||||
}//GEN-LAST:event_buttonCancelActionPerformed
|
||||
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
Game game = new TestGame(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, new VancouverMulligan(0), 20);
|
||||
Player player = new StubPlayer("player1", RangeOfInfluence.ALL);
|
||||
Deck deck = new Deck();
|
||||
game.addPlayer(player, deck);
|
||||
|
||||
BigCard big = new BigCard();
|
||||
CardsView view = new CardsView();
|
||||
PermanentView card;
|
||||
card = createCard(game, player.getId(), "RNA", "263", 0); // mountain
|
||||
view.put(card.getId(), card);
|
||||
card = createCard(game, player.getId(), "RNA", "185", 0); // Judith, the Scourge Diva
|
||||
view.put(card.getId(), card);
|
||||
card = createCard(game, player.getId(), "RNA", "14", 1); // Knight of Sorrows
|
||||
view.put(card.getId(), card);
|
||||
|
||||
cardArea1.loadCards(view, big, null);
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonCancel;
|
||||
private mage.client.cards.CardArea cardArea1;
|
||||
private javax.swing.JButton jButton1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
class TestGame extends GameImpl {
|
||||
|
||||
private int numPlayers;
|
||||
|
||||
public TestGame(MultiplayerAttackOption attackOption, RangeOfInfluence range, Mulligan mulligan, int startLife) {
|
||||
super(attackOption, range, mulligan, startLife);
|
||||
}
|
||||
|
||||
public TestGame(final TestGame game) {
|
||||
super(game);
|
||||
this.numPlayers = game.numPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatchType getGameType() {
|
||||
return new TestGameType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumPlayers() {
|
||||
return numPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestGame copy() {
|
||||
return new TestGame(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TestGameType extends MatchType {
|
||||
|
||||
public TestGameType() {
|
||||
this.name = "Test Game Type";
|
||||
this.maxPlayers = 10;
|
||||
this.minPlayers = 3;
|
||||
this.numTeams = 0;
|
||||
this.useAttackOption = true;
|
||||
this.useRange = true;
|
||||
this.sideboardingAllowed = true;
|
||||
}
|
||||
|
||||
protected TestGameType(final TestGameType matchType) {
|
||||
super(matchType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestGameType copy() {
|
||||
return new TestGameType(this);
|
||||
}
|
||||
}
|
|
@ -1,41 +1,21 @@
|
|||
|
||||
package org.mage.test.mulligan;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.basiclands.Forest;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.game.Game;
|
||||
import mage.game.GameOptions;
|
||||
import mage.game.TwoPlayerDuel;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.match.Match;
|
||||
import mage.game.mulligan.Mulligan;
|
||||
import mage.game.mulligan.MulliganType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.players.Player;
|
||||
import mage.players.PlayerImpl;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetAmount;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.players.StubPlayer;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
@ -43,7 +23,6 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static mage.constants.MultiplayerAttackOption.LEFT;
|
||||
import static mage.constants.RangeOfInfluence.ONE;
|
||||
import static mage.constants.Rarity.LAND;
|
||||
|
@ -167,7 +146,8 @@ public class MulliganTestBase {
|
|||
return deck;
|
||||
}
|
||||
|
||||
interface Step {}
|
||||
interface Step {
|
||||
}
|
||||
|
||||
interface MulliganStep extends Step {
|
||||
boolean mulligan();
|
||||
|
@ -242,192 +222,4 @@ public class MulliganTestBase {
|
|||
|
||||
}
|
||||
|
||||
static class StubPlayer extends PlayerImpl implements Player {
|
||||
|
||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
|
||||
if (target instanceof TargetPlayer) {
|
||||
for (Player player : game.getPlayers().values()) {
|
||||
if (player.getId().equals(getId()) && target.canTarget(getId(), game)) {
|
||||
target.add(player.getId(), game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
|
||||
cards.getCards(game).stream().map(MageItem::getId).forEach(cardId -> target.add(cardId, game));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
|
||||
if ("cards to PUT on the BOTTOM of your library (Discard for Mulligan)".equals(target.getFilter().getMessage())) {
|
||||
chooseDiscardBottom(game, target.getMinNumberOfTargets(), cards.getCards(game)
|
||||
.stream().map(MageItem::getId).collect(toList())).forEach(cardId -> target.add(cardId, game));
|
||||
} else {
|
||||
UUID cardId = getOnlyElement(cards.getCards(game)).getId();
|
||||
if (chooseScry(game, cardId)) {
|
||||
target.add(cardId, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<UUID> chooseDiscardBottom(Game game, int count, List<UUID> cardIds) {
|
||||
return cardIds.subList(0, count);
|
||||
}
|
||||
|
||||
public boolean chooseScry(Game game, UUID cardId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shuffleLibrary(Ability source, Game game) {
|
||||
|
||||
}
|
||||
|
||||
public StubPlayer(String name, RangeOfInfluence range) {
|
||||
super(name, range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abort() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skip() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player copy() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean priority(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseMulligan(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseUse(Outcome outcome, String message, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseUse(Outcome outcome, String message, String secondMessage, String trueText, String falseText, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Choice choice, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playMana(Ability ability, ManaCost unpaid, String promptText, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int announceXCost(int min, int max, String message, Game game, Ability ability, VariableCost variableCost) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int chooseReplacementEffect(Map<String, String> abilityMap, Game game) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode chooseMode(Modes modes, Ability source, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAttackers(Game game, UUID attackingPlayerId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectBlockers(Game game, UUID defendingPlayerId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID chooseAttackerOrder(List<Permanent> attacker, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID chooseBlockerOrder(List<Permanent> blockers, CombatGroup combatGroup, List<UUID> blockerOrder, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount(int min, int max, String message, Game game) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sideboard(Match match, Deck deck) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void construct(Tournament tournament, Deck deck) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pickCard(List<Card> cards, Deck deck, Draft draft) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
221
Mage/src/main/java/mage/players/StubPlayer.java
Normal file
221
Mage/src/main/java/mage/players/StubPlayer.java
Normal file
|
@ -0,0 +1,221 @@
|
|||
package mage.players;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.Modes;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.choices.Choice;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.draft.Draft;
|
||||
import mage.game.match.Match;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.tournament.Tournament;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetAmount;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class StubPlayer extends PlayerImpl implements Player {
|
||||
|
||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game) {
|
||||
if (target instanceof TargetPlayer) {
|
||||
for (Player player : game.getPlayers().values()) {
|
||||
if (player.getId().equals(getId()) && target.canTarget(getId(), game)) {
|
||||
target.add(player.getId(), game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
|
||||
cards.getCards(game).stream().map(MageItem::getId).forEach(cardId -> target.add(cardId, game));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
|
||||
if ("cards to PUT on the BOTTOM of your library (Discard for Mulligan)".equals(target.getFilter().getMessage())) {
|
||||
chooseDiscardBottom(game, target.getMinNumberOfTargets(), cards.getCards(game)
|
||||
.stream().map(MageItem::getId).collect(toList())).forEach(cardId -> target.add(cardId, game));
|
||||
} else {
|
||||
UUID cardId = getOnlyElement(cards.getCards(game)).getId();
|
||||
if (chooseScry(game, cardId)) {
|
||||
target.add(cardId, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<UUID> chooseDiscardBottom(Game game, int count, List<UUID> cardIds) {
|
||||
return cardIds.subList(0, count);
|
||||
}
|
||||
|
||||
public boolean chooseScry(Game game, UUID cardId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shuffleLibrary(Ability source, Game game) {
|
||||
|
||||
}
|
||||
|
||||
public StubPlayer(String name, RangeOfInfluence range) {
|
||||
super(name, range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abort() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skip() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player copy() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean priority(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Target target, UUID sourceId, Game game, Map<String, Serializable> options) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseMulligan(Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseUse(Outcome outcome, String message, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chooseUse(Outcome outcome, String message, String secondMessage, String trueText, String falseText, Ability source, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Choice choice, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playMana(Ability ability, ManaCost unpaid, String promptText, Game game) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int announceXCost(int min, int max, String message, Game game, Ability ability, VariableCost variableCost) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int chooseReplacementEffect(Map<String, String> abilityMap, Game game) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mode chooseMode(Modes modes, Ability source, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectAttackers(Game game, UUID attackingPlayerId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectBlockers(Game game, UUID defendingPlayerId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID chooseAttackerOrder(List<Permanent> attacker, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID chooseBlockerOrder(List<Permanent> blockers, CombatGroup combatGroup, List<UUID> blockerOrder, Game game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount(int min, int max, String message, Game game) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sideboard(Match match, Deck deck) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void construct(Tournament tournament, Deck deck) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pickCard(List<Card> cards, Deck deck, Draft draft) {
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue