protected BetTreeNodeModel LoadNode(BetTreeNodeModel parent, BetTreeNodeXml node, bool relative) { BetTreeNodeModel ret = Service.AddChild(this, parent); ret.LoadFromXml(node, relative); if (!ret.Snapshot.IsHandEnd) foreach (BetTreeNodeXml child in node.Children) LoadNode(ret, child, relative); return ret; }
public void LoadFromXml(BetTreeNodeXml xml, bool relative) { if (relative) { float pot = this.Snapshot.Bets.Sum(); float amount = xml.MetaXml.BetXml.BetAmount * pot; if (this.Snapshot.CurrentPlayer != null) { float remaining = this.Snapshot.Stacks[(int)this.Snapshot.CurrentPlayer] - this.Snapshot.Bets[(int)this.Snapshot.CurrentPlayer]; if (amount >= remaining) { amount = remaining; } } xml.MetaXml.BetXml.BetAmount = amount; } this.Meta = xml.MetaXml.Name; this.IsDefault = xml.IsDefault; this.Data.LoadFromXml(xml.MetaXml); this.Info.LoadFromXml(xml.InfoXml); this.Save(null); }
public BetTreeNodeXml SaveToXml() { BetTreeNodeXml ret = new BetTreeNodeXml(); ret.IsDefault = this.IsDefault; ret.MetaXml = this.Data.SaveToXml(); ret.InfoXml = this.Info.SaveToXml(); foreach (BetTreeNodeModel child in Children) ret.Children.Add(child.SaveToXml()); return ret; }
private BetTreeNodeModel LoadNode(BetTreeNodeModel parent, BetTreeNodeXml node) { BetTreeNodeModel ret = Service.AddChild(Tree, parent); ret.LoadFromXml(node, true); if (!ret.Snapshot.IsHandEnd) foreach (BetTreeNodeXml child in node.Children) LoadNode(ret, child); return ret; }