示例#1
0
		public PlayerAward(Hashtable data)
		{
			foreach(string x in data.Keys)
			{			
				if(x == "date") 
				{
					var d = new DateTime(1970, 1, 1, 0, 0, 0);
					date = d.AddSeconds ((double)data[x]);
					continue;
				} 

				if(x == "awarded") {
					awarded = new PlayerAchievement ((Hashtable) data[x]);
					continue;
				}

				this[x] = data[x];
			}
		}
示例#2
0
		public static void Save(Action done) {

			const string section = "PTestAchievements.Save";
			Console.WriteLine (section);

			var achievement = new PlayerAchievement {
				{"achievement", "Super Mega Achievement #1"},
				{"achievementkey", "secretkey"},
				{"playerid", rnd.ToString()},
				{"playername", "a random name " + rnd},
				{"fields", new Hashtable {
					{"rnd", rnd }
					}}
			};

            OneGame.Achievements.Save(achievement, r =>
            {
				AssertTrue(section + "#1", "Request succeeded", r.success);
				AssertEquals(section + "#1", "No errorcode", r.errorcode, 0);

				// second save gets rejected
                OneGame.Achievements.Save(achievement, r2 =>
                {
					AssertFalse(section + "#2", "Request failed", r2.success);
					AssertEquals(section + "#2", "Already had achievement errorcode", r2.errorcode, 505);

					// third save overwrites the first
					achievement.overwrite = true;

                    OneGame.Achievements.Save(achievement, r3 =>
                    {
						AssertTrue(section + "#3", "Request succeeded", r3.success);
						AssertEquals(section + "#3", "Already had achievement errorcode", r3.errorcode, 506);

						// fourth saves with allow duplicates
						achievement.allowduplicates = true;
						achievement.Remove("overwrite");

                        OneGame.Achievements.Save(achievement, r4 =>
                        {
							AssertTrue(section + "#4", "Request succeeded", r4.success);
							AssertEquals(section + "#4", "Already had achievement errorcode", r4.errorcode, 506);
							done();
						});
					});
				});
			});
		}