package solace.game;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

/**
 * Represents a weapon proficiency
 */
public class WeaponProficiency {
  private static final String TYPE_SIMPLE = "simple";
  private static final String TYPE_MARTIAL = "martial";
  private static final String STYLE_MELEE = "melee";
  private static final String STYLE_RANGED = "ranged";

  private String name;
  private String type;
  private String style;
  private String skill;
  private int hands;
  private Collection<String> damageTypes = new ArrayList<>();

  /**
   * Creates a new weapon proficiency with the given parameters.
   * @param name Name for the proficiency.
   * @param type Type of proficiency.
   * @param skill Skill associated with the proficiency.
   * @param hands Number of hands needed to wield weapons that have the proficiency.
   * @param damTypes Damage types for weapons that have the proficiency.
   */
  public WeaponProficiency(String name, String type, String style, String skill, int hands, Collection<String> damTypes) {
    setName(name);
    setType(type);
    setSkill(skill);
    setHands(hands);
    damageTypes = damTypes;
  }

  /**
   * @return The name of the weapon proficiency.
   */
  public String getName() { return name; }

  /**
   * Sets the name of the weapon proficiency.
   * @param name The name to set.
   */
  public void setName(String name) { this.name = name; }

  /**
   * @return The type of the weapon proficiency.
   */
  public String getType() { return type; }

  /**
   * Sets the type for the weapon proficiency.
   * @param type Type name to set.
   */
  public void setType(String type) { this.type = type; }

  /**
   * @return The skill associated with the weapon proficiency.
   */
  public String getSkill() { return skill; }

  /**
   * Sets the skill associated with the weapon proficiency.
   * @param skill Skill name to set.
   */
  public void setSkill(String skill) { this.skill = skill; }

  /**
   * @return The damage types for weapons that have the proficiency.
   */
  public Collection<String> getDamageTypes() { return Collections.unmodifiableCollection(damageTypes); }

  /**
   * Adds a damage type for weapons that have the proficiency.
   * @param type Name for the type of damage to add.
   */
  public void addDamageType(String type) { damageTypes.add(type); }

  /**
   * @return Number of hands needed to wield weapons with this proficiency.
   */
  public int getHands() { return hands; }

  /**
   * Sets the number of hands needed to wield weapons with this proficiency.
   * @param hands Number of hands to set.
   */
  public void setHands(int hands) { this.hands = hands; }

  /**
   * @return `true` if this is a simple weapon proficiency, `false` otherwise.
   */
  public boolean isSimple() { return type.equals(TYPE_SIMPLE); }

  /**
   * @return `true` if this is a martial weapon proficiency, `false` otherwise.
   */
  public boolean isMartial() { return type.equals(TYPE_MARTIAL); }

  /**
   * @return The style of the weapon proficiency.
   */
  public String getStyle() { return style; }

  /**
   * Sets the style for the weapon proficiency.
   * @param style Style to set.
   */
  public void setStyle(String style) { this.style = style; }

  /**
   * @return `true` if the style is melee, `false` otherwise.
   */
  public boolean isMelee() { return getStyle().equals(STYLE_MELEE); }

  /**
   * @return `true` if the style is ranged, `false` otherwise.
   */
  public boolean isRanged() { return getStyle().equals(STYLE_RANGED); }
}

@@ -26,57 +26,96 @@
 ort 
-java.util.ArrayList;%0Aimport java.util.Collection;
+solace.io.AssetNotFoundException;%0Aimport solace.io.DamageTypes;%0Aimport solace.util.Log;%0A
 %0Aimp
@@ -128,27 +128,17 @@
 va.util.
-Collections
+*
 ;%0A%0A/**%0A 
@@ -552,33 +552,31 @@
 private 
-Collection%3CString
+List%3CDamageType
 %3E damage
@@ -1003,16 +1003,21 @@
 iciency(
+%0A    
 String n
@@ -1020,16 +1020,20 @@
 ng name,
+%0A   
  String 
@@ -1037,16 +1037,20 @@
 ng type,
+%0A   
  String 
@@ -1055,16 +1055,20 @@
 g style,
+%0A   
  String 
@@ -1073,16 +1073,20 @@
 g skill,
+%0A   
  int han
@@ -1088,16 +1088,20 @@
 t hands,
+%0A   
  Collect
@@ -1120,16 +1120,19 @@
 damTypes
+%0A  
 ) %7B%0A    
@@ -1211,34 +1211,319 @@
 s);%0A
-    damageTypes = damTypes
+%0A    damTypes.forEach(dmgTypeName -%3E %7B%0A      try %7B%0A        damageTypes.add(DamageTypes.getInstance().get(dmgTypeName));%0A      %7D catch (AssetNotFoundException e) %7B%0A        Log.warn(String.format(%0A          %22Invalid damage '%25s' referenced by weapon proficiency '%25s'%22,%0A          dmgTypeName, name));%0A      %7D%0A    %7D)
 ;%0A  
@@ -2430,22 +2430,26 @@
 lection%3C
-String
+DamageType
 %3E getDam
@@ -2524,205 +2524,8 @@
  %7D%0A%0A
-  /**%0A   * Adds a damage type for weapons that have the proficiency.%0A   * @param type Name for the type of damage to add.%0A   */%0A  public void addDamageType(String type) %7B damageTypes.add(type); %7D%0A%0A
   /*

Update weapon proficiencies to handle damage types.