예제 #1
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.CalculateTotal(dat, character, new DbClassStats(acc), 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);

            Sets.Remove(0, $"alive.{acc.AccountId}", idBuff);
            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);
            }
        }