forked from External/mage
* Added 3 cards from Ravinca City of Gold set.
This commit is contained in:
parent
d99fe5a70e
commit
3708ea2a89
8 changed files with 345 additions and 7 deletions
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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.target.targetpointer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ludwig.Hirth
|
||||
*/
|
||||
public class ThirdTargetPointer implements TargetPointer {
|
||||
|
||||
private Map<UUID, Integer> zoneChangeCounter = new HashMap<>();
|
||||
|
||||
public static ThirdTargetPointer getInstance() {
|
||||
return new ThirdTargetPointer();
|
||||
}
|
||||
|
||||
public ThirdTargetPointer() {
|
||||
}
|
||||
|
||||
public ThirdTargetPointer(ThirdTargetPointer targetPointer) {
|
||||
this.zoneChangeCounter = new HashMap<>();
|
||||
for (Map.Entry<UUID, Integer> entry : targetPointer.zoneChangeCounter.entrySet()) {
|
||||
this.zoneChangeCounter.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Game game, Ability source) {
|
||||
if (source.getTargets().size() > 2) {
|
||||
for (UUID target : source.getTargets().get(2).getTargets()) {
|
||||
Card card = game.getCard(target);
|
||||
if (card != null) {
|
||||
this.zoneChangeCounter.put(target, card.getZoneChangeCounter(game));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<>();
|
||||
if (source.getTargets().size() > 2) {
|
||||
for (UUID targetId : source.getTargets().get(2).getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null && zoneChangeCounter.containsKey(targetId)
|
||||
&& card.getZoneChangeCounter(game) != zoneChangeCounter.get(targetId)) {
|
||||
continue;
|
||||
}
|
||||
target.add(targetId);
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getFirst(Game game, Ability source) {
|
||||
if (source.getTargets().size() > 2) {
|
||||
UUID targetId = source.getTargets().get(2).getFirstTarget();
|
||||
if (zoneChangeCounter.containsKey(targetId)) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null && zoneChangeCounter.containsKey(targetId)
|
||||
&& card.getZoneChangeCounter(game) != zoneChangeCounter.get(targetId)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return targetId;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPointer copy() {
|
||||
return new ThirdTargetPointer(this);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue