コード例 #1
0
ファイル: Database.cs プロジェクト: Zemagaia/LoE-Realm-NC-2
        public void Death(EmbeddedData dat, DbAccount acc, DbChar character, FameStats stats, string killer)
        {
            character.Dead = true;
            SaveCharacter(acc, character, acc.LockToken != null);
            var finalFame = stats.CalculateTotalFame(dat, new DbClassStats(acc), character, character.Fame, out bool firstBorn);
            var death     = new DbDeath(acc, character.CharId)
            {
                ObjectType = character.ObjectType,
                Level      = character.Level,
                TotalFame  = finalFame,
                Killer     = killer,
                FirstBorn  = firstBorn,
                DeathTime  = DateTime.Now
            };

            death.Flush();

            var idBuff = BitConverter.GetBytes(character.CharId);

            Connection.Sets.Remove(0, $"alive.{acc.AccountId}", idBuff);
            Connection.Lists.AddFirst(0, $"dead.{acc.AccountId}", idBuff);

            UpdateFame(acc, finalFame);

            var entry = new DbLegendEntry()
            {
                AccId     = int.Parse(acc.AccountId),
                ChrId     = character.CharId,
                TotalFame = finalFame
            };

            DbLegend.Insert(this, death.DeathTime, entry);
        }
コード例 #2
0
        public void Death(EmbeddedData dat, DbAccount acc, DbChar character, FameStats stats, string killer)
        {
            character.Dead = true;
            SaveCharacter(acc, character, acc.LockToken != null);
            var finalFame = stats.CalculateTotalFame(dat, new DbClassStats(acc), character, character.Fame, out bool firstBorn);
            var death     = new DbDeath(acc, character.CharId)
            {
                ObjectType = character.ObjectType,
                Level      = character.Level,
                TotalFame  = finalFame,
                Killer     = killer,
                FirstBorn  = firstBorn,
                DeathTime  = DateTime.UtcNow
            };

            death.FlushAsync();

            var idBuff = BitConverter.GetBytes(character.CharId);

            _db.SetRemoveAsync("alive." + acc.AccountId, idBuff, CommandFlags.FireAndForget);
            _db.ListLeftPushAsync("dead." + acc.AccountId, idBuff, When.Always, CommandFlags.FireAndForget);

            UpdateFame(acc, finalFame, true);

            if (acc.AccountType <= (int)AccountType.VIP)
            {
                DbLegend.Insert(_db, int.Parse(acc.AccountId), character.CharId, finalFame);
            }
        }