mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
- Shining Shoal will now work with spells. Yes, more work on this needs to be done. If a chosen source deals damage to multiple targets, the controller should be able to choose how that damage is distributed.
This commit is contained in:
parent
97ccd22564
commit
9cf0ebb2ae
1 changed files with 11 additions and 7 deletions
|
@ -140,14 +140,15 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl {
|
|||
if (prevented > 0) {
|
||||
UUID redirectTo = source.getTargets().get(1).getFirstTarget();
|
||||
Permanent permanent = game.getPermanent(redirectTo);
|
||||
MageObject sourceObject = game.getObject(source.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
game.informPlayers("Dealing " + prevented + " to " + permanent.getName() + " instead");
|
||||
game.informPlayers(sourceObject.getIdName() + "deals " + prevented + " to " + permanent.getName() + " instead");
|
||||
// keep the original source id as it is redirecting
|
||||
permanent.damage(prevented, event.getSourceId(), game, ((DamageEvent) event).isCombatDamage(), ((DamageEvent) event).isPreventable(), event.getAppliedEffects());
|
||||
}
|
||||
Player player = game.getPlayer(redirectTo);
|
||||
if (player != null) {
|
||||
game.informPlayers("Dealing " + prevented + " to " + player.getLogName() + " instead");
|
||||
game.informPlayers(sourceObject.getIdName() + "deals " + prevented + " to " + player.getLogName() + " instead");
|
||||
// keep the original source id as it is redirecting
|
||||
player.damage(prevented, event.getSourceId(), game, ((DamageEvent) event).isCombatDamage(), ((DamageEvent) event).isPreventable(), event.getAppliedEffects());
|
||||
}
|
||||
|
@ -160,14 +161,17 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!this.used && super.applies(event, source, game)) {
|
||||
|
||||
// check source
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (object == null) {
|
||||
// get source of the damage event
|
||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
||||
// get the chosen damage source
|
||||
MageObject chosenSourceObject = game.getObject(source.getFirstTarget());
|
||||
// does the source of the damage exist?
|
||||
if (sourceObject == null) {
|
||||
game.informPlayers("Couldn't find source of damage");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!object.getId().equals(source.getFirstTarget())) {
|
||||
// do the 2 objects match?
|
||||
if (sourceObject.getId() != chosenSourceObject.getId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue