Esempio n. 1
0
        public void RandomlyRotateFlipTiles(Die dieRed, Chip chpBridge)
        {
            int iBridgesUsed = 0;

            // Iterate through each tile, manipulating it within the list
            for (int iIndex = 0; iIndex < lstTiles.Count; iIndex++)
            {
                // Roll the die
                int     iFace = TokenUtilities.rndGenerator.Next(0, dieRed.Faces.Count);
                DieFace dFace = (DieFace)(dieRed.Faces[iFace]);
                // Act on the results
                Tile currentTile = (Tile)(lstTiles[iIndex]);
                if ((null != currentTile.ReverseSideTile) && (dFace.Bams > 0))
                {
                    // Flip the tile and replaced it in the list
                    currentTile      = currentTile.ReverseSideTile;
                    lstTiles[iIndex] = currentTile;
                }
                // Add a bridge if it is not the last tile
                if ((dFace.Diamonds > 0) && (iBridgesUsed < 2) && (iIndex < (lstTiles.Count - 1)))
                {
                    currentTile.Bridge = chpBridge;
                    iBridgesUsed++;
                }
                // Rotate the tile clockwise, based on the number of swords rolled
                currentTile.RotateTile(dFace.Swords);
            }
        }
Esempio n. 2
0
        public Die(XmlNode xmlDie)
        {
            lstFaces = new ArrayList();

            if (null == xmlDie)
            {
                // Nothing to parse
                return;
            }

            if ((null != xmlDie.Attributes) && (null != xmlDie.Attributes["Color"]))
            {
                sName = xmlDie.Attributes["Color"].Value;
            }

            if (null != xmlDie.ChildNodes)
            {
                foreach (XmlNode infoElement in xmlDie.ChildNodes)
                {
                    // Only support the "Face" element
                    if (infoElement.Name == "Face")
                    {
                        DieFace newDieFace = new DieFace();

                        string   sFaceContent = infoElement.InnerText;
                        string[] faceConents  = sFaceContent.ToLower().Split(",".ToCharArray());
                        foreach (string sContentItem in faceConents)
                        {
                            switch (sContentItem)
                            {
                            case "sword":
                                newDieFace.Swords++;
                                break;

                            case "shield":
                                newDieFace.Shields++;
                                break;

                            case "bam":
                                newDieFace.Bams++;
                                break;

                            case "diamond":
                                newDieFace.Diamonds++;
                                break;

                            default:
                                break;
                            }
                        }

                        lstFaces.Add(newDieFace);
                    }
                }
            }
        }
Esempio n. 3
0
        public void AddChips(Die dieGreen, Chip chpStart, Chip chpExit, Chip chpDoor)
        {
            // Add the start chip to the first tile
            ((Tile)(lstTiles[0])).Start = chpStart;
            // Add the exit chip to the last tile
            ((Tile)(lstTiles[lstTiles.Count - 1])).Exit = chpExit;

            // Iterate through each tile, adding the appropriate number of doors
            int iTotalDoors = 0;

            for (int iIndex = 0; iIndex < lstTiles.Count; iIndex++)
            {
                // Roll the die
                int     iFace = TokenUtilities.rndGenerator.Next(0, dieGreen.Faces.Count);
                DieFace dFace = (DieFace)(dieGreen.Faces[iFace]);
                // Act on the results
                Tile currentTile       = (Tile)(lstTiles[iIndex]);
                int  iDoorsForThisTile = (0 == dFace.Shields)? 1 : dFace.Shields;
                currentTile.Doors = iDoorsForThisTile;
                iTotalDoors      += iDoorsForThisTile;
                currentTile.Door  = chpDoor;
            }

            // Can only have a maximum of 15 doors spread across all the tiles.  Randomly remove any extra doors.
            if (15 < iTotalDoors)
            {
                int iDoorsLeftToRemove = iTotalDoors - 15;

                while (0 < iDoorsLeftToRemove)
                {
                    int  iTileIndexToRemoveDoor = TokenUtilities.rndGenerator.Next(0, lstTiles.Count);
                    Tile tTileToExamine         = (Tile)(lstTiles[iTileIndexToRemoveDoor]);
                    if (1 < tTileToExamine.Doors) // Must leave at least one door
                    {
                        tTileToExamine.Doors -= 1;
                        iDoorsLeftToRemove--;
                    }
                }
            }
        }