private static void FriendsScoresLoop(ArrayList playerids, int points, Action finished) { Thread.Sleep(500); points += 1000; var playerid = playerids [0].ToString(); playerids.RemoveAt(0); var score = new PlayerScore { playername = "playerid" + playerid, playerid = playerid, table = "friends" + rnd, points = points, highest = true, fields = { { "rnd", rnd } } }; Leaderboards.Save(score, r => { if (playerids.Count > 0) { FriendsScoresLoop(playerids, points, finished); return; } finished(); }); }
private static void OwnScoresLoop(int count, int points, Action finished) { Thread.Sleep(500); points += 1000; count++; var score = new PlayerScore { playername = "test account", playerid = "*****@*****.**", table = "personal" + rnd, points = points, highest = true, allowduplicates = true, fields = { { "rnd", rnd } } }; Leaderboards.Save(score, r => { if (count < 9) { OwnScoresLoop(count, points, finished); return; } finished(); }); }
public static void FirstScore(Action done) { const string section = "TestLeaderboards.FirstScore"; Console.WriteLine(section); var score = new PlayerScore { table = "scores" + rnd, playername = "person1", points = 10000, highest = true, fields = new Hashtable { { "rnd", rnd } } }; Leaderboards.Save(score, r => { AssertTrue(section + "#1", "Request succeeded", r.success); AssertEquals(section + "#1", "No errorcode", r.errorcode, 0); // duplicate score gets rejected score.points = 9000; Thread.Sleep(1000); Leaderboards.Save(score, r2 => { AssertTrue(section + "#2", "Request succeeded", r2.success); AssertEquals(section + "#2", "Rejected duplicate score", r2.errorcode, 209); // better score gets accepted score.points = 11000; Leaderboards.Save(score, r3 => { AssertTrue(section + "#3", "Request succeeded", r3.success); AssertEquals(section + "#3", "No errorcode", r3.errorcode, 0); // score gets accepted score.points = 9000; score.allowduplicates = true; Leaderboards.Save(score, r4 => { AssertTrue(section + "#4", "Request succeeded", r4.success); AssertEquals(section + "#4", "No errorcode", r4.errorcode, 0); done(); }); }); }); }); }
public static void SecondScore(Action done) { const string section = "TestLeaderboards.SecondScore"; Console.WriteLine(section); var score = new PlayerScore { table = "scores" + rnd, playername = "person2", points = 20000, allowduplicates = true, highest = true, fields = new Hashtable { { "rnd", rnd } } }; Thread.Sleep(1000); Leaderboards.Save(score, r => { AssertTrue(section, "Request succeeded", r.success); AssertEquals(section, "No errorcode", r.errorcode, 0); done(); }); }