mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Refactor: overflow method naming
This commit is contained in:
parent
2393485320
commit
b6f6bac5e0
51 changed files with 139 additions and 138 deletions
|
@ -75,7 +75,7 @@ class AngrathsMaraudersEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class AnthemOfRakdosHellbentEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,7 +169,7 @@ class BitterFeudEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ enum BlazingEffigyCount implements DynamicValue {
|
|||
return 3;
|
||||
}
|
||||
int effigyDamage = watcher.damageDoneTo(sourceAbility.getSourceId(), sourceAbility.getSourceObjectZoneChangeCounter() - 1, game);
|
||||
return CardUtil.addWithOverflowCheck(3, effigyDamage);
|
||||
return CardUtil.overflowInc(3, effigyDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -77,7 +77,7 @@ class FurnaceOfRathEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class BranchingEvolutionEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmountForCounters(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()), true);
|
||||
event.setAmountForCounters(CardUtil.overflowMultiply(event.getAmount(), 2), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class BruvacTheGrandiloquentReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class CalamityBearerEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class ChargingTuskodonEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class CurseOfBloodlettingEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ class DesperateGambitEffect extends PreventionEffectImpl {
|
|||
if (controller != null && object != null) {
|
||||
if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) {
|
||||
if (wonFlip) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
this.discard();
|
||||
} else {
|
||||
preventDamageAction(event, source, game);
|
||||
|
|
|
@ -15,7 +15,6 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.DamageEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
@ -90,13 +89,13 @@ class DictateOfTheTwinGodsEffect extends ReplacementEffectImpl {
|
|||
if (damageEvent.getType() == GameEvent.EventType.DAMAGE_PLAYER) {
|
||||
Player targetPlayer = game.getPlayer(event.getTargetId());
|
||||
if (targetPlayer != null) {
|
||||
targetPlayer.damage(CardUtil.addWithOverflowCheck(damageEvent.getAmount(), damageEvent.getAmount()), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
targetPlayer.damage(CardUtil.overflowInc(damageEvent.getAmount(), damageEvent.getAmount()), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Permanent targetPermanent = game.getPermanent(event.getTargetId());
|
||||
if (targetPermanent != null) {
|
||||
targetPermanent.damage(CardUtil.addWithOverflowCheck(damageEvent.getAmount(), damageEvent.getAmount()), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
targetPermanent.damage(CardUtil.overflowInc(damageEvent.getAmount(), damageEvent.getAmount()), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,8 +106,8 @@ class DracoplasmEffect extends ReplacementEffectImpl {
|
|||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent targetCreature = game.getPermanent(targetId);
|
||||
if (targetCreature != null && targetCreature.sacrifice(source, game)) {
|
||||
power = CardUtil.addWithOverflowCheck(power, targetCreature.getPower().getValue());
|
||||
toughness = CardUtil.addWithOverflowCheck(toughness, targetCreature.getToughness().getValue());
|
||||
power = CardUtil.overflowInc(power, targetCreature.getPower().getValue());
|
||||
toughness = CardUtil.overflowInc(toughness, targetCreature.getToughness().getValue());
|
||||
}
|
||||
}
|
||||
ContinuousEffect effect = new SetPowerToughnessSourceEffect(power, toughness, Duration.Custom, SubLayer.SetPT_7b);
|
||||
|
|
|
@ -95,7 +95,7 @@ class EmbermawHellionEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), 1));
|
||||
event.setAmount(CardUtil.overflowInc(event.getAmount(), 1));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class FarrelsMantleEffect extends OneShotEffect{
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent perm = game.getPermanent(source.getSourceId());
|
||||
int damage = CardUtil.addWithOverflowCheck(perm.getPower().getValue(), 2);
|
||||
int damage = CardUtil.overflowInc(perm.getPower().getValue(), 2);
|
||||
DamageTargetEffect dmgEffect = new DamageTargetEffect(damage);
|
||||
return dmgEffect.apply(game, source);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class FiendishDuoEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ class FieryEmancipationEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(
|
||||
CardUtil.addWithOverflowCheck(
|
||||
event.setAmount(CardUtil.overflowInc(
|
||||
CardUtil.overflowInc(
|
||||
event.getAmount(), event.getAmount()
|
||||
), event.getAmount()
|
||||
));
|
||||
|
|
|
@ -86,7 +86,7 @@ class FireServantEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class FurnaceOfRathEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class GiselaBladeOfGoldnightDoubleDamageEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.DamageEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
@ -94,13 +93,13 @@ class GoblinBowlingTeamEffect extends ReplacementEffectImpl {
|
|||
if (damageEvent.getType() == GameEvent.EventType.DAMAGE_PLAYER) {
|
||||
Player targetPlayer = game.getPlayer(event.getTargetId());
|
||||
if (targetPlayer != null) {
|
||||
targetPlayer.damage(CardUtil.addWithOverflowCheck(damageEvent.getAmount(), controller.rollDice(source, game, 6)), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
targetPlayer.damage(CardUtil.overflowInc(damageEvent.getAmount(), controller.rollDice(source, game, 6)), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Permanent targetPermanent = game.getPermanent(event.getTargetId());
|
||||
if (targetPermanent != null) {
|
||||
targetPermanent.damage(CardUtil.addWithOverflowCheck(damageEvent.getAmount(), controller.rollDice(source, game, 6)), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
targetPermanent.damage(CardUtil.overflowInc(damageEvent.getAmount(), controller.rollDice(source, game, 6)), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class GoblinGoliathDamageEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
@ -93,14 +92,14 @@ class GoldnightCastigatorDoubleDamageEffect extends ReplacementEffectImpl {
|
|||
switch (event.getType()) {
|
||||
case DAMAGE_PLAYER:
|
||||
if (event.getTargetId().equals(source.getControllerId())) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
}
|
||||
break;
|
||||
case DAMAGE_CREATURE:
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
if (permanent != null) {
|
||||
if (permanent.getId().equals(source.getSourceId())) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class GratuitousViolenceReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class ImpulsiveManeuversEffect extends PreventionEffectImpl {
|
|||
DamageEvent damageEvent = (DamageEvent) event;
|
||||
if (damageEvent.isCombatDamage()) {
|
||||
if (wonFlip) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
this.discard();
|
||||
} else {
|
||||
preventDamageAction(event, source, game);
|
||||
|
|
|
@ -101,7 +101,7 @@ class InquisitorsFlailEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ class InsultDoubleDamageEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ class JayaVeneratedFiremageEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), 1));
|
||||
event.setAmount(CardUtil.overflowInc(event.getAmount(), 1));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,8 +150,8 @@ class JeskaThriceRebornEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
int amount = event.getAmount();
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(amount, event.getAmount()));
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(amount, event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowInc(amount, event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowInc(amount, event.getAmount()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,22 +56,22 @@ class ManaReflectionReplacementEffect extends ReplacementEffectImpl {
|
|||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Mana mana = ((ManaEvent) event).getMana();
|
||||
if (mana.getBlack() > 0) {
|
||||
mana.set(ManaType.BLACK, CardUtil.multiplyWithOverflowCheck(mana.getBlack(), 2));
|
||||
mana.set(ManaType.BLACK, CardUtil.overflowMultiply(mana.getBlack(), 2));
|
||||
}
|
||||
if (mana.getBlue() > 0) {
|
||||
mana.set(ManaType.BLUE, CardUtil.multiplyWithOverflowCheck(mana.getBlue(), 2));
|
||||
mana.set(ManaType.BLUE, CardUtil.overflowMultiply(mana.getBlue(), 2));
|
||||
}
|
||||
if (mana.getWhite() > 0) {
|
||||
mana.set(ManaType.WHITE, CardUtil.multiplyWithOverflowCheck(mana.getWhite(), 2));
|
||||
mana.set(ManaType.WHITE, CardUtil.overflowMultiply(mana.getWhite(), 2));
|
||||
}
|
||||
if (mana.getGreen() > 0) {
|
||||
mana.set(ManaType.GREEN, CardUtil.multiplyWithOverflowCheck(mana.getGreen(), 2));
|
||||
mana.set(ManaType.GREEN, CardUtil.overflowMultiply(mana.getGreen(), 2));
|
||||
}
|
||||
if (mana.getRed() > 0) {
|
||||
mana.set(ManaType.RED, CardUtil.multiplyWithOverflowCheck(mana.getRed(), 2));
|
||||
mana.set(ManaType.RED, CardUtil.overflowMultiply(mana.getRed(), 2));
|
||||
}
|
||||
if (mana.getColorless() > 0) {
|
||||
mana.set(ManaType.COLORLESS, CardUtil.multiplyWithOverflowCheck(mana.getColorless(), 2));
|
||||
mana.set(ManaType.COLORLESS, CardUtil.overflowMultiply(mana.getColorless(), 2));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -65,22 +65,22 @@ class NyxbloomAncientReplacementEffect extends ReplacementEffectImpl {
|
|||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Mana mana = ((ManaEvent) event).getMana();
|
||||
if (mana.getBlack() > 0) {
|
||||
mana.set(ManaType.BLACK, CardUtil.multiplyWithOverflowCheck(mana.getBlack(), 3));
|
||||
mana.set(ManaType.BLACK, CardUtil.overflowMultiply(mana.getBlack(), 3));
|
||||
}
|
||||
if (mana.getBlue() > 0) {
|
||||
mana.set(ManaType.BLUE, CardUtil.multiplyWithOverflowCheck(mana.getBlue(), 3));
|
||||
mana.set(ManaType.BLUE, CardUtil.overflowMultiply(mana.getBlue(), 3));
|
||||
}
|
||||
if (mana.getWhite() > 0) {
|
||||
mana.set(ManaType.WHITE, CardUtil.multiplyWithOverflowCheck(mana.getWhite(), 3));
|
||||
mana.set(ManaType.WHITE, CardUtil.overflowMultiply(mana.getWhite(), 3));
|
||||
}
|
||||
if (mana.getGreen() > 0) {
|
||||
mana.set(ManaType.GREEN, CardUtil.multiplyWithOverflowCheck(mana.getGreen(), 3));
|
||||
mana.set(ManaType.GREEN, CardUtil.overflowMultiply(mana.getGreen(), 3));
|
||||
}
|
||||
if (mana.getRed() > 0) {
|
||||
mana.set(ManaType.RED, CardUtil.multiplyWithOverflowCheck(mana.getRed(), 3));
|
||||
mana.set(ManaType.RED, CardUtil.overflowMultiply(mana.getRed(), 3));
|
||||
}
|
||||
if (mana.getColorless() > 0) {
|
||||
mana.set(ManaType.COLORLESS, CardUtil.multiplyWithOverflowCheck(mana.getColorless(), 3));
|
||||
mana.set(ManaType.COLORLESS, CardUtil.overflowMultiply(mana.getColorless(), 3));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ class OboshThePreypiercerEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class OverblazeEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class PhthisisEffect extends OneShotEffect {
|
|||
if (creature != null) {
|
||||
Player controller = game.getPlayer(creature.getControllerId());
|
||||
if (controller != null) {
|
||||
int lifeLoss = CardUtil.addWithOverflowCheck(creature.getPower().getValue(), creature.getToughness().getValue());
|
||||
int lifeLoss = CardUtil.overflowInc(creature.getPower().getValue(), creature.getToughness().getValue());
|
||||
creature.destroy(source, game, false);
|
||||
// the life loss happens also if the creature is indestructible or regenerated (legal targets)
|
||||
controller.loseLife(lifeLoss, game, source, false);
|
||||
|
|
|
@ -47,7 +47,7 @@ class TargetPermanentPowerPlusToughnessCount implements DynamicValue {
|
|||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Permanent sourcePermanent = game.getPermanent(sourceAbility.getFirstTarget());
|
||||
if (sourcePermanent != null) {
|
||||
return CardUtil.addWithOverflowCheck(sourcePermanent.getPower().getValue(), sourcePermanent.getToughness().getValue());
|
||||
return CardUtil.overflowInc(sourcePermanent.getPower().getValue(), sourcePermanent.getToughness().getValue());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class PyromancersGauntletReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), 2));
|
||||
event.setAmount(CardUtil.overflowInc(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class PyromancersSwathReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), 2));
|
||||
event.setAmount(CardUtil.overflowInc(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import mage.constants.Zone;
|
|||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -119,7 +118,7 @@ class QuestForPureFlameEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), event.getAmount()));
|
||||
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class SentinelEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
|
||||
if (controller != null && targetPermanent != null) {
|
||||
int newToughness = CardUtil.addWithOverflowCheck(targetPermanent.getPower().getValue(), 1);
|
||||
int newToughness = CardUtil.overflowInc(targetPermanent.getPower().getValue(), 1);
|
||||
game.addEffect(new SetToughnessSourceEffect(StaticValue.get(newToughness), Duration.Custom, SubLayer.SetPT_7b), source);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class SulfuricVaporsEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), 1));
|
||||
event.setAmount(CardUtil.overflowInc(event.getAmount(), 1));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ class SwornDefenderEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
|
||||
if (controller != null && targetPermanent != null) {
|
||||
int newPower = CardUtil.subtractWithOverflowCheck(targetPermanent.getToughness().getValue(), 1);
|
||||
int newToughness = CardUtil.addWithOverflowCheck(targetPermanent.getPower().getValue(), 1);
|
||||
int newPower = CardUtil.overflowDec(targetPermanent.getToughness().getValue(), 1);
|
||||
int newToughness = CardUtil.overflowInc(targetPermanent.getPower().getValue(), 1);
|
||||
game.addEffect(new SetPowerToughnessSourceEffect(newPower, newToughness, Duration.EndOfTurn, SubLayer.SetPT_7b), source);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class TheFlameOfKeldDamageEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), 2));
|
||||
event.setAmount(CardUtil.overflowInc(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class TorbranThaneOfRedFellEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(CardUtil.addWithOverflowCheck(event.getAmount(), 2));
|
||||
event.setAmount(CardUtil.overflowInc(event.getAmount(), 2));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class WallOfTombstonesEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int newToughness = CardUtil.addWithOverflowCheck(1, new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this));
|
||||
int newToughness = CardUtil.overflowInc(1, new CardsInControllerGraveyardCount(StaticFilters.FILTER_CARD_CREATURE).calculate(game, source, this));
|
||||
game.addEffect(new SetToughnessSourceEffect(StaticValue.get(newToughness), Duration.Custom, SubLayer.SetPT_7b), source);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class MageInt implements Serializable, Copyable<MageInt> {
|
|||
}
|
||||
|
||||
public void boostValue(int amount) {
|
||||
this.boostedValue = CardUtil.addWithOverflowCheck(this.boostedValue, amount);
|
||||
this.boostedValue = CardUtil.overflowInc(this.boostedValue, amount);
|
||||
}
|
||||
|
||||
public void resetToBaseValue() {
|
||||
|
|
|
@ -41,20 +41,20 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
}
|
||||
|
||||
protected void incrementAmount(ManaColor manaColor) {
|
||||
this.amount = CardUtil.addWithOverflowCheck(this.amount, manaColor.amount);
|
||||
this.snowAmount = CardUtil.addWithOverflowCheck(this.snowAmount, manaColor.snowAmount);
|
||||
this.amount = CardUtil.overflowInc(this.amount, manaColor.amount);
|
||||
this.snowAmount = CardUtil.overflowInc(this.snowAmount, manaColor.snowAmount);
|
||||
}
|
||||
|
||||
protected void incrementAmount(int amount, boolean snow) {
|
||||
this.amount = CardUtil.addWithOverflowCheck(this.amount, amount);
|
||||
this.amount = CardUtil.overflowInc(this.amount, amount);
|
||||
if (snow) {
|
||||
this.snowAmount = CardUtil.addWithOverflowCheck(this.snowAmount, amount);
|
||||
this.snowAmount = CardUtil.overflowInc(this.snowAmount, amount);
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeAmount(ManaColor manaColor) {
|
||||
this.amount = CardUtil.subtractWithOverflowCheck(this.amount, manaColor.amount);
|
||||
this.snowAmount = CardUtil.subtractWithOverflowCheck(this.snowAmount, manaColor.snowAmount);
|
||||
this.amount = CardUtil.overflowDec(this.amount, manaColor.amount);
|
||||
this.snowAmount = CardUtil.overflowDec(this.snowAmount, manaColor.snowAmount);
|
||||
}
|
||||
|
||||
protected void clear() {
|
||||
|
@ -67,11 +67,11 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
return false;
|
||||
}
|
||||
if (manaColor.getSnowAmount() > 0) {
|
||||
manaColor.snowAmount = CardUtil.subtractWithOverflowCheck(manaColor.snowAmount, 1);
|
||||
this.snowAmount = CardUtil.addWithOverflowCheck(this.snowAmount, 1);
|
||||
manaColor.snowAmount = CardUtil.overflowDec(manaColor.snowAmount, 1);
|
||||
this.snowAmount = CardUtil.overflowInc(this.snowAmount, 1);
|
||||
}
|
||||
manaColor.amount = CardUtil.subtractWithOverflowCheck(manaColor.amount, 1);
|
||||
this.amount = CardUtil.addWithOverflowCheck(this.amount, 1);
|
||||
manaColor.amount = CardUtil.overflowDec(manaColor.amount, 1);
|
||||
this.amount = CardUtil.overflowInc(this.amount, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -597,25 +597,25 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
}
|
||||
int count = 0;
|
||||
if (filter.isWhite()) {
|
||||
count = CardUtil.addWithOverflowCheck(count, white.getAmount());
|
||||
count = CardUtil.overflowInc(count, white.getAmount());
|
||||
}
|
||||
if (filter.isBlue()) {
|
||||
count = CardUtil.addWithOverflowCheck(count, blue.getAmount());
|
||||
count = CardUtil.overflowInc(count, blue.getAmount());
|
||||
}
|
||||
if (filter.isBlack()) {
|
||||
count = CardUtil.addWithOverflowCheck(count, black.getAmount());
|
||||
count = CardUtil.overflowInc(count, black.getAmount());
|
||||
}
|
||||
if (filter.isRed()) {
|
||||
count = CardUtil.addWithOverflowCheck(count, red.getAmount());
|
||||
count = CardUtil.overflowInc(count, red.getAmount());
|
||||
}
|
||||
if (filter.isGreen()) {
|
||||
count = CardUtil.addWithOverflowCheck(count, green.getAmount());
|
||||
count = CardUtil.overflowInc(count, green.getAmount());
|
||||
}
|
||||
if (filter.isGeneric()) {
|
||||
count = CardUtil.addWithOverflowCheck(count, generic.getAmount());
|
||||
count = CardUtil.overflowInc(count, generic.getAmount());
|
||||
}
|
||||
if (filter.isColorless()) {
|
||||
count = CardUtil.addWithOverflowCheck(count, colorless.getAmount());
|
||||
count = CardUtil.overflowInc(count, colorless.getAmount());
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
@ -811,13 +811,13 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
}
|
||||
if (compare.generic.getAmount() < 0) {
|
||||
int remaining = 0;
|
||||
remaining = CardUtil.addWithOverflowCheck(remaining, Math.min(0, compare.white.getAmount()));
|
||||
remaining = CardUtil.addWithOverflowCheck(remaining, Math.min(0, compare.blue.getAmount()));
|
||||
remaining = CardUtil.addWithOverflowCheck(remaining, Math.min(0, compare.black.getAmount()));
|
||||
remaining = CardUtil.addWithOverflowCheck(remaining, Math.min(0, compare.red.getAmount()));
|
||||
remaining = CardUtil.addWithOverflowCheck(remaining, Math.min(0, compare.green.getAmount()));
|
||||
remaining = CardUtil.addWithOverflowCheck(remaining, Math.min(0, compare.colorless.getAmount()));
|
||||
remaining = CardUtil.addWithOverflowCheck(remaining, Math.min(0, compare.any.getAmount()));
|
||||
remaining = CardUtil.overflowInc(remaining, Math.min(0, compare.white.getAmount()));
|
||||
remaining = CardUtil.overflowInc(remaining, Math.min(0, compare.blue.getAmount()));
|
||||
remaining = CardUtil.overflowInc(remaining, Math.min(0, compare.black.getAmount()));
|
||||
remaining = CardUtil.overflowInc(remaining, Math.min(0, compare.red.getAmount()));
|
||||
remaining = CardUtil.overflowInc(remaining, Math.min(0, compare.green.getAmount()));
|
||||
remaining = CardUtil.overflowInc(remaining, Math.min(0, compare.colorless.getAmount()));
|
||||
remaining = CardUtil.overflowInc(remaining, Math.min(0, compare.any.getAmount()));
|
||||
if (remaining > 0) {
|
||||
int diff = Math.min(remaining, Math.abs(compare.generic.getAmount()));
|
||||
compare.generic.incrementAmount(diff, false);
|
||||
|
@ -1148,7 +1148,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
case GREEN:
|
||||
return green.getAmount();
|
||||
case COLORLESS:
|
||||
return CardUtil.addWithOverflowCheck(generic.getAmount(), colorless.getAmount());
|
||||
return CardUtil.overflowInc(generic.getAmount(), colorless.getAmount());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1246,7 +1246,7 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
&& this.green.getAmount() >= mana.green.getAmount()
|
||||
&& this.colorless.getAmount() >= mana.colorless.getAmount()
|
||||
&& (this.generic.getAmount() >= mana.generic.getAmount()
|
||||
|| CardUtil.addWithOverflowCheck(this.countColored(), this.colorless.getAmount()) >= mana.count());
|
||||
|| CardUtil.overflowInc(this.countColored(), this.colorless.getAmount()) >= mana.count());
|
||||
|
||||
}
|
||||
|
||||
|
@ -1282,33 +1282,33 @@ public class Mana implements Comparable<Mana>, Serializable, Copyable<Mana> {
|
|||
moreMana = mana1;
|
||||
lessMana = mana2;
|
||||
}
|
||||
int anyDiff = CardUtil.subtractWithOverflowCheck(mana2.getAny(), mana1.getAny());
|
||||
int anyDiff = CardUtil.overflowDec(mana2.getAny(), mana1.getAny());
|
||||
if (lessMana.getWhite() > moreMana.getWhite()) {
|
||||
anyDiff = CardUtil.subtractWithOverflowCheck(anyDiff, CardUtil.subtractWithOverflowCheck(lessMana.getWhite(), moreMana.getWhite()));
|
||||
anyDiff = CardUtil.overflowDec(anyDiff, CardUtil.overflowDec(lessMana.getWhite(), moreMana.getWhite()));
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getRed() > moreMana.getRed()) {
|
||||
anyDiff = CardUtil.subtractWithOverflowCheck(anyDiff, CardUtil.subtractWithOverflowCheck(lessMana.getRed(), moreMana.getRed()));
|
||||
anyDiff = CardUtil.overflowDec(anyDiff, CardUtil.overflowDec(lessMana.getRed(), moreMana.getRed()));
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getGreen() > moreMana.getGreen()) {
|
||||
anyDiff = CardUtil.subtractWithOverflowCheck(anyDiff, CardUtil.subtractWithOverflowCheck(lessMana.getGreen(), moreMana.getGreen()));
|
||||
anyDiff = CardUtil.overflowDec(anyDiff, CardUtil.overflowDec(lessMana.getGreen(), moreMana.getGreen()));
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getBlue() > moreMana.getBlue()) {
|
||||
anyDiff = CardUtil.subtractWithOverflowCheck(anyDiff, CardUtil.subtractWithOverflowCheck(lessMana.getBlue(), moreMana.getBlue()));
|
||||
anyDiff = CardUtil.overflowDec(anyDiff, CardUtil.overflowDec(lessMana.getBlue(), moreMana.getBlue()));
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lessMana.getBlack() > moreMana.getBlack()) {
|
||||
anyDiff = CardUtil.subtractWithOverflowCheck(anyDiff, CardUtil.subtractWithOverflowCheck(lessMana.getBlack(), moreMana.getBlack()));
|
||||
anyDiff = CardUtil.overflowDec(anyDiff, CardUtil.overflowDec(lessMana.getBlack(), moreMana.getBlack()));
|
||||
if (anyDiff < 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class AddConditionalManaEffect extends ManaEffect {
|
|||
if (amountAvailableMana > 0) {
|
||||
Mana calculatedMana = mana.copy();
|
||||
for (ManaType manaType : ManaType.getTrueManaTypes()) {
|
||||
calculatedMana.set(manaType, CardUtil.multiplyWithOverflowCheck(calculatedMana.get(manaType), amountAvailableMana));
|
||||
calculatedMana.set(manaType, CardUtil.overflowMultiply(calculatedMana.get(manaType), amountAvailableMana));
|
||||
}
|
||||
maxAvailableMana.add(manaBuilder.setMana(calculatedMana, source, game).build());
|
||||
}
|
||||
|
|
|
@ -1026,7 +1026,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
addCounters(CounterType.M1M1.createInstance(actualDamage), game.getControllerId(attackerId), damageSourceAbility, game);
|
||||
}
|
||||
} else {
|
||||
this.damage = CardUtil.addWithOverflowCheck(this.damage, actualDamage);
|
||||
this.damage = CardUtil.overflowInc(this.damage, actualDamage);
|
||||
}
|
||||
DamagedEvent damagedEvent = new DamagedCreatureEvent(this.getId(), attackerId, this.getControllerId(), actualDamage, combat);
|
||||
damagedEvent.setExcess(actualDamage - lethal);
|
||||
|
|
|
@ -388,7 +388,7 @@ public class ManaPool implements Serializable {
|
|||
private void removeConditional(ConditionalManaInfo manaInfo, Ability ability, Game game, Cost costToPay, Mana usedManaToPay) {
|
||||
for (ConditionalMana mana : getConditionalMana()) {
|
||||
if (mana.get(manaInfo.manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId(), costToPay)) {
|
||||
mana.set(manaInfo.manaType, CardUtil.subtractWithOverflowCheck(mana.get(manaInfo.manaType), 1));
|
||||
mana.set(manaInfo.manaType, CardUtil.overflowDec(mana.get(manaInfo.manaType), 1));
|
||||
usedManaToPay.increase(manaInfo.manaType, manaInfo.sourceObject.isSnow());
|
||||
GameEvent event = new ManaPaidEvent(ability, mana.getManaProducerId(), mana.getFlag(), mana.getManaProducerOriginalId());
|
||||
game.fireEvent(event);
|
||||
|
|
|
@ -2004,7 +2004,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
GameEvent event = new GameEvent(GameEvent.EventType.LOSE_LIFE,
|
||||
playerId, source, playerId, amount, atCombat);
|
||||
if (!game.replaceEvent(event)) {
|
||||
this.life = CardUtil.subtractWithOverflowCheck(this.life, event.getAmount());
|
||||
this.life = CardUtil.overflowDec(this.life, event.getAmount());
|
||||
if (!game.isSimulation()) {
|
||||
UUID needId = attackerId;
|
||||
if (needId == null) {
|
||||
|
@ -2048,7 +2048,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// TODO: lock life at Integer.MAX_VALUE if reached, until it's set to a different amount
|
||||
// (https://magic.wizards.com/en/articles/archive/news/unstable-faqawaslfaqpaftidawabiajtbt-2017-12-06 - "infinite" life total stays infinite no matter how much is gained or lost)
|
||||
// this.life += event.getAmount();
|
||||
this.life = CardUtil.addWithOverflowCheck(this.life, event.getAmount());
|
||||
this.life = CardUtil.overflowInc(this.life, event.getAmount());
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(this.getLogName() + " gains " + event.getAmount() + " life" + CardUtil.getSourceLogName(game, source));
|
||||
}
|
||||
|
@ -3244,7 +3244,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
restVal = 0;
|
||||
availableLifeMana -= oldPayOption.get(manaType);
|
||||
} else {
|
||||
restVal = CardUtil.subtractWithOverflowCheck(oldPayOption.get(manaType), availableLifeMana);
|
||||
restVal = CardUtil.overflowDec(oldPayOption.get(manaType), availableLifeMana);
|
||||
availableLifeMana = 0;
|
||||
}
|
||||
manaCopy.set(manaType, restVal);
|
||||
|
|
|
@ -628,44 +628,49 @@ public final class CardUtil {
|
|||
return "<font color = 'blue'>" + text + "</font>";
|
||||
}
|
||||
|
||||
public static boolean cardCanBePlayedNow(Card card, UUID playerId, Game game) {
|
||||
if (card.isLand()) {
|
||||
return game.canPlaySorcery(playerId) && game.getPlayer(playerId).canPlayLand();
|
||||
/**
|
||||
* Integer operation with overflow protection
|
||||
*
|
||||
* @param base
|
||||
* @param increment
|
||||
* @return
|
||||
*/
|
||||
public static int overflowInc(int base, int increment) {
|
||||
return overflowResult((long) base + increment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer operation with overflow protection
|
||||
*
|
||||
* @param base
|
||||
* @param decrement
|
||||
* @return
|
||||
*/
|
||||
public static int overflowDec(int base, int decrement) {
|
||||
return overflowResult((long) base - decrement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer operation with overflow protection
|
||||
*
|
||||
* @param base
|
||||
* @param multiply
|
||||
* @return
|
||||
*/
|
||||
public static int overflowMultiply(int base, int multiply) {
|
||||
return overflowResult((long) base * multiply);
|
||||
}
|
||||
|
||||
private static int overflowResult(long value) {
|
||||
if (value > Integer.MAX_VALUE) {
|
||||
return Integer.MAX_VALUE;
|
||||
} else if (value < Integer.MIN_VALUE) {
|
||||
return Integer.MIN_VALUE;
|
||||
} else {
|
||||
return card.getSpellAbility() != null && card.getSpellAbility().spellCanBeActivatedRegularlyNow(playerId, game);
|
||||
return (int) value;
|
||||
}
|
||||
}
|
||||
|
||||
public static int addWithOverflowCheck(int base, int increment) {
|
||||
long result = ((long) base) + increment;
|
||||
if (result > Integer.MAX_VALUE) {
|
||||
return Integer.MAX_VALUE;
|
||||
} else if (result < Integer.MIN_VALUE) {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
return base + increment;
|
||||
}
|
||||
|
||||
public static int subtractWithOverflowCheck(int base, int decrement) {
|
||||
long result = ((long) base) - decrement;
|
||||
if (result > Integer.MAX_VALUE) {
|
||||
return Integer.MAX_VALUE;
|
||||
} else if (result < Integer.MIN_VALUE) {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
return base - decrement;
|
||||
}
|
||||
|
||||
public static int multiplyWithOverflowCheck(int base, int multiply) {
|
||||
long result = ((long) base) * multiply;
|
||||
if (result > Integer.MAX_VALUE) {
|
||||
return Integer.MAX_VALUE;
|
||||
} else if (result < Integer.MIN_VALUE) {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
return base * multiply;
|
||||
}
|
||||
|
||||
public static String createObjectRealtedWindowTitle(Ability source, Game game, String textSuffix) {
|
||||
String title;
|
||||
if (source != null) {
|
||||
|
|
Loading…
Reference in a new issue