Exemple #1
0
        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            StageCycle <T> othercycle = obj as StageCycle <T>;

            if ((System.Object)othercycle == null)
            {
                return(false);
            }

            // Compare the StageCycles
            if (idx != othercycle.idx)
            {
                return(false);
            }

            if (queuedNext != othercycle.queuedNext)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        private CardGame CloneCommon()
        {
            var temp = new CardGame(); //here, players is being initialzed as an empty list of players

            // Clone Source Deck and Index Cards
            //*****************
            for (int i = 0; i < sourceDeck.Count; ++i)
            {
                Card c = sourceDeck[i].Clone();
                temp.sourceDeck.Add(c);
            }

            // Clone table
            temp.table[0] = table[0].Clone();

            // Clone players in the same play order
            temp.players = new Player[players.Length];
            for (int i = 0; i < players.Length; i++)
            {
                Player op        = players[i];
                Player newPlayer = op.Clone();
                temp.players[i] = newPlayer;
            }

            // Clone teams in the same team order, look up their players
            foreach (Team orig in teams)
            {
                Team newTeam = orig.Clone();
                foreach (Player p in orig.teamPlayers)
                {
                    Player newPlayer = temp.players[p.id];
                    newPlayer.team = newTeam;
                    newTeam.teamPlayers.Add(newPlayer);
                }
                temp.teams.Add(newTeam);
            }

            // Reconstruct team and player cycles
            foreach (var cycle in this.currentPlayer.Reverse())
            {
                var newCycle = new StageCycle <Player>(temp.players)
                {
                    idx        = cycle.idx,
                    queuedNext = cycle.queuedNext
                };
                temp.currentPlayer.Push(newCycle);
            }

            foreach (var cycle in this.currentTeam.Reverse())
            {
                var newCycle = new StageCycle <Team>(temp.teams)
                {
                    idx        = cycle.idx,
                    queuedNext = cycle.queuedNext
                };
                temp.currentTeam.Push(newCycle);
            }

            return(temp);
        }
Exemple #3
0
 /********
  * A way to ShallowCopy the given source StageCycle when going into
  * a deeper stage
  */
 public StageCycle(StageCycle <T> source)
 {
     memberList = source.memberList;
     idx        = source.idx;
 }