New RNG, eliminate item ID collisions, start working on Anchor Stone
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / Item.as
blobd7dcfcb75279d43bac2558d6971aac49b818b965
1 package org.sevenchan.dongs
3 import adobe.utils.CustomActions;
4 import org.sevenchan.dongs.items.*;
5 import org.sevenchan.dongs.screens.InfoScreen;
7 /**
8 * ...
9 * @author Harbinger
11 public class Item
13 public static var Registry:Object = {};
15 public var id:int = 0;
16 public var name:String = "";
17 public var descr:String = "";
18 public var value:int = 0;
19 public var amount:uint = 0;
20 public var isSexuallyTransmitted:Boolean = false;
22 public function Item(num:uint = 0)
24 amount = num;
27 public function copy():Item
29 return null;
32 public static function fillRegistry():void
34 Registry = {
35 berry_white: new WhiteBerries(),
36 harpy_tincture: new HarpyTincture(),
37 spider_venom: new SpiderVenomSac(),
38 darkharpyegg: new DarkHarpyEgg(),
39 potion_pink: new PinkPotion(),
40 potion_gold: new GoldPotion(),
41 spider_egg: new SpiderEgg(),
42 gas_mask: new GasMask(),
43 milk: new Milk(),
44 spider_gonad: new SpiderGonad(),
45 anchor_stone: new AnchorStone()
47 var ids:Array = new Array();
48 for each (var i:Item in Registry)
50 trace(i.name+"\t"+i.id);
51 if (ids[i.id] != null)
52 throw new Error(i.name + " has duplicate ID! Conflicts with " + (ids[i.id] as Item).name);
53 ids[i.id] = i;
57 public static function findByID(id:int):Item
59 trace("Asked to find", id);
60 for each (var item:Item in Registry)
62 trace(item.name, item.id);
63 if (item.id == id)
64 return item.copy();
66 return null;
69 public function Use(host:Creature):Boolean
71 InfoScreen.push("<h2>Use Item</h2><p>Nothing happens.</p>");
72 return false;