public Result(Hashtable ht, string ourName) { if (ht.ContainsKey(ourName)) { Hashtable data = ht[ourName] as Hashtable; date = new YDate(data["date"] as Hashtable); switch (data["first"] as string) { case "first": first = First.FIRST; break; case "was_leader": first = First.WAS_LEADER; break; case "unknown": first = First.UNKNOWN; break; case "not_first": first = First.NOT_FIRST; break; default: throw new Exception(String.Format("Bad 'first' value {0}", data["first"] as string)); } } else { date = null; first = First.UNKNOWN; } }
public int CompareTo(YDate other) { if (other.year != year) { return(year.CompareTo(other.year)); } return(day.CompareTo(other.day)); }
public Game(Hashtable ht) { mindate = new YDate(ht["mindate"] as Hashtable); players = new Dictionary <string, Player>(); foreach (DictionaryEntry de in ht["players"] as Hashtable) { players.Add(de.Key.ToString(), new Player(de.Value as Hashtable)); } }
public GameListEntry(Hashtable ht) { mindate = new YDate(ht["mindate"] as Hashtable); players = new List <string>(); foreach (object obj in ht["players"] as ArrayList) { players.Add(obj as string); } }
public Game(Dictionary <string, object> ht) { mindate = new YDate(ht["mindate"] as Dictionary <string, object>); players = new Dictionary <string, Player>(); foreach (KeyValuePair <string, object> de in ht["players"] as Dictionary <string, object> ) { players.Add(de.Key.ToString(), new Player(de.Value as Dictionary <string, object>)); } }
public GameListEntry(Dictionary <string, object> ht) { mindate = new YDate(ht["mindate"] as Dictionary <string, object>); players = new List <string>(); foreach (object obj in ht["players"] as List <object> ) { players.Add(obj as string); } }
public int CompareTo(object obj) { if (obj == null) { return(1); } YDate other = obj as YDate; if (other == null) { throw new ArgumentException("Object is not a YDate"); } return(CompareTo(other)); }
public void Load(ConfigNode node) { if (node == null) { Reset(); return; } if (node.HasValue("year") && node.HasValue("day")) { completed = new YDate(node); } if (node.HasValue("reported")) { reported = bool.Parse(node.GetValue("reported")); } if (node.HasValue("result")) { result = (Result.First) int.Parse(node.GetValue("result")); } }
public CancelDelegate SyncTail(ResultCallback cb) { WebClient client = new WebClient(); client.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) => { bool result = false; try { if (e.Cancelled) { Logging.Log("Sync cancelled"); } else if (e.Error != null) { Logging.LogException(e.Error); } else { string json = e.Result; Logging.Log("Sync: " + json); Hashtable ht = MiniJSON.jsonDecode(json) as Hashtable; checkError(ht); game = new Game(ht); result = true; } } catch (Exception exc) { /* Job failed, but we still have to exit job state */ Logging.LogException(exc); } cb.Invoke(result); }; YDate date = new YDate(Planetarium.GetUniversalTime()); int kia = KerbalMonitor.CountDeadKerbals(); client.DownloadStringAsync(Page("/sync", "game={0}&player={1}&year={2:D}&day={3:D}&kia={4:D}", inGame, ourName, date.year, date.day, kia)); return(client.CancelAsync); }
public Player(Hashtable ht) { date = new YDate(ht["date"] as Hashtable); leader = (bool)ht["leader"]; }
private void Reset() { completed = null; reported = false; result = Result.First.UNKNOWN; }
public Player(Dictionary <string, object> ht) { date = new YDate(ht["date"] as Dictionary <string, object>); leader = (bool)ht["leader"]; }