protected void addAbilities(List<Ability> abilities) { for (Ability ability : abilities) { addAbility(ability); } }
@Override public boolean addCounters(Counter counter, Ability source, Game game) { return addCounters(counter, source, game, null, true); }
public static Card createCard(Class<?> clazz, CardSetInfo setInfo) { return createCard(clazz, setInfo, null); }
@Override public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect) { boolean returnCode = true; UUID sourceId = getId(); if (source != null) { MageObject object = game.getObject(source.getId()); GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, sourceId, getControllerOrOwner(), counter.getName(), counter.getCount()); countersEvent.setAppliedEffects(appliedEffects); countersEvent.setFlag(isEffect); Counter eventCounter = counter.copy(); eventCounter.remove(eventCounter.getCount() - 1); GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, sourceId, getControllerOrOwner(), counter.getName(), 1); event.setAppliedEffects(appliedEffects); if (!game.replaceEvent(event)) { getCounters(game).addCounter(eventCounter); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, sourceId, getControllerOrOwner(), counter.getName(), 1)); } else { finalAmount--; game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERS_ADDED, objectId, sourceId, getControllerOrOwner(), counter.getName(), amount));
@Override public void updateZoneChangeCounter(Game game, ZoneChangeEvent event) { if (isCopy() || !isMelded()) { super.updateZoneChangeCounter(game, event); return; } game.getState().updateZoneChangeCounter(objectId); if (topLastZoneChangeCounter == topHalfCard.getZoneChangeCounter(game) && halves.contains(topHalfCard.getId())) { topHalfCard.updateZoneChangeCounter(game, event); topLastZoneChangeCounter = topHalfCard.getZoneChangeCounter(game); } if (bottomLastZoneChangeCounter == bottomHalfCard.getZoneChangeCounter(game) && halves.contains(bottomHalfCard.getId())) { bottomHalfCard.updateZoneChangeCounter(game, event); bottomLastZoneChangeCounter = bottomHalfCard.getZoneChangeCounter(game); } }
@Override public void removeCounters(String name, int amount, Game game) { for (int i = 0; i < amount; i++) { if (!getCounters(game).removeCounter(name, 1)) { break; } GameEvent event = GameEvent.getEvent(GameEvent.EventType.COUNTER_REMOVED, objectId, getControllerOrOwner()); event.setData(name); game.fireEvent(event); } }
/** * Currently only gets the fuse SpellAbility if there is one, but generally * gets any abilities on a split card as a whole, and not on either half * individually. * * @return */ public Abilities<Ability> getSharedAbilities() { return super.getAbilities(); }
@Override public void assignNewId() { super.assignNewId(); leftHalfCard.assignNewId(); rightHalfCard.assignNewId(); }
@Override public Counters getCounters(Game game) { return getCounters(game.getState()); }
@Override public void adjustCosts(Ability ability, Game game) { super.adjustCosts(ability, game); int reductionAmount = game.getBattlefield().count(filter, ability.getSourceId(), ability.getControllerId(), game); Iterator<ManaCost> iter = ability.getManaCostsToPay().iterator(); while ( reductionAmount > 0 && iter.hasNext() ) { ManaCost manaCost = iter.next(); if (manaCost.getMana().getGreen() > 0) { // in case another effect adds additional mana cost iter.remove(); reductionAmount--; } } }
@Override public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) { switch (ability.getSpellAbilityType()) { case SPLIT_LEFT: return this.getLeftHalfCard().cast(game, fromZone, ability, controllerId); case SPLIT_RIGHT: return this.getRightHalfCard().cast(game, fromZone, ability, controllerId); default: this.getLeftHalfCard().getSpellAbility().setControllerId(controllerId); this.getRightHalfCard().getSpellAbility().setControllerId(controllerId); return super.cast(game, fromZone, ability, controllerId); } }
super.updateZoneChangeCounter(game, event); Counters copyTo = null; if (event.getTarget() != null && event.getToZone() == Zone.BATTLEFIELD) {
@Override public Abilities<Ability> getAbilities(Game game) { Abilities<Ability> allAbilites = new AbilitiesImpl<>(); for (Ability ability : super.getAbilities(game)) { if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT && ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT_AFTERMATH) { allAbilites.add(ability); } } allAbilites.addAll(leftHalfCard.getAbilities(game)); allAbilites.addAll(rightHalfCard.getAbilities(game)); return allAbilites; }
@Override public void assignNewId() { super.assignNewId(); topHalfCard.assignNewId(); bottomHalfCard.assignNewId(); }
public static Card createCard(String name, CardSetInfo setInfo) { try { return createCard(Class.forName(name), setInfo); } catch (ClassNotFoundException ex) { try { return createCard(PluginClassloaderRegistery.forName(name), setInfo); } catch (ClassNotFoundException ex2) { // ignored } logger.fatal("Error loading card: " + name, ex); return null; } }
@Override public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects) { return addCounters(counter, source, game, appliedEffects, true); }
@Override public Abilities<Ability> getAbilities() { Abilities<Ability> allAbilites = new AbilitiesImpl<>(); for (Ability ability : super.getAbilities()) { if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT && ((SpellAbility) ability).getSpellAbilityType() != SpellAbilityType.SPLIT_AFTERMATH) { allAbilites.add(ability); } } allAbilites.addAll(leftHalfCard.getAbilities()); allAbilites.addAll(rightHalfCard.getAbilities()); return allAbilites; }
protected void addAbility(Ability ability, Watcher watcher) { addAbility(ability); ability.addWatcher(watcher); }
@Override public final Card getSecondCardFace() { if (secondSideCardClazz == null && secondSideCard == null) { return null; } if (secondSideCard != null) { return secondSideCard; } List<ExpansionSet.SetCardInfo> cardInfo = Sets.findSet(expansionSetCode).findCardInfoByClass(secondSideCardClazz); assert cardInfo.size() == 1; // should find 1 second side card if (cardInfo.isEmpty()) { return null; } ExpansionSet.SetCardInfo info = cardInfo.get(0); return secondSideCard = createCard(secondSideCardClazz, new CardSetInfo(info.getName(), expansionSetCode, info.getCardNumber(), info.getRarity(), info.getGraphicInfo())); }
@Override public boolean addCounters(Counter counter, Ability source, Game game, boolean isEffect) { return addCounters(counter, source, game, null, isEffect); }