コード例 #1
0
ファイル: Database.cs プロジェクト: Zemagaia/LoE-Realm-NC-2
        public bool SaveCharacter(DbAccount acc, DbChar character, bool lockAcc)
        {
            try
            {
                using (var trans = Connection.CreateTransaction())
                {
                    if (lockAcc)
                    {
                        trans.AddCondition(Condition.KeyEquals(1,
                                                               $"lock.{acc.AccountId}", acc.LockToken));
                    }
                    character.Flush(trans);
                    var stats = new DbClassStats(acc);
                    stats.Update(character);
                    stats.Flush(trans);
                    return(trans.Execute().Exec());
                }
            }
            catch { }

            return(false);
        }
コード例 #2
0
        public IEnumerable <Tuple <string, string, double> > GetBonuses(EmbeddedData data, DbChar character, bool firstBorn)
        {
            foreach (var i in bonusDat)
            {
                if (i.Item3(this, character, character.Fame))
                {
                    yield return(Tuple.Create(i.Item1, i.Item2, i.Item4(character.Fame)));
                }
            }

            //Well Equiped
            var bonus = character.Items.Take(4).Where(x => x != -1).Sum(x => data.Items[(ushort)x].FameBonus) / 100.0;

            if (bonus > 0)
            {
                yield return(Tuple.Create("Well Equipped", "Bonus for equipment", character.Fame * bonus));
            }

            //First born
            if (firstBorn)
            {
                yield return(Tuple.Create("First Born", "Best fame of any of your previous incarnations", character.Fame * 0.1));
            }
        }
コード例 #3
0
        public CreateStatus CreateCharacter(EmbeddedData dat, DbAccount acc, ushort type, int skin, out DbChar character)
        {
            var @class = dat.ObjectTypeToElement[type];

            if (Sets.GetLength(0, "alive." + acc.AccountId).Exec() >= acc.MaxCharSlot)
            {
                character = null;
                return(CreateStatus.ReachCharLimit);
            }

            int newId = (int)Hashes.Increment(0, acc.Key, "nextCharId").Exec();

            character = new DbChar(acc, newId)
            {
                ObjectType  = type,
                Level       = 1,
                Experience  = 0,
                Fame        = 0,
                HasBackpack = false,
                Items       = @class.Element("Equipment").Value.Replace("0xa22", "-1").CommaToArray <int>(),
                Stats       = new int[] {
                    int.Parse(@class.Element("MaxHitPoints").Value),
                    int.Parse(@class.Element("MaxMagicPoints").Value),
                    int.Parse(@class.Element("Attack").Value),
                    int.Parse(@class.Element("Defense").Value),
                    int.Parse(@class.Element("Speed").Value),
                    int.Parse(@class.Element("Dexterity").Value),
                    int.Parse(@class.Element("HpRegen").Value),
                    int.Parse(@class.Element("MpRegen").Value),
                },
                HP         = int.Parse(@class.Element("MaxHitPoints").Value),
                MP         = int.Parse(@class.Element("MaxMagicPoints").Value),
                Tex1       = 0,
                Tex2       = 0,
                Skin       = skin,
                Pet        = 0,
                FameStats  = new byte[0],
                TaskStats  = string.Empty,
                CreateTime = DateTime.Now,
                LastSeen   = DateTime.Now
            };
            character.Flush();
            Sets.Add(0, "alive." + acc.AccountId, BitConverter.GetBytes(newId));
            return(CreateStatus.OK);
        }
コード例 #4
0
 public bool IsAlive(DbChar character) => Sets.Contains(0, $"alive.{character.Account.AccountId}", BitConverter.GetBytes(character.CharId)).Exec();
コード例 #5
0
        public CreateStatus CreateCharacter(EmbeddedData dat, DbAccount acc, ushort type, int skin, out DbChar character)
        {
            var @class = dat.ObjectTypeToElement[type];

            if (_db.SetLength("alive." + acc.AccountId) >= acc.MaxCharSlot)
            {
                character = null;
                return(CreateStatus.ReachCharLimit);
            }

            var newId = (int)_db.HashIncrement(acc.Key, "nextCharId");

            character = new DbChar(acc, newId)
            {
                //LootCaches = new LootCache[] { },
                ObjectType      = type,
                Level           = 1,
                Experience      = 0,
                FakeExperience  = 0,
                IsFakeEnabled   = true,
                Bless1          = false,
                Bless2          = false,
                Bless3          = false,
                Bless4          = false,
                Bless5          = false,
                EnablePetAttack = true,
                Fame            = 0,
                HasBackpack     = false,
                Items           = @class.Element("Equipment").Value.Replace("0xa22", "-1").CommaToArray <int>(),
                Stats           = new int[] {
                    int.Parse(@class.Element("MaxHitPoints").Value),
                    int.Parse(@class.Element("MaxMagicPoints").Value),
                    int.Parse(@class.Element("Attack").Value),
                    int.Parse(@class.Element("Defense").Value),
                    int.Parse(@class.Element("Speed").Value),
                    int.Parse(@class.Element("Dexterity").Value),
                    int.Parse(@class.Element("HpRegen").Value),
                    int.Parse(@class.Element("MpRegen").Value),
                },
                HP         = int.Parse(@class.Element("MaxHitPoints").Value),
                MP         = int.Parse(@class.Element("MaxMagicPoints").Value),
                Tex1       = 0,
                Tex2       = 0,
                Skin       = skin,
                Pet        = 0,
                FameStats  = new byte[0],
                TaskStats  = string.Empty,
                CreateTime = DateTime.UtcNow,
                LastSeen   = DateTime.UtcNow
            };
            character.FlushAsync();
            _db.SetAdd("alive." + acc.AccountId, BitConverter.GetBytes(newId));
            return(CreateStatus.OK);
        }
コード例 #6
0
 public bool IsAlive(DbChar character) => _db.SetContains("alive." + character.Account.AccountId, BitConverter.GetBytes(character.CharId));
コード例 #7
0
ファイル: FameStats.cs プロジェクト: Zemagaia/LoE-Realm-NC-2
        public int CalculateTotalFame(EmbeddedData data, DbClassStats stats, DbChar chr, int baseFame, out bool firstBorn)
        {
            double bonus = 0;

            //Ancestor
            if (chr.CharId < 2)
            {
                bonus = Math.Floor(bonus) + ((baseFame + Math.Floor(bonus)) * 0.1) + 20;
            }

            //Pacifist
            if (ShotsThatDamage == 0)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25;
            }

            //Thirsty
            if (PotionsDrunk == 0)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25;
            }

            //Mundane
            if (SpecialAbilityUses == 0)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25;
            }

            //Boots on the Ground
            if (Teleports == 0)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25;
            }

            //Tunnel Rat
            if (PirateCavesCompleted > 0 && UndeadLairsCompleted > 0 && AbyssOfDemonsCompleted > 0 && SnakePitsCompleted > 0 && SpiderDensCompleted > 0 &&
                SpriteWorldsCompleted > 0 && TombsCompleted > 0 && TrenchesCompleted > 0 && JunglesCompleted > 0 && ManorsCompleted > 0)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Enemy of the Gods
            if ((double)GodKills / (GodKills + MonsterKills) > 0.1)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Slayer of the Gods
            if ((double)GodKills / (GodKills + MonsterKills) > 0.5)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Oryx Slayer
            if (OryxKills > 0)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Accurate
            if ((double)ShotsThatDamage / Shots > 0.25)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Sharpshooter
            if ((double)ShotsThatDamage / Shots > 0.5)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Sniper
            if ((double)ShotsThatDamage / Shots > 0.75)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Explorer
            if (TilesUncovered > 1000000)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05;
            }

            //Cartographer
            if (TilesUncovered > 4000000)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05;
            }

            //Team Player
            if (LevelUpAssists > 100)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Leader of Men
            if (LevelUpAssists > 1000)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Doer of Deeds
            if (QuestsCompleted > 1000)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            //Friend of the Cubes
            if (CubeKills == 0)
            {
                bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
            }

            double eq = 0;

            //Well Equipped
            for (int i = 0; i < 4; i++)
            {
                if (chr.Items[i] == -1)
                {
                    continue;
                }

                var b = data.Items[(ushort)chr.Items[i]].FameBonus;

                if (b > 0)
                {
                    eq += (baseFame + Math.Floor(bonus)) * b / 100;
                }
            }

            bonus = Math.Floor(bonus) + Math.Floor(eq);

            if (baseFame + Math.Floor(bonus) > stats.AllKeys.Select(x => stats[ushort.Parse(x)].BestFame).Max())
            {
                bonus     = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1;
                firstBorn = true;
            }
            else
            {
                firstBorn = false;
            }

            return((int)(baseFame + Math.Floor(bonus)));
        }