public static bool giveUser(ref DataContainer cont, long I_Id) { UnreadableSQLExecuter exec = new UnreadableSQLExecuter(); exec.query = "update `BelongsTo` set Amount=Amount+1 where I_Id=? and C_Id=?"; exec.add_parameter(I_Id); exec.add_parameter(cont.c_data.C_Id); exec.execute_query(); if (exec.error) { Console.WriteLine(exec.error_string); return false; } if (exec.rows_affected == 0) { exec = new UnreadableSQLExecuter(); exec.query = "insert into `BelongsTo` (I_Id,C_Id,Amount,Equipped) values (?,?,1,0)"; exec.add_parameter(I_Id); exec.add_parameter(cont.c_data.C_Id); exec.execute_query(); if (exec.error) { Console.WriteLine(exec.error_string); return false; } } cont.c_data.calculateItemStats(); return true; }
public static Monster getMonsterByName(ref DataContainer cont, string monstername) { Monster to_return; ReadableSQLExecuter exec = new ReadableSQLExecuter(); // load monster attributes exec.query = "select `Monster`.M_Id from Monster, MonsterIsIn as MIIn where `Monster`.M_Id=MIIn.M_Id and MIIn.RespawnAtTime < NOW() and MIIn.R_Id=? and `Monster`.Name=?"; exec.add_parameter(cont.r_data.R_Id); exec.add_parameter(monstername); exec.execute_query(); if (exec.error) { Console.WriteLine(exec.error_string); return null; } if (!exec.HasRows) // no monster with this name { Console.WriteLine("No monster " + monstername); return null; } long M_Id = Convert.ToInt64(exec.result[0][0]); to_return = new Monster(ref cont, M_Id); return to_return; }
public CharacterData(ref DataContainer cont,long CharacterId) { this.container = cont; this.C_Id = CharacterId; loadAttributes(); calculateBuffs(); calculateItemStats(); Console.WriteLine(C_Id); }
public GameLoopDialogue(UserDialogue.WriteMethod write,long C_Id) { this.write = write; this.C_Id = C_Id; container = new DataContainer(); container.c_data = new CharacterData(ref container, C_Id); container.r_data = new Room(ref container); c_engine = new CommandEngine(write, container); writeStartMessage(); }
public static GameObject getObjectByName(ref DataContainer cont, string objectName) { ReadableSQLExecuter sql = new ReadableSQLExecuter(); sql.query = "select `Objekt`.O_Id from `Objekt`,`ObjInRoom` where `Objekt`.O_Id=`ObjInRoom`.O_Id and `ObjInRoom`.R_Id=? and `Objekt`.O_Id not in (select O_Id from `Takeable` where R_Id=? and not Takefrom='') and `Objekt`.Name=?"; sql.add_parameter(cont.r_data.R_Id); sql.add_parameter(cont.r_data.R_Id); sql.add_parameter(objectName); sql.execute_query(); if (sql.error) { Console.WriteLine(sql.error_string); return null; } if (!sql.HasRows) { return null; } return new GameObject(ref cont,Convert.ToInt64(sql.result[0][0])); }
public static TakeableGameObject getObjectByName(ref DataContainer cont, string objectName,string object_in) { ReadableSQLExecuter sql = new ReadableSQLExecuter(); sql.query = "select O_Id from `Objekt` where `Objekt`.O_Id in (select O_Id from `Takeable` where R_Id=? and Takefrom=? and RespawnAtTime<NOW()) and `Objekt`.Name=?"; sql.add_parameter(cont.r_data.R_Id); sql.add_parameter(object_in); sql.add_parameter(objectName); sql.execute_query(); if (sql.error) { Console.WriteLine(sql.error_string); return null; } if (!sql.HasRows) { return null; } return new TakeableGameObject(ref cont, Convert.ToInt64(sql.result[0][0])); }
public static Item getItemByName(ref DataContainer cont, string name) { ReadableSQLExecuter exec = new ReadableSQLExecuter(); exec.query = "select `Item`.I_Id from `Item`,`BelongsTo` where `Item`.I_Id=`BelongsTo`.I_Id and `BelongsTo`.C_Id=? and `Item`.Name=?"; exec.add_parameter(cont.c_data.C_Id); exec.add_parameter(name); exec.execute_query(); if (exec.error) { Console.WriteLine(exec.error_string); return null; } if (!exec.HasRows) { return null; } return new Item(ref cont, Convert.ToInt64(exec.result[0][0])); }
public static List<Monster> loadMonsters(ref DataContainer cont) { List<Monster> monsters = new List<Monster>(); ReadableSQLExecuter exec = new ReadableSQLExecuter(); exec.query = "select M_Id from MonsterIsIn where RespawnAtTime<NOW() and R_Id=?"; exec.add_parameter(cont.r_data.R_Id); exec.execute_query(); if (exec.error) { Console.WriteLine(exec.error_string); return null; } if (!exec.HasRows) { return null; } foreach (object[] tmp in exec.result) { long id = Convert.ToInt64(tmp[0]); monsters.Add(new Monster(ref cont, id)); } return monsters; }
public static List<Item> loadItems(ref DataContainer cont) { List<Item> items = new List<Item>(); ReadableSQLExecuter exec = new ReadableSQLExecuter(); exec.query = "select I_Id from BelongsTo where C_Id=?"; exec.add_parameter(cont.c_data.C_Id); exec.execute_query(); if (exec.error) { Console.WriteLine(exec.error_string); return null; } if (!exec.HasRows) { return null; } foreach (object[] tmp in exec.result) { long id = Convert.ToInt64(tmp[0]); items.Add(new Item(ref cont, id)); } return items; }
public Benutzen(UserDialogue.WriteMethod write ,DataContainer cont) { this.write = write; this.container = cont; }
public Statistiken(UserDialogue.WriteMethod write, DataContainer cont) { this.write = write; this.container = cont; }
public Room(ref DataContainer cont) { this.container = cont; loadAttributes(); }
public GameObject(ref DataContainer cont,long objectId) { this.O_Id = objectId; this.container = cont; loadAttributes(); }
public Monster(ref DataContainer cont, long M_Id) { this.container = cont; this.M_Id = M_Id; loadAttributes(); }
public static TakeableGameObject getObjectByName(ref DataContainer cont, string objectName) { return getObjectByName(ref cont, objectName, ""); }
public Item(ref DataContainer cont, long I_Id) { this.container = cont; this.I_Id = I_Id; loadAttributes(); }