private MateDb CreateNewMate(ulong itemId, string name) { if (_mates.ContainsKey(itemId)) { return(null); } var template = new MateDb { // TODO Id = MateIdManager.Instance.GetNextId(), ItemId = itemId, Level = 50, Name = name, Owner = Owner.Id, Mileage = 0, Xp = ExpirienceManager.Instance.GetExpForLevel(50, true), Hp = 999999, Mp = 999999, UpdatedAt = DateTime.Now, CreatedAt = DateTime.Now }; _mates.Add(template.ItemId, template); return(template); }
public void Load(MySqlConnection connection) { using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM mates WHERE `owner` = @owner"; command.Parameters.AddWithValue("@owner", Owner.Id); command.Prepare(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var template = new MateDb { Id = reader.GetUInt32("id"), ItemId = reader.GetUInt64("item_id"), Name = reader.GetString("name"), Xp = reader.GetInt32("xp"), Level = reader.GetUInt16("level"), Mileage = reader.GetInt32("mileage"), Hp = reader.GetInt32("hp"), Mp = reader.GetInt32("mp"), Owner = reader.GetUInt32("owner"), UpdatedAt = reader.GetDateTime("updated_at"), CreatedAt = reader.GetDateTime("created_at") }; _mates.Add(template.ItemId, template); } } } }