namespace Holo.Managers { using Holo; using System; using System.Collections; using System.Runtime.InteropServices; using System.Text; public static class rankManager { private static gameRank[] gameRanksBB; private static gameRank[] gameRanksSS; private static Hashtable userRanks; public static bool containsRight(byte rankID, string fuseRight) { userRank rank = (userRank) userRanks[rankID]; for (int i = 0; i < rank.fuseRights.Length; i++) { if (rank.fuseRights[i] == fuseRight) { return true; } } return false; } public static string fuseRights(byte rankID) { string[] fuseRights = ((userRank) userRanks[rankID]).fuseRights; StringBuilder builder = new StringBuilder(); for (int i = 0; i < fuseRights.Length; i++) { builder.Append(fuseRights[i] + Convert.ToChar(2)); } return builder.ToString(); } public static gameRank getGameRank(bool isBattleBall, string Title) { gameRank[] gameRanksBB = null; if (isBattleBall) { gameRanksBB = rankManager.gameRanksBB; } else { gameRanksBB = gameRanksSS; } foreach (gameRank rank in gameRanksBB) { if (rank.Title == Title) { return rank; } } return new gameRank("holo.cast.gamerank.null", 0, 0); } public static string getGameRankTitle(bool isBattleBall, int Score) { gameRank[] gameRanksBB = null; if (isBattleBall) { gameRanksBB = rankManager.gameRanksBB; } else { gameRanksBB = gameRanksSS; } foreach (gameRank rank in gameRanksBB) { if ((Score >= rank.minPoints) && ((rank.maxPoints == 0) || (Score <= rank.maxPoints))) { return rank.Title; } } return "holo.cast.gamerank.null"; } public static void Init() { int num2; Out.WriteLine("Carico livelli utenti..."); userRanks = new Hashtable(); for (byte i = 1; i <= 7; i = (byte) (i + 1)) { userRanks.Add(i, new userRank(i)); } Out.WriteLine("Caricati per 7 livelli."); Out.WriteBlank(); Out.WriteLine("Carico i livelli su giochi..."); string[] strArray = DB.runReadColumn("SELECT title FROM games_ranks WHERE type = 'bb' ORDER BY id ASC", 0); int[] numArray = DB.runReadColumn("SELECT minpoints FROM games_ranks WHERE type = 'bb' ORDER BY id ASC", 0, null); int[] numArray2 = DB.runReadColumn("SELECT maxpoints FROM games_ranks WHERE type = 'bb' ORDER BY id ASC", 0, null); gameRanksBB = new gameRank[strArray.Length]; for (num2 = 0; num2 < gameRanksBB.Length; num2++) { gameRanksBB[num2] = new gameRank(strArray[num2], numArray[num2], numArray2[num2]); Out.WriteLine(string.Concat(new object[] { "Carico livello '", strArray[num2], "' [", numArray[num2], "-", numArray2[num2], "] per 'BattleBall'." })); } Out.WriteLine("Caricati " + strArray.Length + " livelli per 'BattleBall'."); strArray = DB.runReadColumn("SELECT title FROM games_ranks WHERE type = 'ss' ORDER BY id ASC", 0); numArray = DB.runReadColumn("SELECT minpoints FROM games_ranks WHERE type = 'ss' ORDER BY id ASC", 0, null); numArray2 = DB.runReadColumn("SELECT maxpoints FROM games_ranks WHERE type = 'ss' ORDER BY id ASC", 0, null); gameRanksSS = new gameRank[strArray.Length]; for (num2 = 0; num2 < gameRanksSS.Length; num2++) { gameRanksSS[num2] = new gameRank(strArray[num2], numArray[num2], numArray2[num2]); Out.WriteLine(string.Concat(new object[] { "Carico livello '", strArray[num2], "' [", numArray[num2], "-", numArray2[num2], "] per 'SnowStorm'." })); } Out.WriteLine("Caricati " + strArray.Length + " livelli per 'SnowStorm'."); } [StructLayout(LayoutKind.Sequential)] public struct gameRank { internal int minPoints; internal int maxPoints; internal string Title; internal gameRank(string Title, int minPoints, int maxPoints) { this.Title = Title; this.minPoints = minPoints; this.maxPoints = maxPoints; } } [StructLayout(LayoutKind.Sequential)] private struct userRank { internal string[] fuseRights; internal userRank(byte rankID) { this.fuseRights = DB.runReadColumn("SELECT fuseright FROM system_fuserights WHERE minrank <= " + rankID, 0); } } } }