* Kydele, Chosen of Kruphix - Fixed a bug caused by the watcher object.

This commit is contained in:
LevelX2 2016-11-06 23:37:34 +01:00
parent ed70fd1f00
commit 6962f02ab8
3 changed files with 21 additions and 22 deletions

View file

@ -65,7 +65,7 @@ public class KydeleChosenOfKruphix extends CardImpl {
// {T}: Add {C} to your mana pool for each card you've drawn this turn.
DynamicManaAbility ability = new DynamicManaAbility(Mana.ColorlessMana(1), new CardsDrawnThisTurnDynamicValue(), new TapSourceCost());
this.addAbility(ability, new CardsDrawnThisTurnWatcher());
this.addAbility(ability, new KydeleCardsDrawnThisTurnWatcher());
// Partner
this.addAbility(PartnerAbility.getInstance());
@ -85,7 +85,7 @@ class CardsDrawnThisTurnDynamicValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
CardsDrawnThisTurnWatcher watcher = (CardsDrawnThisTurnWatcher) game.getState().getWatchers().get("CardsDrawnThisTurnWatcher");
KydeleCardsDrawnThisTurnWatcher watcher = (KydeleCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(KydeleCardsDrawnThisTurnWatcher.class.getName());
return watcher.getNumCardsDrawnThisTurn(sourceAbility.getControllerId());
}
@ -105,15 +105,15 @@ class CardsDrawnThisTurnDynamicValue implements DynamicValue {
}
}
class CardsDrawnThisTurnWatcher extends Watcher {
class KydeleCardsDrawnThisTurnWatcher extends Watcher {
private final Map<UUID, Set<UUID>> cardsDrawnThisTurn = new HashMap<>();
public CardsDrawnThisTurnWatcher() {
super("CardsDrawnThisTurnWatcher", WatcherScope.GAME);
public KydeleCardsDrawnThisTurnWatcher() {
super(KydeleCardsDrawnThisTurnWatcher.class.getName(), WatcherScope.GAME);
}
public CardsDrawnThisTurnWatcher(final CardsDrawnThisTurnWatcher watcher) {
public KydeleCardsDrawnThisTurnWatcher(final KydeleCardsDrawnThisTurnWatcher watcher) {
super(watcher);
this.cardsDrawnThisTurn.putAll(watcher.cardsDrawnThisTurn);
}
@ -130,10 +130,6 @@ class CardsDrawnThisTurnWatcher extends Watcher {
}
}
private Set<UUID> getCardsDrawnThisTurn(UUID playerId) {
return cardsDrawnThisTurn.get(playerId);
}
public int getNumCardsDrawnThisTurn(UUID playerId) {
if (cardsDrawnThisTurn.get(playerId) == null) {
return 0;
@ -145,11 +141,11 @@ class CardsDrawnThisTurnWatcher extends Watcher {
public void reset() {
super.reset();
cardsDrawnThisTurn.clear();
}
@Override
public CardsDrawnThisTurnWatcher copy() {
return new CardsDrawnThisTurnWatcher(this);
public KydeleCardsDrawnThisTurnWatcher copy() {
return new KydeleCardsDrawnThisTurnWatcher(this);
}
}

View file

@ -60,11 +60,11 @@ import mage.watchers.Watcher;
public class SylvanLibrary extends CardImpl {
public SylvanLibrary(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
// At the beginning of your draw step, you may draw two additional cards. If you do, choose two cards in your hand drawn this turn. For each of those cards, pay 4 life or put the card on top of your library.
this.addAbility(new BeginningOfDrawTriggeredAbility(new SylvanLibraryEffect(), TargetController.YOU, true),
new CardsDrawnThisTurnWatcher());
new SylvanLibraryCardsDrawnThisTurnWatcher());
}
@ -99,7 +99,7 @@ class SylvanLibraryEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.drawCards(2, game);
CardsDrawnThisTurnWatcher watcher = (CardsDrawnThisTurnWatcher) game.getState().getWatchers().get("CardsDrawnThisTurnWatcher");
SylvanLibraryCardsDrawnThisTurnWatcher watcher = (SylvanLibraryCardsDrawnThisTurnWatcher) game.getState().getWatchers().get("SylvanLibraryCardsDrawnThisTurnWatcher");
if (watcher != null) {
Cards cards = new CardsImpl();
Set<UUID> cardsDrawnThisTurn = watcher.getCardsDrawnThisTurn(controller.getId());
@ -141,15 +141,15 @@ class SylvanLibraryEffect extends OneShotEffect {
}
}
class CardsDrawnThisTurnWatcher extends Watcher {
class SylvanLibraryCardsDrawnThisTurnWatcher extends Watcher {
private final Map<UUID, Set<UUID>> cardsDrawnThisTurn = new HashMap<>();
public CardsDrawnThisTurnWatcher() {
super("CardsDrawnThisTurnWatcher", WatcherScope.GAME);
public SylvanLibraryCardsDrawnThisTurnWatcher() {
super("SylvanLibraryCardsDrawnThisTurnWatcher", WatcherScope.GAME);
}
public CardsDrawnThisTurnWatcher(final CardsDrawnThisTurnWatcher watcher) {
public SylvanLibraryCardsDrawnThisTurnWatcher(final SylvanLibraryCardsDrawnThisTurnWatcher watcher) {
super(watcher);
this.cardsDrawnThisTurn.putAll(watcher.cardsDrawnThisTurn);
}
@ -177,8 +177,8 @@ class CardsDrawnThisTurnWatcher extends Watcher {
}
@Override
public CardsDrawnThisTurnWatcher copy() {
return new CardsDrawnThisTurnWatcher(this);
public SylvanLibraryCardsDrawnThisTurnWatcher copy() {
return new SylvanLibraryCardsDrawnThisTurnWatcher(this);
}
}

View file

@ -189,6 +189,9 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
* @return
*/
private boolean canDamage(Permanent perm, boolean first) {
if (perm == null) {
return false;
}
// if now first strike combat damage step
if (first) {
// should have first strike or double strike