Exemplo n.º 1
0
        public void TestGetPoints()
        {
            var hex = new HexEdge(0, 0, 1, 0);
            var points = hex.GetPoints();
            Assert.AreEqual(2, points.Count, "A hex edge must have 2 points.");

            var msg = "Hex edge is missing a point.";
            Assert.IsTrue(points.Contains(new HexPoint(0, 0, 1, 0, 1, 1)), msg);
            Assert.IsTrue(points.Contains(new HexPoint(0, 0, 1, 0, 0, -1)), msg);
        }
Exemplo n.º 2
0
 private bool IsPlayerBuildingHere(int player, HexEdge edge)
 {
     foreach (var point in edge.GetPoints())
     {
         if (IsPlayerBuildingHere(player, point))
             return true;
     }
     return false;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the point which connects two edges.
 /// </summary>
 public HexPoint GetNeighborPoint(HexEdge neighborEdge)
 {
     var point = this.GetPoints().Intersect(neighborEdge.GetPoints()).ToList();
     if (point.Count != 1)
         throw new ArgumentException("Invalid neighbor edge.");
     return point[0];
 }