qa report v2
This commit is contained in:
@@ -10,6 +10,8 @@ public class GameTutorialManager : MonoBehaviour
|
||||
{
|
||||
public const string CpuOpponentName = "CPU";
|
||||
public const string DefaultGameSceneName = "Game";
|
||||
public const string CpuL10PrefsKey = "practice_cpu_l10";
|
||||
const int L10Window = 10;
|
||||
|
||||
public static bool tutorialModeTrigger = false;
|
||||
public bool isTutorial = false;
|
||||
@@ -241,14 +243,58 @@ public class GameTutorialManager : MonoBehaviour
|
||||
|
||||
public static MatchmadePlayer CreateCpuOpponent()
|
||||
{
|
||||
GetCpuL10(out int wins, out int losses);
|
||||
return new MatchmadePlayer
|
||||
{
|
||||
Name = CpuOpponentName,
|
||||
l10_wins = 10,
|
||||
l10_losses = 0
|
||||
l10_wins = wins,
|
||||
l10_losses = losses
|
||||
};
|
||||
}
|
||||
|
||||
public static void GetCpuL10(out int wins, out int losses)
|
||||
{
|
||||
CountL10(PlayerPrefs.GetString(CpuL10PrefsKey, string.Empty), out wins, out losses);
|
||||
}
|
||||
|
||||
public static void ApplyCpuL10(MatchmadePlayer cpu)
|
||||
{
|
||||
if (cpu == null)
|
||||
return;
|
||||
GetCpuL10(out int wins, out int losses);
|
||||
cpu.l10_wins = wins;
|
||||
cpu.l10_losses = losses;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records one practice result from the CPU's perspective (rolling last 10).
|
||||
/// Cleared on logout because <see cref="LoginManager.Logout"/> calls PlayerPrefs.DeleteAll.
|
||||
/// </summary>
|
||||
public static void RecordCpuL10Result(bool cpuWon)
|
||||
{
|
||||
string history = PlayerPrefs.GetString(CpuL10PrefsKey, string.Empty) ?? string.Empty;
|
||||
history += cpuWon ? 'W' : 'L';
|
||||
if (history.Length > L10Window)
|
||||
history = history.Substring(history.Length - L10Window);
|
||||
PlayerPrefs.SetString(CpuL10PrefsKey, history);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
static void CountL10(string history, out int wins, out int losses)
|
||||
{
|
||||
wins = 0;
|
||||
losses = 0;
|
||||
if (string.IsNullOrEmpty(history))
|
||||
return;
|
||||
for (int i = 0; i < history.Length; i++)
|
||||
{
|
||||
if (history[i] == 'W')
|
||||
wins++;
|
||||
else if (history[i] == 'L')
|
||||
losses++;
|
||||
}
|
||||
}
|
||||
|
||||
public static MatchmadePlayer CreateMyPlayerFromUser(UserData user)
|
||||
{
|
||||
return new MatchmadePlayer
|
||||
|
||||
Reference in New Issue
Block a user