Card-Forge / Card-Forge/forge

Add cmcLE in ChooseCardNameEffect and CardFacePredicates

Open
#7,580 4 comments 0 reactions 2 assignees Assigned to @Hanmac View on GitHub
Game Mechanics keep
Dominant language
Java
Stars
2.7k
Forks
1.1k
Avg merge
1d 1h
Merged PRs (30d)
163

Description

Currently we have checks for cmc to be equal to something "cncEQ" but nothing for less than or equal.

I've implemented the solution but am not a project contributor. Here is the code:
In ChooseCardNameEffect.java at line 101 add:
`
else if (valid.contains("cmcLE") && !StringUtils.isNumeric(valid.split("cmcLE")[1])) {
String s = valid.split("cmcLE")[1];
valid = valid.replace(s, String.valueOf(AbilityUtils.calculateAmount(host, s, sa)));
}
`

In CardFacePredicates at line 106 add:
`
} else if (m.contains("cmcLE")) {
int i = Integer.parseInt(m.substring(5));
if (!hasCMC_LE(input, i)) return false;
`

And also in CardFacePredicates at line 129 add:
`
static protected boolean hasCMC_LE(ICardFace input, final int value) {
ManaCost cost = input.getManaCost();
return cost != null && cost.getCMC() <= value;
}
`

I've tested the code and it works fine. Since it is an extra feature and not a change to existing logic it fits in nicely with existing code.

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.