mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Add "ask simulated ai" dev option. (#2180)
* Add "ask simulated ai" dev option. Also moves the setup/dump game state options at the end of the list, as they're different from the other ones and shouldn't just be in the middle. Also makes the code a bit more concise for the different mouse listeners. * Fix comment location.
This commit is contained in:
@@ -28,31 +28,32 @@ public final class CDev implements ICDoc {
|
||||
this.view = new VDev(this);
|
||||
addListener(view);
|
||||
|
||||
view.getLblUnlimitedLands().addMouseListener(madUnlimited);
|
||||
view.getLblViewAll().addMouseListener(madViewAll);
|
||||
view.getLblGenerateMana().addMouseListener(madMana);
|
||||
view.getLblSetupGame().addMouseListener(madSetup);
|
||||
view.getLblDumpGame().addMouseListener(madDump);
|
||||
view.getLblTutor().addMouseListener(madTutor);
|
||||
view.getLblCardToHand().addMouseListener(madCardToHand);
|
||||
view.getLblExileFromHand().addMouseListener(madExileFromHand);
|
||||
view.getLblCardToBattlefield().addMouseListener(madCardToBattlefield);
|
||||
view.getLblCardToLibrary().addMouseListener(madCardToLibrary);
|
||||
view.getLblCardToGraveyard().addMouseListener(madCardToGraveyard);
|
||||
view.getLblCardToExile().addMouseListener(madCardToExile);
|
||||
view.getLblCastSpell().addMouseListener(madCastASpell);
|
||||
view.getLblRepeatAddCard().addMouseListener(madRepeatAddCard);
|
||||
view.getLblAddCounterPermanent().addMouseListener(madAddCounter);
|
||||
view.getLblSubCounterPermanent().addMouseListener(madSubCounter);
|
||||
view.getLblTapPermanent().addMouseListener(madTap);
|
||||
view.getLblUntapPermanent().addMouseListener(madUntap);
|
||||
view.getLblSetLife().addMouseListener(madLife);
|
||||
view.getLblWinGame().addMouseListener(madWinGame);
|
||||
view.getLblExileFromPlay().addMouseListener(madExileFromPlay);
|
||||
view.getLblRemoveFromGame().addMouseListener(madRemoveFromGame);
|
||||
view.getLblRiggedRoll().addMouseListener(madRiggedRoll);
|
||||
view.getLblWalkTo().addMouseListener(madWalkToPlane);
|
||||
view.getLblAskAI().addMouseListener(madAskAI);
|
||||
view.getLblUnlimitedLands().addMouseListener(onClick(this::togglePlayManyLandsPerTurn));
|
||||
view.getLblViewAll().addMouseListener(onClick(this::toggleViewAllCards));
|
||||
view.getLblGenerateMana().addMouseListener(onClick(this::generateMana));
|
||||
view.getLblSetupGame().addMouseListener(onClick(this::setupGameState));
|
||||
view.getLblDumpGame().addMouseListener(onClick(this::dumpGameState));
|
||||
view.getLblTutor().addMouseListener(onClick(this::tutorForCard));
|
||||
view.getLblCardToHand().addMouseListener(onClick(this::addCardToHand));
|
||||
view.getLblExileFromHand().addMouseListener(onClick(this::exileCardsFromHand));
|
||||
view.getLblCardToBattlefield().addMouseListener(onClick(this::addCardToBattlefield));
|
||||
view.getLblCardToLibrary().addMouseListener(onClick(this::addCardToLibrary));
|
||||
view.getLblCardToGraveyard().addMouseListener(onClick(this::addCardToGraveyard));
|
||||
view.getLblCardToExile().addMouseListener(onClick(this::addCardToExile));
|
||||
view.getLblCastSpell().addMouseListener(onClick(this::castASpell));
|
||||
view.getLblRepeatAddCard().addMouseListener(onClick(this::repeatAddCard));
|
||||
view.getLblAddCounterPermanent().addMouseListener(onClick(this::addCounterToPermanent));
|
||||
view.getLblSubCounterPermanent().addMouseListener(onClick(this::removeCountersFromPermanent));
|
||||
view.getLblTapPermanent().addMouseListener(onClick(this::tapPermanent));
|
||||
view.getLblUntapPermanent().addMouseListener(onClick(this::untapPermanent));
|
||||
view.getLblSetLife().addMouseListener(onClick(this::setPlayerLife));
|
||||
view.getLblWinGame().addMouseListener(onClick(this::winGame));
|
||||
view.getLblExileFromPlay().addMouseListener(onClick(this::exileCardsFromPlay));
|
||||
view.getLblRemoveFromGame().addMouseListener(onClick(this::removeCardsFromGame));
|
||||
view.getLblRiggedRoll().addMouseListener(onClick(this::riggedPlanerRoll));
|
||||
view.getLblWalkTo().addMouseListener(onClick(this::planeswalkTo));
|
||||
view.getLblAskAI().addMouseListener(onClick(this::askAI));
|
||||
view.getLblAskSimulationAI().addMouseListener(onClick(this::askSimulationAI));
|
||||
}
|
||||
public IGameController getController() {
|
||||
return matchUI.getGameController();
|
||||
@@ -66,258 +67,99 @@ public final class CDev implements ICDoc {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
private final MouseListener madUnlimited = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
togglePlayManyLandsPerTurn();
|
||||
}
|
||||
};
|
||||
private MouseListener onClick(Runnable r) {
|
||||
return new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
r.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void togglePlayManyLandsPerTurn() {
|
||||
final boolean newValue = !view.getLblUnlimitedLands().getToggled();
|
||||
getController().cheat().setCanPlayUnlimitedLands(newValue);
|
||||
update();
|
||||
}
|
||||
|
||||
private final MouseListener madViewAll = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
toggleViewAllCards();
|
||||
}
|
||||
};
|
||||
public void toggleViewAllCards() {
|
||||
final boolean newValue = !view.getLblViewAll().getToggled();
|
||||
getController().cheat().setViewAllCards(newValue);
|
||||
update();
|
||||
}
|
||||
|
||||
private final MouseListener madMana = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
generateMana();
|
||||
}
|
||||
};
|
||||
public void generateMana() {
|
||||
getController().cheat().generateMana();
|
||||
}
|
||||
|
||||
private final MouseListener madSetup = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
setupGameState();
|
||||
}
|
||||
};
|
||||
public void setupGameState() {
|
||||
getController().cheat().setupGameState();
|
||||
}
|
||||
|
||||
private final MouseListener madDump = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
dumpGameState();
|
||||
}
|
||||
};
|
||||
public void dumpGameState() {
|
||||
getController().cheat().dumpGameState();
|
||||
}
|
||||
|
||||
private final MouseListener madTutor = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
tutorForCard();
|
||||
}
|
||||
};
|
||||
public void tutorForCard() {
|
||||
getController().cheat().tutorForCard();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToHand = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
addCardToHand();
|
||||
}
|
||||
};
|
||||
public void addCardToHand() {
|
||||
getController().cheat().addCardToHand();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToLibrary = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
addCardToLibrary();
|
||||
}
|
||||
};
|
||||
public void addCardToLibrary() {
|
||||
getController().cheat().addCardToLibrary();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToGraveyard = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
addCardToGraveyard();
|
||||
}
|
||||
};
|
||||
public void addCardToGraveyard() {
|
||||
getController().cheat().addCardToGraveyard();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToExile = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
addCardToExile();
|
||||
}
|
||||
};
|
||||
public void addCardToExile() {
|
||||
getController().cheat().addCardToExile();
|
||||
}
|
||||
|
||||
private final MouseListener madCastASpell = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
castASpell();
|
||||
}
|
||||
};
|
||||
public void castASpell() {
|
||||
getController().cheat().castASpell();
|
||||
}
|
||||
|
||||
private final MouseListener madRepeatAddCard = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
repeatAddCard();
|
||||
}
|
||||
};
|
||||
public void repeatAddCard() {
|
||||
getController().cheat().repeatLastAddition();
|
||||
}
|
||||
|
||||
private final MouseListener madExileFromHand = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
exileCardsFromHand();
|
||||
}
|
||||
};
|
||||
public void exileCardsFromHand() {
|
||||
getController().cheat().exileCardsFromHand();
|
||||
}
|
||||
|
||||
private final MouseListener madAddCounter = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
addCounterToPermanent();
|
||||
}
|
||||
};
|
||||
public void addCounterToPermanent() {
|
||||
getController().cheat().addCountersToPermanent();
|
||||
}
|
||||
|
||||
private final MouseListener madSubCounter = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
removeCountersFromPermanent();
|
||||
}
|
||||
};
|
||||
public void removeCountersFromPermanent() {
|
||||
getController().cheat().removeCountersFromPermanent();
|
||||
}
|
||||
|
||||
private final MouseListener madTap = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
tapPermanent();
|
||||
}
|
||||
};
|
||||
public void tapPermanent() {
|
||||
getController().cheat().tapPermanents();
|
||||
}
|
||||
|
||||
private final MouseListener madUntap = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
untapPermanent();
|
||||
}
|
||||
};
|
||||
public void untapPermanent() {
|
||||
getController().cheat().untapPermanents();
|
||||
}
|
||||
|
||||
private final MouseListener madLife = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
setPlayerLife();
|
||||
}
|
||||
};
|
||||
public void setPlayerLife() {
|
||||
getController().cheat().setPlayerLife();
|
||||
}
|
||||
|
||||
private final MouseListener madWinGame = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
winGame();
|
||||
}
|
||||
};
|
||||
public void winGame() {
|
||||
getController().cheat().winGame();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToBattlefield = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
addCardToBattlefield();
|
||||
}
|
||||
};
|
||||
public void addCardToBattlefield() {
|
||||
getController().cheat().addCardToBattlefield();
|
||||
}
|
||||
|
||||
private final MouseListener madExileFromPlay = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
exileCardsFromPlay();
|
||||
}
|
||||
};
|
||||
public void exileCardsFromPlay() {
|
||||
getController().cheat().exileCardsFromBattlefield();
|
||||
}
|
||||
|
||||
private final MouseListener madRemoveFromGame = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
removeCardsFromGame();
|
||||
}
|
||||
};
|
||||
public void removeCardsFromGame() {
|
||||
getController().cheat().removeCardsFromGame();
|
||||
}
|
||||
|
||||
private final MouseListener madRiggedRoll = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
riggedPlanerRoll();
|
||||
}
|
||||
};
|
||||
public void riggedPlanerRoll() {
|
||||
getController().cheat().riggedPlanarRoll();
|
||||
}
|
||||
|
||||
private final MouseListener madWalkToPlane = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
planeswalkTo();
|
||||
}
|
||||
};
|
||||
public void planeswalkTo() {
|
||||
getController().cheat().planeswalkTo();
|
||||
}
|
||||
|
||||
private final MouseListener madAskAI = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
askAI();
|
||||
}
|
||||
};
|
||||
public void askAI() {
|
||||
getController().cheat().askAI();
|
||||
getController().cheat().askAI(false);
|
||||
}
|
||||
public void askSimulationAI() {
|
||||
getController().cheat().askAI(true);
|
||||
}
|
||||
|
||||
//========== End mouse listener inits
|
||||
|
||||
@@ -82,6 +82,7 @@ public class VDev implements IVDoc<CDev>, IDevListener {
|
||||
private final DevLabel lblWalkTo = new DevLabel(Localizer.getInstance().getMessage("lblWalkTo"));
|
||||
|
||||
private final DevLabel lblAskAI = new DevLabel(Localizer.getInstance().getMessage("lblAskAI"));
|
||||
private final DevLabel lblAskSimulationAI = new DevLabel(Localizer.getInstance().getMessage("lblAskSimulationAI"));
|
||||
|
||||
|
||||
private final CDev controller;
|
||||
@@ -91,7 +92,6 @@ public class VDev implements IVDoc<CDev>, IDevListener {
|
||||
public VDev(final CDev controller) {
|
||||
this.controller = controller;
|
||||
|
||||
final String constraints = "w 95%!, gap 0 0 4px 0";
|
||||
final String halfConstraints = "w 47%!, gap 0 0 4px 0";
|
||||
final String halfConstraintsLeft = halfConstraints + ", split 2";
|
||||
viewport.setOpaque(false);
|
||||
@@ -113,13 +113,14 @@ public class VDev implements IVDoc<CDev>, IDevListener {
|
||||
viewport.add(this.lblWinGame, halfConstraints);
|
||||
viewport.add(this.lblAddCounterPermanent, halfConstraintsLeft);
|
||||
viewport.add(this.lblSubCounterPermanent, halfConstraints);
|
||||
viewport.add(this.lblSetupGame, halfConstraintsLeft);
|
||||
viewport.add(this.lblDumpGame, halfConstraints);
|
||||
viewport.add(this.lblTapPermanent, halfConstraintsLeft);
|
||||
viewport.add(this.lblUntapPermanent, halfConstraints);
|
||||
viewport.add(this.lblRiggedRoll, halfConstraintsLeft);
|
||||
viewport.add(this.lblWalkTo, halfConstraints);
|
||||
viewport.add(this.lblAskAI, halfConstraintsLeft);
|
||||
viewport.add(this.lblAskSimulationAI, halfConstraintsLeft);
|
||||
viewport.add(this.lblSetupGame, halfConstraintsLeft);
|
||||
viewport.add(this.lblDumpGame, halfConstraints);
|
||||
}
|
||||
|
||||
//========= Overridden methods
|
||||
@@ -302,20 +303,23 @@ public class VDev implements IVDoc<CDev>, IDevListener {
|
||||
return this.lblAskAI;
|
||||
}
|
||||
|
||||
public DevLabel getLblAskSimulationAI() {
|
||||
return this.lblAskSimulationAI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Labels that act as buttons which control dev mode functions. Labels are
|
||||
* used to support multiline text.
|
||||
*/
|
||||
public class DevLabel extends SkinnedLabel {
|
||||
public static class DevLabel extends SkinnedLabel {
|
||||
private static final long serialVersionUID = 7917311680519060700L;
|
||||
|
||||
private FSkin.SkinColor defaultBG;
|
||||
private final FSkin.SkinColor hoverBG = FSkin.getColor(FSkin.Colors.CLR_HOVER);
|
||||
private final FSkin.SkinColor pressedBG = FSkin.getColor(FSkin.Colors.CLR_INACTIVE);
|
||||
private boolean toggled;
|
||||
private int w, h; // Width, height, radius, insets (for paintComponent)
|
||||
|
||||
private final int r, i;
|
||||
private final int r, i; // Radius, insets (for paintComponent)
|
||||
|
||||
public DevLabel(final String text0) {
|
||||
super();
|
||||
@@ -380,10 +384,10 @@ public class VDev implements IVDoc<CDev>, IDevListener {
|
||||
*/
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
this.w = this.getWidth();
|
||||
this.h = this.getHeight();
|
||||
int w = this.getWidth();
|
||||
int h = this.getHeight();
|
||||
g.setColor(this.getBackground());
|
||||
g.fillRoundRect(this.i, this.i, this.w - (2 * this.i), this.h - this.i, this.r, this.r);
|
||||
g.fillRoundRect(this.i, this.i, w - (2 * this.i), h - this.i, this.r, this.r);
|
||||
super.paintComponent(g);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user