diff --git a/forge-gui/MANUAL.txt b/forge-gui/MANUAL.txt index ff59c7440ce..bee33f254ac 100644 --- a/forge-gui/MANUAL.txt +++ b/forge-gui/MANUAL.txt @@ -391,8 +391,11 @@ 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. +BlackRedLand - black_red_land.wav - triggered when a land with the "B" and "R" 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. 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. @@ -403,7 +406,10 @@ 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. +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. 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. 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. @@ -412,6 +418,7 @@ ManaBurn - mana_burn.wav - triggered during a mana burn if the appropriate rule OtherLand - other_land.wav - triggered when a land with non-color mana abilities or any other land is played. 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. 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. @@ -421,7 +428,10 @@ 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. +WhiteBlueLand - white_blue_land.wav - triggered when a land with the "W" 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. +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. All sounds use the event bus model now and are not called directly. diff --git a/forge-gui/src/main/java/forge/sound/EventVisualizer.java b/forge-gui/src/main/java/forge/sound/EventVisualizer.java index 882b725648b..60ed7eaa667 100644 --- a/forge-gui/src/main/java/forge/sound/EventVisualizer.java +++ b/forge-gui/src/main/java/forge/sound/EventVisualizer.java @@ -179,28 +179,69 @@ public class EventVisualizer extends IGameEventVisitor.Base imp return SoundEffectType.ScriptedEffect; } + // I want to get first two real colors this land can produce - no interest in colorless or devoid + String fullManaColors = ""; for (final SpellAbility sa : event.land.getManaAbilities()) { - final String manaColors = sa.getManaPartRecursive().getOrigProduced(); - - if (manaColors.contains("B")) { - return SoundEffectType.BlackLand; - } - if (manaColors.contains("U")) { - return SoundEffectType.BlueLand; - } - if (manaColors.contains("G")) { - return SoundEffectType.GreenLand; - } - if (manaColors.contains("R")) { - return SoundEffectType.RedLand; - } - if (manaColors.contains("W")) { - return SoundEffectType.WhiteLand; + String currManaColor = sa.getManaPartRecursive().getOrigProduced(); + if(!"C".equals(currManaColor)) { + fullManaColors = fullManaColors + currManaColor; } } + // No interest if "colors together" or "alternative colors" - only interested in colors themselves + fullManaColors = fullManaColors.replaceAll("\\s", ""); - // play a generic land sound if no other sound corresponded to it. - return SoundEffectType.OtherLand; + // No interest in third color if present, at least for the moment + + SoundEffectType resultSound = null; + int fullManaColorsLength = fullManaColors.length(); + if(fullManaColorsLength >= 2) { + fullManaColors = fullManaColors.substring(0,2); + if (fullManaColors.contains("W") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueLand)) { + resultSound = SoundEffectType.WhiteBlueLand; + } else if (fullManaColors.contains("W") && (fullManaColors.contains("G")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteGreenLand)) { + resultSound = SoundEffectType.WhiteGreenLand; + } else if (fullManaColors.contains("W") && (fullManaColors.contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteRedLand)) { + resultSound = SoundEffectType.WhiteRedLand; + } else if (fullManaColors.contains("B") && (fullManaColors.contains("W")) && SoundSystem.instance.hasResource(SoundEffectType.BlackWhiteLand)) { + resultSound = SoundEffectType.BlackWhiteLand; + } else if (fullManaColors.contains("B") && (fullManaColors.contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.BlackRedLand)) { + resultSound = SoundEffectType.BlackRedLand; + } else if (fullManaColors.contains("U") && (fullManaColors.contains("B")) && SoundSystem.instance.hasResource(SoundEffectType.BlueBlackLand)) { + resultSound = SoundEffectType.BlueBlackLand; + } else if (fullManaColors.contains("G") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.GreenBlueLand)) { + resultSound = SoundEffectType.GreenBlueLand; + } else if (fullManaColors.contains("G") && (fullManaColors.contains("B")) && SoundSystem.instance.hasResource(SoundEffectType.GreenBlackLand)) { + resultSound = SoundEffectType.GreenBlackLand; + } else if (fullManaColors.contains("G") && (fullManaColors.contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.GreenRedLand)) { + resultSound = SoundEffectType.GreenRedLand; + } else if (fullManaColors.contains("R") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.RedBlueLand)) { + resultSound = SoundEffectType.RedBlueLand; + } + } + + if(resultSound == null) { + // multicolor land without sounds installed, or single mana land, or colorless/devoid land + // in case of multicolor, lets take only the 1st color of the list, it sure has sound + if(fullManaColorsLength >= 2) { + fullManaColors = fullManaColors.substring(0,1); + } + if (fullManaColors.contains("B")) { + resultSound = SoundEffectType.BlackLand; + } else if (fullManaColors.contains("U")) { + resultSound = SoundEffectType.BlueLand; + } else if (fullManaColors.contains("G")) { + resultSound = SoundEffectType.GreenLand; + } else if (fullManaColors.contains("R")) { + resultSound = SoundEffectType.RedLand; + } else if (fullManaColors.contains("W")) { + resultSound = SoundEffectType.WhiteLand; + } else { + resultSound = SoundEffectType.OtherLand; + } + } + + return resultSound; + } /** diff --git a/forge-gui/src/main/java/forge/sound/SoundEffectType.java b/forge-gui/src/main/java/forge/sound/SoundEffectType.java index d5b5ca775ea..655aabb2953 100644 --- a/forge-gui/src/main/java/forge/sound/SoundEffectType.java +++ b/forge-gui/src/main/java/forge/sound/SoundEffectType.java @@ -40,7 +40,10 @@ public enum SoundEffectType { Artifact("artifact.wav", false), ArtifactCreature("artifact_creature.wav", false), BlackLand("black_land.wav", false), + BlackRedLand("black_red_land.wav", false), + BlackWhiteLand("black_white_land.wav", false), Block("block.wav", false), + BlueBlackLand("blue_black_land.wav", false), BlueLand("blue_land.wav", false), Creature("creature.wav", false), Damage("damage.wav", true), @@ -52,7 +55,10 @@ public enum SoundEffectType { Equip("equip.wav", false), Exile("exile.wav", false), FlipCoin("flip_coin.wav", false), + GreenBlackLand("green_black_land.wav", false), + GreenBlueLand("green_blue_land.wav", false), GreenLand("green_land.wav", false), + GreenRedLand("green_red_land.wav", false), Instant("instant.wav", false), LifeGain("life_gain.wav", true), LifeLoss("life_loss.wav", true), @@ -62,6 +68,7 @@ public enum SoundEffectType { Phasing("phasing.wav", true), Planeswalker("planeswalker.wav", false), Poison("poison.wav", true), + RedBlueLand("red_blue_land.wav", false), RedLand("red_land.wav", false), Regen("regeneration.wav", false), RemoveCounter("remove_counter.wav", true), @@ -72,7 +79,10 @@ public enum SoundEffectType { Tap("tap.wav", false), Token("token.wav", true), Untap("untap.wav", true), + WhiteBlueLand("white_blue_land.wav", false), + WhiteGreenLand("white_green_land.wav", false), WhiteLand("white_land.wav", false), + WhiteRedLand("white_red_land.wav", false), WinDuel("win_duel.wav", false); private final String resourceFileName; diff --git a/forge-gui/src/main/java/forge/sound/SoundSystem.java b/forge-gui/src/main/java/forge/sound/SoundSystem.java index c7831aa6676..a7e23a1d176 100644 --- a/forge-gui/src/main/java/forge/sound/SoundSystem.java +++ b/forge-gui/src/main/java/forge/sound/SoundSystem.java @@ -81,6 +81,15 @@ public class SoundSystem { return clip; } + public boolean hasResource(final SoundEffectType type) { + boolean result = true; + IAudioClip clip = fetchResource(type); + if(clip.equals(emptySound)) { + result = false; + } + return result; + } + /** * Play the sound associated with the resource specified by the file name * ("synchronized" with other sounds of the same kind means: only one can play at a time).