// Tafiok's general jewelry

ON INIT {
 SET_SHOP YES
 SHOP_CATEGORY JEWELRY
 INVENTORY ADD "JEWELRY\\BRACELET\\BRACELET"
 SET §unlock 1
 SET £key "KEY_BASE_0073"
 >>JEWELRY_REFILL_6
 INVENTORY ADD "JEWELRY\\BRACELET\\BRACELET"
 INVENTORY ADD "JEWELRY\\NECKLACE\\NECKLACE"
 INVENTORY ADD "JEWELRY\\GOLD_CUP\\GOLD_CUP"
>>JEWELRY_REFILL_5
 INVENTORY ADD "JEWELRY\\BRACELET\\BRACELET"
 INVENTORY ADD "JEWELRY\\NECKLACE\\NECKLACE"
>>JEWELRY_REFILL_4
 INVENTORY ADD "JEWELRY\\NECKLACE\\NECKLACE"
>>JEWELRY_REFILL_3
 INVENTORY ADD "JEWELRY\\BRACELET\\BRACELET"
>>JEWELRY_REFILL_2
 INVENTORY ADD "JEWELRY\\NECKLACE\\NECKLACE"
>>JEWELRY_REFILL_1
 INVENTORY ADD "JEWELRY\\BRACELET\\BRACELET"
 SET §rawgems 0
 ACCEPT
}

ON INITEND {
 SENDEVENT -ri IDENTIFY 100 ""
 ACCEPT
}

ON RELOAD {
  IF (#TROLL_QUEST < 2) {
    SHOP_MULTIPLY 1.3
    ACCEPT
  }
 SHOP_MULTIPLY 1.1
 ACCEPT
}

ON GAME_READY {
 IF (#TROLL_QUEST < 2) ACCEPT
 IF (§unlock == 0) ACCEPT
 IF (§rawgems > 20) GOTO JEWELRY_REFILL_6
 IF (§rawgems > 16) GOTO JEWELRY_REFILL_5
 IF (§rawgems > 12) GOTO JEWELRY_REFILL_4
 IF (§rawgems > 8) GOTO JEWELRY_REFILL_3
 IF (§rawgems > 4) GOTO JEWELRY_REFILL_2
 IF (§rawgems == 1) GOTO JEWELRY_REFILL_1
 ACCEPT 
}

ON CUSTOM {
  IF (^$PARAM1 == "DEAD") {
    SET_SHOP NO
    SET §unlock 0
    ACCEPT
  }
 IF (^$PARAM1 == "LOCK") {
   SET §unlock 0
   SET_SHOP NO
   ACCEPT
 }  
 IF (^$PARAM1 == "UNLOCK") {
   SET §unlock 1
   SET_SHOP YES
   ACCEPT
 }
 IF (^$PARAM1 == "GOTGEMS") {
   INC §rawgems 1	// the more raw gems are given to tafiok during the troll strike, the more jewelry he gets in his chests after the strike is over.
   ACCEPT
 }
 ACCEPT
}

ON INVENTORY2_OPEN {
 IF (#SHOPPING == 1) ACCEPT
 SET #SHOPPING 1
 HEROSAY [tutorial_shop]
 ACCEPT
}