Search in sources :

Example 1 with TraceInfo

use of mage.util.trace.TraceInfo in project mage by magefree.

the class ContinuousEffects method traceAddContinuousEffects.

public static void traceAddContinuousEffects(Map orderedEffects, ContinuousEffectsList<?> cel, Game game, String listName) {
    for (ContinuousEffect effect : cel) {
        Set<Ability> abilities = cel.getAbility(effect.getId());
        for (Ability ability : abilities) {
            Player controller = game.getPlayer(ability.getControllerId());
            MageObject source = game.getObject(ability.getSourceId());
            TraceInfo traceInfo = new TraceInfo();
            traceInfo.setInfo(listName);
            traceInfo.setOrder(effect.getOrder());
            if (ability instanceof MageSingleton) {
                traceInfo.setPlayerName("Mage Singleton");
                traceInfo.setSourceName("Mage Singleton");
            } else {
                traceInfo.setPlayerName(controller == null ? "no controller" : controller.getName());
                traceInfo.setSourceName(source == null ? "no source" : source.getIdName());
            }
            traceInfo.setRule(ability.getRule());
            traceInfo.setAbilityId(ability.getId());
            traceInfo.setEffectId(effect.getId());
            traceInfo.setDuration(effect.getDuration());
            orderedEffects.put(traceInfo.getPlayerName() + traceInfo.getSourceName() + effect.getId() + ability.getId(), traceInfo);
        }
    }
}
Also used : StaticAbility(mage.abilities.StaticAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) MageObject(mage.MageObject) MageSingleton(mage.abilities.MageSingleton) TraceInfo(mage.util.trace.TraceInfo)

Aggregations

MageObject (mage.MageObject)1 Ability (mage.abilities.Ability)1 MageSingleton (mage.abilities.MageSingleton)1 StaticAbility (mage.abilities.StaticAbility)1 Player (mage.players.Player)1 TraceInfo (mage.util.trace.TraceInfo)1