package de.gurkenlabs.litiengine.abilities.effects;

import de.gurkenlabs.litiengine.Game;
import de.gurkenlabs.litiengine.abilities.Ability;
import de.gurkenlabs.litiengine.entities.ICombatEntity;
import de.gurkenlabs.litiengine.sound.Sound;

public class SoundEffect extends Effect {
  private final Sound[] sounds;

  /**
   * Initializes a new instance of the <code>SoundEffect</code> class.
   *
   * @param ability
   *          The ability that performs the effect.
   * @param sounds
   *          The sounds to chose from when applying the effect.
   */
  public SoundEffect(final Ability ability, final Sound... sounds) {
    super(ability, EffectTarget.EXECUTINGENTITY);
    this.sounds = sounds;
  }

  @Override
  protected void apply(final ICombatEntity entity) {
    super.apply(entity);
    if (this.sounds.length == 0) {
      return;
    }

    Game.audio().playSound(this.getRandomSound(), entity);
  }

  private Sound getRandomSound() {
    if (this.sounds.length == 0) {
      return null;
    }

    return Game.random().choose(this.sounds);
  }
}

@@ -48,16 +48,81 @@
 cts;%0D%0A%0D%0A
+import java.util.Arrays;%0D%0Aimport java.util.stream.Collectors;%0D%0A%0D%0A
 import d
@@ -152,16 +152,16 @@
 .Game;%0D%0A
-
 import d
@@ -257,24 +257,78 @@
 batEntity;%0D%0A
+import de.gurkenlabs.litiengine.resources.Resources;%0D%0A
 import de.gu
@@ -810,24 +810,24 @@
 NGENTITY);%0D%0A
-
     this.sou
@@ -848,16 +848,295 @@
 %0A  %7D%0D%0A%0D%0A
+  public SoundEffect(final Ability ability, final String... sounds) %7B%0D%0A    super(ability, EffectTarget.EXECUTINGENTITY);%0D%0A    this.sounds = Arrays.asList(sounds).stream().map(x -%3E Resources.sounds().get(x)).collect(Collectors.toList()).toArray(new Sound%5Bsounds.length%5D);%0D%0A  %7D%0D%0A%0D%0A
   @Overr

Add support to define sounds by their names for SoundEffect