mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
* Prowl ability - Fixed the bug, that creatures with Changeling did not count for Prowl.
This commit is contained in:
parent
093bc5e0e9
commit
71e3670d0c
2 changed files with 28 additions and 14 deletions
|
|
@ -117,12 +117,10 @@ public class ProwlAbility extends StaticAbility<ProwlAbility> implements Alterna
|
||||||
throw new IllegalArgumentException("Params can't be null");
|
throw new IllegalArgumentException("Params can't be null");
|
||||||
}
|
}
|
||||||
boolean canProwl = false;
|
boolean canProwl = false;
|
||||||
if (prowlWatcher.getDamagingSubtypes(ability.getControllerId()) != null) {
|
for (String subtype: card.getSubtype()) {
|
||||||
for (String subtype : prowlWatcher.getDamagingSubtypes(ability.getControllerId())) {
|
if (prowlWatcher.hasSubtypeMadeCombatDamage(ability.getControllerId(), subtype)) {
|
||||||
if (card.getSubtype().contains(subtype)) {
|
canProwl = true;
|
||||||
canProwl = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (canProwl) {
|
if (canProwl) {
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,13 @@
|
||||||
package mage.watchers.common;
|
package mage.watchers.common;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.abilities.keyword.ChangelingAbility;
|
||||||
import mage.constants.WatcherScope;
|
import mage.constants.WatcherScope;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.DamagedPlayerEvent;
|
import mage.game.events.DamagedPlayerEvent;
|
||||||
|
|
@ -50,6 +52,7 @@ import mage.watchers.WatcherImpl;
|
||||||
public class ProwlWatcher extends WatcherImpl<ProwlWatcher> {
|
public class ProwlWatcher extends WatcherImpl<ProwlWatcher> {
|
||||||
|
|
||||||
private Map<UUID, Set<String>> damagingSubtypes = new HashMap<UUID, Set<String>>();
|
private Map<UUID, Set<String>> damagingSubtypes = new HashMap<UUID, Set<String>>();
|
||||||
|
private Set<UUID> allSubtypes = new HashSet<UUID>();
|
||||||
|
|
||||||
public ProwlWatcher() {
|
public ProwlWatcher() {
|
||||||
super("Prowl", WatcherScope.GAME);
|
super("Prowl", WatcherScope.GAME);
|
||||||
|
|
@ -73,13 +76,17 @@ public class ProwlWatcher extends WatcherImpl<ProwlWatcher> {
|
||||||
DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
|
DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
|
||||||
if (dEvent.isCombatDamage()) {
|
if (dEvent.isCombatDamage()) {
|
||||||
Permanent creature = game.getPermanent(dEvent.getSourceId());
|
Permanent creature = game.getPermanent(dEvent.getSourceId());
|
||||||
if (creature != null) {
|
if (creature != null && !allSubtypes.contains(creature.getControllerId())) {
|
||||||
Set<String> subtypes = damagingSubtypes.get(creature.getControllerId());
|
if (creature.getAbilities().containsKey(ChangelingAbility.getInstance().getId())) {
|
||||||
if (subtypes == null) {
|
allSubtypes.add(creature.getControllerId());
|
||||||
subtypes = new LinkedHashSet<String>();
|
} else {
|
||||||
|
Set<String> subtypes = damagingSubtypes.get(creature.getControllerId());
|
||||||
|
if (subtypes == null) {
|
||||||
|
subtypes = new LinkedHashSet<String>();
|
||||||
|
}
|
||||||
|
subtypes.addAll(creature.getSubtype());
|
||||||
|
damagingSubtypes.put(creature.getControllerId(), subtypes);
|
||||||
}
|
}
|
||||||
subtypes.addAll(creature.getSubtype());
|
|
||||||
damagingSubtypes.put(creature.getControllerId(), subtypes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -89,9 +96,18 @@ public class ProwlWatcher extends WatcherImpl<ProwlWatcher> {
|
||||||
public void reset() {
|
public void reset() {
|
||||||
super.reset();
|
super.reset();
|
||||||
damagingSubtypes.clear();
|
damagingSubtypes.clear();
|
||||||
|
allSubtypes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getDamagingSubtypes(UUID playerId) {
|
public boolean hasSubtypeMadeCombatDamage(UUID playerId, String subtype) {
|
||||||
return damagingSubtypes.get(playerId);
|
if (allSubtypes.contains(playerId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Set<String> subtypes = damagingSubtypes.get(playerId);
|
||||||
|
if (subtypes != null) {
|
||||||
|
return subtypes.contains(subtype);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue