mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Added Bands with others support
- Add 5 Legends Bands with Other lands, Master of the Hunt, Shelkin Brownie, Tolaria - Small fixes to Combat and CCombat
This commit is contained in:
@@ -46,23 +46,52 @@ public class AttackingBand implements Comparable<AttackingBand> {
|
||||
|
||||
public void calculateBlockedState() { this.blocked = !this.blockers.isEmpty(); }
|
||||
|
||||
public boolean canJoinBand(Card card) {
|
||||
// If this card has banding it can definitely join
|
||||
if (card.hasKeyword("Banding")) {
|
||||
public static boolean isValidBand(List<Card> band, boolean shareDamage) {
|
||||
if (band.isEmpty()) {
|
||||
// An empty band is not a valid band
|
||||
return false;
|
||||
}
|
||||
|
||||
int bandingCreatures = CardLists.getKeyword(band, "Banding").size();
|
||||
int neededBandingCreatures = shareDamage ? 1 : band.size() - 1;
|
||||
if (neededBandingCreatures <= bandingCreatures) {
|
||||
// For starting a band, only one can be non-Banding
|
||||
// For sharing damage, only one needs to be Banding
|
||||
return true;
|
||||
}
|
||||
|
||||
// If all of the cards in the Band have banding, it can definitely join
|
||||
if (attackers.size() == CardLists.getKeyword(attackers, "Banding").size()) {
|
||||
return true;
|
||||
// Legends lands, Master of the Hunt, Old Fogey (just in case)
|
||||
// Since Bands With Other is a dead keyword, no major reason to make this more generic
|
||||
// But if someone is super motivated, feel free to do it. Just make sure you update Tolaria and Shelkie Brownie
|
||||
String[] bandsWithString = { "Bands with Other Legendary Creatures", "Bands with Other Creatures named Wolves of the Hunt",
|
||||
"Bands with Other Dinosaurs" };
|
||||
String[] validString = { "Legendary.Creature", "Creature.namedWolves of the Hunt", "Dinosaur" };
|
||||
|
||||
Card source = band.get(0);
|
||||
for(int i = 0; i < bandsWithString.length; i++) {
|
||||
String keyword = bandsWithString[i];
|
||||
String valid = validString[i];
|
||||
|
||||
// Check if a bands with other keyword exists in band, and each creature in the band fits the valid quality
|
||||
if (!CardLists.getKeyword(band, keyword).isEmpty() &&
|
||||
CardLists.getValidCards(band, valid, source.getController(), source).size() == band.size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO add checks for bands with other
|
||||
//List<Card> bandsWithOther = CardLists.getKeyword(attackers, "Bands with Other");
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canJoinBand(Card card) {
|
||||
// Trying to join an existing band, attackers should be non-empty and card should exist
|
||||
List<Card> newBand = new ArrayList<Card>(attackers);
|
||||
if (card != null) {
|
||||
newBand.add(card);
|
||||
}
|
||||
|
||||
return isValidBand(newBand, false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
|
||||
@@ -446,7 +446,7 @@ public class Combat {
|
||||
if (ordered) {
|
||||
list = this.attackerDamageAssignmentOrder.containsKey(card) ? this.attackerDamageAssignmentOrder.get(card) : null;
|
||||
} else {
|
||||
list = this.getBandByAttacker(card) != null ? this.getBandByAttacker(card).getBlockers() : null;
|
||||
list = this.attackerToBandMap.containsKey(card) ? this.getBandByAttacker(card).getBlockers() : null;
|
||||
}
|
||||
|
||||
if (list == null) {
|
||||
@@ -619,13 +619,8 @@ public class Combat {
|
||||
Player attackingPlayer = this.getAttackingPlayer();
|
||||
Player assigningPlayer = blocker.getController();
|
||||
|
||||
List<Card> bandingAttackers = CardLists.getKeyword(attackers, "Banding");
|
||||
if (!bandingAttackers.isEmpty()) {
|
||||
if (AttackingBand.isValidBand(attackers, true)) {
|
||||
assigningPlayer = attackingPlayer;
|
||||
} else {
|
||||
// TODO Get each bands with other creature
|
||||
// Check if any other valid creatures matches the bands with other
|
||||
// assigningPlayer = blockingBand.get(0).getController();
|
||||
}
|
||||
|
||||
assignedDamage = true;
|
||||
@@ -677,13 +672,8 @@ public class Combat {
|
||||
if (defender instanceof Player && defender.hasKeyword("You assign combat damage of each creature attacking you.")) {
|
||||
assigningPlayer = (Player)defender;
|
||||
} else {
|
||||
List<Card> blockingBand = CardLists.getKeyword(blockers, "Banding");
|
||||
if (!blockingBand.isEmpty()) {
|
||||
assigningPlayer = blockingBand.get(0).getController();
|
||||
} else {
|
||||
// TODO Get each bands with other creature
|
||||
// Check if any other valid creatures matches the bands with other
|
||||
// assigningPlayer = blockingBand.get(0).getController();
|
||||
if (AttackingBand.isValidBand(blockers, true)) {
|
||||
assigningPlayer = blockers.get(0).getController();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,8 +123,9 @@ public class InputAttack extends InputSyncronizedBase {
|
||||
combat.removeFromCombat(card);
|
||||
card.setUsedToPay(false);
|
||||
showCombat();
|
||||
// When removing an attacker should I clear the attacking band?
|
||||
this.activateBand(this.activeBand);
|
||||
// When removing an attacker clear the attacking band
|
||||
this.activateBand(null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,11 +88,17 @@ public enum CCombat implements ICDoc {
|
||||
display.append(defender.getName()).append(" is attacked by:\n");
|
||||
|
||||
// Associate Bands, Attackers Blockers
|
||||
boolean previousBand = false;
|
||||
for(AttackingBand band : bands) {
|
||||
// Space out band blocks from non-band blocks
|
||||
if (previousBand) {
|
||||
display.append("\n");
|
||||
}
|
||||
|
||||
boolean isBand = band.getAttackers().size() > 1;
|
||||
if (isBand) {
|
||||
// Only print Band data if it's actually a band
|
||||
display.append(" BAND");
|
||||
display.append(" > BAND");
|
||||
if (band.getBlocked()) {
|
||||
display.append(" (blocked)");
|
||||
}
|
||||
@@ -114,6 +120,7 @@ public enum CCombat implements ICDoc {
|
||||
for (final Card element : band.getBlockers()) {
|
||||
display.append(" < ").append(combatantToString(element)).append("\n");
|
||||
}
|
||||
previousBand = isBand;
|
||||
}
|
||||
}
|
||||
return display.toString().trim();
|
||||
|
||||
Reference in New Issue
Block a user