示例#1
0
        public void UpdateEnergy(string userId, int energy)
        {
            var user = _db.Users.Single(usr => usr.Id == userId);

            user.Energy = energy;
            _db.SaveChanges();
        }
示例#2
0
 public void SpawnMonster(Monster monster, string channel)
 {
     _db.SpawnedMonsters.Add(new SpawnedMonster {
         Health = monster.MaxHealth, MonsterId = monster.Id, Channel = channel
     });
     _db.SaveChanges();
 }
示例#3
0
        public void AddTaxesToRuler(int amount)
        {
            var ruler = GetRuler();

            ruler.Credits += amount;
            _db.SaveChanges();
        }
示例#4
0
        public void AddCredits(string userId, int amount)
        {
            var user = _db.Users.Single(usr => usr.Id == userId);

            user.Credits += amount;

            _db.SaveChanges();
        }
示例#5
0
        public List <EquipmentItem> EquipItem(User user, EquipmentItem item)
        {
            var equipment = user.Equip(item);

            _db.SaveChanges();

            return(equipment);
        }
示例#6
0
        public void RemoveGambleChallenge(string target)
        {
            var challenge = _db.GambleChallenges.SingleOrDefault(cha => cha.TargetId == target);

            if (challenge != null)
            {
                _db.GambleChallenges.Remove(challenge);
                _db.SaveChanges();
            }
        }
示例#7
0
 public void AddToRoster(string userId)
 {
     if (!_db.Roster.Any(user => user.Id == userId))
     {
         _db.Roster.Add(new Roster()
         {
             Id = userId
         });
         _db.SaveChanges();
     }
 }
示例#8
0
        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);
        }
示例#9
0
        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();
            }
        }
示例#10
0
        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();
            }
        }
示例#11
0
        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();
        }
示例#12
0
        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();
        }
示例#13
0
        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();
        }
示例#14
0
        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();
        }
示例#15
0
        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();
        }
示例#16
0
        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();
        }
示例#17
0
 public void ClearRecentSlurs()
 {
     _db.RecentSlurs.RemoveRange(_db.RecentSlurs);
     _db.SaveChanges();
 }
示例#18
0
        public void AddItem(User user, Item item)
        {
            AddItemToUser(user, item);

            _db.SaveChanges();
        }
示例#19
0
        public void AddItem(User user, string itemId)
        {
            AddItemToUser(user, itemId);

            _db.SaveChanges();
        }