mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
* Fixed wrong re-targeting on copy complex cards (fixed adjustTargets for copies)
* Oath Of Lieges - Fixed that copy of opponent's card don't work; * Oath Of Lieges - Fixed that it can shuffle lib without search;
This commit is contained in:
parent
59bda7f1d5
commit
bb18814c84
3 changed files with 225 additions and 84 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.o;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -18,6 +17,7 @@ import mage.filter.predicate.ObjectSourcePlayer;
|
|||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
|
@ -25,12 +25,10 @@ import mage.target.targetpointer.FixedTarget;
|
|||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public final class OathOfLieges extends CardImpl {
|
||||
|
||||
private final UUID originalId;
|
||||
private static final FilterPlayer FILTER = new FilterPlayer("player who controls more lands than you do and is your opponent");
|
||||
|
||||
static {
|
||||
|
|
@ -43,26 +41,19 @@ public final class OathOfLieges extends CardImpl {
|
|||
// At the beginning of each player's upkeep, that player chooses target player who controls more lands than he or she does and is their opponent. The first player may search their library for a basic land card, put that card onto the battlefield, then shuffle their library.
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(new OathOfLiegesEffect(), TargetController.ANY, false);
|
||||
ability.addTarget(new TargetPlayer(1, 1, false, FILTER));
|
||||
originalId = ability.getOriginalId();
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability.getOriginalId().equals(originalId)) {
|
||||
Player activePlayer = game.getPlayer(game.getActivePlayerId());
|
||||
if (activePlayer != null) {
|
||||
ability.getTargets().clear();
|
||||
TargetPlayer target = new TargetPlayer(1, 1, false, FILTER);
|
||||
target.setTargetController(activePlayer.getId());
|
||||
ability.getTargets().add(target);
|
||||
}
|
||||
// target controller must be active player (even for copies)
|
||||
for (Target target : ability.getTargets()) {
|
||||
target.setTargetController(game.getActivePlayerId());
|
||||
}
|
||||
}
|
||||
|
||||
public OathOfLieges(final OathOfLieges card) {
|
||||
super(card);
|
||||
this.originalId = card.originalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -93,7 +84,7 @@ class OathOfLiegesEffect extends OneShotEffect {
|
|||
Player activePlayer = game.getPlayer(game.getActivePlayerId());
|
||||
if (activePlayer != null) {
|
||||
if (activePlayer.chooseUse(outcome, "Search your library for a basic land card, put that card onto the battlefield, then shuffle your library?", source, game)) {
|
||||
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, true, Outcome.PutLandInPlay, true);
|
||||
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, false, Outcome.PutLandInPlay, true);
|
||||
effect.setTargetPointer(new FixedTarget(game.getActivePlayerId()));
|
||||
return effect.apply(game, source);
|
||||
}
|
||||
|
|
@ -110,18 +101,25 @@ class OathOfLiegesPredicate implements ObjectSourcePlayerPredicate<ObjectSourceP
|
|||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
|
||||
// input.getPlayerId() -- source controller id
|
||||
// input.getObject() -- checking player
|
||||
|
||||
Player targetPlayer = input.getObject();
|
||||
//Get active input.playerId because adjust target is used after canTarget function
|
||||
UUID activePlayerId = game.getActivePlayerId();
|
||||
if (targetPlayer == null || activePlayerId == null) {
|
||||
return false;
|
||||
}
|
||||
if (!targetPlayer.hasOpponent(activePlayerId, game)) {
|
||||
return false;
|
||||
}
|
||||
int countTargetPlayer = game.getBattlefield().countAll(FILTER, targetPlayer.getId(), game);
|
||||
int countActivePlayer = game.getBattlefield().countAll(FILTER, activePlayerId, game);
|
||||
Player activePlayer = game.getPlayer(game.getActivePlayerId());
|
||||
|
||||
if (targetPlayer == null || activePlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// must be opponent
|
||||
if (!activePlayer.hasOpponent(targetPlayer.getId(), game)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// must have more lands than active player
|
||||
int countTargetPlayer = game.getBattlefield().countAll(FILTER, targetPlayer.getId(), game);
|
||||
int countActivePlayer = game.getBattlefield().countAll(FILTER, activePlayer.getId(), game);
|
||||
return countTargetPlayer > countActivePlayer;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue