mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
[KHM] fixed Reidane, God of the Worthy - rollback error on some events check without sourceId;
This commit is contained in:
parent
f692a1f097
commit
9416c6140a
2 changed files with 10 additions and 5 deletions
|
@ -169,17 +169,18 @@ class ValkmiraProtectorsShieldPreventionEffect extends PreventionEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (!game.getOpponents(game.getControllerId(event.getSourceId())).contains(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
switch (event.getType()) {
|
||||
case DAMAGE_PLAYER:
|
||||
return source.isControlledBy(event.getTargetId())
|
||||
boolean isOpponent = game.getOpponents(game.getControllerId(event.getSourceId())).contains(source.getControllerId());
|
||||
return isOpponent
|
||||
&& source.isControlledBy(event.getTargetId())
|
||||
&& super.applies(event, source, game);
|
||||
case DAMAGE_CREATURE:
|
||||
case DAMAGE_PLANESWALKER:
|
||||
isOpponent = game.getOpponents(game.getControllerId(event.getSourceId())).contains(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
return permanent != null
|
||||
return isOpponent
|
||||
&& permanent != null
|
||||
&& permanent.isControlledBy(source.getControllerId())
|
||||
&& super.applies(event, source, game);
|
||||
}
|
||||
|
|
|
@ -135,6 +135,10 @@ public interface Game extends MageItem, Serializable {
|
|||
*/
|
||||
default Set<UUID> getOpponents(UUID playerId) {
|
||||
Player player = getPlayer(playerId);
|
||||
if (player == null) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
return player.getInRange().stream()
|
||||
.filter(opponentId -> !opponentId.equals(playerId))
|
||||
.collect(Collectors.toSet());
|
||||
|
|
Loading…
Reference in a new issue