mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
Some more changes to get/check opponents.
This commit is contained in:
parent
d959edb4b3
commit
d9a03b35d2
22 changed files with 51 additions and 47 deletions
|
@ -55,15 +55,12 @@ public class FeralContest extends CardImpl<FeralContest> {
|
||||||
|
|
||||||
this.color.setGreen(true);
|
this.color.setGreen(true);
|
||||||
|
|
||||||
// Put a +1/+1 counter on target creature you control. Another target creature blocks it this turn if able.
|
// Put a +1/+1 counter on target creature you control.
|
||||||
TargetControlledCreaturePermanent target1 = new TargetControlledCreaturePermanent();
|
this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance()));
|
||||||
TargetCreaturePermanent target2 = new TargetCreaturePermanent();
|
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
|
||||||
Effect effect1 = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
|
// Another target creature blocks it this turn if able.
|
||||||
RequirementEffect effect2 = new FeralContestEffect();
|
this.getSpellAbility().addEffect(new FeralContestEffect());
|
||||||
this.getSpellAbility().addEffect(effect1);
|
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||||
this.getSpellAbility().addTarget(target1);
|
|
||||||
this.getSpellAbility().addEffect(effect2);
|
|
||||||
this.getSpellAbility().addTarget(target2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeralContest(final FeralContest card) {
|
public FeralContest(final FeralContest card) {
|
||||||
|
|
|
@ -172,7 +172,7 @@ public abstract class ActivatedAbilityImpl<T extends ActivatedAbilityImpl<T>> ex
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if(!game.getOpponents(controllerId).contains(playerId)){
|
if (! game.getPlayer(controllerId).hasOpponent(playerId, game)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl<Begi
|
||||||
}
|
}
|
||||||
return yours;
|
return yours;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class BeginningOfDrawTriggeredAbility extends TriggeredAbilityImpl<Beginn
|
||||||
}
|
}
|
||||||
return yours;
|
return yours;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||||
if (getTargets().size() == 0) {
|
if (getTargets().size() == 0) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl<Beg
|
||||||
}
|
}
|
||||||
return yours;
|
return yours;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||||
if (getTargets().size() == 0) {
|
if (getTargets().size() == 0) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class BeginningOfPreCombatMainTriggeredAbility extends TriggeredAbilityIm
|
||||||
}
|
}
|
||||||
return yours;
|
return yours;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class BeginningOfUntapTriggeredAbility extends TriggeredAbilityImpl<Begin
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||||
if (getTargets().size() == 0) {
|
if (getTargets().size() == 0) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl<Begi
|
||||||
}
|
}
|
||||||
return yours;
|
return yours;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
if (game.getPlayer(this.controllerId).hasOpponent(event.getPlayerId(), game)) {
|
||||||
if (setTargetPointer && getTargets().size() == 0) {
|
if (setTargetPointer && getTargets().size() == 0) {
|
||||||
for (Effect effect : this.getEffects()) {
|
for (Effect effect : this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class DrawCardOpponentTriggeredAbility extends TriggeredAbilityImpl<DrawC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
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) {
|
if (setTargetPointer) {
|
||||||
for (Effect effect:this.getEffects()) {
|
for (Effect effect:this.getEffects()) {
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class OpponentSacrificesNonTokenPermanentTriggeredAbility extends Trigger
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
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);
|
MageObject object = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||||
if (object instanceof Permanent && !(object instanceof PermanentToken) ) {
|
if (object instanceof Permanent && !(object instanceof PermanentToken) ) {
|
||||||
for (Effect effect : getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class OpponentSacrificesPermanentTriggeredAbility extends TriggeredAbilit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
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);
|
MageObject object = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||||
if (object instanceof Permanent) {
|
if (object instanceof Permanent) {
|
||||||
for (Effect effect : getEffects()) {
|
for (Effect effect : getEffects()) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl<Spel
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
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());
|
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||||
if (spell != null && filter.match(spell, game)) {
|
if (spell != null && filter.match(spell, game)) {
|
||||||
if (setTargetPointerPlayer) {
|
if (setTargetPointerPlayer) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class AtEndOfTurnDelayedTriggeredAbility extends DelayedTriggeredAbility<
|
||||||
boolean yours = event.getPlayerId().equals(this.controllerId);
|
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||||
return yours;
|
return yours;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class AtTheBeginOfPreCombatMainDelayedTriggeredAbility extends DelayedTri
|
||||||
boolean yours = event.getPlayerId().equals(this.controllerId);
|
boolean yours = event.getPlayerId().equals(this.controllerId);
|
||||||
return yours;
|
return yours;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
|
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -61,7 +61,8 @@ public class OwnerPredicate implements ObjectPlayerPredicate<ObjectPlayer<Card>>
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(playerId).contains(card.getOwnerId())) {
|
if (!card.getOwnerId().equals(playerId) &&
|
||||||
|
game.getPlayer(playerId).hasOpponent(card.getOwnerId(), game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -61,7 +61,8 @@ public class PlayerPredicate implements ObjectSourcePlayerPredicate<ObjectSource
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(playerId).contains(player.getId())) {
|
if (!player.getId().equals(playerId) &&
|
||||||
|
game.getPlayer(playerId).hasOpponent(player.getId(), game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class ControllerPredicate implements ObjectPlayerPredicate<ObjectPlayer<C
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
if (game.getOpponents(playerId).contains(object.getControllerId())) {
|
if (!object.getControllerId().equals(playerId) &&
|
||||||
|
game.getPlayer(playerId).hasOpponent(object.getControllerId(), game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -43,7 +43,7 @@ import mage.watchers.common.PlayerDamagedBySourceWatcher;
|
||||||
|
|
||||||
public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate<ObjectPlayer<Controllable>> {
|
public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate<ObjectPlayer<Controllable>> {
|
||||||
|
|
||||||
private TargetController controller;
|
private final TargetController controller;
|
||||||
|
|
||||||
public DamagedPlayerThisTurnPredicate(TargetController controller) {
|
public DamagedPlayerThisTurnPredicate(TargetController controller) {
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
|
|
|
@ -144,6 +144,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines player whose turn this player controls at the moment.
|
* Defines player whose turn this player controls at the moment.
|
||||||
|
* @param game
|
||||||
* @param playerId
|
* @param playerId
|
||||||
*/
|
*/
|
||||||
void controlPlayersTurn(Game game, UUID playerId);
|
void controlPlayersTurn(Game game, UUID playerId);
|
||||||
|
@ -316,13 +317,15 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
/**
|
/**
|
||||||
* asThough effect to reveal faceDown cards
|
* asThough effect to reveal faceDown cards
|
||||||
*
|
*
|
||||||
|
* @param card
|
||||||
|
* @param game
|
||||||
*/
|
*/
|
||||||
void revealFaceDownCard(Card card, Game game);
|
void revealFaceDownCard(Card card, Game game);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set seconds left to play the game.
|
* Set seconds left to play the game.
|
||||||
*
|
*
|
||||||
* @return
|
* @param timeLeft
|
||||||
*/
|
*/
|
||||||
void setPriorityTimeLeft(int timeLeft);
|
void setPriorityTimeLeft(int timeLeft);
|
||||||
|
|
||||||
|
@ -344,14 +347,14 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
boolean canJoinTable(Table table);
|
boolean canJoinTable(Table table);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the commanderId of the player
|
* Set the commanderId of the player
|
||||||
* @param card
|
* @param commanderId
|
||||||
*/
|
*/
|
||||||
void setCommanderId(UUID commanderId);
|
void setCommanderId(UUID commanderId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the commanderId of the player
|
* Get the commanderId of the player
|
||||||
* @param card
|
* @return
|
||||||
*/
|
*/
|
||||||
UUID getCommanderId();
|
UUID getCommanderId();
|
||||||
|
|
||||||
|
@ -374,9 +377,16 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
* @param game
|
* @param game
|
||||||
* @param fromZone
|
* @param fromZone
|
||||||
* @param sourceId
|
* @param sourceId
|
||||||
* @param game
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -492,7 +492,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
} else if (source instanceof StackObject) {
|
} else if (source instanceof StackObject) {
|
||||||
controllerId = ((StackObject) source).getControllerId();
|
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)) {
|
!game.getContinuousEffects().asThough(this.getId(), AsThoughEffectType.HEXPROOF, game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1446,12 +1446,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetPassed() {
|
public void resetPassed() {
|
||||||
if (!this.loses && !this.hasLeft()) {
|
this.passed = this.loses || this.hasLeft();
|
||||||
this.passed = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.passed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2093,9 +2088,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
return this.commanderId;
|
return this.commanderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
|
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
@ -2108,9 +2100,6 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId) {
|
public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
@ -2123,5 +2112,10 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasOpponent(UUID playerToCheckId, Game game) {
|
||||||
|
return game.isOpponent(this, playerToCheckId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard<TargetCardInOppon
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
Card card = game.getCard(id);
|
Card card = game.getCard(id);
|
||||||
if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
|
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()) {
|
if (allFromOneOpponent && !targets.isEmpty()) {
|
||||||
Card firstCard = game.getCard((UUID)targets.keySet().iterator().next());
|
Card firstCard = game.getCard((UUID)targets.keySet().iterator().next());
|
||||||
if (firstCard != null && !card.getOwnerId().equals(firstCard.getOwnerId())) {
|
if (firstCard != null && !card.getOwnerId().equals(firstCard.getOwnerId())) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class BloodthirstWatcher extends WatcherImpl<BloodthirstWatcher> {
|
||||||
return;
|
return;
|
||||||
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
|
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
|
||||||
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
|
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
|
||||||
if (game.getOpponents(this.controllerId).contains(damageEvent.getPlayerId())) {
|
if (game.getPlayer(this.getControllerId()).hasOpponent(damageEvent.getPlayerId(), game)) {
|
||||||
condition = true;
|
condition = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue