using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace TheSlimesJourney { public class Item { public string name = "Unknown item"; public int experience = 0; public bool equipped = false; public string[] combatUseScript = null; public string[] useScript = null; public string[] equipScript = null; public string[] unequipScript = null; public Item(string filename) { StreamReader sr = new StreamReader("items/" + filename + ".sji"); while (!sr.EndOfStream) { string currentLine = Utils.Filter(sr.ReadLine()); switch (currentLine) { case "item": sr.ReadLine(); //Skip the { while (currentLine != "}") { currentLine = Utils.Filter(sr.ReadLine()); string[] split = currentLine.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); if (split.Length > 0) { string baseCommand = split[0]; string argument = Utils.RBQ(currentLine); switch (baseCommand) { case "name": this.name = argument; break; case "experience": this.experience = Convert.ToInt32(argument); break; case "use": this.useScript = Utils.ReadScope(sr); break; case "combatuse": this.combatUseScript = Utils.ReadScope(sr); break; case "equip": this.equipScript = Utils.ReadScope(sr); break; case "unequip": this.unequipScript = Utils.ReadScope(sr); break; } } } break; } } } public string GetName() { if (equipped) return name + " (equipped)"; else return name; } } }