using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; namespace Chop.Game.Catalogue { public class ItemTemplate { #region Fields private int mID; private string mSprite; private string mType; private byte mTypeID; private int mLength; private int mWidth; private double mTop; private string mColour; private int mRevision; private bool mTradeable; private bool mRecycleable; private bool mDoor; private bool mSoundMachine; private bool mJukebox; public string[] posterString; #endregion #region Properties public int ID { get { return mID; } } public string Sprite { get { return mSprite; } } public string Type { get { return mType; } } public byte TypeID { get { return mTypeID; } } public int Length { get { return mLength; } } public int Width { get { return mWidth; } } public double Top { get { return mTop; } } public string Colour { get { return mColour; } } public int Revision { get { return mRevision; } } public bool Tradeable { get { return mTradeable; } } public bool Recycleable { get { return mRecycleable; } } public bool Door { get { return mDoor; } } public bool SoundMachine { get { return mSoundMachine; } } public bool Jukebox { get { return mJukebox; } } #endregion #region Methods public static ItemTemplate Parse(DataRow row) { ItemTemplate item = new ItemTemplate { mID = Convert.ToInt32(row["id"]), mSprite = row["sprite"].ToString(), mType = row["type"].ToString(), mTypeID = Convert.ToByte(row["typeid"]), mLength = Convert.ToInt32(row["length"]), mWidth = Convert.ToInt32(row["width"]), mTop = Convert.ToDouble(row["top"]), mColour = row["colour"].ToString(), mRevision = Convert.ToInt32(row["revision"]), mTradeable = (row["tradeable"].ToString() == "1"), mRecycleable = (row["recycleable"].ToString() == "1"), mDoor = (row["door"].ToString() == "1") }; item.mSoundMachine = item.mSprite.StartsWith("sound_machine"); item.mJukebox = item.mSprite.StartsWith("jukebox"); if (item.mSprite.Contains(" ")) { item.posterString = new string[2]; item.posterString[0] = item.mSprite.Split(' ')[0]; item.posterString[1] = item.mSprite.Split(' ')[1]; } return item; } #endregion } }