forked from External/mage
[TLA] Implement Razor Rings, rework excess damage (#13910)
* [TLA] Implement Razor Rings * add overflow protection
This commit is contained in:
parent
96dbfc757e
commit
b64f1dce45
17 changed files with 209 additions and 153 deletions
|
|
@ -1,32 +1,33 @@
|
|||
package mage.cards.w;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.ElfWarriorToken;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.EachTargetPointer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static mage.filter.StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author bwsinger
|
||||
*/
|
||||
public final class WindswiftSlice extends CardImpl {
|
||||
|
||||
public WindswiftSlice(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}");
|
||||
|
||||
|
||||
|
||||
// Target creature you control deals damage equal to its power to target creature you don't control. Create a number of 1/1 green Elf Warrior creature tokens equal to the amount of excess damage dealt this way.
|
||||
this.getSpellAbility().addEffect(new WindswiftSliceEffect());
|
||||
|
|
@ -48,6 +49,7 @@ class WindswiftSliceEffect extends OneShotEffect {
|
|||
|
||||
WindswiftSliceEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.setTargetPointer(new EachTargetPointer());
|
||||
staticText = "Target creature you control deals damage equal to its power to target " +
|
||||
"creature you don't control. Create a number of 1/1 green Elf Warrior creature " +
|
||||
"tokens equal to the amount of excess damage dealt this way.";
|
||||
|
|
@ -64,27 +66,26 @@ class WindswiftSliceEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent myPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
Permanent anotherPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
|
||||
if (myPermanent == null || anotherPermanent == null) {
|
||||
List<Permanent> permanents = this
|
||||
.getTargetPointer()
|
||||
.getTargets(game, source)
|
||||
.stream()
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
if (permanents.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int power = myPermanent.getPower().getValue();
|
||||
Permanent permanent = permanents.get(0);
|
||||
int power = permanent.getPower().getValue();
|
||||
if (power < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int lethal = anotherPermanent.getLethalDamage(myPermanent.getId(), game);
|
||||
lethal = Math.min(lethal, power);
|
||||
|
||||
anotherPermanent.damage(power, myPermanent.getId(), source, game);
|
||||
|
||||
if (lethal < power) {
|
||||
new ElfWarriorToken().putOntoBattlefield(power - lethal, game, source, source.getControllerId());
|
||||
Permanent creature = permanents.get(1);
|
||||
int excess = creature.damageWithExcess(power, permanent.getId(), source, game);
|
||||
if (excess > 0) {
|
||||
new ElfWarriorToken().putOntoBattlefield(excess, game, source);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue