From a492cbe985d74ebd36d24e830b59245daf23e6dc Mon Sep 17 00:00:00 2001 From: RumbleBBU Date: Tue, 11 Sep 2012 15:15:09 +0000 Subject: [PATCH] Sealed Deck mini tournaments, stage 1 (no sideboarding yet). --- .gitattributes | 2 + src/main/java/forge/AllZone.java | 19 ++ src/main/java/forge/Card.java | 3 +- src/main/java/forge/deck/Deck.java | 44 ++++ src/main/java/forge/deck/DeckGroup.java | 33 ++- .../java/forge/game/limited/GauntletMini.java | 208 +++++++++++++++++ .../gui/home/sanctioned/CSubmenuSealed.java | 62 ++--- .../gui/home/sanctioned/VSubmenuSealed.java | 2 +- .../java/forge/gui/match/GauntletWinLose.java | 211 ++++++++++++++++++ .../java/forge/gui/match/ViewWinLose.java | 4 + 10 files changed, 556 insertions(+), 32 deletions(-) create mode 100644 src/main/java/forge/game/limited/GauntletMini.java create mode 100644 src/main/java/forge/gui/match/GauntletWinLose.java diff --git a/.gitattributes b/.gitattributes index d0e95fc5713..9d3d680b211 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12191,6 +12191,7 @@ src/main/java/forge/game/limited/CardRatings.java -text src/main/java/forge/game/limited/CreatureComparator.java -text src/main/java/forge/game/limited/CustomLimited.java svneol=native#text/plain src/main/java/forge/game/limited/DeckColors.java svneol=native#text/plain +src/main/java/forge/game/limited/GauntletMini.java -text src/main/java/forge/game/limited/IBoosterDraft.java svneol=native#text/plain src/main/java/forge/game/limited/LimitedDeck.java -text src/main/java/forge/game/limited/ReadDraftRankings.java -text @@ -12357,6 +12358,7 @@ src/main/java/forge/gui/home/utilities/VSubmenuUtilities.java -text src/main/java/forge/gui/home/utilities/package-info.java svneol=native#text/plain src/main/java/forge/gui/match/CMatchUI.java -text src/main/java/forge/gui/match/ControlWinLose.java -text +src/main/java/forge/gui/match/GauntletWinLose.java -text src/main/java/forge/gui/match/QuestWinLoseCardViewer.java -text src/main/java/forge/gui/match/QuestWinLoseHandler.java -text src/main/java/forge/gui/match/VMatchUI.java -text diff --git a/src/main/java/forge/AllZone.java b/src/main/java/forge/AllZone.java index 80bc047bc68..be4c2e5420b 100644 --- a/src/main/java/forge/AllZone.java +++ b/src/main/java/forge/AllZone.java @@ -35,6 +35,8 @@ import forge.game.zone.ZoneType; import forge.properties.ForgeProps; import forge.properties.NewConstants; import forge.quest.QuestController; +import forge.game.limited.GauntletMini; + /** * Please use public getters and setters instead of direct field access. @@ -58,6 +60,9 @@ public final class AllZone { /** Global questData. */ private static forge.quest.QuestController quest = null; + /** Global gauntletData. */ + private static forge.game.limited.GauntletMini gauntlet = null; + /** Constant NAME_CHANGER. */ private static final NameChanger NAME_CHANGER = new NameChanger(); @@ -132,7 +137,21 @@ public final class AllZone { return AllZone.quest; } + /** + *

+ * getGauntletData. + *

+ * + * @return a {@link forge.quest.data.QuestData} object. + * @since 1.0.15 + */ + public static forge.game.limited.GauntletMini getGauntlet() { + if (gauntlet == null) { + gauntlet = new GauntletMini(); + } + return AllZone.gauntlet; + } /** *

diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index 904aea9774f..cac753accee 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -8787,8 +8787,7 @@ public class Card extends GameEntity implements Comparable { } if (kw.equals("Protection from colored spells") - && (source.isInstant() || source.isSorcery() - || (source.isAura() && !source.isInZone(ZoneType.Battlefield))) + && (source.isInstant() || source.isSorcery() || source.isAura()) && CardFactoryUtil.isColored(source)) { return true; } diff --git a/src/main/java/forge/deck/Deck.java b/src/main/java/forge/deck/Deck.java index 5413a3823e9..304dc6cf9a9 100644 --- a/src/main/java/forge/deck/Deck.java +++ b/src/main/java/forge/deck/Deck.java @@ -36,6 +36,7 @@ import forge.deck.io.DeckSerializer; import forge.gui.deckeditor.tables.TableSorter; import forge.item.CardPrinted; import forge.item.ItemPoolView; +import forge.game.limited.ReadDraftRankings; import forge.util.FileSection; import forge.util.FileUtil; import forge.util.closures.Lambda1; @@ -271,6 +272,49 @@ public class Deck extends DeckBase implements Serializable { return out; } + /** + *

+ * getDraftValue. + *

+ * + * @return the combined draft values of cards in the main deck + */ + public double getDraftValue() { + + double value = 0; + double divider = 0; + + ReadDraftRankings ranker = new ReadDraftRankings(); + + if (this.getMain().isEmpty()) { + return 0; + } + + double best = 1.0; + + for (int i = 0; i < this.getMain().toForgeCardList().size(); i++) { + CardPrinted evalCard = this.getMain().toFlatList().get(i); + if (ranker.getRanking(evalCard.getName(), evalCard.getEdition()) != null) { + double add = ranker.getRanking(evalCard.getName(), evalCard.getEdition()); + // System.out.println(this.getMain().toFlatList().get(i).getName() + " is worth " + add); + value += add; + divider += 1.0; + if (best > add) { + best = add; + } + } + } + + if (divider == 0 || value == 0) { + return 0; + } + + value /= divider; + + return (20.0 / (best + (2 * value))); + } + + public static final Lambda1 FN_NAME_SELECTOR = new Lambda1() { @Override public String apply(Deck arg1) { diff --git a/src/main/java/forge/deck/DeckGroup.java b/src/main/java/forge/deck/DeckGroup.java index 123cd8f65a5..83153e125a7 100644 --- a/src/main/java/forge/deck/DeckGroup.java +++ b/src/main/java/forge/deck/DeckGroup.java @@ -18,6 +18,8 @@ package forge.deck; import java.util.ArrayList; +import java.util.TreeMap; +// import java.lang.Double; import java.util.List; @@ -42,7 +44,7 @@ public class DeckGroup extends DeckBase { private static final long serialVersionUID = -1628725522049635829L; private Deck humanDeck; - private final List aiDecks = new ArrayList(); + private List aiDecks = new ArrayList(); /** * Gets the human deck. @@ -71,6 +73,35 @@ public class DeckGroup extends DeckBase { this.humanDeck = humanDeck; } + /** + * Evaluate and 'rank' the ai decks. + * + * + */ + public final void rankAiDecks() { + if (this.aiDecks.size() < 2) { + return; + } + + // double [] draftValues = new double [this.aiDecks.size()]; + TreeMap draftData = new TreeMap(); + + for (int i = 0; i < this.aiDecks.size(); i++) { + // draftValues[i] = this.aiDecks.get(i).getDraftValue(); + draftData.put(new Double(this.aiDecks.get(i).getDraftValue()), this.aiDecks.get(i)); + // System.out.println("\nAI Deck " + i + "(" + this.aiDecks.get(i) + ") has draft value:" + this.aiDecks.get(i).getDraftValue() + "\n\n"); + } + + List sortedData = new ArrayList(draftData.values()); + + for (int j = 0; j < sortedData.size(); j++) { + Deck getDeck = sortedData.get(j); + } + + this.aiDecks = sortedData; + + } + @Override protected void cloneFieldsTo(final DeckBase clone) { super.cloneFieldsTo(clone); diff --git a/src/main/java/forge/game/limited/GauntletMini.java b/src/main/java/forge/game/limited/GauntletMini.java new file mode 100644 index 00000000000..2ad91faad92 --- /dev/null +++ b/src/main/java/forge/game/limited/GauntletMini.java @@ -0,0 +1,208 @@ +/* + * Forge: Play Magic: the Gathering. + * Copyright (C) 2011 Forge Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package forge.game.limited; + +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; + +import forge.Constant; +import forge.AllZone; +import forge.Command; +import forge.Singletons; +import forge.control.FControl; +import forge.deck.Deck; +import forge.deck.DeckBase; +import forge.deck.DeckGroup; +import forge.game.GameNew; +import forge.game.GameType; +import forge.gui.GuiUtils; +import forge.gui.SOverlayUtils; +import forge.gui.deckeditor.CDeckEditorUI; +import forge.gui.deckeditor.controllers.ACEditorBase; +import forge.gui.deckeditor.controllers.CEditorLimited; +import forge.gui.framework.ICDoc; +import forge.gui.toolbox.FSkin; +import forge.item.CardPrinted; +import forge.item.ItemPool; +import forge.properties.ForgeProps; +import forge.properties.NewConstants; +import forge.util.TextUtil; + +/** + *

+ * GauntletMini class. + *

+ * + * @author Forge + * @version $Id: GauntletMini.java $ + * @since 1.2.xx + */ +public class GauntletMini { + + private int rounds; + private Deck humanDeck; + private int currentRound; + private int wins; + private int losses; + + // private final String humanName; + /** + * TODO: Write javadoc for Constructor. + */ + public void gauntletMini() { + currentRound = 1; + wins = 0; + losses = 0; + // humanName = hName; + } + + /** + * TODO: Write javadoc. + * @param gameRounds + * the number of rounds in the mini tournament + */ + + public void setRounds(int gameRounds) { + rounds = gameRounds; + } + + /** + * TODO: Write javadoc. + * @param hDeck + * the human deck for this tournament + */ + public void setHumanDeck(Deck hDeck) { + humanDeck = hDeck; + } + + /** + * TODO: Write javadoc. + */ + public void resetCurrentRound() { + wins = 0; + losses = 0; + Constant.Runtime.HUMAN_DECK[0] = humanDeck; + Constant.Runtime.COMPUTER_DECK[0] = Singletons.getModel().getDecks().getSealed().get(humanDeck.getName()).getAiDecks().get(0); + currentRound = 1; + } + + + /** + * TODO: Write javadoc. + */ + public void nextRound() { + + // System.out.println("Moving from round " + currentRound + " to round " + currentRound + 1 + " of " + rounds); + if (currentRound >= rounds) { + currentRound = rounds; + return; + } + + Constant.Runtime.HUMAN_DECK[0] = humanDeck; + Constant.Runtime.COMPUTER_DECK[0] = Singletons.getModel().getDecks().getSealed().get(humanDeck.getName()).getAiDecks().get(currentRound); + currentRound += 1; + + } + + /** + * TODO: Write javadoc for this method. + * @param args + */ + public void launch() { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + SOverlayUtils.startGameOverlay(); + SOverlayUtils.showOverlay(); + } + }); + + final SwingWorker worker = new SwingWorker() { + @Override + + public Object doInBackground() { + + Constant.Runtime.setGameType(GameType.Sealed); + + GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]); + + return null; + } + + @Override + public void done() { + SOverlayUtils.hideOverlay(); + } + }; + worker.execute(); + } + + + /** + * TODO: Write javadoc for this method. + * @param args + * @return int, number of rounds in the Sealed Deck tournament + */ + public final int getRounds() { + return rounds; + } + + /** + * TODO: Write javadoc for this method. + * @param args + * @return int, number of rounds in the Sealed Deck tournament + */ + public final int getCurrentRound() { + return currentRound; + } + + /** + * TODO: Write javadoc for this method. + * @param args + */ + public void addWin() { + wins++; + } + + /** + * TODO: Write javadoc for this method. + * @param args + */ + public void addLoss() { + losses++; + } + + /** + * TODO: Write javadoc for this method. + * @param args + */ + public final int getWins() { + return wins; + } + + /** + * TODO: Write javadoc for this method. + * @param args + */ + public final int getLosses() { + return losses; + } + + +} + diff --git a/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java b/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java index c58599c8247..bb6f4e49244 100644 --- a/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java +++ b/src/main/java/forge/gui/home/sanctioned/CSubmenuSealed.java @@ -13,6 +13,7 @@ import javax.swing.SwingWorker; import org.apache.commons.lang3.StringUtils; +import forge.AllZone; import forge.Command; import forge.Constant; import forge.Singletons; @@ -24,6 +25,7 @@ import forge.game.GameNew; import forge.game.GameType; import forge.game.limited.SealedDeck; import forge.game.limited.SealedDeckFormat; +import forge.game.limited.GauntletMini; import forge.gui.GuiUtils; import forge.gui.SOverlayUtils; import forge.gui.deckeditor.CDeckEditorUI; @@ -125,37 +127,19 @@ public enum CSubmenuSealed implements ICDoc { return; } - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - SOverlayUtils.startGameOverlay(); - SOverlayUtils.showOverlay(); - } - }); + int rounds = Singletons.getModel().getDecks().getSealed().get(human.getName()).getAiDecks().size(); + // System.out.println("There are " + rounds + " rounds in this game."); - final SwingWorker worker = new SwingWorker() { - @Override - public Object doInBackground() { - Constant.Runtime.HUMAN_DECK[0] = human; - Constant.Runtime.COMPUTER_DECK[0] = Singletons.getModel().getDecks().getSealed().get(human.getName()).getAiDecks().get(0); - - Constant.Runtime.setGameType(GameType.Sealed); - - GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]); - return null; - } - - @Override - public void done() { - SOverlayUtils.hideOverlay(); - } - }; - worker.execute(); + AllZone.getGauntlet().setRounds(rounds); + AllZone.getGauntlet().setHumanDeck(human); + AllZone.getGauntlet().resetCurrentRound(); + AllZone.getGauntlet().launch(); } /** */ @SuppressWarnings("unchecked") private void setupSealed() { + final ArrayList sealedTypes = new ArrayList(); sealedTypes.add("Full Cardpool"); sealedTypes.add("Block / Set"); @@ -186,6 +170,16 @@ public enum CSubmenuSealed implements ICDoc { return; } + final Integer[] integers = new Integer[5]; + + for (int i = 0; i <= 4; i++) { + integers[i] = Integer.valueOf(i + 1); + } + + Integer rounds = GuiUtils.chooseOne("How many rounds?", integers); + + // System.out.println("You selected " + rounds + " rounds."); + final String sDeckName = JOptionPane.showInputDialog(null, ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_MSG), ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_TTL), @@ -195,10 +189,12 @@ public enum CSubmenuSealed implements ICDoc { return; } - // May check for name uniqueness here + // NOTE: Here we should check if a similarly-named tournament already exists, + // and if it does, delete it first! -BBU + final ItemPool sDeck = sd.getCardpool(); - final ItemPool sDeck2 = sd.getCardpool(); + ItemPool aiDecks = sd.getCardpool(); final Deck deck = new Deck(sDeckName); deck.getSideboard().addAll(sDeck); @@ -209,7 +205,17 @@ public enum CSubmenuSealed implements ICDoc { final DeckGroup sealed = new DeckGroup(sDeckName); sealed.setHumanDeck(deck); - sealed.addAiDeck(new SealedDeck(sDeck2.toFlatList()).buildDeck()); + for (int i = 0; i < rounds; i++) { + if (i > 0) { + // Re-randomize for AI decks beyond the first... + aiDecks = sd.getCardpool(); + } + sealed.addAiDeck(new SealedDeck(aiDecks.toFlatList()).buildDeck()); + } + + // Rank the AI decks + sealed.rankAiDecks(); + Singletons.getModel().getDecks().getSealed().add(sealed); final ACEditorBase editor = (ACEditorBase) new CEditorLimited( diff --git a/src/main/java/forge/gui/home/sanctioned/VSubmenuSealed.java b/src/main/java/forge/gui/home/sanctioned/VSubmenuSealed.java index 35216c149aa..c619577b437 100644 --- a/src/main/java/forge/gui/home/sanctioned/VSubmenuSealed.java +++ b/src/main/java/forge/gui/home/sanctioned/VSubmenuSealed.java @@ -49,7 +49,7 @@ public enum VSubmenuSealed implements IVSubmenu { private final DeckLister lstDecks = new DeckLister(GameType.Sealed); private final JLabel btnBuildDeck = new FLabel.Builder() .fontSize(16) - .opaque(true).hoverable(true).text("Build a Sealed Deck").build(); + .opaque(true).hoverable(true).text("Build a Sealed Deck Game").build(); private final JLabel btnDirections = new FLabel.Builder() .fontSize(16) .text("Click For Directions").fontAlign(SwingConstants.CENTER).build(); diff --git a/src/main/java/forge/gui/match/GauntletWinLose.java b/src/main/java/forge/gui/match/GauntletWinLose.java new file mode 100644 index 00000000000..2bdbfc879fc --- /dev/null +++ b/src/main/java/forge/gui/match/GauntletWinLose.java @@ -0,0 +1,211 @@ +package forge.gui.match; + +/** Forge: Play Magic: the Gathering. + * Copyright (C) 2011 Forge Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import forge.AllZone; +import forge.Singletons; +import javax.swing.JLabel; + +import forge.gui.toolbox.FSkin; +import forge.model.FMatchState; +import forge.properties.ForgePreferences.FPref; +import forge.game.limited.GauntletMini; + +import java.awt.Color; +import java.awt.Dimension; + +import javax.swing.BorderFactory; +import javax.swing.SwingConstants; + +/** + * TODO: Write javadoc for this type. + * + */ +public class GauntletWinLose extends ControlWinLose { + + private final transient boolean wonMatch; + private transient ViewWinLose view; + private GauntletMini gauntlet; + private boolean nextRound = false; + + /** String constraint parameters. */ + private static final String CONSTRAINTS_TITLE = "w 95%!, gap 0 0 20px 10px"; + private static final String CONSTRAINTS_TEXT = "w 95%!,, h 180px!, gap 0 0 0 20px"; + + private transient JLabel lblTemp1; + private transient JLabel lblTemp2; + private final transient FMatchState matchState; + + /** + * Instantiates a new gauntlet win/lose handler. + * + * @param view0 ViewWinLose object + */ + public GauntletWinLose(final ViewWinLose view0) { + super(view0); + this.view = view0; + gauntlet = AllZone.getGauntlet(); + matchState = Singletons.getModel().getMatchState(); + this.wonMatch = matchState.isMatchWonBy(AllZone.getHumanPlayer().getName()); + } + + + /** + *

+ * populateCustomPanel. + *

+ * @return true, if successful + */ + @Override + public final boolean populateCustomPanel() { + + // view.getBtnRestart().setVisible(false); + // Deliberate; allow replaying bad tournaments + + //TODO: do per-game actions like ante here... + + resetView(); + nextRound = false; + if (Singletons.getModel().getMatchState().hasWonLastGame(AllZone.getHumanPlayer().getName())) { + gauntlet.addWin(); + } + else { + gauntlet.addLoss(); + } + + if (!matchState.isMatchOver()) { + showTournamentInfo("Tournament Info"); + return true; + } else { + if (this.wonMatch) { + if (gauntlet.getCurrentRound() < gauntlet.getRounds()) { + view.getBtnContinue().setText("Next Round (" + (gauntlet.getCurrentRound() + 1) + + "/" + gauntlet.getRounds() + ")"); + nextRound = true; + view.getBtnContinue().setEnabled(true); + showTournamentInfo("YOU HAVE WON ROUND " + gauntlet.getCurrentRound() + "/" + + gauntlet.getRounds()); + } + else { + showTournamentInfo("***CONGRATULATIONS! YOU HAVE WON THE TOURNAMENT!***"); + } + } else { + showTournamentInfo("YOU HAVE LOST ON ROUND " + gauntlet.getCurrentRound() + "/" + + gauntlet.getRounds()); + view.getBtnContinue().setVisible(false); + } + } + + + + return true; + } + + private void showTournamentInfo(final String newTitle) { + + this.lblTemp1 = new TitleLabel(newTitle); + this.lblTemp2 = new JLabel("Round: " + gauntlet.getCurrentRound() + "/" + gauntlet.getRounds() + + " Total Wins: " + gauntlet.getWins() + + " Total Losses: " + gauntlet.getLosses()); + this.lblTemp2.setHorizontalAlignment(SwingConstants.CENTER); + this.lblTemp2.setFont(FSkin.getFont(14)); + this.lblTemp2.setForeground(Color.white); + this.lblTemp2.setIconTextGap(50); + this.getView().getPnlCustom().add(this.lblTemp1, GauntletWinLose.CONSTRAINTS_TITLE); + this.getView().getPnlCustom().add(this.lblTemp2, GauntletWinLose.CONSTRAINTS_TEXT); + } + + /** + *

+ * actionOnRestart. + *

+ * When "quit" button is pressed, this method restarts the whole tournament. + * + */ + @Override + public final void actionOnRestart() { + resetView(); + gauntlet.resetCurrentRound(); + super.actionOnRestart(); + } + + /** + *

+ * actionOnQuit. + *

+ * When "quit" button is pressed, we exit the tournament. + * + */ + @Override + public final void actionOnQuit() { + resetView(); + gauntlet.resetCurrentRound(); + super.actionOnQuit(); + } + + /** + *

+ * actionOnContinue. + *

+ * When "continue / next round" button is pressed, we either continue + * to the next game in the current match or (next round) proceed to + * the next round in the mini tournament. + * + */ + @Override + public final void actionOnContinue() { + resetView(); + + if (nextRound) { + gauntlet.nextRound(); + super.actionOnRestart(); + } + else { + super.actionOnContinue(); + } + } + + /** + *

+ * ResetView + *

+ * Restore the default texts to the win/lose panel buttons. + * + */ + private void resetView() { + view.getBtnQuit().setText("Quit"); + view.getBtnContinue().setText("Continue"); + } + + /** + * JLabel header, adapted from QuestWinLoseHandler. + * + */ + @SuppressWarnings("serial") + private class TitleLabel extends JLabel { + TitleLabel(final String msg) { + super(msg); + this.setFont(FSkin.getFont(16)); + this.setPreferredSize(new Dimension(200, 40)); + this.setHorizontalAlignment(SwingConstants.CENTER); + this.setForeground(Color.white); + this.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.white)); + } + } + +} diff --git a/src/main/java/forge/gui/match/ViewWinLose.java b/src/main/java/forge/gui/match/ViewWinLose.java index 86c8d603b2c..8b68a92c794 100644 --- a/src/main/java/forge/gui/match/ViewWinLose.java +++ b/src/main/java/forge/gui/match/ViewWinLose.java @@ -58,6 +58,10 @@ public class ViewWinLose { if (Constant.Runtime.getGameType() == GameType.Quest) { control = new QuestWinLoseHandler(this); } + else if (Constant.Runtime.getGameType() == GameType.Sealed) { + System.out.println("Sealed game over!"); + control = new ControlWinLose(this); + } else { control = new ControlWinLose(this); }