Merge branch 'manor' into 'master'

JHH: Some "seek" cards

See merge request core-developers/forge!5119
This commit is contained in:
Michael Kamensky
2021-07-27 04:55:21 +00:00
4 changed files with 70 additions and 2 deletions

View File

@@ -421,7 +421,7 @@ public class CardFactoryUtil {
/**
* <p>
* getMostProminentCreatureType.
* getMostProminentCreatureTypeSize.
* </p>
*
* @param list
@@ -457,6 +457,49 @@ public class CardFactoryUtil {
return max + allCreatureType;
}
/**
* <p>
* getMostProminentCreatureType.
* </p>
*
* @param list
* a {@link forge.game.card.CardCollection} object.
* @return a string.
*/
public static String[] getMostProminentCreatureType(final CardCollectionView list) {
if (list.isEmpty()) {
return null;
}
final Map<String, Integer> map = Maps.newHashMap();
for (final Card c : list) {
// Remove Duplicated types
final Set<String> creatureTypes = c.getType().getCreatureTypes();
for (String creatureType : creatureTypes) {
Integer count = map.get(creatureType);
map.put(creatureType, count == null ? 1 : count + 1);
}
}
int max = 0;
for (final Entry<String, Integer> entry : map.entrySet()) {
if (max < entry.getValue()) {
max = entry.getValue();
}
}
if (max == 0) {
return null;
}
StringBuilder sb = new StringBuilder();
for (final Entry<String, Integer> entry : map.entrySet()) {
if (max == entry.getValue()) {
sb.append(entry.getKey()).append(",");
}
}
return sb.toString().split(",");
}
/**
* <p>
* sharedKeywords.

View File

@@ -720,6 +720,16 @@ public class CardProperty {
}
}
}
} else if (property.startsWith("MostProminentCreatureTypeInLibrary")) {
final CardCollectionView list = sourceController.getCardsIn(ZoneType.Library);
String[] type = CardFactoryUtil.getMostProminentCreatureType(list);
if (type != null); {
for (String s : type) {
if (!card.getType().hasCreatureType(s)) {
return false;
}
}
}
} else if (property.startsWith("sharesCreatureTypeWith")) {
if (property.equals("sharesCreatureTypeWith")) {
if (!card.sharesCreatureTypeWith(source)) {

View File

@@ -0,0 +1,8 @@
Name:Faceless Agent
ManaCost:3
Types:Creature Shapeshifter
PT:2/1
K:Changeling
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigSeek | TriggerDescription$ When CARDNAME enters the battlefield, seek a creature card of the most prevalent creature type in your library.
SVar:TrigSeek:DB$ ChangeZone | Origin$ Library | Destination$ Hand | AtRandom$ True | NoShuffle$ True | Mandatory$ True | NoLooking$ True | NoReveal$ True | ChangeType$ Card.Creature+MostProminentCreatureTypeInLibrary | ChangeNum$ 1
Oracle:Changeling\nWhen Faceless Agent enters the battlefield, seek a creature card of the most prevalent creature type in your library.

View File

@@ -0,0 +1,7 @@
Name:Manor Guardian
ManaCost:2 B
Types:Creature Demon
PT:4/3
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ TrigSeek | TriggerDescription$ When CARDNAME dies, each player seeks a nonland card with mana value 2 or less.
SVar:TrigSeek:DB$ ChangeZone | Origin$ Library | Destination$ Hand | AtRandom$ True | NoShuffle$ True | Mandatory$ True | NoLooking$ True | NoReveal$ True | ChangeType$ Card.nonLand+cmcLE2 | ChangeNum$ 1 | DefinedPlayer$ Player
Oracle:When Manor Guardian dies, each player seeks a nonland card with mana value 2 or less.