示例#1
0
 /// <summary>
 /// Generates a new PlayGen object
 /// </summary>
 /// <param name="playGen">The playgen</param>
 /// <param name="pl">The pl</param>
 public PlayGen(PlayGen playGen, string pl)
 {
     this._collections = playGen._collections;
     if (this._collections.ContainsKey(pl))
         this._collections[pl] += 1;
     else
         this._collections.Add(pl, 1);
 }
示例#2
0
 /// <summary>
 /// Generates a new PlayGen object
 /// </summary>
 /// <param name="playGen">The play gen</param>
 public PlayGen(PlayGen playGen)
 {
     this._collections = playGen._collections;
 }
        /// <summary>
        /// This continues generating the play from a board, this is a recursive function.
        /// </summary>
        /// <param name="board">The start tile of the board</param>
        /// <param name="moves">The moves</param>
        /// <param name="boardDesign">The board design</param>
        /// <param name="curPath">The current path</param>
        /// <param name="pg">The play gen</param>
        private void GeneratePlaysFromBoardHelper(ITile board, int moves, String boardDesign, String curPath, PlayGen pg)
        {
            if (moves == _numMoves) // last space
            {
                List<PrizeLevel> wonPL = new List<PrizeLevel>();
                foreach (PrizeLevel pl in _prizeLevels)
                {
                    if (pl.numCollections == pg.HasCollection((String)_prizeLevelConverter.Convert(pl.prizeLevel)))
                    {
                        wonPL.Add(pl);
                    }
                }

                if (wonPL.Count == 0)
                {
                    AddPath("none", boardDesign, curPath);
                    return;
                }

                int count = 0;
                foreach (DivisionModel div in _divisions)
                {
                    count = 0;
                    foreach (PrizeLevel pl in div.selectedPrizes)
                    {
                        if (wonPL.Contains(pl))
                        {
                            count++;
                        }
                        else
                        {
                            count = Int32.MinValue;
                        }
                    }

                    if (count == wonPL.Count)
                    {
                        AddPath(div.DivisionNumber.ToString(), boardDesign, curPath);
                        return;
                    }
                }

                AddPath("BadGame", boardDesign, curPath);
                return;
            }

            //if (board.Connections.Keys.Count < 6)
            //{

            //}

            foreach (int t in board.Connections.Keys)
            {
                if (_numDice == 0) //Spinner in use
                {
                    if (board.Connections[t].Type == TileTypes.collection)
                    {
                        String getter = board.Connections[t].TileAction().TileInformation;
                        getter = getter.Substring(getter.Length - 1);
                        GeneratePlaysFromBoardHelper(board.Connections[t], moves + 1, boardDesign, curPath + "," + t, new PlayGen(pg, getter));
                    }
                    else
                    {
                        GeneratePlaysFromBoardHelper(board.Connections[t].TileAction(), moves + 1, boardDesign, curPath + "," + t, new PlayGen(pg));
                    }
                }
                else
                {
                    if (board.Connections[t].Type == TileTypes.collection)
                    {
                        String getter = board.Connections[t].TileAction().TileInformation;
                        getter = getter.Substring(getter.Length - 1);
                        GeneratePlaysFromBoardHelper(board.Connections[t], moves + 1, boardDesign, curPath + "," + _rollOptions[t][SRandom.NextInt(0, _rollOptions[t].Count)], new PlayGen(pg, getter));
                    }
                    else
                    {
                        GeneratePlaysFromBoardHelper(board.Connections[t].TileAction(), moves + 1, boardDesign, curPath + "," + _rollOptions[t][SRandom.NextInt(0, _rollOptions[t].Count)], new PlayGen(pg));
                    }
                }
            }
        }