예제 #1
0
        public RegisterStatus Register(string uuid, string password, bool isGuest, out DbAccount acc)
        {
            acc = null;
            if (!Connection.Hashes.SetIfNotExists(0, "logins", uuid.ToUpperInvariant(), "{}").Exec())
            {
                return(RegisterStatus.UsedName);
            }

            int newAccId = (int)Connection.Strings.Increment(0, "nextAccId").Exec();

            acc = new DbAccount(this, newAccId.ToString())
            {
                AccountType       = (int)AccountType.FREE_ACCOUNT,
                AccountLifetime   = DateTime.MinValue,
                UUID              = uuid,
                Name              = Names[(uint)uuid.GetHashCode() % Names.Length],
                Admin             = false,
                NameChosen        = false,
                Verified          = Settings.STARTUP.VERIFIED,
                Converted         = false,
                GuildId           = "-1",
                GuildRank         = 0,
                GuildFame         = 0,
                VaultCount        = 1,
                MaxCharSlot       = Settings.STARTUP.MAX_CHAR_SLOTS,
                RegTime           = DateTime.Now,
                Guest             = isGuest,
                Fame              = Settings.STARTUP.FAME,
                TotalFame         = Settings.STARTUP.TOTAL_FAME,
                Credits           = Settings.STARTUP.GOLD,
                EmpiresCoin       = Settings.STARTUP.EMPIRES_COIN,
                FortuneTokens     = Settings.STARTUP.TOKENS,
                Gifts             = new int[] { },
                PetYardType       = 1,
                IsAgeVerified     = Settings.STARTUP.IS_AGE_VERIFIED,
                OwnedSkins        = new int[] { },
                PurchasedPackages = new int[] { },
                PurchasedBoxes    = new int[] { },
                AuthToken         = GenerateRandomString(128),
                Muted             = false,
                Banned            = false,
                Locked            = new int[] { 0 },
                Ignored           = new int[] { 0 }
            };
            acc.Flush();

            var login = new DbLoginInfo(this, uuid);

            var x = new byte[0x10];

            gen.GetNonZeroBytes(x);
            string salt = Convert.ToBase64String(x);
            string hash = Convert.ToBase64String(Utils.SHA1(password + salt));

            login.HashedPassword = hash;
            login.Salt           = salt;
            login.AccountId      = acc.AccountId;
            login.Flush();

            var stats = new DbClassStats(acc);

            stats.Flush();

            var vault = new DbVault(acc);

            vault[0] = Enumerable.Repeat(-1, 8).ToArray();
            vault.Flush();

            return(RegisterStatus.OK);
        }
예제 #2
0
        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)));
        }