Refactor: move player.damage params to default (same as permanent.damage);

This commit is contained in:
Oleg Agafonov 2020-01-14 09:15:33 +04:00
parent 76387057b7
commit 11976b5c89
228 changed files with 1104 additions and 1454 deletions

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
@ -13,7 +11,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author LoneFox
*/
public class DamageAttachedControllerEffect extends OneShotEffect {
@ -24,7 +21,7 @@ public class DamageAttachedControllerEffect extends OneShotEffect {
super(Outcome.Damage);
this.amount = StaticValue.get(amount);
}
public DamageAttachedControllerEffect(DynamicValue amount) {
super(Outcome.Damage);
this.amount = amount;
@ -43,16 +40,16 @@ public class DamageAttachedControllerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if(enchantment == null) {
if (enchantment == null) {
return false;
}
Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
if(enchanted == null) {
if (enchanted == null) {
return false;
}
Player player = game.getPlayer(enchanted.getControllerId());
if(player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game);
return true;
}
return false;
@ -66,6 +63,6 @@ public class DamageAttachedControllerEffect extends OneShotEffect {
if ("equal to".equals(amount.toString())) {
return "{this} deals damage " + amount + " that creatures toughness to that creature's controller";
}
return "{this} deals " + amount + " damage to that creature's controller";
return "{this} deals " + amount + " damage to that creature's controller";
}
}

View file

@ -1,22 +1,20 @@
package mage.abilities.effects.common;
import java.util.List;
import java.util.UUID;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DamageEverythingEffect extends OneShotEffect {
@ -48,7 +46,7 @@ public class DamageEverythingEffect extends OneShotEffect {
public DamageEverythingEffect(DynamicValue amount, FilterPermanent filter) {
this(amount, filter, null);
}
public DamageEverythingEffect(DynamicValue amount, FilterPermanent filter, UUID damageSource) {
super(Outcome.Damage);
this.amount = amount;
@ -78,13 +76,13 @@ public class DamageEverythingEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
int damage = amount.calculate(game, source, this);
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
for (Permanent permanent: permanents) {
permanent.damage(damage, damageSource == null ? source.getSourceId(): damageSource, game, false, true);
for (Permanent permanent : permanents) {
permanent.damage(damage, damageSource == null ? source.getSourceId() : damageSource, game, false, true);
}
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(damage, damageSource == null ? source.getSourceId(): damageSource, game, false, true);
player.damage(damage, damageSource == null ? source.getSourceId() : damageSource, game);
}
}
return true;

View file

@ -63,11 +63,11 @@ public class DamageMultiEffect extends OneShotEffect {
if (permanent != null) {
if (permanent.damage(multiTarget.getTargetAmount(target), source.getSourceId(), game, false, true) > 0) {
damagedSet.add(new MageObjectReference(permanent, game));
} ;
}
} else {
Player player = game.getPlayer(target);
if (player != null) {
player.damage(multiTarget.getTargetAmount(target), source.getSourceId(), game, false, true);
player.damage(multiTarget.getTargetAmount(target), source.getSourceId(), game);
}
}
}

View file

@ -1,18 +1,17 @@
package mage.abilities.effects.common;
import java.util.UUID;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DamagePlayersEffect extends OneShotEffect {
@ -58,18 +57,18 @@ public class DamagePlayersEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
switch (controller) {
case ANY:
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
player.damage(amount.calculate(game, source, this), source.getSourceId(), game);
}
}
break;
case OPPONENT:
for (UUID playerId: game.getOpponents(source.getControllerId())) {
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
player.damage(amount.calculate(game, source, this), source.getSourceId(), game);
}
}
break;
@ -84,8 +83,7 @@ public class DamagePlayersEffect extends OneShotEffect {
return new DamagePlayersEffect(this);
}
private void setText()
{
private void setText() {
StringBuilder sb = new StringBuilder().append(this.sourceName).append(" deals ").append(amount.toString());
switch (controller) {
case ANY:

View file

@ -43,7 +43,7 @@ public class DamageWithPowerFromOneToAnotherTargetEffect extends OneShotEffect {
anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true);
return true;
} else if (myPermanent != null && anotherPlayer != null) {
anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true);
anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game);
return true;
}
return false;

View file

@ -43,7 +43,7 @@ public class DamageWithPowerFromSourceToAnotherTargetEffect extends OneShotEffec
anotherPermanent.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true);
return true;
} else if (myPermanent != null && anotherPlayer != null) {
anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game, false, true);
anotherPlayer.damage(myPermanent.getPower().getValue(), myPermanent.getId(), game);
return true;
}
return false;

View file

@ -1535,7 +1535,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.FIGHTED_PERMANENT, fightTarget.getId(), getId(), source.getControllerId()));
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.FIGHTED_PERMANENT, getId(), fightTarget.getId(), source.getControllerId()));
damage(fightTarget.getPower().getValue(), fightTarget.getId(), game, false, true);
fightTarget.damage(getPower().getValue(), getId(), game, false, true);
fightTarget.damage(getPower().getValue(), getId(), game);
return true;
}

View file

@ -1,9 +1,5 @@
package mage.game.permanent.token;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -21,13 +17,17 @@ import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.players.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
*
* @author LoneFox
*/
public final class BelzenlokDemonToken extends TokenImpl {
static final private List<String> tokenImageSets = new ArrayList<>();
static {
tokenImageSets.addAll(Arrays.asList("DOM"));
}
@ -95,7 +95,7 @@ class BelzenlokDemonTokenEffect extends OneShotEffect {
} else {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.damage(6, source.getSourceId(), game, false, true);
controller.damage(6, source.getSourceId(), game);
}
}
return true;