| 48 | import forge.util.Lang; |
| 49 | |
| 50 | public abstract class GameEntity implements GameObject, IIdentifiable { |
| 51 | protected int id; |
| 52 | private String name = ""; |
| 53 | protected CardCollection attachedCards = new CardCollection(); |
| 54 | protected Map<CounterType, Integer> counters = Maps.newHashMap(); |
| 55 | protected List<Pair<Integer, Boolean>> damageReceivedThisTurn = Lists.newArrayList(); |
| 56 | |
| 57 | protected GameEntity(int id0) { |
| 58 | id = id0; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public int getId() { |
| 63 | return id; |
| 64 | } |
| 65 | public void dangerouslySetId(int i) { id = i; } |
| 66 | |
| 67 | public String getName() { |
| 68 | return name; |
| 69 | } |
| 70 | public void setName(final String s) { |
| 71 | name = s; |
| 72 | getView().updateName(this); |
| 73 | } |
| 74 | |
| 75 | // This function handles damage after replacement and prevention effects are applied |
| 76 | public abstract int addDamageAfterPrevention(final int damage, final Card source, final SpellAbility cause, final boolean isCombat, GameEntityCounterTable counterTable); |
| 77 | |
| 78 | // This should be also usable by the AI to forecast an effect (so it must |
| 79 | // not change the game state) |
| 80 | public int staticDamagePrevention(int damage, final int possiblePrevention, final Card source, final boolean isCombat) { |
| 81 | if (damage <= 0) { |
| 82 | return 0; |
| 83 | } |
| 84 | if (!source.canDamagePrevented(isCombat)) { |
| 85 | return damage; |
| 86 | } |
| 87 | |
| 88 | if (isCombat && getGame().getReplacementHandler().isPreventCombatDamageThisTurn()) { |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | for (final Card ca : getGame().getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) { |
| 93 | for (final ReplacementEffect re : ca.getReplacementEffects()) { |
| 94 | if (!re.getMode().equals(ReplacementType.DamageDone) || |
| 95 | (!re.hasParam("PreventionEffect") && !re.hasParam("Prevent"))) { |
| 96 | continue; |
| 97 | } |
| 98 | if (!re.zonesCheck(getGame().getZoneOf(ca))) { |
| 99 | continue; |
| 100 | } |
| 101 | if (!re.requirementsCheck(getGame())) { |
| 102 | continue; |
| 103 | } |
| 104 | // Immortal Coil prevents the damage but has a similar negative effect |
| 105 | if ("Immortal Coil".equals(ca.getName())) { |
| 106 | continue; |
| 107 | } |
nothing calls this directly
no outgoing calls
no test coverage detected