WIP: Implement Role mechanic (#10816)

* [WOE] Implement Embereth Veteran

* add SBA for role tokens

* [WOE] Implement Cursed Courtier

* [WOE] Implement Conceited Witch

* [WOE] Implement Besotted Knight

* [WOE] Implement Syr Armont, the Redeemer

* [WOE] Implement Living Lectern

* add role test

* [WOE] Implement Lord Skitter's Blessing

* [WOE] Implement Faunsbane Troll

* [WOE] Implement Twisted Fealty

* [WOC] Implement Ellivere of the Wild Court

* [WOE] Implement Monstrous Rage

* [WOE] Implement Spellbook Vendor

* add verify skips

* extra fix
This commit is contained in:
Evan Kranzler 2023-08-17 10:18:21 -04:00 committed by GitHub
parent bf508aca9b
commit b20bdcede7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 1230 additions and 6 deletions

View file

@ -63,11 +63,7 @@ import mage.target.Target;
import mage.target.TargetCard;
import mage.target.TargetPermanent;
import mage.target.TargetPlayer;
import mage.util.CardUtil;
import mage.util.GameLog;
import mage.util.MessageToClient;
import mage.util.MultiAmountMessage;
import mage.util.RandomUtil;
import mage.util.*;
import mage.util.functions.CopyApplier;
import mage.watchers.Watcher;
import mage.watchers.common.*;
@ -2331,6 +2327,7 @@ public abstract class GameImpl implements Game {
List<Permanent> legendary = new ArrayList<>();
List<Permanent> worldEnchantment = new ArrayList<>();
Map<UUID, Map<UUID, Set<Permanent>>> roleMap = new HashMap<>();
List<FilterCreaturePermanent> usePowerInsteadOfToughnessForDamageLethalityFilters = getState().getActivePowerInsteadOfToughnessForDamageLethalityFilters();
for (Permanent perm : getBattlefield().getAllActivePermanents()) {
if (perm.isCreature(this)) {
@ -2510,6 +2507,11 @@ public abstract class GameImpl implements Game {
}
}
}
if (perm.hasSubtype(SubType.ROLE, this) && state.getZone(perm.getId()) == Zone.BATTLEFIELD) {
roleMap.computeIfAbsent(perm.getControllerId(), x -> new HashMap<>())
.computeIfAbsent(perm.getAttachedTo(), x -> new HashSet<>())
.add(perm);
}
}
// 704.5s If the number of lore counters on a Saga permanent is greater than or equal to its final chapter number
// and it isn't the source of a chapter ability that has triggered but not yet left the stack, that Saga's controller sacrifices it.
@ -2733,6 +2735,29 @@ public abstract class GameImpl implements Game {
}
}
if (!roleMap.isEmpty()) {
List<Set<Permanent>> rolesToHandle = roleMap.values()
.stream()
.map(Map::values)
.flatMap(Collection::stream)
.filter(s -> s.size() > 1)
.collect(Collectors.toList());
if (!rolesToHandle.isEmpty()) {
for (Set<Permanent> roleSet : rolesToHandle) {
int newest = roleSet
.stream()
.mapToInt(Permanent::getCreateOrder)
.max()
.orElse(-1);
roleSet.removeIf(permanent -> permanent.getCreateOrder() == newest);
for (Permanent permanent : roleSet) {
movePermanentToGraveyardWithInfo(permanent);
somethingHappened = true;
}
}
}
}
// Daybound/Nightbound permanents should be transformed according to day/night
// This is not a state-based action but it's unclear where else to put it
if (hasDayNight()) {