Example #1
0
        private void EliminateBeComponent(HexGridCoordinate position)
        {
            int beMagnitude = _hexVectorUtility.GetMagnitudeAlongCardinalDirection(position, HexAxis.B);

            if (beMagnitude == 0)
            {
                return;
            }

            position.CfCoordinate = position.CfCoordinate + beMagnitude;
            position.DaCoordinate = position.DaCoordinate - beMagnitude;

            _hexVectorUtility.EliminateComponentsAlongCardinalDirection(position, HexAxis.B);
        }
        public void TestComponentElimination()
        {
            var vectorA = new RawHexVector();

            vectorA.AddComponent(HexAxis.B, 3);
            vectorA.AddComponent(HexAxis.B, 2);
            vectorA.AddComponent(HexAxis.E, 7);
            vectorA.AddComponent(HexAxis.A, 2);
            vectorA.AddComponent(HexAxis.C, 2);

            _utilityLibrary.GetMagnitudeAlongCardinalDirection(vectorA, HexAxis.B).Should().Be(-2);
            _utilityLibrary.GetMagnitudeAlongCardinalDirection(vectorA, HexAxis.A).Should().Be(2);
            _utilityLibrary.GetMagnitudeAlongCardinalDirection(vectorA, HexAxis.C).Should().Be(2);

            _utilityLibrary.EliminateComponentsAlongCardinalDirection(vectorA, HexAxis.B);
            _utilityLibrary.GetMagnitudeAlongCardinalDirection(vectorA, HexAxis.B).Should().Be(0);
            _utilityLibrary.GetMagnitudeAlongCardinalDirection(vectorA, HexAxis.A).Should().Be(2);
            _utilityLibrary.GetMagnitudeAlongCardinalDirection(vectorA, HexAxis.C).Should().Be(2);
        }