text: import {data} from "./data/abilities.js"
  import {Trait} from "./trait.js"
  
  export function get_name(form) {
      let name = form.get("name") || "template";
      let regex = new RegExp("^[a-zA-Z0-9 ]*$");
      if(name.length > 0 && regex.test(name)) {
          name = name.toLowerCase();
          name = name.split(" ").join("_");
          return name;
      }
      return false;
  }
  
  export function get_level(form) {
      let level = form.get("level") || "-1";
      if(!isNaN(level)) {
          level = parseInt(level);
          if (-1 <= level && level <= 24) {
              return level.toString();
          }
      }
      return false;
  }
  
  export function get_fields(form) {
      let fields_dictionary = {}
      let fields = data["values"]["fields"]
      for(let field of Object.keys(fields)) {
          fields_dictionary[field] = form.get(field);
      }
      return fields_dictionary;
  }
  
  export function get_items(form) {
      let items_dictionary = {}
      let items = data["values"]["items"]
      for(let item of Object.keys(items)) {
          items_dictionary[item] = form.get(item);
      }
      return items_dictionary;
  }
  
  export function get_traits() {
      let traits_dictionary = {}
      let traits = Trait.getItems()
      for(let trait of traits) {
          traits_dictionary[trait] = Trait.getItem(trait);
      }
      return traits_dictionary
  }