Merge branch 'master' into 'master'

Sound support for multicolor lands

See merge request core-developers/forge!1445
This commit is contained in:
Michael Kamensky
2019-03-06 17:56:56 +00:00
4 changed files with 88 additions and 18 deletions

View File

@@ -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. Artifact[*] - artifact.wav - triggered when an artifact is played.
ArtifactCreature [*] - artifact_creature.wav - triggered when an artifact creature 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. 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. Block [*] - block.wav - triggered when a blocker is assigned.
BlueLand [*] - blue_land.wav - triggered when a land with the "U" mana ability is played. 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. Creature [*] - creature.wav - triggered when a creature is played.
Damage - damage.wav - triggered when a creature is damaged. Damage - damage.wav - triggered when a creature is damaged.
Destroy [*] - destroy.wav - triggered when a permanent is destroyed. 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. Equip [*] - equip.wav - triggered when an equipment is equipped.
Exile - exile.wav - triggered when a card is exiled. Exile - exile.wav - triggered when a card is exiled.
FlipCoin [*] - flip_coin.wav - triggered when a coin is flipped. 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. 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. Instant [*] - instant.wav - triggered when an instant is played.
LifeGain - life_gain.wav - triggered when a player gains life. LifeGain - life_gain.wav - triggered when a player gains life.
LifeLoss [*] - life_loss.wav - triggered when a player loses 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. 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. Planeswalker [*] - planeswalker.wav - triggered when a planeswalker is played.
Poison [*] - poison.wav - triggered when a player receives a poison counter. 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. RedLand [*] - red_land.wav - triggered when a land with the "R" mana ability is played.
Regen - regeneration.wav - triggered when a creature is regenerated. Regen - regeneration.wav - triggered when a creature is regenerated.
RemoveCounter - remove_counter.wav - triggered when a counter is removed from a permanent. 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. Tap [*] - tap.wav - triggered when a permanent is tapped.
Token [*] - token.wav - triggered when a token is created. Token [*] - token.wav - triggered when a token is created.
Untap [*] - untap.wav - triggered when a permanent is untapped. 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. 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. WinDuel [*] - win_duel.wav - triggered when a player wins the duel.
All sounds use the event bus model now and are not called directly. All sounds use the event bus model now and are not called directly.

View File

@@ -179,28 +179,69 @@ public class EventVisualizer extends IGameEventVisitor.Base<SoundEffectType> imp
return SoundEffectType.ScriptedEffect; 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()) { for (final SpellAbility sa : event.land.getManaAbilities()) {
final String manaColors = sa.getManaPartRecursive().getOrigProduced(); 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", "");
if (manaColors.contains("B")) { // No interest in third color if present, at least for the moment
return SoundEffectType.BlackLand;
} SoundEffectType resultSound = null;
if (manaColors.contains("U")) { int fullManaColorsLength = fullManaColors.length();
return SoundEffectType.BlueLand; if(fullManaColorsLength >= 2) {
} fullManaColors = fullManaColors.substring(0,2);
if (manaColors.contains("G")) { if (fullManaColors.contains("W") && (fullManaColors.contains("U")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteBlueLand)) {
return SoundEffectType.GreenLand; resultSound = SoundEffectType.WhiteBlueLand;
} } else if (fullManaColors.contains("W") && (fullManaColors.contains("G")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteGreenLand)) {
if (manaColors.contains("R")) { resultSound = SoundEffectType.WhiteGreenLand;
return SoundEffectType.RedLand; } else if (fullManaColors.contains("W") && (fullManaColors.contains("R")) && SoundSystem.instance.hasResource(SoundEffectType.WhiteRedLand)) {
} resultSound = SoundEffectType.WhiteRedLand;
if (manaColors.contains("W")) { } else if (fullManaColors.contains("B") && (fullManaColors.contains("W")) && SoundSystem.instance.hasResource(SoundEffectType.BlackWhiteLand)) {
return SoundEffectType.WhiteLand; 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;
} }
} }
// play a generic land sound if no other sound corresponded to it. if(resultSound == null) {
return SoundEffectType.OtherLand; // 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;
} }
/** /**

View File

@@ -40,7 +40,10 @@ public enum SoundEffectType {
Artifact("artifact.wav", false), Artifact("artifact.wav", false),
ArtifactCreature("artifact_creature.wav", false), ArtifactCreature("artifact_creature.wav", false),
BlackLand("black_land.wav", false), BlackLand("black_land.wav", false),
BlackRedLand("black_red_land.wav", false),
BlackWhiteLand("black_white_land.wav", false),
Block("block.wav", false), Block("block.wav", false),
BlueBlackLand("blue_black_land.wav", false),
BlueLand("blue_land.wav", false), BlueLand("blue_land.wav", false),
Creature("creature.wav", false), Creature("creature.wav", false),
Damage("damage.wav", true), Damage("damage.wav", true),
@@ -52,7 +55,10 @@ public enum SoundEffectType {
Equip("equip.wav", false), Equip("equip.wav", false),
Exile("exile.wav", false), Exile("exile.wav", false),
FlipCoin("flip_coin.wav", false), FlipCoin("flip_coin.wav", false),
GreenBlackLand("green_black_land.wav", false),
GreenBlueLand("green_blue_land.wav", false),
GreenLand("green_land.wav", false), GreenLand("green_land.wav", false),
GreenRedLand("green_red_land.wav", false),
Instant("instant.wav", false), Instant("instant.wav", false),
LifeGain("life_gain.wav", true), LifeGain("life_gain.wav", true),
LifeLoss("life_loss.wav", true), LifeLoss("life_loss.wav", true),
@@ -62,6 +68,7 @@ public enum SoundEffectType {
Phasing("phasing.wav", true), Phasing("phasing.wav", true),
Planeswalker("planeswalker.wav", false), Planeswalker("planeswalker.wav", false),
Poison("poison.wav", true), Poison("poison.wav", true),
RedBlueLand("red_blue_land.wav", false),
RedLand("red_land.wav", false), RedLand("red_land.wav", false),
Regen("regeneration.wav", false), Regen("regeneration.wav", false),
RemoveCounter("remove_counter.wav", true), RemoveCounter("remove_counter.wav", true),
@@ -72,7 +79,10 @@ public enum SoundEffectType {
Tap("tap.wav", false), Tap("tap.wav", false),
Token("token.wav", true), Token("token.wav", true),
Untap("untap.wav", true), Untap("untap.wav", true),
WhiteBlueLand("white_blue_land.wav", false),
WhiteGreenLand("white_green_land.wav", false),
WhiteLand("white_land.wav", false), WhiteLand("white_land.wav", false),
WhiteRedLand("white_red_land.wav", false),
WinDuel("win_duel.wav", false); WinDuel("win_duel.wav", false);
private final String resourceFileName; private final String resourceFileName;

View File

@@ -81,6 +81,15 @@ public class SoundSystem {
return clip; 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 * 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). * ("synchronized" with other sounds of the same kind means: only one can play at a time).