mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Added GainLiverPlayersCost and GainLiveOpponentCost.
This commit is contained in:
parent
a7b7a88bde
commit
238e31dcac
4 changed files with 185 additions and 1 deletions
|
@ -68,6 +68,8 @@ public class ControlsPermanentCondition implements Condition {
|
|||
* {@link #apply(mage.game.Game, mage.abilities.Ability) apply} method invocation.
|
||||
*
|
||||
* @param filter
|
||||
* @param type
|
||||
* @param count
|
||||
*/
|
||||
public ControlsPermanentCondition ( FilterPermanent filter, CountType type, int count ) {
|
||||
this.filter = filter;
|
||||
|
@ -82,6 +84,8 @@ public class ControlsPermanentCondition implements Condition {
|
|||
* as well. This will force both conditions to apply for this to be true.
|
||||
*
|
||||
* @param filter
|
||||
* @param type
|
||||
* @param count
|
||||
* @param conditionToDecorate
|
||||
*/
|
||||
public ControlsPermanentCondition ( FilterPermanent filter, CountType type, int count, Condition conditionToDecorate ) {
|
||||
|
|
|
@ -36,6 +36,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.costs.CostImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
@ -70,7 +71,7 @@ public class ExileFromHandCost extends CostImpl<ExileFromHandCost> {
|
|||
return false;
|
||||
}
|
||||
this.cards.add(card.copy());
|
||||
paid |= card.moveToExile(ability.getSourceId(), "from Hand", ability.getSourceId(), game);
|
||||
paid |= player.moveCardToExileWithInfo(card, null, null, ability.getSourceId(), game, Zone.HAND);
|
||||
}
|
||||
}
|
||||
return paid;
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package mage.abilities.costs.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.FilterPlayer;
|
||||
import mage.filter.predicate.other.PlayerCanGainLifePredicate;
|
||||
import mage.filter.predicate.other.PlayerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class GainLiveOpponentCost extends CostImpl<GainLiveOpponentCost> {
|
||||
|
||||
private static final FilterPlayer filter = new FilterPlayer("opponent that can gain life");
|
||||
|
||||
static {
|
||||
filter.add(new PlayerPredicate(TargetController.OPPONENT));
|
||||
filter.add(new PlayerCanGainLifePredicate());
|
||||
}
|
||||
|
||||
private final int amount;
|
||||
|
||||
public GainLiveOpponentCost(int amount) {
|
||||
this.amount = amount;
|
||||
this.text = new StringBuilder("you may have an opponent gain ").append(amount).append(" life").toString();
|
||||
}
|
||||
|
||||
public GainLiveOpponentCost(GainLiveOpponentCost cost) {
|
||||
super(cost);
|
||||
this.amount = cost.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (UUID opponentId : game.getOpponents(controllerId)) {
|
||||
Player player = game.getPlayer(opponentId);
|
||||
if (player != null && player.isCanGainLife()) {
|
||||
// at least one opponent must be able to gain life
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
TargetPlayer target = new TargetPlayer(1, 1, true, filter);
|
||||
if (controller.chooseTarget(Outcome.Detriment, target, ability, game)) {
|
||||
Player opponent = game.getPlayer(target.getFirstTarget());
|
||||
if (opponent != null) {
|
||||
opponent.gainLife(amount, game);
|
||||
paid = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainLiveOpponentCost copy() {
|
||||
return new GainLiveOpponentCost(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* 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.costs.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class GainLivePlayersCost extends CostImpl<GainLivePlayersCost> {
|
||||
|
||||
private final int amount;
|
||||
|
||||
public GainLivePlayersCost(int amount) {
|
||||
this.amount = amount;
|
||||
this.text = new StringBuilder("you may have each other player gain ").append(amount).append(" life").toString();
|
||||
}
|
||||
|
||||
public GainLivePlayersCost(GainLivePlayersCost cost) {
|
||||
super(cost);
|
||||
this.amount = cost.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
if (!playerId.equals(controllerId)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.isCanGainLife()) {
|
||||
// if only one other player can't gain life, the cost can't be paid
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
if (!playerId.equals(controllerId)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.gainLife(amount, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
paid = true;
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainLivePlayersCost copy() {
|
||||
return new GainLivePlayersCost(this);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue