Card-Forge / Card-Forge/forge

Simplification/Unification of StaticAbility variants

Open
#10,097 2 comments 0 reactions 2 assignees Claimed by @tool4ever View on GitHub
Game Mechanics keep
Dominant language
Java
Stars
2.7k
Forks
1.1k
Avg merge
1d 1h
Merged PRs (30d)
158

Description

Example:

https://github.com/Card-Forge/forge/blob/5972acb0a26b89b55d0097eadfe48dc10e13bfed/forge-game/src/main/java/forge/game/staticability/StaticAbilityCantAttach.java#L9-L21

most of the uses in these Static classes return a boolean if some static ability gets triggered by it
(in some cases, like this one, it returns the first one that does trigger it)

So shouldn't it be possible to make a helper version that uses stream of it?

Like this part is nearly identical in most versions (+some use extra LKI, but these can be added)
`target.getGame().getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES).stream().flatMap(c -> c.getStaticAbilities().stream())`

And then use `anyMatch`/`filter` with a `Predicate` like this?
`stAb -> stAb.checkConditions(StaticAbilityMode.CantAttach) && applyCantAttachAbility(stAb, card, target, checkSBA)`

Maybe do the Mode check in a `filter` first?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.