Support for three color lands

This commit is contained in:
Alessandro Coli
2019-03-30 15:58:49 +01:00
parent 42f6cdbb46
commit a9124743ef
3 changed files with 69 additions and 15 deletions

View File

@@ -391,11 +391,14 @@ AddCounter [*] - add_counter.wav - triggered when a counter is added to a perman
Artifact[*] - artifact.wav - triggered when an artifact is played.
ArtifactCreature [*] - artifact_creature.wav - triggered when an artifact creature is played.
BlackLand [*] - black_land.wav - triggered when a land with the "B" mana ability is played.
BlackRedGreenLand - black_red_green_land.wav - triggered when a land with the "B" and "R" and "G" mana ability is played.
BlackRedLand - black_red_land.wav - triggered when a land with the "B" and "R" mana ability is played.
BlackWhiteGreenLand - black_white_green_land.wav - triggered when a land with the "B" and "W" and "G" mana ability is played.
BlackWhiteLand - black_white_land.wav - triggered when a land with the "B" and "W" mana ability is played.
Block [*] - block.wav - triggered when a blocker is assigned.
BlueLand [*] - blue_land.wav - triggered when a land with the "U" mana ability is played.
BlueBlackLand - blue_black_land.wav - triggered when a land with the "U" and "B" mana ability is played.
BlueBlackRedLand - blue_black_red_land.wav - triggered when a land with the "U" and "B" and "R" mana ability is played.
Creature [*] - creature.wav - triggered when a creature is played.
Damage - damage.wav - triggered when a creature is damaged.
Destroy [*] - destroy.wav - triggered when a permanent is destroyed.
@@ -406,10 +409,13 @@ EndOfTurn [*] - end_of_turn.wav - triggered at the end of turn.
Equip [*] - equip.wav - triggered when an equipment is equipped.
Exile - exile.wav - triggered when a card is exiled.
FlipCoin [*] - flip_coin.wav - triggered when a coin is flipped.
GreenBlackBlueLand - green_black_blue_land.wav - triggered when a land with the "G" and "B" and "U" mana ability is played.
GreenBlackLand - green_black_land.wav - triggered when a land with the "G" and "B" mana ability is played.
GreenBlueLand - green_blue_land.wav - triggered when a land with the "G" and "U" mana ability is played.
GreenBlueRedLand - green_blue_red_land.wav - triggered when a land with the "G" and "U" and "R" mana ability is played.
GreenLand [*] - green_land.wav - triggered when a land with the "G" mana ability is played.
GreenRedLand - green_red_land.wav - triggered when a land with the "G" and "R" mana ability is played.
GreenRedWhiteLand - green_red_white_land.wav - triggered when a land with the "G" and "R" and "W" mana ability is played.
Instant [*] - instant.wav - triggered when an instant is played.
LifeGain - life_gain.wav - triggered when a player gains life.
LifeLoss [*] - life_loss.wav - triggered when a player loses life.
@@ -419,6 +425,7 @@ OtherLand - other_land.wav - triggered when a land with non-color mana abilities
Planeswalker [*] - planeswalker.wav - triggered when a planeswalker is played.
Poison [*] - poison.wav - triggered when a player receives a poison counter.
RedBlueLand - red_blue_land.wav - triggered when a land with the "R" and "U" mana ability is played.
RedBlueWhiteLand - red_blue_white_land.wav - triggered when a land with the "R" and "U" and "W" mana ability is played.
RedLand [*] - red_land.wav - triggered when a land with the "R" mana ability is played.
Regen - regeneration.wav - triggered when a creature is regenerated.
RemoveCounter - remove_counter.wav - triggered when a counter is removed from a permanent.
@@ -428,9 +435,12 @@ Shuffle [*] - shuffle.wav - triggered when a player shuffles his deck.
Tap [*] - tap.wav - triggered when a permanent is tapped.
Token [*] - token.wav - triggered when a token is created.
Untap [*] - untap.wav - triggered when a permanent is untapped.
WhiteBlueBlackLand - white_blue_black_land.wav - triggered when a land with the "W" and "U" and "B" mana ability is played.
WhiteBlueLand - white_blue_land.wav - triggered when a land with the "W" and "U" mana ability is played.
WhiteGreenBlueLand - white_green_blue_land.wav - triggered when a land with the "W" and "G" and "U" mana ability is played.
WhiteGreenLand - white_green_land.wav - triggered when a land with the "W" and "G" mana ability is played.
WhiteLand [*] - white_land.wav - triggered when a land with the "W" mana ability is played.
WhiteRedBlackLand - white_red_black_land.wav - triggered when a land with the "W" and "R" and "B" mana ability is played.
WhiteRedLand - white_red_land.wav - triggered when a land with the "W" and "R" mana ability is played.
WinDuel [*] - win_duel.wav - triggered when a player wins the duel.

View File

@@ -182,30 +182,64 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
ZoneType zoneTo = event.zoneType;
EventValueChangeType zoneEventMode = event.mode;
SoundEffectType resultSound = null;
if(zoneEventMode == EventValueChangeType.Added && zoneTo == ZoneType.Battlefield && card.isLand()) {
Card land = card;
// if there's a specific effect for this particular card, play it and
// we're done.
if (hasSpecificCardEffect(land)) {
return SoundEffectType.ScriptedEffect;
if(zoneEventMode == EventValueChangeType.Added && zoneTo == ZoneType.Battlefield) {
if(card.isLand()) {
resultSound = getLandSound(card);
}
}
return resultSound;
}
// I want to get first two real colors this land can produce - no interest in colorless or devoid
private SoundEffectType getLandSound(Card land) {
SoundEffectType resultSound = null;
// if there's a specific effect for this particular card, play it and
// we're done.
if (hasSpecificCardEffect(land)) {
resultSound = SoundEffectType.ScriptedEffect;
} else {
// I want to get all real colors this land can produce - no interest in colorless or devoid
String fullManaColors = "";
for (final SpellAbility sa : land.getManaAbilities()) {
String currManaColor = sa.getManaPartRecursive().getOrigProduced();
if(!"C".equals(currManaColor)) {
fullManaColors = fullManaColors + currManaColor;
fullManaColors = fullManaColors + currManaColor;
}
}
// No interest if "colors together" or "alternative colors" - only interested in colors themselves
fullManaColors = fullManaColors.replaceAll("\\s", "");
// No interest in third color if present, at least for the moment
int fullManaColorsLength = fullManaColors.length();
if(fullManaColorsLength >= 2) {
if(fullManaColorsLength >= 3) {
// three color land
fullManaColors = fullManaColors.substring(0,3);
if (fullManaColors.contains("W") && fullManaColors.contains("U") && fullManaColors.contains("B") && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueBlackLand)) {
resultSound = SoundEffectType.WhiteBlueBlackLand;
} else if (fullManaColors.contains("W") && fullManaColors.contains("G") && fullManaColors.contains("U") && SoundSystem.instance.hasResource(SoundEffectType.WhiteGreenBlueLand)) {
resultSound = SoundEffectType.WhiteGreenBlueLand;
} else if (fullManaColors.contains("W") && fullManaColors.contains("R") && fullManaColors.contains("B") && SoundSystem.instance.hasResource(SoundEffectType.WhiteRedBlackLand)) {
resultSound = SoundEffectType.WhiteRedBlackLand;
} else if (fullManaColors.contains("B") && fullManaColors.contains("W") && fullManaColors.contains("G") && SoundSystem.instance.hasResource(SoundEffectType.BlackWhiteGreenLand)) {
resultSound = SoundEffectType.BlackWhiteGreenLand;
} else if (fullManaColors.contains("B") && fullManaColors.contains("R") && fullManaColors.contains("G") && SoundSystem.instance.hasResource(SoundEffectType.BlackRedGreenLand)) {
resultSound = SoundEffectType.BlackRedGreenLand;
} else if (fullManaColors.contains("U") && fullManaColors.contains("B") && fullManaColors.contains("R") && SoundSystem.instance.hasResource(SoundEffectType.BlueBlackRedLand)) {
resultSound = SoundEffectType.BlueBlackRedLand;
} else if (fullManaColors.contains("G") && fullManaColors.contains("U") && fullManaColors.contains("R") && SoundSystem.instance.hasResource(SoundEffectType.GreenBlueRedLand)) {
resultSound = SoundEffectType.GreenBlueRedLand;
} else if (fullManaColors.contains("G") && fullManaColors.contains("B") && fullManaColors.contains("U") && SoundSystem.instance.hasResource(SoundEffectType.GreenBlackBlueLand)) {
resultSound = SoundEffectType.GreenBlackBlueLand;
} else if (fullManaColors.contains("G") && fullManaColors.contains("R") && fullManaColors.contains("W") && SoundSystem.instance.hasResource(SoundEffectType.GreenRedWhiteLand)) {
resultSound = SoundEffectType.GreenRedWhiteLand;
} else if (fullManaColors.contains("R") && fullManaColors.contains("U") && fullManaColors.contains("W") && SoundSystem.instance.hasResource(SoundEffectType.RedBlueWhiteLand)) {
resultSound = SoundEffectType.RedBlueWhiteLand;
}
}
if(resultSound == null && fullManaColorsLength >= 2) {
// three color land without sounds installed, or two color land
// lets try with two colored lands' sounds
fullManaColors = fullManaColors.substring(0,2);
if (fullManaColors.contains("W") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueLand)) {
resultSound = SoundEffectType.WhiteBlueLand;
@@ -227,7 +261,7 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
resultSound = SoundEffectType.GreenRedLand;
} else if (fullManaColors.contains("R") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.RedBlueLand)) {
resultSound = SoundEffectType.RedBlueLand;
}
}
}
if(resultSound == null) {
@@ -248,11 +282,11 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
resultSound = SoundEffectType.WhiteLand;
} else {
resultSound = SoundEffectType.OtherLand;
}
}
}
}
return resultSound;
}
/**

View File

@@ -40,10 +40,13 @@ public enum SoundEffectType {
Artifact("artifact.wav", false),
ArtifactCreature("artifact_creature.wav", false),
BlackLand("black_land.wav", false),
BlackRedGreenLand("black_red_green_land.wav", false),
BlackRedLand("black_red_land.wav", false),
BlackWhiteGreenLand("black_white_green_land.wav", false),
BlackWhiteLand("black_white_land.wav", false),
Block("block.wav", false),
BlueBlackLand("blue_black_land.wav", false),
BlueBlackRedLand("blue_black_red_land.wav", false),
BlueLand("blue_land.wav", false),
Creature("creature.wav", false),
Damage("damage.wav", true),
@@ -55,10 +58,13 @@ public enum SoundEffectType {
Equip("equip.wav", false),
Exile("exile.wav", false),
FlipCoin("flip_coin.wav", false),
GreenBlackBlueLand("green_black_blue_land.wav", false),
GreenBlackLand("green_black_land.wav", false),
GreenBlueLand("green_blue_land.wav", false),
GreenBlueRedLand("green_blue_red_land.wav", false),
GreenLand("green_land.wav", false),
GreenRedLand("green_red_land.wav", false),
GreenRedWhiteLand("green_red_white_land.wav", false),
Instant("instant.wav", false),
LifeGain("life_gain.wav", true),
LifeLoss("life_loss.wav", true),
@@ -69,6 +75,7 @@ public enum SoundEffectType {
Planeswalker("planeswalker.wav", false),
Poison("poison.wav", true),
RedBlueLand("red_blue_land.wav", false),
RedBlueWhiteLand("red_blue_white_land.wav", false),
RedLand("red_land.wav", false),
Regen("regeneration.wav", false),
RemoveCounter("remove_counter.wav", true),
@@ -79,9 +86,12 @@ public enum SoundEffectType {
Tap("tap.wav", false),
Token("token.wav", true),
Untap("untap.wav", true),
WhiteBlueBlackLand("white_blue_black_land.wav", false),
WhiteBlueLand("white_blue_land.wav", false),
WhiteGreenBlueLand("white_green_blue_land.wav", false),
WhiteGreenLand("white_green_land.wav", false),
WhiteLand("white_land.wav", false),
WhiteRedBlackLand("white_red_black_land.wav", false),
WhiteRedLand("white_red_land.wav", false),
WinDuel("win_duel.wav", false);