blades-engine load ItemData
This commit is contained in:
99
projects/blades-engine/source/data/ItemData.hx
Normal file
99
projects/blades-engine/source/data/ItemData.hx
Normal file
@@ -0,0 +1,99 @@
|
||||
package data;
|
||||
|
||||
using Type;
|
||||
using Reflect;
|
||||
|
||||
enum ItemVariety {
|
||||
Null;
|
||||
OneHand;
|
||||
TwoHand;
|
||||
Gold;
|
||||
Food;
|
||||
ThrownMissile;
|
||||
Bow;
|
||||
Potion;
|
||||
Scroll;
|
||||
WandOrRod;
|
||||
Tool;
|
||||
Pants;
|
||||
Shield;
|
||||
Armor;
|
||||
Helm;
|
||||
Gloves;
|
||||
Boots;
|
||||
Cloak;
|
||||
Ring;
|
||||
Necklace;
|
||||
Bracelet;
|
||||
Object;
|
||||
Crossbow;
|
||||
Arrows;
|
||||
Bolts;
|
||||
}
|
||||
|
||||
class ItemData {
|
||||
public function new() {}
|
||||
|
||||
public function clone():ItemData {
|
||||
var id = new ItemData();
|
||||
for (field in ItemData.getInstanceFields()) {
|
||||
id.setField(field, this.field(field));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public var name = "";
|
||||
public var full_name = "";
|
||||
private var variety = 0;
|
||||
public function getVariety() {
|
||||
return ItemVariety.createEnumIndex(variety);
|
||||
}
|
||||
public var damage_per_level = 0;
|
||||
public var bonus = 0;
|
||||
private var weapon_skill_used = 4;
|
||||
// TODO public getter to convert weapon skill to a skill enum using the skill numbers in the appendix
|
||||
public var protection = 0;
|
||||
public var charges = 0;
|
||||
public var encumbrance = 0;
|
||||
public var floor_which_sheet = 0;
|
||||
public var floor_which_icon = 0;
|
||||
public var icon_adjust = 0;
|
||||
public var inventory_icon = 0;
|
||||
private var ability_1 = -1;
|
||||
private var ability_str_1 = 0;
|
||||
private var ability_2 = -1;
|
||||
private var ability_str_2 = 0;
|
||||
private var ability_3 = -1;
|
||||
private var ability_str_3 = 0;
|
||||
private var ability_4 = -1;
|
||||
private var ability_str_4 = 0;
|
||||
// TODO public getters for ability types as an enum
|
||||
public var special_class = 0;
|
||||
public var value = 0;
|
||||
private var weight = 0;
|
||||
public function getWeight():Float {
|
||||
return weight / 10.0;
|
||||
}
|
||||
private var identified = 0;
|
||||
public function isIdentified() {
|
||||
return identified == 1;
|
||||
}
|
||||
private var magic = 0;
|
||||
public function isMagic() {
|
||||
return magic == 1;
|
||||
}
|
||||
private var cursed = 0;
|
||||
public function isCursed() {
|
||||
return cursed == 1;
|
||||
}
|
||||
private var once_per_day = 0;
|
||||
public function oncePerDay() {
|
||||
return once_per_day == 1;
|
||||
}
|
||||
private var junk_item = 0;
|
||||
public function junkItem() {
|
||||
return junk_item == 1;
|
||||
}
|
||||
private var missile_anim_type = 0;
|
||||
// TODO make missile anim type publically available as an enum
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package data;
|
||||
|
||||
import haxe.iterators.DynamicAccessIterator;
|
||||
import hscript.Parser;
|
||||
import hscript.Interp;
|
||||
import sys.io.File;
|
||||
@@ -13,6 +14,7 @@ class ScenData {
|
||||
public var floorData:Map<Int, FloorData> = [];
|
||||
public var terrainData:Map<Int, TerrainData> = [];
|
||||
public var creatureData:Map<Int, CreatureData> = [];
|
||||
public var itemData:Map<Int, ItemData> = [];
|
||||
|
||||
static var failed:Array<String> = [];
|
||||
static var passed = 0;
|
||||
@@ -67,6 +69,8 @@ class ScenData {
|
||||
terrainData;
|
||||
case "creature":
|
||||
creatureData;
|
||||
case "item":
|
||||
itemData;
|
||||
default:
|
||||
null;
|
||||
};
|
||||
@@ -75,7 +79,6 @@ class ScenData {
|
||||
function commitData() {
|
||||
data = interp.variables["data"];
|
||||
if (data == null) return;
|
||||
trace(data);
|
||||
|
||||
mapFor(defining)[id] = data;
|
||||
data = data.clone();
|
||||
@@ -90,6 +93,8 @@ class ScenData {
|
||||
new TerrainData();
|
||||
case "creature":
|
||||
new CreatureData();
|
||||
case "item":
|
||||
new ItemData();
|
||||
default:
|
||||
null;
|
||||
};
|
||||
@@ -132,6 +137,8 @@ class ScenData {
|
||||
line = "data." + line.substr(3);
|
||||
} else if (line.startsWith("cr_")) {
|
||||
line = "data." + line.substr(3);
|
||||
} else if (line.startsWith("it_")) {
|
||||
line = "data." + line.substr(3);
|
||||
} else if (line == "clear;") {
|
||||
line = "clear();";
|
||||
} else if (line.startsWith("import =")) {
|
||||
|
Reference in New Issue
Block a user