mirror of
https://github.com/correl/mage.git
synced 2025-03-31 01:07:39 -09:00
Added ChooseModeEffect and ModeChoiceSourceCondition.
This commit is contained in:
parent
c370189787
commit
f6dbf0214b
8 changed files with 177 additions and 5 deletions
Mage/src/mage/abilities
AbilityImpl.javaTriggeredAbilityImpl.java
common
BeginningOfUpkeepTriggeredAbility.javaEntersBattlefieldAbility.javaZoneChangeAllTriggeredAbility.java
condition/common
effects/common
Utils/release
|
@ -212,7 +212,8 @@ public abstract class AbilityImpl implements Ability {
|
||||||
game.getContinuousEffects().applySpliceEffects(this, game);
|
game.getContinuousEffects().applySpliceEffects(this, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Because all (non targeted) choices have to be done during resolution
|
||||||
|
// this has to be removed, if all using effects are changed
|
||||||
MageObject sourceObject = game.getObject(sourceId);
|
MageObject sourceObject = game.getObject(sourceId);
|
||||||
if (sourceObject != null) {
|
if (sourceObject != null) {
|
||||||
sourceObject.adjustChoices(this, game);
|
sourceObject.adjustChoices(this, game);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.constants.AbilityType;
|
import mage.constants.AbilityType;
|
||||||
|
@ -35,8 +36,6 @@ import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
|
@ -43,8 +43,10 @@ import mage.target.targetpointer.FixedTarget;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl {
|
public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
private TargetController targetController;
|
private TargetController targetController;
|
||||||
private boolean setTargetPointer;
|
private boolean setTargetPointer;
|
||||||
|
protected String ruleTrigger;
|
||||||
|
|
||||||
public BeginningOfUpkeepTriggeredAbility(Effect effect, TargetController targetController, boolean isOptional) {
|
public BeginningOfUpkeepTriggeredAbility(Effect effect, TargetController targetController, boolean isOptional) {
|
||||||
this(Zone.BATTLEFIELD, effect, targetController, isOptional);
|
this(Zone.BATTLEFIELD, effect, targetController, isOptional);
|
||||||
|
@ -55,15 +57,21 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeginningOfUpkeepTriggeredAbility(Zone zone, Effect effect, TargetController targetController, boolean isOptional, boolean setTargetPointer) {
|
public BeginningOfUpkeepTriggeredAbility(Zone zone, Effect effect, TargetController targetController, boolean isOptional, boolean setTargetPointer) {
|
||||||
|
this(zone, effect, targetController, isOptional, setTargetPointer, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BeginningOfUpkeepTriggeredAbility(Zone zone, Effect effect, TargetController targetController, boolean isOptional, boolean setTargetPointer, String ruleTrigger) {
|
||||||
super(zone, effect, isOptional);
|
super(zone, effect, isOptional);
|
||||||
this.targetController = targetController;
|
this.targetController = targetController;
|
||||||
this.setTargetPointer = setTargetPointer;
|
this.setTargetPointer = setTargetPointer;
|
||||||
|
this.ruleTrigger = ruleTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeginningOfUpkeepTriggeredAbility(final BeginningOfUpkeepTriggeredAbility ability) {
|
public BeginningOfUpkeepTriggeredAbility(final BeginningOfUpkeepTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.targetController = ability.targetController;
|
this.targetController = ability.targetController;
|
||||||
this.setTargetPointer = ability.setTargetPointer;
|
this.setTargetPointer = ability.setTargetPointer;
|
||||||
|
this.ruleTrigger = ability.ruleTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,6 +134,9 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
StringBuilder sb = new StringBuilder(super.getRule());
|
StringBuilder sb = new StringBuilder(super.getRule());
|
||||||
|
if (ruleTrigger != null && !ruleTrigger.isEmpty()) {
|
||||||
|
return sb.insert(0, ruleTrigger).toString();
|
||||||
|
}
|
||||||
switch (targetController) {
|
switch (targetController) {
|
||||||
case YOU:
|
case YOU:
|
||||||
if (this.optional) {
|
if (this.optional) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class EntersBattlefieldAbility extends StaticAbility {
|
||||||
this.abilityRule = abilityRule;
|
this.abilityRule = abilityRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntersBattlefieldAbility(EntersBattlefieldAbility ability) {
|
public EntersBattlefieldAbility(final EntersBattlefieldAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.abilityRule = ability.abilityRule;
|
this.abilityRule = ability.abilityRule;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class ZoneChangeAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZoneChangeAllTriggeredAbility(ZoneChangeAllTriggeredAbility ability) {
|
public ZoneChangeAllTriggeredAbility(final ZoneChangeAllTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.fromZone = ability.fromZone;
|
this.fromZone = ability.fromZone;
|
||||||
this.toZone = ability.toZone;
|
this.toZone = ability.toZone;
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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.abilities.condition.common;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
|
import mage.game.Game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class ModeChoiceSourceCondition implements Condition {
|
||||||
|
|
||||||
|
private final String mode;
|
||||||
|
|
||||||
|
|
||||||
|
public ModeChoiceSourceCondition(String mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
String choosenMode = (String) game.getState().getValue(source.getSourceId() + "_modeChoice");
|
||||||
|
return choosenMode != null && choosenMode.equals(mode);
|
||||||
|
}
|
||||||
|
}
|
106
Mage/src/mage/abilities/effects/common/ChooseModeEffect.java
Normal file
106
Mage/src/mage/abilities/effects/common/ChooseModeEffect.java
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* 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.abilities.effects.common;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.choices.Choice;
|
||||||
|
import mage.choices.ChoiceImpl;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class ChooseModeEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
protected final ArrayList<String> modes = new ArrayList();
|
||||||
|
protected final String choiceMessage;
|
||||||
|
|
||||||
|
public ChooseModeEffect(String choiceMessage, String... modes) {
|
||||||
|
super(Outcome.Neutral);
|
||||||
|
this.choiceMessage = choiceMessage;
|
||||||
|
this.modes.addAll(Arrays.asList(modes));
|
||||||
|
this.staticText = setText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChooseModeEffect(final ChooseModeEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.modes.addAll(effect.modes);
|
||||||
|
this.choiceMessage = effect.choiceMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChooseModeEffect copy() {
|
||||||
|
return new ChooseModeEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||||
|
if (controller != null) {
|
||||||
|
Choice choice = new ChoiceImpl(true);
|
||||||
|
choice.setMessage(choiceMessage);
|
||||||
|
choice.getChoices().addAll(modes);
|
||||||
|
while (!choice.isChosen()) {
|
||||||
|
if (!controller.isInGame()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
controller.choose(Outcome.Neutral, choice, game);
|
||||||
|
}
|
||||||
|
if (choice.isChosen()) {
|
||||||
|
game.informPlayers(new StringBuilder(sourcePermanent.getLogName()).append(": ").append(controller.getName()).append(" has chosen ").append(choice.getChoice()).toString());
|
||||||
|
game.getState().setValue(source.getSourceId() + "_modeChoice", choice.getChoice());
|
||||||
|
sourcePermanent.addInfo("_modeChoice", "<font color = 'blue'>Chosen mode: " + choice.getChoice() + "</font>");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String setText() {
|
||||||
|
StringBuilder sb = new StringBuilder("choose ");
|
||||||
|
int count = 0;
|
||||||
|
for (String choice: modes) {
|
||||||
|
count++;
|
||||||
|
sb.append(choice);
|
||||||
|
if (count + 1 < modes.size()) {
|
||||||
|
sb.append(", ");
|
||||||
|
} else if (count < modes.size()) {
|
||||||
|
sb.append(" or ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -81,6 +81,9 @@ git log 96ce77e9d0e21610569071c81e661f91c53a3a17..HEAD --diff-filter=A --name-st
|
||||||
since 1.3.0-2014-11-29v5 (2014-12-27)
|
since 1.3.0-2014-11-29v5 (2014-12-27)
|
||||||
git log c4ad51c4af2467f3483204e29f23b76c53f8f880..HEAD --diff-filter=A --name-status | sed -ne "s/^A[^u]Mage.Sets\/src\/mage\/sets\///p" | sort > added_cards.txt
|
git log c4ad51c4af2467f3483204e29f23b76c53f8f880..HEAD --diff-filter=A --name-status | sed -ne "s/^A[^u]Mage.Sets\/src\/mage\/sets\///p" | sort > added_cards.txt
|
||||||
|
|
||||||
|
since 1.3.0-2014-11-29v7 (2015-01-01)
|
||||||
|
git log c370189787cff7fc129b1ccf1b223807143460de..HEAD --diff-filter=A --name-status | sed -ne "s/^A[^u]Mage.Sets\/src\/mage\/sets\///p" | sort > added_cards.txt
|
||||||
|
|
||||||
3. Copy added_cards.txt to trunk\Utils folder
|
3. Copy added_cards.txt to trunk\Utils folder
|
||||||
4. Run script:
|
4. Run script:
|
||||||
> perl extract_in_wiki_format.perl
|
> perl extract_in_wiki_format.perl
|
||||||
|
|
Loading…
Add table
Reference in a new issue