/* This code is for dynamically generating file strings at save/load time instead of always keeping the file names in memory.
        protected string FileString()
        {
            var ParentString = Parent.FileString();
            var MyAddtionalString = FileStringBit();

            if (ParentString != null)
            {
                if (MyAddtionalString != null)
                    return ParentString + MyAddtionalString;
                else
                    return ParentString;
            }
            else
            {
                if (MyAddtionalString != null)
                    return MyAddtionalString;
                else
                    return null;
            }
        }

        protected virtual string FileStringBit()
        {
            return null;
        }
         * */
        public Node(Node parent, int Spent, int Pot)
        {
            Parent = parent;

            if (Parent == null)
                BetCode = null;
            else
                BetCode = Parent.BetCode;

            if (Parent != null)
            {
                MyPhaseRoot = Parent.MyPhaseRoot;
                MyCommunity = Parent.MyCommunity;
                Depth = Parent.Depth + 1;
            }
            else
            {
                MyPhaseRoot = null;
                MyCommunity = null;
                Depth = 0;
            }

            DataOffset = Depth;

            this.Spent = Spent;
            this.Pot = Pot;
        }
        protected override void CreateBranches()
        {
            Branches = new List<Node>(MyCommunity.Branches.Count);
            BranchesByIndex = new List<Node>(MyCommunity.BranchesByIndex.Count);

            int RootCount = 0;
            foreach (CommunityNode community in MyCommunity.BranchesByIndex)
            {
                PhaseRoot NewRoot = null;

                if (community != null)
                {
                    if (Phase == BettingPhase.PreFlop)
                        NewRoot = new FlopRoot(this, community, Spent, Pot, RootCount);
                    else
                        NewRoot = new PhaseRoot(this, community, Spent, Pot, RootCount);
                    Branches.Add(NewRoot);
                }

                BranchesByIndex.Add(NewRoot);
                RootCount++;
            }
        }