Dev: added additional info to some classes for easy debug;

This commit is contained in:
Oleg Agafonov 2021-03-07 17:16:54 +04:00
parent bde6222ea6
commit 0e916b6e29
19 changed files with 133 additions and 19 deletions

View file

@ -21,6 +21,7 @@ import mage.filter.Filter;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.CardState;
import mage.game.Game;
import mage.game.GameState;
import mage.game.command.Commander;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
@ -1290,4 +1291,29 @@ public final class CardUtil {
}
return mapOldToNew;
}
/**
* Return turn info for game. Uses in game logs and debug.
*
* @param game
* @return
*/
public static String getTurnInfo(Game game) {
return getTurnInfo(game == null ? null : game.getState());
}
public static String getTurnInfo(GameState gameState) {
// no turn info
if (gameState == null) {
return null;
}
// not started game
if (gameState.getTurn().getStep() == null) {
return "T0";
}
// normal game
return "T" + gameState.getTurnNum() + "." + gameState.getTurn().getStep().getType().getStepShortText();
}
}