public void UpdateEnergy(string userId, int energy) { var user = _db.Users.Single(usr => usr.Id == userId); user.Energy = energy; _db.SaveChanges(); }
public void SpawnMonster(Monster monster, string channel) { _db.SpawnedMonsters.Add(new SpawnedMonster { Health = monster.MaxHealth, MonsterId = monster.Id, Channel = channel }); _db.SaveChanges(); }
public void AddTaxesToRuler(int amount) { var ruler = GetRuler(); ruler.Credits += amount; _db.SaveChanges(); }
public void AddCredits(string userId, int amount) { var user = _db.Users.Single(usr => usr.Id == userId); user.Credits += amount; _db.SaveChanges(); }
public List <EquipmentItem> EquipItem(User user, EquipmentItem item) { var equipment = user.Equip(item); _db.SaveChanges(); return(equipment); }
public void RemoveGambleChallenge(string target) { var challenge = _db.GambleChallenges.SingleOrDefault(cha => cha.TargetId == target); if (challenge != null) { _db.GambleChallenges.Remove(challenge); _db.SaveChanges(); } }
public void AddToRoster(string userId) { if (!_db.Roster.Any(user => user.Id == userId)) { _db.Roster.Add(new Roster() { Id = userId }); _db.SaveChanges(); } }
public Party CreateParty(User host) { var party = new Party { UserId = host.Id, Users = new List <User> { host } }; _db.Parties.Add(party); _db.SaveChanges(); return(party); }
public void AddUser(string userId) { if (!_db.Users.Any(user => user.Id == userId)) { var user = new User() { Id = userId, Credits = 10 }; _db.Users.Add(user); _db.SaveChanges(); } }
public void Migrate(DougContext db) { var lines = File.ReadLines("droptables.csv").ToList(); lines.RemoveAt(0); foreach (var line in lines) { var values = Split(line); var existingTable = db.Droptables.Include(t => t.Items).SingleOrDefault(table => table.Id == values[0]); if (existingTable != null) { if (existingTable.Items.Any(itm => itm.Id == values[1])) { continue; } existingTable.Items.Add(new LootItem(values[1], int.Parse(values[2]), double.Parse(values[3]))); } else { var droptable = new DropTable() { Id = values[0] }; droptable.Items.Add(new LootItem(values[1], int.Parse(values[2]), double.Parse(values[3]))); db.Droptables.Add(droptable); } db.SaveChanges(); } }
public void AddEffect(User user, string effectId, int durationMinutes) { var effect = _db.UserEffect.SingleOrDefault(eff => eff.UserId == user.Id && eff.EffectId == effectId); if (effect != null) { _db.UserEffect.Remove(effect); } user.Effects.Add(new UserEffect { EffectId = effectId, UserId = user.Id, Effect = new UnknownEffect(), EndTime = DateTime.UtcNow.AddMinutes(durationMinutes) }); _db.SaveChanges(); }
public void EquipItem(string userId, EquipmentItem item) { var user = _db.Users .Include(usr => usr.Loadout) .Single(usr => usr.Id == userId); user.LoadItems(_itemFactory); user.Loadout.Equip(item); _db.SaveChanges(); }
public void Migrate(DougContext db) { var lines = File.ReadLines("items.csv").ToList(); lines.RemoveAt(0); var items = lines.Select(CreateEntity); foreach (var item in items) { if (!db.Items.Any(itm => itm.Id == item.Id)) { db.Items.Add(item); } } db.SaveChanges(); }
public void Migrate(DougContext db) { var lines = File.ReadLines("monsters.csv").Where(line => line[0] != ',').ToList(); lines.RemoveAt(0); var items = lines.Select(CreateEntity); foreach (var item in items) { if (!db.Monsters.Any(itm => itm.Id == item.Id)) { db.Monsters.Add(item); } else { db.Entry(db.Monsters.Find(item.Id)).CurrentValues.SetValues(item); } } db.SaveChanges(); }
public void Migrate(DougContext db, string path) { var lines = File.ReadLines(path).ToList(); lines.RemoveAt(0); var items = lines.Select(CreateEntity); foreach (var item in items) { if (!db.Items.Any(itm => itm.Id == item.Id)) { db.Items.Add(item); } else { db.Entry(db.Items.Find(item.Id)).CurrentValues.SetValues(item); } } db.SaveChanges(); }
public void Migrate(DougContext db) { var lines = File.ReadLines("shops.csv").ToList(); lines.RemoveAt(0); var items = lines.Select(CreateEntity).ToList(); var shops = db.Shops.Include(shp => shp.ShopItems).ToList(); foreach (var shop in shops) { var shopItems = items.Where(itm => itm.ShopId == shop.Id).ToList(); if (!shopItems.Any()) { continue; } shop.ShopItems = shopItems; } db.SaveChanges(); }
public void ClearRecentSlurs() { _db.RecentSlurs.RemoveRange(_db.RecentSlurs); _db.SaveChanges(); }
public void AddItem(User user, Item item) { AddItemToUser(user, item); _db.SaveChanges(); }
public void AddItem(User user, string itemId) { AddItemToUser(user, itemId); _db.SaveChanges(); }