forked from External/mage
Implementing "Start your engines!" mechanic (#13259)
* add initial speed handling * finish speed implementation * remove skip list * add initial test * add some more tests * change speed initialization to state-based action * add opponent speed check * add control change test * add check for speed 5
This commit is contained in:
parent
655af10b2e
commit
ef213b1bef
11 changed files with 393 additions and 15 deletions
|
|
@ -38,9 +38,21 @@ class MaxSpeedAbilityEffect extends ContinuousEffectImpl {
|
|||
|
||||
private final Ability ability;
|
||||
|
||||
private static Duration getDuration(Ability ability) {
|
||||
switch (ability.getZone()) {
|
||||
case BATTLEFIELD:
|
||||
return Duration.WhileOnBattlefield;
|
||||
case GRAVEYARD:
|
||||
return Duration.WhileInGraveyard;
|
||||
default:
|
||||
return Duration.Custom;
|
||||
}
|
||||
}
|
||||
|
||||
MaxSpeedAbilityEffect(Ability ability) {
|
||||
super(Duration.Custom, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
super(getDuration(ability), Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
this.ability = ability;
|
||||
this.ability.setRuleVisible(false);
|
||||
}
|
||||
|
||||
private MaxSpeedAbilityEffect(final MaxSpeedAbilityEffect effect) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
|
@ -13,8 +16,10 @@ public enum ControllerSpeedCount implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
// TODO: Implement this
|
||||
return 0;
|
||||
return Optional
|
||||
.ofNullable(game.getPlayer(sourceAbility.getControllerId()))
|
||||
.map(Player::getSpeed)
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.dynamicvalue.common.ControllerSpeedCount;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
import mage.constants.Zone;
|
||||
|
||||
/**
|
||||
* TODO: Implement this
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class StartYourEnginesAbility extends StaticAbility {
|
||||
|
||||
private static final Hint hint = new ValueHint("Your current speed", ControllerSpeedCount.instance);
|
||||
|
||||
public StartYourEnginesAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
this.addHint(hint);
|
||||
}
|
||||
|
||||
private StartYourEnginesAbility(final StartYourEnginesAbility ability) {
|
||||
|
|
@ -25,6 +29,6 @@ public class StartYourEnginesAbility extends StaticAbility {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Start your engines!";
|
||||
return "start your engines!";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue