mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Acolyte's Reward - Fixed a bug that always were prevented all damage instead only devotion to white amount.
This commit is contained in:
parent
0d1921d8cb
commit
16c3df2abd
1 changed files with 23 additions and 19 deletions
|
@ -103,49 +103,53 @@ class AcolytesRewardEffect extends PreventionEffectImpl<AcolytesRewardEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getControllerId(), source.getId(), source.getControllerId(), event.getAmount(), false);
|
boolean result = false;
|
||||||
|
int toPrevent = amount;
|
||||||
|
if (event.getAmount() < this.amount) {
|
||||||
|
toPrevent = event.getAmount();
|
||||||
|
amount -= event.getAmount();
|
||||||
|
} else {
|
||||||
|
amount = 0;
|
||||||
|
}
|
||||||
|
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getControllerId(), source.getId(), source.getControllerId(), toPrevent, false);
|
||||||
if (!game.replaceEvent(preventEvent)) {
|
if (!game.replaceEvent(preventEvent)) {
|
||||||
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
|
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
|
||||||
if (targetCreature != null) {
|
if (targetCreature != null) {
|
||||||
int damage = event.getAmount();
|
if (amount == 0) {
|
||||||
if (event.getAmount() >= this.amount) {
|
|
||||||
event.setAmount(damage - this.amount);
|
|
||||||
damage = this.amount;
|
|
||||||
this.used = true;
|
this.used = true;
|
||||||
this.discard();
|
this.discard();
|
||||||
|
}
|
||||||
|
if (event.getAmount() >= toPrevent) {
|
||||||
|
event.setAmount(event.getAmount() - toPrevent);
|
||||||
} else {
|
} else {
|
||||||
event.setAmount(0);
|
event.setAmount(0);
|
||||||
this.amount -= damage;
|
result = true;
|
||||||
}
|
}
|
||||||
if (damage > 0) {
|
if (toPrevent > 0) {
|
||||||
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("prevented ").append(damage).append(" to ").append(targetCreature.getName()).toString());
|
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("prevented ").append(toPrevent).append(" to ").append(targetCreature.getName()).toString());
|
||||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), damage));
|
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
|
||||||
|
|
||||||
Player targetPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
|
Player targetPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
targetPlayer.damage(damage, source.getSourceId(), game, false, true);
|
targetPlayer.damage(toPrevent, source.getSourceId(), game, false, true);
|
||||||
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("deals ").append(damage).append(" damge to ").append(targetPlayer.getName()).toString());
|
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("deals ").append(toPrevent).append(" damage to ").append(targetPlayer.getName()).toString());
|
||||||
} else {
|
} else {
|
||||||
Permanent targetDamageCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
Permanent targetDamageCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||||
if (targetDamageCreature != null) {
|
if (targetDamageCreature != null) {
|
||||||
targetDamageCreature.damage(damage, source.getSourceId(), game, true, false);
|
targetDamageCreature.damage(toPrevent, source.getSourceId(), game, true, false);
|
||||||
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("deals ").append(damage).append(" damge to ").append(targetDamageCreature.getName()).toString());
|
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("deals ").append(toPrevent).append(" damage to ").append(targetDamageCreature.getName()).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getFirstTarget())) {
|
return !this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getFirstTarget());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue