forked from External/mage
[AFR] Implementing Class enchantments (ready for review) (#7992)
* [AFR] Implemented Druid Class * [AFR] Implemented Wizard Class * [AFR] Implemented Cleric Class * [AFR] Implemented Fighter Class * reworked class ability implementation * fixed an error with setting class level * small reworking of class triggers * added class level hint * added tests * small change * added common class for reminder text
This commit is contained in:
parent
d00765c2d5
commit
5b88484cb6
17 changed files with 884 additions and 5 deletions
|
|
@ -0,0 +1,88 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TimingRule;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class ClassLevelAbility extends ActivatedAbilityImpl {
|
||||
|
||||
private final int level;
|
||||
private final String manaString;
|
||||
|
||||
public ClassLevelAbility(int level, String manaString) {
|
||||
super(Zone.BATTLEFIELD, new SetClassLevelEffect(level), new ManaCostsImpl<>(manaString));
|
||||
this.level = level;
|
||||
this.manaString = manaString;
|
||||
setTiming(TimingRule.SORCERY);
|
||||
}
|
||||
|
||||
private ClassLevelAbility(final ClassLevelAbility ability) {
|
||||
super(ability);
|
||||
this.level = ability.level;
|
||||
this.manaString = ability.manaString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLevelAbility copy() {
|
||||
return new ClassLevelAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return manaString + ": Level " + level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
Permanent permanent = getSourcePermanentIfItStillExists(game);
|
||||
if (permanent != null && permanent.getClassLevel() == level - 1) {
|
||||
return super.canActivate(playerId, game);
|
||||
}
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
}
|
||||
|
||||
class SetClassLevelEffect extends OneShotEffect {
|
||||
|
||||
private final int level;
|
||||
|
||||
SetClassLevelEffect(int level) {
|
||||
super(Outcome.Benefit);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
private SetClassLevelEffect(final SetClassLevelEffect effect) {
|
||||
super(effect);
|
||||
this.level = effect.level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetClassLevelEffect copy() {
|
||||
return new SetClassLevelEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
if (permanent == null || !permanent.setClassLevel(level)) {
|
||||
return false;
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(
|
||||
GameEvent.EventType.GAINS_CLASS_LEVEL, source.getSourceId(),
|
||||
source, source.getControllerId(), level
|
||||
));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue