mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Merge branch 'master' of https://github.com/magefree/mage.git
This commit is contained in:
commit
62466a669c
15 changed files with 594 additions and 18 deletions
|
@ -651,7 +651,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCommandZoneActionPerformed(java.awt.event.ActionEvent evt) {
|
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
|
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
|
||||||
|
|
|
@ -28,13 +28,12 @@
|
||||||
|
|
||||||
package mage.client.util;
|
package mage.client.util;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
import mage.view.*;
|
import mage.view.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -55,12 +54,17 @@ public class CardsViewUtil {
|
||||||
return cards;
|
return cards;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CardsView convertEmblems(List<EmblemView> view) {
|
public static CardsView convertCommandObject(List<CommandObjectView> view) {
|
||||||
CardsView cards = new CardsView();
|
CardsView cards = new CardsView();
|
||||||
|
|
||||||
for (EmblemView emblem : view) {
|
for (CommandObjectView commandObject : view) {
|
||||||
CardView cardView = new CardView(emblem);
|
if(commandObject instanceof EmblemView ){
|
||||||
cards.put(emblem.getId(), cardView);
|
CardView cardView = new CardView((EmblemView)commandObject);
|
||||||
|
cards.put(commandObject.getId(), cardView);
|
||||||
|
}
|
||||||
|
else if(commandObject instanceof CommanderView ){
|
||||||
|
cards.put(commandObject.getId(),(CommanderView)commandObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cards;
|
return cards;
|
||||||
|
|
47
Mage.Common/src/mage/view/CommandObjectView.java
Normal file
47
Mage.Common/src/mage/view/CommandObjectView.java
Normal file
|
@ -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<String> getRules();
|
||||||
|
}
|
48
Mage.Common/src/mage/view/CommanderView.java
Normal file
48
Mage.Common/src/mage/view/CommanderView.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
||||||
/**
|
/**
|
||||||
* @author noxx
|
* @author noxx
|
||||||
*/
|
*/
|
||||||
public class EmblemView implements Serializable {
|
public class EmblemView implements CommandObjectView, Serializable {
|
||||||
|
|
||||||
protected UUID id;
|
protected UUID id;
|
||||||
protected String name;
|
protected String name;
|
||||||
|
@ -24,18 +24,22 @@ public class EmblemView implements Serializable {
|
||||||
rules = emblem.getAbilities().getRules(sourceCard.getName());
|
rules = emblem.getAbilities().getRules(sourceCard.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getExpansionSetCode() {
|
public String getExpansionSetCode() {
|
||||||
return expansionSetCode;
|
return expansionSetCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<String> getRules() {
|
public List<String> getRules() {
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import mage.players.Player;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import mage.game.command.Commander;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -61,7 +62,7 @@ public class PlayerView implements Serializable {
|
||||||
private Map<UUID, PermanentView> battlefield = new LinkedHashMap<UUID, PermanentView>();
|
private Map<UUID, PermanentView> battlefield = new LinkedHashMap<UUID, PermanentView>();
|
||||||
private CardView topCard;
|
private CardView topCard;
|
||||||
private UserDataView userDataView;
|
private UserDataView userDataView;
|
||||||
private List<EmblemView> emblemList = new ArrayList<EmblemView>();
|
private List<CommandObjectView> commandList = new ArrayList<CommandObjectView>();
|
||||||
private List<UUID> attachments = new ArrayList<UUID>();
|
private List<UUID> attachments = new ArrayList<UUID>();
|
||||||
private int statesSavedSize;
|
private int statesSavedSize;
|
||||||
private int priorityTimeLeft;
|
private int priorityTimeLeft;
|
||||||
|
@ -100,7 +101,16 @@ public class PlayerView implements Serializable {
|
||||||
if (emblem.getControllerId().equals(this.playerId)) {
|
if (emblem.getControllerId().equals(this.playerId)) {
|
||||||
Card sourceCard = game.getCard(((CommandObject)emblem).getSourceId());
|
Card sourceCard = game.getCard(((CommandObject)emblem).getSourceId());
|
||||||
if (sourceCard != null) {
|
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;
|
return this.userDataView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EmblemView> getEmblemList() {
|
public List<CommandObjectView> getCommadObjectList() {
|
||||||
return emblemList;
|
return commandList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UUID> getAttachments() {
|
public List<UUID> getAttachments() {
|
||||||
|
|
|
@ -31,11 +31,15 @@ package mage.game;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.constants.MultiplayerAttackOption;
|
import mage.constants.MultiplayerAttackOption;
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.RangeOfInfluence;
|
import mage.constants.RangeOfInfluence;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.game.command.Commander;
|
||||||
import mage.game.match.MatchType;
|
import mage.game.match.MatchType;
|
||||||
import mage.game.turn.TurnMod;
|
import mage.game.turn.TurnMod;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
public class CommanderDuel extends GameImpl<CommanderDuel> {
|
public class CommanderDuel extends GameImpl<CommanderDuel> {
|
||||||
|
|
||||||
|
@ -68,6 +72,22 @@ public class CommanderDuel extends GameImpl<CommanderDuel> {
|
||||||
@Override
|
@Override
|
||||||
protected void init(UUID choosingPlayerId, GameOptions gameOptions) {
|
protected void init(UUID choosingPlayerId, GameOptions gameOptions) {
|
||||||
super.init(choosingPlayerId, 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));
|
state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,4 +117,5 @@ public class CommanderDuel extends GameImpl<CommanderDuel> {
|
||||||
return new CommanderDuel(this);
|
return new CommanderDuel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
127
Mage.Sets/src/mage/sets/morningtide/GiltLeafArchdruid.java
Normal file
127
Mage.Sets/src/mage/sets/morningtide/GiltLeafArchdruid.java
Normal file
|
@ -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<GiltLeafArchdruid> {
|
||||||
|
|
||||||
|
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<GainControlAllLandsEffect> {
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
108
Mage/src/mage/abilities/common/CastCommanderAbility.java
Normal file
108
Mage/src/mage/abilities/common/CastCommanderAbility.java
Normal file
|
@ -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<CastCommanderAbility> {
|
||||||
|
|
||||||
|
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<CastCommanderEffect> {
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -50,6 +50,7 @@ import org.apache.log4j.Logger;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import mage.constants.SpellAbilityType;
|
import mage.constants.SpellAbilityType;
|
||||||
|
import mage.game.command.Commander;
|
||||||
|
|
||||||
|
|
||||||
public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T> implements Card {
|
public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T> implements Card {
|
||||||
|
@ -290,6 +291,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
case OUTSIDE:
|
case OUTSIDE:
|
||||||
game.getPlayer(ownerId).getSideboard().remove(this);
|
game.getPlayer(ownerId).getSideboard().remove(this);
|
||||||
break;
|
break;
|
||||||
|
case COMMAND:
|
||||||
case STACK:
|
case STACK:
|
||||||
case PICK:
|
case PICK:
|
||||||
break;
|
break;
|
||||||
|
@ -313,6 +315,9 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
case EXILED:
|
case EXILED:
|
||||||
game.getExile().getPermanentExile().add(this);
|
game.getExile().getPermanentExile().add(this);
|
||||||
break;
|
break;
|
||||||
|
case COMMAND:
|
||||||
|
game.addCommander(new Commander(this));
|
||||||
|
break;
|
||||||
case LIBRARY:
|
case LIBRARY:
|
||||||
if (flag) {
|
if (flag) {
|
||||||
game.getPlayer(ownerId).getLibrary().putOnTop(this, game);
|
game.getPlayer(ownerId).getLibrary().putOnTop(this, game);
|
||||||
|
@ -369,6 +374,10 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
||||||
case OUTSIDE:
|
case OUTSIDE:
|
||||||
game.getPlayer(ownerId).getSideboard().remove(this);
|
game.getPlayer(ownerId).getSideboard().remove(this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case COMMAND:
|
||||||
|
game.getState().getCommand().remove((Commander)game.getObject(objectId));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
//logger.warning("moveToZone, not fully implemented: from="+event.getFromZone() + ", to="+event.getToZone());
|
//logger.warning("moveToZone, not fully implemented: from="+event.getFromZone() + ", to="+event.getToZone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ public enum MageObjectType {
|
||||||
TOKEN ("Token", true, true),
|
TOKEN ("Token", true, true),
|
||||||
SPELL ("Spell", false, false),
|
SPELL ("Spell", false, false),
|
||||||
PERMANENT ("Permanent", true, true),
|
PERMANENT ("Permanent", true, true),
|
||||||
EMBLEM ("Emblem", false, false);
|
EMBLEM ("Emblem", false, false),
|
||||||
|
COMMANDER ("Commander", false, false);
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
private boolean permanent;
|
private boolean permanent;
|
||||||
|
|
|
@ -66,6 +66,7 @@ import mage.util.functions.ApplyToPermanent;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import mage.game.command.Commander;
|
||||||
|
|
||||||
public interface Game extends MageItem, Serializable {
|
public interface Game extends MageItem, Serializable {
|
||||||
|
|
||||||
|
@ -174,6 +175,7 @@ public interface Game extends MageItem, Serializable {
|
||||||
void emptyManaPools();
|
void emptyManaPools();
|
||||||
void addEffect(ContinuousEffect continuousEffect, Ability source);
|
void addEffect(ContinuousEffect continuousEffect, Ability source);
|
||||||
void addEmblem(Emblem emblem, Ability source);
|
void addEmblem(Emblem emblem, Ability source);
|
||||||
|
void addCommander(Commander commander);
|
||||||
void addPermanent(Permanent permanent);
|
void addPermanent(Permanent permanent);
|
||||||
|
|
||||||
// priority methods
|
// priority methods
|
||||||
|
|
|
@ -90,7 +90,9 @@ import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import mage.abilities.common.CastCommanderAbility;
|
||||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
|
import mage.game.command.Commander;
|
||||||
|
|
||||||
|
|
||||||
public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializable {
|
public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializable {
|
||||||
|
@ -305,6 +307,13 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (CommandObject commandObject : state.getCommand()) {
|
||||||
|
if (commandObject instanceof Commander && commandObject.getId().equals(objectId)) {
|
||||||
|
return commandObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object = getCard(objectId);
|
object = getCard(objectId);
|
||||||
|
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
|
@ -998,7 +1007,18 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
for (Ability ability : newEmblem.getAbilities()) {
|
for (Ability ability : newEmblem.getAbilities()) {
|
||||||
ability.setSourceId(newEmblem.getId());
|
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
|
@Override
|
||||||
|
|
|
@ -42,6 +42,7 @@ import mage.choices.Choice;
|
||||||
import mage.game.combat.Combat;
|
import mage.game.combat.Combat;
|
||||||
import mage.game.combat.CombatGroup;
|
import mage.game.combat.CombatGroup;
|
||||||
import mage.game.command.Command;
|
import mage.game.command.Command;
|
||||||
|
import mage.game.command.CommandObject;
|
||||||
import mage.game.command.Emblem;
|
import mage.game.command.Emblem;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Battlefield;
|
import mage.game.permanent.Battlefield;
|
||||||
|
@ -501,10 +502,10 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEmblem(Emblem emblem) {
|
public void addCommandObject(CommandObject commandObject) {
|
||||||
getCommand().add(emblem);
|
getCommand().add(commandObject);
|
||||||
for (Ability ability: emblem.getAbilities()) {
|
for (Ability ability: commandObject.getAbilities()) {
|
||||||
addAbility(ability, emblem);
|
addAbility(ability, commandObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
174
Mage/src/mage/game/command/Commander.java
Normal file
174
Mage/src/mage/game/command/Commander.java
Normal file
|
@ -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<Ability> abilites = new AbilitiesImpl<Ability>();
|
||||||
|
|
||||||
|
|
||||||
|
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<CardType> getCardType() {
|
||||||
|
return card.getCardType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSubtype() {
|
||||||
|
return card.getSubtype();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasSubtype(String subtype) {
|
||||||
|
return card.hasSubtype(subtype);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSupertype() {
|
||||||
|
return card.getSubtype();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Abilities<Ability> getAbilities() {
|
||||||
|
return abilites;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectColor getColor() {
|
||||||
|
return card.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManaCosts<ManaCost> 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue