forked from External/mage
* Added some trace output for continous effects and triggered abilities. Changed duration of AffinityEffect to WhileOnStack to prevent wrong handling for removement of the effect.
This commit is contained in:
parent
8c85c0dbad
commit
9fc0e2f25a
10 changed files with 323 additions and 48 deletions
|
|
@ -1,6 +1,12 @@
|
|||
package mage.util;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Abilities;
|
||||
|
|
@ -36,13 +42,6 @@ import mage.target.targetpointer.FixedTarget;
|
|||
import mage.util.functions.CopyTokenFunction;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
*/
|
||||
|
|
@ -818,7 +817,7 @@ public final class CardUtil {
|
|||
}
|
||||
|
||||
public static boolean isFusedPartAbility(Ability ability, Game game) {
|
||||
// TODO: is works fine with copies of spells on stack?
|
||||
// TODO: does it work fine with copies of spells on stack?
|
||||
if (ability instanceof SpellAbility) {
|
||||
Spell mainSpell = game.getSpell(ability.getId());
|
||||
if (mainSpell == null) {
|
||||
|
|
|
|||
85
Mage/src/main/java/mage/util/trace/TraceInfo.java
Normal file
85
Mage/src/main/java/mage/util/trace/TraceInfo.java
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
package mage.util.trace;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.Duration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class TraceInfo {
|
||||
public String info;
|
||||
public String playerName;
|
||||
public String sourceName;
|
||||
public String rule;
|
||||
public UUID abilityId;
|
||||
public UUID effectId;
|
||||
public Duration duration;
|
||||
public long order;
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public void setPlayerName(String playerName) {
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
public String getSourceName() {
|
||||
return sourceName;
|
||||
}
|
||||
|
||||
public void setSourceName(String sourceName) {
|
||||
this.sourceName = sourceName;
|
||||
}
|
||||
|
||||
public String getRule() {
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void setRule(String rule) {
|
||||
this.rule = rule;
|
||||
}
|
||||
|
||||
public UUID getAbilityId() {
|
||||
return abilityId;
|
||||
}
|
||||
|
||||
public void setAbilityId(UUID abilityId) {
|
||||
this.abilityId = abilityId;
|
||||
}
|
||||
|
||||
public UUID getEffectId() {
|
||||
return effectId;
|
||||
}
|
||||
|
||||
public void setEffectId(UUID effectId) {
|
||||
this.effectId = effectId;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public Duration getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(Duration duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public long getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(long order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package mage.util.trace;
|
||||
|
||||
import java.util.*;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffectsList;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.keyword.CantBeBlockedSourceAbility;
|
||||
|
|
@ -14,10 +16,9 @@ import mage.game.Game;
|
|||
import mage.game.combat.Combat;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
|
|
@ -210,4 +211,31 @@ public final class TraceUtil {
|
|||
public static void trace(String msg) {
|
||||
log.info(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints out a status of the currently existing triggered abilities
|
||||
* @param game
|
||||
*/
|
||||
public static void traceTriggeredAbilities(Game game) {
|
||||
log.info("-------------------------------------------------------------------------------------------------");
|
||||
log.info("Turn: " + game.getTurnNum() + " - currently existing triggered abilities: " + game.getState().getTriggers().size());
|
||||
Map<String, String> orderedAbilities = new TreeMap<>();
|
||||
for (Map.Entry<String, TriggeredAbility> entry : game.getState().getTriggers().entrySet()) {
|
||||
Player controller = game.getPlayer(entry.getValue().getControllerId());
|
||||
MageObject source = game.getObject(entry.getValue().getSourceId());
|
||||
orderedAbilities.put((controller == null ? "no controller": controller.getName()) + (source == null ? "no source": source.getIdName())+ entry.getKey(), entry.getKey());
|
||||
}
|
||||
String playerName = "";
|
||||
for (Map.Entry<String, String> entry : orderedAbilities.entrySet()) {
|
||||
TriggeredAbility trAbility = game.getState().getTriggers().get(entry.getValue());
|
||||
Player controller = game.getPlayer(trAbility.getControllerId());
|
||||
MageObject source = game.getObject(trAbility.getSourceId());
|
||||
if (!controller.getName().equals(playerName)) {
|
||||
playerName = controller.getName();
|
||||
log.info("--- Player: " + playerName + " --------------------------------");
|
||||
}
|
||||
log.info((source == null ? "no source": source.getIdName()) + " -> "
|
||||
+ trAbility.getRule());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue