Initiative abilities - added card hint with initiative info to all related cards (closes #11424);

tests: added verify test for miss initiative card hint;
gui: fixed wrong max amount of card hint windows;
This commit is contained in:
Oleg Agafonov 2023-11-19 23:00:42 +04:00
parent 77eb3b35b8
commit 6e99a3653a
29 changed files with 92 additions and 22 deletions

View file

@ -0,0 +1,37 @@
package mage.abilities.hint.common;
import mage.abilities.Ability;
import mage.abilities.condition.common.HaveInitiativeCondition;
import mage.abilities.hint.ConditionHint;
import mage.abilities.hint.Hint;
import mage.game.Game;
import java.util.Optional;
/**
* @author JayDi85
*/
public enum InitiativeHint implements Hint {
instance;
private static final ConditionHint hint = new ConditionHint(HaveInitiativeCondition.instance, "You have the Initiative");
@Override
public String getText(Game game, Ability ability) {
String res = hint.getText(game, ability);
if (game.getInitiativeId() == null) {
// no initiative
return res + " (no Initiative in the game)";
} else {
// player
return res + Optional.ofNullable(game.getPlayer(game.getInitiativeId()))
.map(p -> " (current owner: " + p.getName() + ")")
.orElse("");
}
}
@Override
public Hint copy() {
return instance;
}
}