update map gen
This commit is contained in:
@@ -53,10 +53,27 @@ namespace Hallucinate.UI
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> RegisterUser(string username)
|
||||
public static async Task<Hallucinate.Game.PlayerEloData> GetPlayerData(string username)
|
||||
{
|
||||
string url = $"{BASE_URL}/{username}.json";
|
||||
string jsonData = "{\"created_at\": \"" + DateTime.Now.ToString() + "\"}";
|
||||
string url = $"{BASE_URL}/{username}/elo.json";
|
||||
using (UnityWebRequest request = UnityWebRequest.Get(url))
|
||||
{
|
||||
var operation = request.SendWebRequest();
|
||||
while (!operation.isDone) await Task.Yield();
|
||||
|
||||
if (request.result != UnityWebRequest.Result.Success || request.downloadHandler.text == "null")
|
||||
{
|
||||
return Hallucinate.Game.PlayerEloData.Default;
|
||||
}
|
||||
|
||||
return JsonUtility.FromJson<Hallucinate.Game.PlayerEloData>(request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> SavePlayerData(string username, Hallucinate.Game.PlayerEloData data)
|
||||
{
|
||||
string url = $"{BASE_URL}/{username}/elo.json";
|
||||
string jsonData = JsonUtility.ToJson(data);
|
||||
|
||||
using (UnityWebRequest request = UnityWebRequest.Put(url, jsonData))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user