Example #1
0
 /// <summary>
 /// Возвращает данные игрока
 /// </summary>
 public PlayerInfo GetInfo(long accountId)
 {
     using (var db = new Database()) {
         var playerInfo     = db.PlayersInfo.First(e => e.AccountId == accountId);
         var additionalInfo = db.PlayersAdditionalInfo.First(e => e.AccountId == accountId);
         var driverInfo     = db.DriversInfo.First(e => e.AccountId == accountId);
         var worksInfo      = db.PlayerWorks.Where(e => e.AccountId == accountId).ToList();
         var wantedInfo     = db.Jail.First(e => e.AccountId == accountId);
         var settings       = db.Settings.First(e => e.AccountId == accountId);
         var clothes        = db.PlayerClothes.Where(e => e.AccountId == accountId).ToList();
         var result         = PlayerInfoConverter.ConvertToModel(playerInfo, additionalInfo, driverInfo, worksInfo, wantedInfo, settings, clothes);
         result.Inventory     = db.Inventory.Where(e => e.OwnerId == accountId).ToList();
         result.Clan          = db.PlayerClanInfos.FirstOrDefault(e => e.AccountId == accountId);
         result.PhoneContacts = db.PhoneContacts.Where(e => e.AccountId == accountId).ToList();
         result.PremiumEnd    = db.Accounts.First(e => e.Id == accountId).PremiumEnd;
         return(result);
     }
 }
Example #2
0
        /// <summary>
        /// Записать данные игрока
        /// todo: попробовать заюзать async
        /// </summary>
        public void SetInfo(PlayerInfo playerInfo)
        {
            var playerEntity     = PlayerInfoConverter.ConvertToEntity(playerInfo);
            var additionalEntity = PlayerInfoConverter.ConvertToAdditionalEntity(playerInfo);
            var driverInfo       = DriverInfoConverter.ConvertToEntity(playerInfo.AccountId, playerInfo.Driver);

            using (var db = new Database()) {
                db.Update(playerEntity);
                db.Update(additionalEntity);
                db.Update(driverInfo);
                db.Update(playerInfo.Wanted);
                db.Update(playerInfo.Settings);
                UpdateClanInfo(db, playerInfo.Clan);
                UpdateInventory(db, playerInfo);
                UpdateWorks(db, playerInfo);
                UpdateClothes(db, playerInfo);
                UpdatePhoneContacts(db, playerInfo);
            }
        }
        public void ConvertPlayerDetailTest()
        {
            var text = "0. id=171, Aona Suzutsuki, pos=(-157.3, 61.1, -115.8), rot=(0.0, 350.2, 0.0), remote=True, health=32, deaths=18, zombies=0, players=0" +
                       ", score=0, level=1, steamid=76561198010715714, ip=192.168.1.45, ping=2";
            var act = PlayerInfoConverter.ConvertPlayerDetail(text);
            var exp = new PlayerInfo
            {
                Id          = "171",
                Name        = "Aona Suzutsuki",
                Health      = "32",
                Deaths      = "18",
                ZombieKills = "0",
                PlayerKills = "0",
                Score       = "0",
                Level       = "1",
                SteamId     = "76561198010715714",
                Coord       = "(-157.3, 61.1, -115.8)",
            };

            Assert.AreEqual(exp, act);
        }
Example #4
0
        public void AddTest()
        {
            var text = "0. id=171, Aona Suzutsuki, pos=(-157.3, 61.1, -115.8), rot=(0.0, 350.2, 0.0), remote=True, health=32, deaths=18, zombies=0, players=0" +
                       ", score=0, level=1, steamid=76561198010715714, ip=192.168.1.45, ping=2";
            var text2 = "0. id=171, Aona Suzutsuki, pos=(-157.3, 61.1, -115.8), rot=(0.0, 350.2, 0.0), remote=True, health=32, deaths=18, zombies=0, players=0" +
                        ", score=0, level=1, steamid=76561198010715714, ip=192.168.1.45, ping=2";
            var exp = new List <PlayerInfo>
            {
                PlayerInfoConverter.ConvertPlayerDetail(text),
                PlayerInfoConverter.ConvertPlayerDetail(text2),
            };

            var act = new List <PlayerInfo>()
            {
                "0. id=171, Aona Suzutsuki, pos=(-157.3, 61.1, -115.8), rot=(0.0, 350.2, 0.0), remote=True, health=32, deaths=18, zombies=0, players=0" +
                ", score=0, level=1, steamid=76561198010715714, ip=192.168.1.45, ping=2\r\n" +
                "aaaaasacasfvafklasdxckjasc0a" +
                "0. id=171, Aona Suzutsuki, pos=(-157.3, 61.1, -115.8), rot=(0.0, 350.2, 0.0), remote=True, health=32, deaths=18, zombies=0, players=0" +
                ", score=0, level=1, steamid=76561198010715714, ip=192.168.1.45, ping=2"
            };

            CollectionAssert.AreEqual(exp, act);
        }