Example #1
0
 public void CreateSampleOrder()
 {
     Generic.List <ShoppingBasketItem> list = new Generic.List <ShoppingBasketItem>();
     list.Add(new ShoppingBasketItem("CodeRush", 20));
     list.Add(new ShoppingBasketItem("DXperience Universal", 2));
     list.Add(new ShoppingBasketItem("DevExtreme", 5));
 }
        private static void ConsoleWriteLinePlayerScore(int playerNumber, bool hasSoftScore, int score,
                                                        Generic.List <LibraryInterfaces.ICard> cards, bool hit = false)
        {
            var builder = new System.Text.StringBuilder();

            builder.Append("Player#");
            builder.Append(playerNumber);
            builder.Append(" has a ");
            if (hasSoftScore)
            {
                builder.Append("soft ");
            }
            builder.Append("score of ");
            builder.Append(score);
            builder.Append(" with card(s): ");
            foreach (var card in cards)
            {
                builder.Append(card.ToString());
                builder.Append(" ");
            }
            if (hit)
            {
                builder.Append("Please enter Y/y to hit.");
            }
            Console.WriteLine(builder);
        }
        //ii.Highest Card wins
        public Generic.List <int> EvaluateWinners()
        {
            Generic.List <int> winningPlayerNumbers = new Generic.List <int>();
            Generic.List <CardGameLibrary.PlayerOfCard> highestPlayersOfCards = new Generic.List <CardGameLibrary.PlayerOfCard>();
            CardGameLibrary.PlayerOfCard highestPlayerOfCards = null;

            //Initially, assign first player as highest card winner
            if (PlayerOfCardsInGame.Count > 0)
            {
                highestPlayerOfCards = PlayerOfCardsInGame[0];
                highestPlayersOfCards.Add(highestPlayerOfCards);
            }

            for (int i = 1; i < PlayerOfCardsInGame.Count; i++)
            {
                //If previous player(s) temporarily assigned
                //as highest card winner is outranked, remove
                //and add new player as currently
                //assigned highest card winner
                if (PlayerOfCardsInGame[i].PlayerScore >
                    highestPlayerOfCards.PlayerScore)
                {
                    highestPlayersOfCards.RemoveAll
                        (match => match.PlayerScore
                        == highestPlayerOfCards.PlayerScore);
                    highestPlayerOfCards = PlayerOfCardsInGame[i];
                    highestPlayersOfCards.Add(highestPlayerOfCards);
                }
                //Multiple players having cards of same rank can be co-winners
                else if (PlayerOfCardsInGame[i].PlayerScore ==
                         highestPlayerOfCards.PlayerScore)
                {
                    highestPlayerOfCards = PlayerOfCardsInGame[i];
                    highestPlayersOfCards.Add(highestPlayerOfCards);
                }
            }

            //This should be a list of at most Count == 4 for co-winner use-cases
            foreach (CardGameLibrary.PlayerOfCard playerOfCards in highestPlayersOfCards)
            {
                winningPlayerNumbers.Add(playerOfCards.PlayerNumber);
            }

            return(winningPlayerNumbers);
        }
Example #4
0
        static void Main(string[] args)
        {
            var missingCards = new Generic.List <Dominion.CardShapedObject>();

            var cardImagesList = new CardImagesList("c:\\trash\\CardImagesList.txt");
            var destinationDir = "C:\\Dropbox\\nathant\\Projects\\Dominion\\Dominulator\\Resources";

            foreach (var cardShapedObject in Dominion.Cards.AllCardsList)
            {
                if (cardShapedObject == Dominion.Cards.Ruins || cardShapedObject == Dominion.Cards.Prize)
                {
                    continue;
                }
                var imagePath = cardImagesList.GetPathForCard(cardShapedObject);
                if (imagePath != null)
                {
                    System.Console.WriteLine(imagePath);
                    var destPath = System.IO.Path.Combine(destinationDir, cardShapedObject.ProgrammaticName + System.IO.Path.GetExtension(imagePath));
                    if (!System.IO.File.Exists(destPath))
                    {
                        System.IO.File.Copy(imagePath, destPath, overwrite: false);
                    }
                }
                else
                {
                    missingCards.Add(cardShapedObject);
                }
            }

            if (missingCards.Count > 0)
            {
                System.Console.WriteLine("Fail");
                foreach (var card in missingCards)
                {
                    System.Console.WriteLine(card.ProgrammaticName);
                }
            }
            else
            {
                System.Console.WriteLine("Success");
            }
        }
        private static void ConsoleWriteLineDealerScore(bool hasSoftScore, int score,
                                                        Generic.List <LibraryInterfaces.ICard> cards)
        {
            var builder = new System.Text.StringBuilder();

            builder.Append("Dealer ");
            builder.Append("has a ");
            if (hasSoftScore)
            {
                builder.Append("soft ");
            }
            builder.Append("score of ");
            builder.Append(score);
            builder.Append(" with cards: ");
            foreach (var card in cards)
            {
                builder.Append(card.ToString());
                builder.Append(" ");
            }
            Console.WriteLine(builder);
        }
 public PlayerOfCard()
 {
     PlayerCards = new Generic.List <Interfaces.ICard>();
 }
Example #7
0
            internal static PythonList Convert(ComprehensionIterator[] iters)
            {
                Generic.List<ComprehensionFor> cfCollector =
                    new Generic.List<ComprehensionFor>();
                Generic.List<Generic.List<ComprehensionIf>> cifCollector =
                    new Generic.List<Generic.List<ComprehensionIf>>();
                Generic.List<ComprehensionIf> cif = null;
                for (int i = 0; i < iters.Length; i++) {
                    if (iters[i] is ComprehensionFor) {
                        ComprehensionFor cf = (ComprehensionFor)iters[i];
                        cfCollector.Add(cf);
                        cif = new Generic.List<ComprehensionIf>();
                        cifCollector.Add(cif);
                    } else {
                        ComprehensionIf ci = (ComprehensionIf)iters[i];
                        cif.Add(ci);
                    }
                }

                PythonList comps = new PythonList();
                for (int i = 0; i < cfCollector.Count; i++)
                    comps.Add(new comprehension(cfCollector[i], cifCollector[i].ToArray()));
                return comps;
            }
Example #8
0
 internal static ComprehensionIterator[] RevertComprehensions(PythonList comprehensions)
 {
     Generic.List<ComprehensionIterator> comprehensionIterators =
         new Generic.List<ComprehensionIterator>();
     foreach (comprehension comp in comprehensions) {
         ComprehensionFor cf = new ComprehensionFor(expr.Revert(comp.target), expr.Revert(comp.iter));
         comprehensionIterators.Add(cf);
         foreach (expr ifs in comp.ifs) {
             comprehensionIterators.Add(new ComprehensionIf(expr.Revert(ifs)));
         }
     }
     return comprehensionIterators.ToArray();
 }
 public void CreateBasket()
 {
     Generic.List <ShoppingBasketItem> list = new Generic.List <ShoppingBasketItem>();
     list.Add(new ShoppingBasketItem("Awesome UI Design - Mark Miller (Book)", 10));
     list.Add(new ShoppingBasketItem("C# in Depth- Jon Skeet (Book)", 10));
 }
Example #10
0
        // ---  Attributes ---
        // -- Properties --
        // -- Public Attributes --
        // -- Private Attributes --
        // --- /Attributes ---

        // ---  Methods ---
        // -- Public Methods --

        /**
         * Loads all data from the TileMaps below the given node.
         * Returns a Graph object, loaded with all the required data.
         */
        public static Graph.Graph LoadGraph(Node root)
        {
            // Prepare the Graph instance.
            Graph.Graph graph = new Graph.Graph();

            // Find all tilemap subnodes.
            Generic.List <TileMap> tilemaps = FindTilemapsUnder(root);

            // Get the limits of all the tilesets.
            Rect2 limits = GetTilemapsLimits(tilemaps);
            // Compute the limits of the loops.
            Vector2 start = limits.Position;
            Vector2 end   = limits.Position + limits.Size;

            // Loop through each tilemap.
            foreach (TileMap tilemap in tilemaps)
            {
                // Loop through the limits of the tilemap.
                for (int x = (int)start.x; x < end.x; x++)
                {
                    for (int y = (int)start.y; y < end.y; y++)
                    {
                        // First, get the identifier of the cell.
                        int tileID = tilemap.GetCell(x, y);

                        // If the identifier is not -1.
                        if (tileID != -1)
                        {
                              {
                                // Get the name of the tile.
                                String tileName = tilemap.TileSet.TileGetName(tileID);

                                // Check if the tile is a wall.
                                ComputeWall(tileName, x, y, ref graph);

                                // Check if the tile is a vertex.
                                ComputeVertex(tileName, x, y, ref graph);

                                // Compute the cost of the tile.
                                ComputeCost(x, y, tilemap);
                            }
                        }

                        // If the tilemap handles zone splitting.
                        if (tilemap.CollisionMask == 0b1000)
                        {
                            // Compute the face this tile belongs to.
                            ComputeFace(x, y, ref graph);

                            // If there is a tile.
                            if (tileID != -1)
                            {
                                // Compute the resources on that tile.
                                ComputeResource(x, y, tilemap, ref graph);
                            }
                        }
                    }
                }
            }

            // Prepare the list of vertices to remove.
            Generic.List <Graph.Vertex> VerticesToRemove = new Generic.List <Graph.Vertex>();

            // Loop through each vertex.
            foreach (Graph.Vertex vtx in graph.Vertices)
            {
                // Check all four sides.
                Vector2[]  directions = new Vector2[] { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right };
                foreach (Vector2 dir in directions)
                {
                    // Check if a wall is present and has not been computed.
                    Vector2   currentPosition = vtx.Position + dir;
                    Tile.Wall dirWall         = graph.GetWallAt(currentPosition);
                    if (dirWall != null && dirWall.Edge == null)
                    {
                        // Get the rooms on each side of the wall.
                        Graph.Face[] faces = graph.GetFacesFromWall(currentPosition);

                        // Start computing a new edge.
                        Graph.Edge edge = new Graph.Edge(faces);

                        // Add the edges to the face.
                        edge.RightFace = faces[0];
                        edge.LeftFace  = faces[1];

                        // Loop until a new vertex is found.
                        while (graph.GetVertexAt(currentPosition) == null)
                        {
                            // If the wall exists.
                            Tile.Wall wall = graph.GetWallAt(currentPosition);
                            if (wall != null)
                            {
                                // Add the wall to the edge.
                                edge.AddWall(wall);

                                // Increment the position.
                                currentPosition += dir;

                                // If the wall stops abruptly, stop execution.
                            }
                            else
                            {
                                throw new Exception("FATAL ERROR: Stray wall found @ " + currentPosition + " ...");
                            }
                        }

                        // Add the vertices to the edge.
                        edge.StartVertex = vtx;
                        edge.EndVertex   = graph.GetVertexAt(currentPosition);

                        // Add the edge to the graph.
                        vtx.Edges.Add(edge);
                        graph.AddEdge(edge);

                        // Add the edge to the face.
                        foreach (Graph.Face face in faces)
                        {
                            face.AddEdge(edge);
                        }
                    }
                }

                // After that is done, check if the vertex object is NOT a tower.
                if (!vtx.IsTower)
                {
                    // If the vertex has two edges.
                    if (vtx.Edges.Count == 2)
                    {
                        // Get the vertex's edges.
                        Tuple <Graph.Edge, Graph.Edge> edges = new Tuple <Graph.Edge, Graph.Edge>(
                            vtx.Edges[0], vtx.Edges[1]
                            );

                        // Merge the edges together.
                        edges.Item1.Merge(edges.Item2);

                        // Remove the second edge.
                        graph.RemoveEdge(edges.Item2);

                        // If the vertex has one single edge.
                    }
                    else if (vtx.Edges.Count == 1)
                    {
                        // Add the vertex's wall to the edge.
                        vtx.Edges[0].AddWall(vtx.Wall);
                    }


                    // Add the vertex to removal.
                    VerticesToRemove.Add(vtx);
                }
            }

            // Remove the vertices.
            foreach (Graph.Vertex vtx in VerticesToRemove)
            {
                graph.RemoveVertex(vtx);
            }

            // Return the generated graph.
            GD.Print(graph.ToString());
            return(graph);
        }
Example #11
0
 //Assumption: One set of 52 cards is being used in the deck of cards and not multiple
 public BlackJackGame(LibraryInterfaces.IDeckOfCards deckOfCards)
 {
     PlayerOfCardsInGame = new Generic.List <CardGameLibrary.PlayerOfCard>();
     _deckOfCards        = deckOfCards;
 }