Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

# VERSION is only bumped in the main worktree, so skip linked worktrees
if [ "$(git rev-parse --git-dir)" != "$(git rev-parse --git-common-dir)" ]; then
exit 0
fi

cd "Assets/Talo Game Services/Talo"

VERSION_FILE="VERSION"
Expand Down
59 changes: 0 additions & 59 deletions .opencode/agents/code-review-verifier.md

This file was deleted.

72 changes: 0 additions & 72 deletions .opencode/agents/code-reviewer.md

This file was deleted.

19 changes: 0 additions & 19 deletions .opencode/commands/review.md

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/Talo Game Services/Talo/Runtime/APIs/BaseAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TaloGameServices
public class BaseAPI
{
// automatically updated with a pre-commit hook
private const string ClientVersion = "1.0.0";
private const string ClientVersion = "1.1.0";

protected string baseUrl;

Expand Down
10 changes: 10 additions & 0 deletions Assets/Talo Game Services/Talo/Runtime/APIs/LeaderboardsAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ public async Task<LeaderboardEntriesResponse> GetEntries(string internalName, Ge
return res;
}

public async Task<LeaderboardTopEntriesResponse> GetTopEntries(string internalName, int limit)
{
Talo.IdentityCheck();

var uri = new Uri($"{baseUrl}/{internalName}/entries/top?limit={limit}");
var json = await Call(uri, "GET");

return JsonUtility.FromJson<LeaderboardTopEntriesResponse>(json);
}

public async Task<AddEntryResult> AddEntry(string internalName, float score, params (string, string)[] propTuples)
{
Talo.IdentityCheck();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace TaloGameServices
{
[System.Serializable]
public class LeaderboardTopEntriesResponse
{
public LeaderboardEntry[] topEntries;
public LeaderboardEntry[] playerEntries;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions Assets/Talo Game Services/Talo/Runtime/Utils/SessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@ private void SaveSession(string sessionToken, string refreshToken)

public async Task<bool> ClearSession(bool resetSocket = true)
{
if (!Talo.HasIdentity())
{
return false;
}
var hadIdentity = Talo.HasIdentity();

_sessionToken = null;
Talo.CurrentAlias = null;
PlayerAlias.DeleteOfflineAlias();

if (hadIdentity)
{
PlayerAlias.DeleteOfflineAlias();
}

PlayerPrefs.DeleteKey("TaloRefreshToken");

Talo.Events.ClearQueue();
Talo.Continuity.ClearRequests();

if (resetSocket)
if (resetSocket && hadIdentity)
{
try
{
Expand All @@ -68,7 +69,7 @@ public async Task<bool> ClearSession(bool resetSocket = true)
}
}

return true;
return hadIdentity;
}

public string GetSessionToken()
Expand Down
8 changes: 8 additions & 0 deletions Assets/Talo Game Services/Talo/Tests/SessionManager.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

namespace TaloGameServices.Test
{
internal class ClearSessionTest
{
[OneTimeSetUp]
public void Setup()
{
var tm = new GameObject().AddComponent<TaloManager>();
tm.settings = ScriptableObject.CreateInstance<TaloSettings>();
tm.settings.autoConnectSocket = false;
tm.settings.autoStartSession = false;

Talo.CurrentAlias = null;
PlayerPrefs.DeleteAll();
}

[UnityTest]
public IEnumerator ClearSession_WithoutIdentity_DeletesStoredToken()
{
Talo.CurrentAlias = null;
PlayerPrefs.SetString("TaloRefreshToken", "stale-token");

// TestMode makes HasIdentity() always return true, which would mask
// the no-identity path this test exercises
TestModeFlag.IsEnabled = false;
try
{
var task = Talo.PlayerAuth.SessionManager.ClearSession(false);
while (!task.IsCompleted)
{
yield return null;
}

Assert.IsFalse(task.Result);
Assert.IsEmpty(PlayerPrefs.GetString("TaloRefreshToken"));
}
finally
{
TestModeFlag.IsEnabled = true;
}
}

[UnityTest]
public IEnumerator ClearSession_WithIdentity_ReturnsTrue()
{
Talo.CurrentAlias = new PlayerAlias() {
player = new Player() {
id = "uuid"
}
};
PlayerPrefs.SetString("TaloRefreshToken", "some-token");

var task = Talo.PlayerAuth.SessionManager.ClearSession(false);
while (!task.IsCompleted)
{
yield return null;
}

Assert.IsTrue(task.Result);
Assert.IsEmpty(PlayerPrefs.GetString("TaloRefreshToken"));
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Talo Game Services/Talo/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.1.0
Loading