예제 #1
0
 // Get guild
 public static Coroutine GetGuild(string guildId, GameDB.ActionOnResult <Guild> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <Guild>(
                                               "Guilds",
                                               guildId,
                                               func
                                               )));
 }
예제 #2
0
 // Get experience
 public static Coroutine GetExperience(string accountId, GameDB.ActionOnResult <ExperienceEntry> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <ExperienceEntry>(
                                               "AccountToExperience",
                                               accountId,
                                               func
                                               )));
 }
예제 #3
0
 // Get character stats
 public static Coroutine GetCharacterStats(string accountId, GameDB.ActionOnResult <CharacterStats> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <CharacterStats>(
                                               "AccountToCharacterStats",
                                               accountId,
                                               func
                                               )));
 }
예제 #4
0
 // Get friends
 public static Coroutine GetFriends(string accountId, GameDB.ActionOnResult <FriendsList> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <FriendsList>(
                                               "AccountToFriends",
                                               accountId,
                                               func
                                               )));
 }
예제 #5
0
 // Get payments list
 public static Coroutine GetPaymentsList(string accountId, GameDB.ActionOnResult <PaymentsList> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <PaymentsList>(
                                               "AccountToPayments",
                                               accountId,
                                               func
                                               )));
 }
예제 #6
0
 // Remove position
 public static Coroutine RemovePosition(string accountId, GameDB.ActionOnResult <bool> func = null)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Remove(
                                               "AccountToPosition",
                                               accountId,
                                               func
                                               )));
 }
예제 #7
0
 // 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
                                               )));
 }
예제 #8
0
    // --------------------------------------------------------------------------------
    // AccountToSkillBuild
    // --------------------------------------------------------------------------------

    // Get skill build
    public static void GetSkillBuild(string accountId, GameDB.ActionOnResult <SkillBuild> func)
    {
        GameDB.instance.StartCoroutine(GameDB.Get <SkillBuild>(
                                           "AccountToSkillBuild",
                                           accountId,
                                           func
                                           ));
    }
예제 #9
0
 // 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
                                               )));
 }
예제 #10
0
 // Get accounts
 public static Coroutine GetAccounts(string ip, GameDB.ActionOnResult <string[]> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <string[]>(
                                               "IPToAccounts",
                                               ip,
                                               func
                                               )));
 }
예제 #11
0
 // Get location
 public static Coroutine GetLocation(string accountId, GameDB.ActionOnResult <PlayerLocation> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <PlayerLocation>(
                                               "AccountToLocation",
                                               accountId,
                                               func
                                               )));
 }
예제 #12
0
 // Get country
 public static Coroutine GetCountry(string accountId, GameDB.ActionOnResult <string> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <string>(
                                               "AccountToCountry",
                                               accountId,
                                               func
                                               )));
 }
예제 #13
0
 // Get portal
 public static Coroutine GetPortal(string accountId, GameDB.ActionOnResult <PortalInfo> func)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Get <PortalInfo>(
                                               "AccountToPortal",
                                               accountId,
                                               func
                                               )));
 }
예제 #14
0
    // --------------------------------------------------------------------------------
    // AccountToItemInventory
    // --------------------------------------------------------------------------------

    // Get item inventory
    public static Coroutine GetItemInventory(string accountId, GameDB.ActionOnResult <ItemInventory> func)
    {
        return(GameDB.instance.StartCoroutine(GameDB.Get <ItemInventory>(
                                                  "AccountToItemInventory",
                                                  accountId,
                                                  func
                                                  )));
    }
예제 #15
0
    // --------------------------------------------------------------------------------
    // AccountToArtifactTree
    // --------------------------------------------------------------------------------

    // Get artifact tree
    public static Coroutine GetArtifactTree(string accountId, GameDB.ActionOnResult <ArtifactTree> func)
    {
        return(GameDB.instance.StartCoroutine(GameDB.Get <ArtifactTree>(
                                                  "AccountToArtifactTree",
                                                  accountId,
                                                  func
                                                  )));
    }
예제 #16
0
    // --------------------------------------------------------------------------------
    // 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
                                                  )));
    }
예제 #17
0
    // --------------------------------------------------------------------------------
    // 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
                                                  )));
    }
예제 #18
0
 // 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
                                               )));
 }
예제 #19
0
 // 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
                                               )));
 }
예제 #20
0
 // 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
                                               )));
 }
예제 #21
0
    // --------------------------------------------------------------------------------
    // 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
                                                  )));
    }
예제 #22
0
    // 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));
        }
    }
예제 #23
0
    // --------------------------------------------------------------------------------
    // 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));
            }
        }
                                                  )));
    }
예제 #24
0
 // 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));
         }
     }
                                               )));
 }
예제 #25
0
    // 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
                                        ));
 }
예제 #27
0
 // GetCountryByIP
 public static Coroutine GetCountryByIP(string ip, GameDB.ActionOnResult <string> func)
 {
     return(IPInfoServer.instance.StartCoroutine(
                IPInfoServer.GetCountryByIPEnumerator(ip, func)
                ));
 }