mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Refactor: added miss Ability source in some choose methods
This commit is contained in:
parent
09a4294466
commit
5474787641
11 changed files with 34 additions and 28 deletions
|
|
@ -54,7 +54,7 @@ public class FilterPermanent extends FilterObject<Permanent> implements FilterIn
|
|||
if (!this.match(permanent, game) || !permanent.isPhasedIn()) {
|
||||
return false;
|
||||
}
|
||||
ObjectSourcePlayer<Permanent> osp = new ObjectSourcePlayer<Permanent>(permanent, playerId, source);
|
||||
ObjectSourcePlayer<Permanent> osp = new ObjectSourcePlayer<>(permanent, playerId, source);
|
||||
return extraPredicates.stream().allMatch(p -> p.apply(osp, game));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -625,7 +625,11 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean choose(Outcome outcome, Target target, Ability source, Game game, Map<String, Serializable> options);
|
||||
|
||||
boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game); // TODO: remove to use choose with "Ability source"
|
||||
// TODO: remove to use choose with "Ability source"
|
||||
default boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
|
||||
return choose(outcome, cards, target, null, game);
|
||||
}
|
||||
boolean choose(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game);
|
||||
|
||||
boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class StubPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
|
||||
public boolean choose(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
|
||||
cards.getCards(game).stream().map(MageItem::getId).forEach(cardId -> target.add(cardId, game));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,8 +211,8 @@ public class TargetCard extends TargetObject {
|
|||
return possibleTargets;
|
||||
}
|
||||
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Cards cards, Game game) {
|
||||
return cards.getCards(filter, game).stream().map(MageItem::getId).collect(Collectors.toSet());
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Cards cards, Ability source, Game game) {
|
||||
return cards.getCards(filter, sourceControllerId, source, game).stream().map(MageItem::getId).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -88,10 +88,14 @@ public class TargetCardInYourGraveyard extends TargetCard {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Cards cards, Game game) {
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Cards cards, Ability source, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
Player player = game.getPlayer(sourceControllerId);
|
||||
for (Card card : cards.getCards(filter, game)) {
|
||||
if (player == null) {
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
for (Card card : cards.getCards(filter, sourceControllerId, source, game)) {
|
||||
if (player.getGraveyard().getCards(game).contains(card)) {
|
||||
possibleTargets.add(card.getId());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue