Updated implementation of Hexproof abilities (#6451)

* updated implementation of hexproof abilities

* added hexproof from color test

* updated generic in AbilityPredicate
This commit is contained in:
Evan Kranzler 2020-04-23 20:01:13 -04:00 committed by GitHub
parent f7309919b9
commit 7f32ea0be2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 128 additions and 126 deletions

View file

@ -610,50 +610,14 @@ public abstract class PlayerImpl implements Player, Serializable {
if (abilities.containsKey(ShroudAbility.getInstance().getId())) {
return false;
}
if (abilities.containsKey(HexproofAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)) {
return false;
}
}
if (abilities.containsKey(HexproofFromWhiteAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)
&& source.getColor(game).isWhite()) {
return false;
}
}
if (abilities.containsKey(HexproofFromBlueAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)
&& source.getColor(game).isBlue()) {
return false;
}
}
if (abilities.containsKey(HexproofFromBlackAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)
&& source.getColor(game).isBlack()) {
return false;
}
}
if (abilities.containsKey(HexproofFromMonocoloredAbility.getInstance().getId())) {
if (sourceControllerId != null && this.hasOpponent(sourceControllerId, game)
&& null == game.getContinuousEffects().asThough(this.getId(),
AsThoughEffectType.HEXPROOF, null, sourceControllerId, game)
&& !source.getColor(game).isColorless()
&& !source.getColor(game).isMulticolored()) {
return false;
}
if (sourceControllerId != null
&& this.hasOpponent(sourceControllerId, game)
&& game.getContinuousEffects().asThough(this.getId(), AsThoughEffectType.HEXPROOF, null, sourceControllerId, game) == null
&& abilities.stream()
.filter(HexproofBaseAbility.class::isInstance)
.map(HexproofBaseAbility.class::cast)
.anyMatch(ability -> ability.checkObject(source, game))) {
return false;
}
return !hasProtectionFrom(source, game);