ITEM = function(name, image_filepath, stats_list, food_type, range, aoe_type, identifier)
{
  var self = {};

  self.name = name;
  //self.unlocked = false;
  self.strength = 0;

  self.id = identifier;

  self.stats  = stats_list;

  self.cooldown = 0.0;

  self.range = range;
  self.aoe_type = aoe_type;

  self.food_type = food_type;
  
  self.image = new Image();
  self.image.src = image_filepath;

  self.draw_stats = function(x, y, w, h)
  {
    var icon_size = w / 3.0;

      //attack timer
      //draw_center(stat_images[STAT_TYPE_ENUM.ATTACK_TIMER], x - .5 * w + .6 * icon_size, y - .5 * h + .6 * icon_size, icon_size, icon_size);
      if(self.cooldown > 0.0)
      {

        draw_text(self.cooldown.toFixed(0), 
        x + .5 * w - .6 * icon_size, 
        y - .5 * h + .85 * icon_size, icon_size);
      }
      
    var counter = 0;
    for(var i in self.stats)
    {
      //if(i == NUM_ATTACKS_ABILITIES)
        //break;
      
      

      if(self.stats[i] > 0)
      { 
        draw_center(stat_images[i], 
          x - .5 * w, 
          y - .5 * h + (counter + .6) * icon_size, icon_size, icon_size, 1.0);

        var color = TEXT_COLOR_ENUM.WHITE;
        
        draw_text((self.strength * self.stats[i]).toFixed(0), 
        x - .5 * w - .125 * icon_size * (self.strength * self.stats[i]).toFixed(0).length, 
        y - .5 * h + (counter + .1 + .625) * icon_size, 
        .5 * icon_size, color);
    
              //console.log(self.attacks[i]);
        //draw_text(i + ": " + self.attacks[i], x - .25 * w, y - .2 * h - .1 * counter * h);
        ++counter;
      }
    }

    if(self.food_type != FOOD_TYPE_ENUM.NUM_FOOD_TYPE)
    {

        draw_center(food_images[self.food_type], 
          x - .5 * w, 
          y - .5 * h + (counter + .6) * icon_size, icon_size, icon_size, 1.0);

    }
  }

  self.draw = function(x, y, w, h, a)
  {
    a = a || 1;
  

    
    if(self.food_type != FOOD_TYPE_ENUM.NUM_FOOD_TYPE)
    {

        draw_center(enemy_frames[self.food_type], 
          x, 
          y, 
          (340.0 / 300.0) *w, 
          (340.0 / 300.0) *h, a);

    }
    else
    {
      
      draw_center(typeless_frame, 
        x, 
        y, 
        (340.0 / 300.0) *w, 
        (340.0 / 300.0) *h, a);
    }

    draw_center(self.image, x, y, w, h, a);

    
    if(self.cooldown > 0)
    {
      draw_center(fade_texture, x, y, w, h, a);
      draw_center(fade_texture, x, 
        y + (1.0 - self.cooldown / 2.0) * h * .5, 
        w, 
        self.cooldown / 2.0 * h, a);

    }

    self.draw_stats(x, y, w,h );

    //draw_text(self.name, x,y);
  }

  return self;

}

var __item_list = {};

                                                                                                 //wp mg fh sk he bf am
__item_list[ITEM_ENUM.POTION]           = ITEM("Healing Potion", "img/item/healing_potion.png",   [0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.NUM_FOOD_TYPE, 1, AOE_TYPE_ENUM.AOE_SINGLE, 0);
__item_list[ITEM_ENUM.SWORD]            = ITEM("Extra Sword", "img/item/extra_sword.png",         [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.NUM_FOOD_TYPE, 1, AOE_TYPE_ENUM.AOE_SINGLE, 1);
__item_list[ITEM_ENUM.WAND]             = ITEM("Magic Wand", "img/item/magic_wand.png",           [0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.NUM_FOOD_TYPE, 1, AOE_TYPE_ENUM.AOE_SINGLE, 2);
__item_list[ITEM_ENUM.CHOCOLATE_SAUCE]  = ITEM("Chocolate Sauce", "img/item/chocolate_sauce.png", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.SWEET, 1, AOE_TYPE_ENUM.AOE_SINGLE, 3);

__item_list[ITEM_ENUM.SHIELD]           = ITEM("Spare Shield", "img/item/spare_shield.png",       [0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.NUM_FOOD_TYPE, 1, AOE_TYPE_ENUM.AOE_SINGLE, 4);
__item_list[ITEM_ENUM.DAGGER]           = ITEM("Hidden Dagger", "img/item/hidden_dagger.png",     [0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.NUM_FOOD_TYPE, 1, AOE_TYPE_ENUM.AOE_SINGLE, 5);
__item_list[ITEM_ENUM.TOME]             = ITEM("Holy Tome", "img/item/holy_tome.png",             [0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.NUM_FOOD_TYPE, 1, AOE_TYPE_ENUM.AOE_SINGLE, 6);
__item_list[ITEM_ENUM.BUFF_POTION]      = ITEM("Strength Potion", "img/item/strength_potion.png", [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.NUM_FOOD_TYPE, 1, AOE_TYPE_ENUM.AOE_SINGLE, 7);

__item_list[ITEM_ENUM.GUAC]             = ITEM("Extra Guac", "img/item/guac.png",                 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.FRUIT, 1, AOE_TYPE_ENUM.AOE_SINGLE, 8);
__item_list[ITEM_ENUM.SLICE_OF_CHEESE] = ITEM("Slice of Cheese", "img/item/cheese.png", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.DAIRY, 1, AOE_TYPE_ENUM.AOE_SINGLE, 9);
__item_list[ITEM_ENUM.BBQ_SAUCE] = ITEM("BBQ Sauce", "img/item/bbq_sauce.png", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.MEAT, 1, AOE_TYPE_ENUM.AOE_SINGLE, 10);
__item_list[ITEM_ENUM.HUMMUS] = ITEM("Hummus", "img/item/hummus.png", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], FOOD_TYPE_ENUM.VEGGIES, 1, AOE_TYPE_ENUM.AOE_SINGLE, 11);
