[AFR] fixed empty class level up logs, added levelled logs (#7808)

This commit is contained in:
Oleg Agafonov 2021-07-16 00:13:27 +04:00
parent 2d8be6663b
commit ad7eb55460
3 changed files with 17 additions and 1 deletions

View file

@ -61,6 +61,7 @@ class SetClassLevelEffect extends OneShotEffect {
SetClassLevelEffect(int level) {
super(Outcome.Benefit);
this.level = level;
staticText = "level up to " + level;
}
private SetClassLevelEffect(final SetClassLevelEffect effect) {
@ -76,9 +77,17 @@ class SetClassLevelEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null || !permanent.setClassLevel(level)) {
if (permanent == null) {
return false;
}
int oldLevel = permanent.getClassLevel();
if (!permanent.setClassLevel(level)) {
return false;
}
game.informPlayers(permanent.getLogName() + " levelled up from " + oldLevel + " to " + permanent.getClassLevel());
game.fireEvent(GameEvent.getEvent(
GameEvent.EventType.GAINS_CLASS_LEVEL, source.getSourceId(),
source, source.getControllerId(), level

View file

@ -75,6 +75,12 @@ public interface Permanent extends Card, Controllable {
int getClassLevel();
/**
* Level up to next level.
*
* @param classLevel
* @return false on wrong settings (e.g. level up to multiple levels)
*/
boolean setClassLevel(int classLevel);
void setCardNumber(String cid);

View file

@ -1528,6 +1528,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override
public boolean setClassLevel(int classLevel) {
// can level up to next (+1) level only
if (this.classLevel == classLevel - 1) {
this.classLevel = classLevel;
return true;