Some more changes to get/check opponents.

This commit is contained in:
LevelX2 2014-01-30 12:55:50 +01:00
parent d959edb4b3
commit d9a03b35d2
22 changed files with 51 additions and 47 deletions

View file

@ -55,15 +55,12 @@ public class FeralContest extends CardImpl<FeralContest> {
this.color.setGreen(true);
// Put a +1/+1 counter on target creature you control. Another target creature blocks it this turn if able.
TargetControlledCreaturePermanent target1 = new TargetControlledCreaturePermanent();
TargetCreaturePermanent target2 = new TargetCreaturePermanent();
Effect effect1 = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
RequirementEffect effect2 = new FeralContestEffect();
this.getSpellAbility().addEffect(effect1);
this.getSpellAbility().addTarget(target1);
this.getSpellAbility().addEffect(effect2);
this.getSpellAbility().addTarget(target2);
// Put a +1/+1 counter on target creature you control.
this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
// Another target creature blocks it this turn if able.
this.getSpellAbility().addEffect(new FeralContestEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
public FeralContest(final FeralContest card) {

View file

@ -172,7 +172,7 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
break;
case OPPONENT:
if(!game.getOpponents(controllerId).contains(playerId)){
if (! game.getPlayer(controllerId).hasOpponent(playerId, game)){
return false;
}
break;

View file

@ -49,7 +49,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl<Begi
}
return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (setTargetPointer) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));

View file

@ -53,7 +53,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl<Beginn
}
return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));

View file

@ -78,7 +78,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl<Beg
}
return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));

View file

@ -58,7 +58,7 @@ public class BeginningOfPreCombatMainTriggeredAbility extends TriggeredAbilityIm
}
return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (setTargetPointer) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));

View file

@ -66,7 +66,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl<Begin
}
break;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));

View file

@ -86,7 +86,7 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<Begi
}
return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
if (setTargetPointer && getTargets().size() == 0) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));

View file

@ -61,7 +61,7 @@ public class DrawCardOpponentTriggeredAbility extends TriggeredAbilityImpl<DrawC
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DREW_CARD && game.getOpponents(this.getControllerId()).contains(event.getPlayerId())) {
if (event.getType() == GameEvent.EventType.DREW_CARD && game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
if (setTargetPointer) {
for (Effect effect:this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));

View file

@ -49,7 +49,7 @@ public class OpponentSacrificesNonTokenPermanentTriggeredAbility extends Trigger
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT && game.getOpponents(controllerId).contains(event.getPlayerId())) {
if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT && game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
MageObject object = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (object instanceof Permanent && !(object instanceof PermanentToken) ) {
for (Effect effect : getEffects()) {

View file

@ -48,7 +48,7 @@ public class OpponentSacrificesPermanentTriggeredAbility extends TriggeredAbilit
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT && game.getOpponents(controllerId).contains(event.getPlayerId())) {
if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT && game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
MageObject object = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (object instanceof Permanent) {
for (Effect effect : getEffects()) {

View file

@ -72,7 +72,7 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl<Spel
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST && game.getOpponents(controllerId).contains(event.getPlayerId())) {
if (event.getType() == GameEvent.EventType.SPELL_CAST && game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell != null && filter.match(spell, game)) {
if (setTargetPointerPlayer) {

View file

@ -67,7 +67,7 @@ public class AtEndOfTurnDelayedTriggeredAbility extends DelayedTriggeredAbility<
boolean yours = event.getPlayerId().equals(this.controllerId);
return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
return true;
}
break;

View file

@ -69,7 +69,7 @@ public class AtTheBeginOfPreCombatMainDelayedTriggeredAbility extends DelayedTri
boolean yours = event.getPlayerId().equals(this.controllerId);
return yours;
case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
return true;
}
break;

View file

@ -61,7 +61,8 @@ public class OwnerPredicate implements ObjectPlayerPredicate<ObjectPlayer<Card>>
}
break;
case OPPONENT:
if (game.getOpponents(playerId).contains(card.getOwnerId())) {
if (!card.getOwnerId().equals(playerId) &&
game.getPlayer(playerId).hasOpponent(card.getOwnerId(), game)) {
return true;
}
break;

View file

@ -61,7 +61,8 @@ public class PlayerPredicate implements ObjectSourcePlayerPredicate<ObjectSource
}
break;
case OPPONENT:
if (game.getOpponents(playerId).contains(player.getId())) {
if (!player.getId().equals(playerId) &&
game.getPlayer(playerId).hasOpponent(player.getId(), game)) {
return true;
}
break;

View file

@ -59,7 +59,8 @@ public class ControllerPredicate implements ObjectPlayerPredicate<ObjectPlayer<C
}
break;
case OPPONENT:
if (game.getOpponents(playerId).contains(object.getControllerId())) {
if (!object.getControllerId().equals(playerId) &&
game.getPlayer(playerId).hasOpponent(object.getControllerId(), game)) {
return true;
}
break;

View file

@ -43,7 +43,7 @@ import mage.watchers.common.PlayerDamagedBySourceWatcher;
public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate<ObjectPlayer<Controllable>> {
private TargetController controller;
private final TargetController controller;
public DamagedPlayerThisTurnPredicate(TargetController controller) {
this.controller = controller;

View file

@ -144,6 +144,7 @@ public interface Player extends MageItem, Copyable<Player> {
/**
* Defines player whose turn this player controls at the moment.
* @param game
* @param playerId
*/
void controlPlayersTurn(Game game, UUID playerId);
@ -316,13 +317,15 @@ public interface Player extends MageItem, Copyable<Player> {
/**
* asThough effect to reveal faceDown cards
*
* @param card
* @param game
*/
void revealFaceDownCard(Card card, Game game);
/**
* Set seconds left to play the game.
*
* @return
* @param timeLeft
*/
void setPriorityTimeLeft(int timeLeft);
@ -344,14 +347,14 @@ public interface Player extends MageItem, Copyable<Player> {
boolean canJoinTable(Table table);
/**
* Get the commanderId of the player
* @param card
* Set the commanderId of the player
* @param commanderId
*/
void setCommanderId(UUID commanderId);
/**
* Set the commanderId of the player
* @param card
* Get the commanderId of the player
* @return
*/
UUID getCommanderId();
@ -374,9 +377,16 @@ public interface Player extends MageItem, Copyable<Player> {
* @param game
* @param fromZone
* @param sourceId
* @param game
* @return
*/
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId);
/**
* Checks if the playerToCheckId is from an opponent in range
*
* @param playerToCheckId
* @param game
* @return true if playerToCheckId belongs to an opponent
*/
boolean hasOpponent(UUID playerToCheckId, Game game);
}

View file

@ -492,7 +492,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
} else if (source instanceof StackObject) {
controllerId = ((StackObject) source).getControllerId();
}
if (controllerId != null && game.getOpponents(this.playerId).contains(controllerId) &&
if (controllerId != null && this.hasOpponent(controllerId, game) &&
!game.getContinuousEffects().asThough(this.getId(), AsThoughEffectType.HEXPROOF, game)) {
return false;
}
@ -1446,12 +1446,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
@Override
public void resetPassed() {
if (!this.loses && !this.hasLeft()) {
this.passed = false;
}
else {
this.passed = true;
}
this.passed = this.loses || this.hasLeft();
}
@Override
@ -2093,9 +2088,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
return this.commanderId;
}
/**
* {@inheritDoc}
*/
@Override
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
boolean result = false;
@ -2108,9 +2100,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
return result;
}
/**
* {@inheritDoc}
*/
@Override
public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId) {
boolean result = false;
@ -2123,5 +2112,10 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
return result;
}
@Override
public boolean hasOpponent(UUID playerToCheckId, Game game) {
return game.isOpponent(this, playerToCheckId);
}
}

View file

@ -37,7 +37,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard<TargetCardInOppon
public boolean canTarget(UUID id, Ability source, Game game) {
Card card = game.getCard(id);
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
if (game.getOpponents(source.getControllerId()).contains(card.getOwnerId())) {
if (game.getPlayer(source.getControllerId()).hasOpponent(card.getOwnerId(), game)) {
if (allFromOneOpponent && !targets.isEmpty()) {
Card firstCard = game.getCard((UUID)targets.keySet().iterator().next());
if (firstCard != null && !card.getOwnerId().equals(firstCard.getOwnerId())) {

View file

@ -55,7 +55,7 @@ public class BloodthirstWatcher extends WatcherImpl<BloodthirstWatcher> {
return;
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
if (game.getOpponents(this.controllerId).contains(damageEvent.getPlayerId())) {
if (game.getPlayer(this.getControllerId()).hasOpponent(damageEvent.getPlayerId(), game)) {
condition = true;
}
}