From 71b7dc26c79cffd09e9efe0c7a91a31d06ae1aff Mon Sep 17 00:00:00 2001 From: Plopman Date: Wed, 17 Jul 2013 20:31:20 +0200 Subject: [PATCH 1/7] [MOR]Added Gilt-Leaf Archdruid --- .../sets/morningtide/GiltLeafArchdruid.java | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/morningtide/GiltLeafArchdruid.java diff --git a/Mage.Sets/src/mage/sets/morningtide/GiltLeafArchdruid.java b/Mage.Sets/src/mage/sets/morningtide/GiltLeafArchdruid.java new file mode 100644 index 0000000000..f2fb57d6fe --- /dev/null +++ b/Mage.Sets/src/mage/sets/morningtide/GiltLeafArchdruid.java @@ -0,0 +1,127 @@ +/* + * 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.sets.morningtide; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SpellCastTriggeredAbility; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.SubLayer; +import mage.constants.Zone; +import mage.filter.FilterSpell; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPlayer; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author Plopman + */ +public class GiltLeafArchdruid extends CardImpl { + + private static final FilterSpell filterSpell = new FilterSpell("a Druid spell"); + + static { + filterSpell.add(new SubtypePredicate("Druid")); + } + + public GiltLeafArchdruid(UUID ownerId) { + super(ownerId, 124, "Gilt-Leaf Archdruid", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{G}{G}"); + this.expansionSetCode = "MOR"; + this.subtype.add("Elf"); + this.subtype.add("Druid"); + + this.color.setGreen(true); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Whenever you cast a Druid spell, you may draw a card. + this.addAbility(new SpellCastTriggeredAbility(new DrawCardControllerEffect(1), filterSpell, true)); + // Tap seven untapped Druids you control: Gain control of all lands target player controls. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GainControlAllLandsEffect(Duration.EndOfGame), new TapTargetCost(new TargetControlledCreaturePermanent(7, 7, new FilterControlledCreaturePermanent("Druid", "Druids you control"), true))); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); + } + + public GiltLeafArchdruid(final GiltLeafArchdruid card) { + super(card); + } + + @Override + public GiltLeafArchdruid copy() { + return new GiltLeafArchdruid(this); + } +} + +class GainControlAllLandsEffect extends ContinuousEffectImpl { + + public GainControlAllLandsEffect(Duration duration) { + super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); + } + + public GainControlAllLandsEffect(final GainControlAllLandsEffect effect) { + super(effect); + } + + @Override + public GainControlAllLandsEffect copy() { + return new GainControlAllLandsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + if (targetPointer != null) { + for(Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), targetPointer.getFirst(game, source), game)){ + if (permanent != null) { + permanent.changeControllerId(source.getControllerId(), game); + } + } + } + return false; + } + + @Override + public String getText(Mode mode) { + return "Gain control of all lands target player controls"; + } +} From 5e3447f4c8e9436ba264b6234e2c2d4a351dfc8b Mon Sep 17 00:00:00 2001 From: Plopman Date: Wed, 17 Jul 2013 20:32:21 +0200 Subject: [PATCH 2/7] [Commander] added Commander and CastCommanderAbility --- .../common/CastCommanderAbility.java | 108 +++++++++++ Mage/src/mage/game/command/Commander.java | 174 ++++++++++++++++++ 2 files changed, 282 insertions(+) create mode 100644 Mage/src/mage/abilities/common/CastCommanderAbility.java create mode 100644 Mage/src/mage/game/command/Commander.java diff --git a/Mage/src/mage/abilities/common/CastCommanderAbility.java b/Mage/src/mage/abilities/common/CastCommanderAbility.java new file mode 100644 index 0000000000..5597164aa1 --- /dev/null +++ b/Mage/src/mage/abilities/common/CastCommanderAbility.java @@ -0,0 +1,108 @@ +/* + * 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.abilities.common; + + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.ActivatedAbilityImpl; +import mage.abilities.SpellAbility; +import mage.abilities.costs.mana.ManaCosts; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.constants.Outcome; +import mage.constants.TimingRule; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.command.Commander; +import mage.players.Player; +import mage.target.Target; + +/** + * + * @author Plopman + */ +public class CastCommanderAbility extends ActivatedAbilityImpl { + + public CastCommanderAbility(Card card) { + super(Zone.COMMAND, new CastCommanderEffect(), card.getManaCost()); + this.timing = TimingRule.SORCERY; + this.usesStack = false; + this.controllerId = card.getOwnerId(); + this.sourceId = card.getId(); + //TODO : add +2 each time you player cast it + } + + public CastCommanderAbility(final CastCommanderAbility ability) { + super(ability); + } + + @Override + public CastCommanderAbility copy() { + return new CastCommanderAbility(this); + } + +} + +class CastCommanderEffect extends OneShotEffect { + + public CastCommanderEffect() { + super(Outcome.Benefit); + staticText = "cast commander"; + } + + public CastCommanderEffect(final CastCommanderEffect effect) { + super(effect); + } + + @Override + public CastCommanderEffect copy() { + return new CastCommanderEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + MageObject object = game.getObject(source.getSourceId()); + if (object != null && object instanceof Commander) { + Commander commander = (Commander)object; + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + SpellAbility spellAbility = commander.getCard().getSpellAbility(); + + spellAbility.clear(); + int amount = source.getManaCostsToPay().getX(); + spellAbility.getManaCostsToPay().setX(amount); + for (Target target : spellAbility.getTargets()) { + target.setRequired(true); + } + return controller.cast(spellAbility, game, true); + } + } + return false; + } +} \ No newline at end of file diff --git a/Mage/src/mage/game/command/Commander.java b/Mage/src/mage/game/command/Commander.java new file mode 100644 index 0000000000..cc12e56ee8 --- /dev/null +++ b/Mage/src/mage/game/command/Commander.java @@ -0,0 +1,174 @@ +/* +* 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.command; + +import java.util.List; +import java.util.UUID; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Abilities; +import mage.abilities.AbilitiesImpl; +import mage.abilities.Ability; +import mage.abilities.common.CastCommanderAbility; +import mage.abilities.costs.mana.ManaCost; +import mage.abilities.costs.mana.ManaCosts; +import mage.cards.Card; +import mage.constants.CardType; +import mage.game.Game; + +/** + * + * @author Plopman + */ + + +public class Commander implements CommandObject{ + + private Card card; + private Abilities abilites = new AbilitiesImpl(); + + + public Commander(Card card){ + this.card = card; + abilites.add(new CastCommanderAbility(card)); + } + + private Commander(Commander copy) { + this.card = copy.card; + } + + public Card getCard(){ + return card; + } + + @Override + public UUID getSourceId() { + return card.getId(); + } + + @Override + public UUID getControllerId() { + return card.getOwnerId(); + } + + @Override + public void assignNewId() { + } + + @Override + public CommandObject copy() { + return new Commander(this); + } + + @Override + public String getName() { + return card.getName(); + } + + @Override + public void setName(String name) { + + } + + @Override + public List getCardType() { + return card.getCardType(); + } + + @Override + public List getSubtype() { + return card.getSubtype(); + } + + @Override + public boolean hasSubtype(String subtype) { + return card.hasSubtype(subtype); + } + + @Override + public List getSupertype() { + return card.getSubtype(); + } + + @Override + public Abilities getAbilities() { + return abilites; + } + + @Override + public ObjectColor getColor() { + return card.getColor(); + } + + @Override + public ManaCosts getManaCost() { + return card.getManaCost(); + } + + @Override + public MageInt getPower() { + return card.getPower(); + } + + @Override + public MageInt getToughness() { + return card.getToughness(); + } + + @Override + public void adjustChoices(Ability ability, Game game) { + } + + @Override + public void adjustCosts(Ability ability, Game game) { + } + + @Override + public void adjustTargets(Ability ability, Game game) { + } + + @Override + public void setCopy(boolean isCopy) { + } + + @Override + public boolean isCopy() { + return false; + } + + @Override + public UUID getId() { + return card.getId(); + } + + @Override + public String getImageName() { + return card.getImageName(); + } + +} From f64aa7e6ae1a1ae3e2ba4a1aeed356c5adf6d122 Mon Sep 17 00:00:00 2001 From: Plopman Date: Wed, 17 Jul 2013 20:33:25 +0200 Subject: [PATCH 3/7] [Commander] Added CommandObjectView and change EmblemView (implements commandObjectView) --- .../src/mage/view/CommandObjectView.java | 47 +++++++++++++++++++ Mage.Common/src/mage/view/EmblemView.java | 6 ++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 Mage.Common/src/mage/view/CommandObjectView.java diff --git a/Mage.Common/src/mage/view/CommandObjectView.java b/Mage.Common/src/mage/view/CommandObjectView.java new file mode 100644 index 0000000000..4059708509 --- /dev/null +++ b/Mage.Common/src/mage/view/CommandObjectView.java @@ -0,0 +1,47 @@ +/* +* 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.view; + +import java.io.Serializable; +import java.util.List; +import java.util.UUID; + +/** + * + * @author Plopman + */ +public interface CommandObjectView extends Serializable { + public String getExpansionSetCode(); + + public String getName(); + + public UUID getId(); + + public List getRules(); +} diff --git a/Mage.Common/src/mage/view/EmblemView.java b/Mage.Common/src/mage/view/EmblemView.java index 0f29713a91..db60b00fc9 100644 --- a/Mage.Common/src/mage/view/EmblemView.java +++ b/Mage.Common/src/mage/view/EmblemView.java @@ -10,7 +10,7 @@ import java.util.UUID; /** * @author noxx */ -public class EmblemView implements Serializable { +public class EmblemView implements CommandObjectView, Serializable { protected UUID id; protected String name; @@ -24,18 +24,22 @@ public class EmblemView implements Serializable { rules = emblem.getAbilities().getRules(sourceCard.getName()); } + @Override public String getExpansionSetCode() { return expansionSetCode; } + @Override public String getName() { return name; } + @Override public UUID getId() { return id; } + @Override public List getRules() { return rules; } From 930e70fbbb7db7b6080bf43e364b116fe718af2f Mon Sep 17 00:00:00 2001 From: Plopman Date: Wed, 17 Jul 2013 20:33:58 +0200 Subject: [PATCH 4/7] [Commander] Added CommanderView --- Mage.Common/src/mage/view/CommanderView.java | 48 ++++++++++++++++++++ Mage/src/mage/constants/MageObjectType.java | 3 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 Mage.Common/src/mage/view/CommanderView.java diff --git a/Mage.Common/src/mage/view/CommanderView.java b/Mage.Common/src/mage/view/CommanderView.java new file mode 100644 index 0000000000..fb18d44dfc --- /dev/null +++ b/Mage.Common/src/mage/view/CommanderView.java @@ -0,0 +1,48 @@ +/* +* 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.view; + +import java.io.Serializable; +import mage.cards.Card; +import mage.constants.MageObjectType; +import mage.game.command.Commander; + +/** + * + * @author Plopman + */ +public class CommanderView extends CardView implements CommandObjectView, Serializable{ + + public CommanderView(Commander commander, Card sourceCard) { + super(sourceCard); + rules.addAll(commander.getAbilities().getRules(sourceCard.getName())); + this.mageObjectType = MageObjectType.COMMANDER; + } + + +} diff --git a/Mage/src/mage/constants/MageObjectType.java b/Mage/src/mage/constants/MageObjectType.java index a478dfbd97..7afa5f3393 100644 --- a/Mage/src/mage/constants/MageObjectType.java +++ b/Mage/src/mage/constants/MageObjectType.java @@ -31,7 +31,8 @@ public enum MageObjectType { TOKEN ("Token", true, true), SPELL ("Spell", false, false), PERMANENT ("Permanent", true, true), - EMBLEM ("Emblem", false, false); + EMBLEM ("Emblem", false, false), + COMMANDER ("Commander", false, false); private String text; private boolean permanent; From e6847a472d1b24e3e8a401bb003c28d26bd746bd Mon Sep 17 00:00:00 2001 From: Plopman Date: Wed, 17 Jul 2013 20:35:52 +0200 Subject: [PATCH 5/7] [Commander] Display Commander in client --- .../java/mage/client/game/PlayerPanelExt.java | 2 +- .../java/mage/client/util/CardsViewUtil.java | 16 ++++++++++------ Mage.Common/src/mage/view/PlayerView.java | 18 ++++++++++++++---- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index c7938ddacf..487e9a6add 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -651,7 +651,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { } private void btnCommandZoneActionPerformed(java.awt.event.ActionEvent evt) { - DialogManager.getManager(gameId).showEmblemsDialog(CardsViewUtil.convertEmblems(player.getEmblemList()), bigCard, gameId); + DialogManager.getManager(gameId).showEmblemsDialog(CardsViewUtil.convertCommandObject(player.getCommadObjectList()), bigCard, gameId); } private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed diff --git a/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java b/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java index 56eca3d5b0..a3c28e8a1f 100644 --- a/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java +++ b/Mage.Client/src/main/java/mage/client/util/CardsViewUtil.java @@ -28,13 +28,12 @@ package mage.client.util; +import java.util.List; import mage.cards.Card; import mage.cards.repository.CardInfo; import mage.cards.repository.CardRepository; import mage.view.*; -import java.util.List; - /** * * @author BetaSteward_at_googlemail.com @@ -55,12 +54,17 @@ public class CardsViewUtil { return cards; } - public static CardsView convertEmblems(List view) { + public static CardsView convertCommandObject(List view) { CardsView cards = new CardsView(); - for (EmblemView emblem : view) { - CardView cardView = new CardView(emblem); - cards.put(emblem.getId(), cardView); + for (CommandObjectView commandObject : view) { + if(commandObject instanceof EmblemView ){ + CardView cardView = new CardView((EmblemView)commandObject); + cards.put(commandObject.getId(), cardView); + } + else if(commandObject instanceof CommanderView ){ + cards.put(commandObject.getId(),(CommanderView)commandObject); + } } return cards; diff --git a/Mage.Common/src/mage/view/PlayerView.java b/Mage.Common/src/mage/view/PlayerView.java index 711e037d85..9b10b0d376 100644 --- a/Mage.Common/src/mage/view/PlayerView.java +++ b/Mage.Common/src/mage/view/PlayerView.java @@ -39,6 +39,7 @@ import mage.players.Player; import java.io.Serializable; import java.util.*; +import mage.game.command.Commander; /** * @@ -61,7 +62,7 @@ public class PlayerView implements Serializable { private Map battlefield = new LinkedHashMap(); private CardView topCard; private UserDataView userDataView; - private List emblemList = new ArrayList(); + private List commandList = new ArrayList(); private List attachments = new ArrayList(); private int statesSavedSize; private int priorityTimeLeft; @@ -100,7 +101,16 @@ public class PlayerView implements Serializable { if (emblem.getControllerId().equals(this.playerId)) { Card sourceCard = game.getCard(((CommandObject)emblem).getSourceId()); if (sourceCard != null) { - emblemList.add(new EmblemView(emblem, sourceCard)); + commandList.add(new EmblemView(emblem, sourceCard)); + } + } + } + else if(commandObject instanceof Commander){ + Commander commander = (Commander)commandObject; + if(commander.getControllerId().equals(this.playerId)){ + Card sourceCard = game.getCard(commander.getSourceId()); + if(sourceCard != null){ + commandList.add(new CommanderView(commander, sourceCard)); } } } @@ -180,8 +190,8 @@ public class PlayerView implements Serializable { return this.userDataView; } - public List getEmblemList() { - return emblemList; + public List getCommadObjectList() { + return commandList; } public List getAttachments() { From 9499c65fe6c31b2b59a2e4070b420c772c9e62e5 Mon Sep 17 00:00:00 2001 From: Plopman Date: Wed, 17 Jul 2013 20:37:31 +0200 Subject: [PATCH 6/7] [Commander] Added possibility to cast Commander --- Mage/src/mage/cards/CardImpl.java | 9 +++++++++ Mage/src/mage/game/Game.java | 2 ++ Mage/src/mage/game/GameImpl.java | 22 +++++++++++++++++++++- Mage/src/mage/game/GameState.java | 9 +++++---- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Mage/src/mage/cards/CardImpl.java b/Mage/src/mage/cards/CardImpl.java index 1f607acb50..20aba69541 100644 --- a/Mage/src/mage/cards/CardImpl.java +++ b/Mage/src/mage/cards/CardImpl.java @@ -50,6 +50,7 @@ import org.apache.log4j.Logger; import java.lang.reflect.Constructor; import java.util.*; import mage.constants.SpellAbilityType; +import mage.game.command.Commander; public abstract class CardImpl> extends MageObjectImpl implements Card { @@ -290,6 +291,7 @@ public abstract class CardImpl> extends MageObjectImpl case OUTSIDE: game.getPlayer(ownerId).getSideboard().remove(this); break; + case COMMAND: case STACK: case PICK: break; @@ -313,6 +315,9 @@ public abstract class CardImpl> extends MageObjectImpl case EXILED: game.getExile().getPermanentExile().add(this); break; + case COMMAND: + game.addCommander(new Commander(this)); + break; case LIBRARY: if (flag) { game.getPlayer(ownerId).getLibrary().putOnTop(this, game); @@ -369,6 +374,10 @@ public abstract class CardImpl> extends MageObjectImpl case OUTSIDE: game.getPlayer(ownerId).getSideboard().remove(this); break; + + case COMMAND: + game.getState().getCommand().remove((Commander)game.getObject(objectId)); + break; default: //logger.warning("moveToZone, not fully implemented: from="+event.getFromZone() + ", to="+event.getToZone()); } diff --git a/Mage/src/mage/game/Game.java b/Mage/src/mage/game/Game.java index 5eedb6188c..0ce2366e99 100644 --- a/Mage/src/mage/game/Game.java +++ b/Mage/src/mage/game/Game.java @@ -66,6 +66,7 @@ import mage.util.functions.ApplyToPermanent; import java.io.Serializable; import java.util.*; +import mage.game.command.Commander; public interface Game extends MageItem, Serializable { @@ -174,6 +175,7 @@ public interface Game extends MageItem, Serializable { void emptyManaPools(); void addEffect(ContinuousEffect continuousEffect, Ability source); void addEmblem(Emblem emblem, Ability source); + void addCommander(Commander commander); void addPermanent(Permanent permanent); // priority methods diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 06368c5daf..2a5dd3974c 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -90,7 +90,9 @@ import java.io.IOException; import java.io.Serializable; import java.util.*; import java.util.Map.Entry; +import mage.abilities.common.CastCommanderAbility; import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.game.command.Commander; public abstract class GameImpl> implements Game, Serializable { @@ -305,6 +307,13 @@ public abstract class GameImpl> implements Game, Serializa return item; } } + + for (CommandObject commandObject : state.getCommand()) { + if (commandObject instanceof Commander && commandObject.getId().equals(objectId)) { + return commandObject; + } + } + object = getCard(objectId); if (object == null) { @@ -998,7 +1007,18 @@ public abstract class GameImpl> implements Game, Serializa for (Ability ability : newEmblem.getAbilities()) { ability.setSourceId(newEmblem.getId()); } - state.addEmblem(newEmblem); + state.addCommandObject(newEmblem); + } + + + @Override + public void addCommander(Commander commander){ + state.addCommandObject(commander); + for(Ability ability : commander.getAbilities()){ + if(ability instanceof CastCommanderAbility){ + state.addOtherAbility(commander.getId(), (CastCommanderAbility)ability); + } + } } @Override diff --git a/Mage/src/mage/game/GameState.java b/Mage/src/mage/game/GameState.java index 90267668d1..14e4ac659b 100644 --- a/Mage/src/mage/game/GameState.java +++ b/Mage/src/mage/game/GameState.java @@ -42,6 +42,7 @@ import mage.choices.Choice; import mage.game.combat.Combat; import mage.game.combat.CombatGroup; import mage.game.command.Command; +import mage.game.command.CommandObject; import mage.game.command.Emblem; import mage.game.events.GameEvent; import mage.game.permanent.Battlefield; @@ -501,10 +502,10 @@ public class GameState implements Serializable, Copyable { } } - public void addEmblem(Emblem emblem) { - getCommand().add(emblem); - for (Ability ability: emblem.getAbilities()) { - addAbility(ability, emblem); + public void addCommandObject(CommandObject commandObject) { + getCommand().add(commandObject); + for (Ability ability: commandObject.getAbilities()) { + addAbility(ability, commandObject); } } From d1ee8a7e9aa18c1e205988e0b81659f711fcd51d Mon Sep 17 00:00:00 2001 From: Plopman Date: Wed, 17 Jul 2013 20:38:07 +0200 Subject: [PATCH 7/7] [Commander] Move commander to command zone at the begging of the game --- .../src/mage/game/CommanderDuel.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Mage.Server.Plugins/Mage.Game.CommanderDuel/src/mage/game/CommanderDuel.java b/Mage.Server.Plugins/Mage.Game.CommanderDuel/src/mage/game/CommanderDuel.java index 9a8d584548..57d8b037cc 100644 --- a/Mage.Server.Plugins/Mage.Game.CommanderDuel/src/mage/game/CommanderDuel.java +++ b/Mage.Server.Plugins/Mage.Game.CommanderDuel/src/mage/game/CommanderDuel.java @@ -31,11 +31,15 @@ package mage.game; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import mage.cards.Card; import mage.constants.MultiplayerAttackOption; import mage.constants.PhaseStep; import mage.constants.RangeOfInfluence; +import mage.constants.Zone; +import mage.game.command.Commander; import mage.game.match.MatchType; import mage.game.turn.TurnMod; +import mage.players.Player; public class CommanderDuel extends GameImpl { @@ -68,6 +72,22 @@ public class CommanderDuel extends GameImpl { @Override protected void init(UUID choosingPlayerId, GameOptions gameOptions) { super.init(choosingPlayerId, gameOptions); + + //Move commender to commande zone + for (UUID playerId: state.getPlayerList(startingPlayerId)) { + Player player = getPlayer(playerId); + if(player != null){ + if(player.getSideboard().size() > 0){ + Card commander = getCard((UUID)player.getSideboard().toArray()[0]); + if(commander != null){ + commander.moveToZone(Zone.COMMAND, null, this, true); + + } + } + } + + } + state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW)); } @@ -97,4 +117,5 @@ public class CommanderDuel extends GameImpl { return new CommanderDuel(this); } + }