MCPcopy Create free account
hub / github.com/Card-Forge/forge / shouldApply

Method shouldApply

forge-ai/src/main/java/forge/ai/ability/CloakAi.java:11–42  ·  view source on GitHub ↗
(final Card card, final Player ai, final SpellAbility sa)

Source from the content-addressed store, hash-verified

9public class CloakAi extends ManifestBaseAi {
10
11 @Override
12 protected boolean shouldApply(final Card card, final Player ai, final SpellAbility sa) {
13 // check to ensure that there are no replacement effects that prevent creatures ETBing from library
14 // (e.g. Grafdigger's Cage)
15 Card topCopy = CardCopyService.getLKICopy(card);
16 topCopy.turnFaceDownNoUpdate();
17 topCopy.setCloaked(sa);
18
19 if (ComputerUtil.isETBprevented(topCopy)) {
20 return false;
21 }
22
23 if (card.getView().canBeShownTo(ai.getView())) {
24 // try to avoid manifest a non Permanent
25 if (!card.isPermanent())
26 return false;
27
28 // do not manifest a card with X in its cost
29 if (card.getManaCost().countX() > 0)
30 return false;
31
32 // try to avoid manifesting a creature with zero or less toughness
33 if (card.isCreature() && card.getNetToughness() <= 0)
34 return false;
35
36 // card has ETBTrigger or ETBReplacement
37 if (card.hasETBTrigger(false) || card.hasETBReplacement()) {
38 return false;
39 }
40 }
41 return true;
42 }
43}

Callers

nothing calls this directly

Calls 13

getLKICopyMethod · 0.95
turnFaceDownNoUpdateMethod · 0.95
setCloakedMethod · 0.95
isETBpreventedMethod · 0.95
canBeShownToMethod · 0.80
countXMethod · 0.80
getNetToughnessMethod · 0.80
hasETBTriggerMethod · 0.80
hasETBReplacementMethod · 0.80
getViewMethod · 0.65
isPermanentMethod · 0.65
getManaCostMethod · 0.65

Tested by

no test coverage detected