Refactoring subtypes to make Maskwood Nexus work (ready for review) (#7432)

* removed and renamed SubTypeList

* updated subtype test

* refactored Changeling to be an ability that actually does something

* moved isAllCreatureTypes into SubTypes class

* renamed copyTo method to copyFrom

* added removeAllCreatureTypes where usable

* replaced some subtype methods

* replaced some more subtype methods

* replaced subtype mass add/remove methods

* updated more subtype methods

* fixed some errors

* made common shared creature type predicate

* refactored another card involving subtypes

* Added usage of object attribute in subTypes's write operations;

* Refactor: use same param styles in subtype methods

* Refactor: simplified usage of copy appliers;

* Refactor: fixed code usage in CopyApplier

Co-authored-by: Oleg Agafonov <jaydi85@gmail.com>
This commit is contained in:
Evan Kranzler 2021-01-26 08:52:35 -05:00 committed by GitHub
parent 6f42b90305
commit dacf30f4b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
259 changed files with 1857 additions and 1922 deletions

View file

@ -1,6 +1,8 @@
package mage.watchers.common;
import mage.cards.Card;
import mage.constants.SubType;
import mage.constants.SubTypeSet;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
@ -39,7 +41,7 @@ public class ProwlWatcher extends Watcher {
if (creature == null || allSubtypes.contains(creature.getControllerId())) {
return;
}
if (creature.isAllCreatureTypes()) {
if (creature.isAllCreatureTypes(game)) {
allSubtypes.add(creature.getControllerId());
return;
}
@ -55,12 +57,16 @@ public class ProwlWatcher extends Watcher {
allSubtypes.clear();
}
public boolean hasSubtypeMadeCombatDamage(UUID playerId, SubType subtype) {
public boolean hasSubtypeMadeCombatDamage(UUID playerId, Card card, Game game) {
if (allSubtypes.contains(playerId)) {
return true;
}
Set<SubType> subtypes = damagingSubtypes.get(playerId);
return subtypes != null && subtypes.contains(subtype);
return subtypes != null
&& subtypes
.stream()
.filter(subType -> subType.getSubTypeSet() == SubTypeSet.CreatureType)
.anyMatch(subType -> card.hasSubtype(subType, game));
}
}