using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace mmoRLserver { public class Item { public int id = 0; public int amount = 1; public int x = 0; public int y = 0; public bool custom = false; public bool equipped = false; public string equipmentType = ""; public static int MAX_STACK = 250; public Item(int id, int x = 0, int y = 0) { this.id = id; this.x = x; this.y = y; Initialize(); } public void Initialize() { switch (id) { case 39: case 40: case 54: case 57: equipmentType = "weapon"; break; case 43: case 46: case 49: equipmentType = "armor"; break; case 44: case 47: case 50: equipmentType = "legs"; break; case 45: case 48: case 51: equipmentType = "head"; break; case 53: case 58: case 69: equipmentType = "feet"; break; } } public Item(byte[] serialized, int x = 0, int y = 0, bool custom = false) { this.x = x; this.y = y; if (serialized[0] != 0xFF || custom) { this.amount = serialized[0]; id = serialized[1] * 256 + serialized[2]; Initialize(); } else { //Custom item } } public byte[] Serialize() { byte[] toReturn = new byte[3]; toReturn[0] = (byte)this.amount; toReturn[1] = (byte)Math.Floor((float)id / 256f); toReturn[2] = (byte)(id - (toReturn[1] * 256)); return toReturn; } public void SetAmount(int newAmount) { this.amount = newAmount; if (this.amount > MAX_STACK) this.amount = MAX_STACK; } public void AddAmount(int toAdd) { this.SetAmount(this.amount + toAdd); } } }