// Get guild public static Coroutine GetGuild(string guildId, GameDB.ActionOnResult <Guild> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <Guild>( "Guilds", guildId, func ))); }
// Get experience public static Coroutine GetExperience(string accountId, GameDB.ActionOnResult <ExperienceEntry> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <ExperienceEntry>( "AccountToExperience", accountId, func ))); }
// Get character stats public static Coroutine GetCharacterStats(string accountId, GameDB.ActionOnResult <CharacterStats> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <CharacterStats>( "AccountToCharacterStats", accountId, func ))); }
// Get friends public static Coroutine GetFriends(string accountId, GameDB.ActionOnResult <FriendsList> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <FriendsList>( "AccountToFriends", accountId, func ))); }
// Get payments list public static Coroutine GetPaymentsList(string accountId, GameDB.ActionOnResult <PaymentsList> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <PaymentsList>( "AccountToPayments", accountId, func ))); }
// Remove position public static Coroutine RemovePosition(string accountId, GameDB.ActionOnResult <bool> func = null) { return(GameDB.instance.StartCoroutine(GameDB.Remove( "AccountToPosition", accountId, func ))); }
// Get guild invitations public static Coroutine GetGuildInvitations(string accountId, GameDB.ActionOnResult <List <string> > func) { return(GameDB.instance.StartCoroutine(GameDB.Get <List <string> >( "AccountToGuildInvitations", accountId, func ))); }
// -------------------------------------------------------------------------------- // AccountToSkillBuild // -------------------------------------------------------------------------------- // Get skill build public static void GetSkillBuild(string accountId, GameDB.ActionOnResult <SkillBuild> func) { GameDB.instance.StartCoroutine(GameDB.Get <SkillBuild>( "AccountToSkillBuild", accountId, func )); }
// Is the account in the activation wait list? public static Coroutine GetAccountAwaitingActivation(string email, GameDB.ActionOnResult <string> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <string>( "AccountsAwaitingActivation", email, func ))); }
// Get accounts public static Coroutine GetAccounts(string ip, GameDB.ActionOnResult <string[]> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <string[]>( "IPToAccounts", ip, func ))); }
// Get location public static Coroutine GetLocation(string accountId, GameDB.ActionOnResult <PlayerLocation> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <PlayerLocation>( "AccountToLocation", accountId, func ))); }
// Get country public static Coroutine GetCountry(string accountId, GameDB.ActionOnResult <string> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <string>( "AccountToCountry", accountId, func ))); }
// Get portal public static Coroutine GetPortal(string accountId, GameDB.ActionOnResult <PortalInfo> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <PortalInfo>( "AccountToPortal", accountId, func ))); }
// -------------------------------------------------------------------------------- // AccountToItemInventory // -------------------------------------------------------------------------------- // Get item inventory public static Coroutine GetItemInventory(string accountId, GameDB.ActionOnResult <ItemInventory> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <ItemInventory>( "AccountToItemInventory", accountId, func ))); }
// -------------------------------------------------------------------------------- // AccountToArtifactTree // -------------------------------------------------------------------------------- // Get artifact tree public static Coroutine GetArtifactTree(string accountId, GameDB.ActionOnResult <ArtifactTree> func) { return(GameDB.instance.StartCoroutine(GameDB.Get <ArtifactTree>( "AccountToArtifactTree", accountId, func ))); }
// -------------------------------------------------------------------------------- // AccountToEmail // -------------------------------------------------------------------------------- // Set email public static Coroutine SetEmail(string accountId, string email, GameDB.ActionOnResult <string> func) { return(GameDB.instance.StartCoroutine(GameDB.Set <string>( "AccountToEmail", accountId, email, func ))); }
// -------------------------------------------------------------------------------- // AccountToPosition // -------------------------------------------------------------------------------- // Set position public static Coroutine SetPosition(string accountId, PlayerPosition position, GameDB.ActionOnResult <PlayerPosition> func = null) { return(GameDB.instance.StartCoroutine(GameDB.Set <PlayerPosition>( "AccountToPosition", accountId, position, func ))); }
// Set experience public static Coroutine SetExperience(string accountId, uint exp, GameDB.ActionOnResult <ExperienceEntry> func = null) { return(GameDB.instance.StartCoroutine(GameDB.Set <ExperienceEntry>( "AccountToExperience", accountId, new ExperienceEntry(exp), func ))); }
// Set guild list public static Coroutine SetGuildList(string accountId, GuildList guildIdList, GameDB.ActionOnResult <GuildList> func = null) { return(GameDB.instance.StartCoroutine(GameDB.Set <GuildList>( "AccountToGuilds", accountId, guildIdList, func ))); }
// Get last registrations public static Coroutine GetLastRegistrations(uint numPlayers, GameDB.ActionOnResult <KeyValue <TimeStamp>[]> func) { return(GameDB.instance.StartCoroutine(GameDB.MapReduce <KeyValue <TimeStamp> >( "AccountToRegistrationDate", GameDB.keyValueMapFunction, timeStampReduceFunction, numPlayers, func ))); }
// -------------------------------------------------------------------------------- // AccountsAwaitingActivation // -------------------------------------------------------------------------------- // Adds an account to the activation waiting list public static Coroutine PutAccountAwaitingActivation(string email, GameDB.ActionOnResult <string> func) { var token = GameDB.GetUniqueKey(); return(GameDB.instance.StartCoroutine(GameDB.Set <string>( "AccountsAwaitingActivation", email, token, func ))); }
// GetCountryByIPEnumerator public static IEnumerator GetCountryByIPEnumerator(string ip, GameDB.ActionOnResult <string> func) { var request = new WWW(IPInfoServer.instance.scriptURL + IPInfoServer.instance.scriptParamaterPrefix + ip); yield return(request); if (request.error == null) { func(request.text); } else { func(default(string)); } }
// -------------------------------------------------------------------------------- // MapReduce // -------------------------------------------------------------------------------- // Get guild ID by guild name public static Coroutine GetGuildIdByGuildName(string guildName, GameDB.ActionOnResult <string> func) { return(GameDB.instance.StartCoroutine(GameDB.MapReduce <KeyValue <string> >( "Guilds", GameDB.GetSearchMapFunction("name"), GameDB.GetSearchReduceFunction(), guildName, data => { if (data != null && data.Length == 1) { func(data[0].key); } else { func(default(string)); } } ))); }
// Get account ID by Email public static Coroutine GetAccountIdByEmail(string email, GameDB.ActionOnResult <string> func) { return(GameDB.instance.StartCoroutine(GameDB.MapReduce <KeyValue <string> >( "AccountToEmail", GameDB.GetSearchMapFunction("v"), GameDB.GetSearchReduceFunction(), email, data => { if (data != null && data.Length == 1) { func(data[0].key); } else { func(default(string)); } } ))); }
// Get top ranks public static IEnumerator GetTopRanks(byte subject, byte page, uint maxPlayerCount, GameDB.ActionOnResult <RankEntry[]> func = null) { // TODO: Use GameDB.MapReduce // Retrieve the highscore list from the database by using MapReduce. The MapReduce request consists of a // map phase and a reduce phase. The phases are expressed as JavaScript code in string form. The reduce // phase also gets the maximum number of scores to fetch as an argument. var bucket = new Bucket("AccountToStats"); var getHighscoresRequest = bucket.MapReduce( new JavaScriptMapPhase(GetHighscoresMapFunction(page)), new JavaScriptReducePhase(highscoresReduceFunction, maxPlayerCount) ); // Wait until the request finishes and then update the local list of highscore entries. yield return(getHighscoresRequest.WaitUntilDone()); if (getHighscoresRequest.isSuccessful) { IEnumerable <RankEntry> rankingEntriesTmp = getHighscoresRequest.GetResult <RankEntry>(); var rankingEntries = rankingEntriesTmp.ToArray(); // Get player names // TODO: Send X requests at once, then wait for all of them var nameBucket = new Bucket("AccountToName"); var countryBucket = new Bucket("AccountToCountry"); var nameRequests = new GetRequest[rankingEntries.Length]; var countryRequests = new GetRequest[rankingEntries.Length]; for (int i = 0; i < rankingEntries.Length; i++) { var entry = rankingEntries[i]; entry.rankIndex = i; // Name string name; if (GameDB.accountIdToName.TryGetValue(entry.accountId, out name)) { entry.name = name; nameRequests[i] = null; } else { nameRequests[i] = nameBucket.Get(entry.accountId); } // Country string country; if (IPInfoServer.accountIdToCountry.TryGetValue(entry.accountId, out country)) { entry.country = country; countryRequests[i] = null; } else { countryRequests[i] = countryBucket.Get(entry.accountId); } } for (int i = 0; i < rankingEntries.Length; i++) { // Name var nameRequest = nameRequests[i]; if (nameRequest != null) { yield return(nameRequest.WaitUntilDone()); if (nameRequest.isSuccessful) { var entry = rankingEntries[i]; entry.name = nameRequest.GetValue <string>(); GameDB.accountIdToName[entry.accountId] = entry.name; } } // Country var countryRequest = countryRequests[i]; if (countryRequest != null) { yield return(countryRequest.WaitUntilDone()); var entry = rankingEntries[i]; if (countryRequest.isSuccessful) { entry.country = countryRequest.GetValue <string>(); IPInfoServer.accountIdToCountry[entry.accountId] = entry.country; } else { entry.country = ""; IPInfoServer.accountIdToCountry[entry.accountId] = ""; } } } // Save in cache GameDB.rankingLists[subject][page] = rankingEntries; //LogManager.General.Log("Sending the ranking list " + rankingEntries + " with " + rankingEntries.Length + " / " + maxPlayerCount + " entries (" + subject + ", " + page + ")"); if (func != null) { func(rankingEntries); } } else { LogManager.General.LogError("Failed getting the ranking list: " + getHighscoresRequest.GetErrorString()); if (func != null) { func(null); } } }
// Set character customization public static void SetCharacterCustomization(string accountId, CharacterCustomization custom, GameDB.ActionOnResult <CharacterCustomization> func = null) { GameDB.instance.StartCoroutine(GameDB.Set <CharacterCustomization>( "AccountToCharacterCustomization", accountId, custom, func )); }
// GetCountryByIP public static Coroutine GetCountryByIP(string ip, GameDB.ActionOnResult <string> func) { return(IPInfoServer.instance.StartCoroutine( IPInfoServer.GetCountryByIPEnumerator(ip, func) )); }