Esempio n. 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);
        }
Esempio n. 2
0
        public static void Insert(Database db, DateTime time, DbLegendEntry entry)
        {
            double t = time.ToUnixTimestamp();

            byte[] buff = new byte[12];
            Buffer.BlockCopy(BitConverter.GetBytes(entry.TotalFame), 0, buff, 0, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(entry.AccId), 0, buff, 4, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(entry.ChrId), 0, buff, 8, 4);
            db.Connection.SortedSets.Add(0, "legends", buff, t);
        }