static void Main(string[] args)
        {
            /*var host = Dns.GetHostEntry(Dns.GetHostName());
             * foreach (var ip in host.AddressList) {
             *      if (ip.AddressFamily == AddressFamily.InterNetwork) {
             *              Console.WriteLine(ip.ToString());
             *      }
             * }
             * throw new Exception("No network adapters with an IPv4 address in the system!");*/

            /*ConnectionForm m = new ConnectionForm();
             * m.Show();*/

            /*Application.EnableVisualStyles();
             * Application.SetCompatibleTextRenderingDefault(false);
             * Application.Run(new InitialForm());*/

            //singleton
            GameController.Instance.netListener = new Net.NetListener();

            //factory
            Checker.Checker c1 = CheckerFactory.CreateChecker("Pawn", Color.Green, 0, 0);

            //prototype (deep clone)
            Checker.Checker c2 = (Checker.Checker)c1.Clone();
            Console.WriteLine(c1.color == c2.color);

            //prototype (shallow clone)
            ClassicBoard classicBoard1 = new ClassicBoard(Color.DarkRed, Color.WhiteSmoke, 10);

            ClassicBoard classicBoard2 = (ClassicBoard)classicBoard1.Clone();

            Console.WriteLine(classicBoard1.subject == classicBoard2.subject);

            //builder
            BoardBuilder builder = new BoardBuilder();

            builder.addFirstColor(Color.Red);
            builder.addSecondColor(Color.White);
            GameBoard board = builder.getBoard(10, 10);


            // command
            Checker.Checker ch      = new Checker.Checker(Color.Black, 2, 2, CheckerType.Pawn);
            Command         command = new MoveDownLeftCommand(ch);

            command.Execute();
            command = new MoveDownRightCommand(ch);
            command.Execute();


            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //Singleton
            Creater player = Creater.getInstance("*****@*****.**");

            Console.WriteLine(player.Email);

            //Abstract Factory
            Chess Whitechesses = new Chess(new WhiteChess(), 2, 8);

            Whitechesses.HorseMove(2);
            Whitechesses.PawnMove(1);


            Chess Blackchesses = new Chess(new BlackChess(), 2, 8);

            Blackchesses.HorseMove(2);
            Blackchesses.PawnMove(4);

            //Builder
            Director     director     = new Director();
            BoardBuilder boardbuilder = new ClassicBoard();
            Board        classicboard = director.Construct(boardbuilder);

            Console.WriteLine(classicboard.ToString());

            boardbuilder = new BorderBoard();
            Board borderboard = director.Construct(boardbuilder);

            Console.WriteLine(borderboard.ToString());

            //Prototype
            IPrototype figure       = new WhitePawn(true);
            IPrototype clonedFigure = figure.Clone();

            figure.GetInfo();
            clonedFigure.GetInfo();

            figure       = new BlackPawn(false);
            clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();

            Console.WriteLine($"Main {DateTime.Now.TimeOfDay}");
            Console.WriteLine(Singleton.text);

            Singleton singleton1 = Singleton.GetInstance();

            Console.WriteLine(singleton1.Date);

            Console.ReadLine();
        }
Beispiel #3
0
        protected override void CreateBoard()
        {
            Board     = new ClassicBoard(new IPiece[8, 8]);
            WhiteKing = CreateKing(new King(PieceColor.White, new Position(4, 0)));
            BlackKing = CreateKing(new King(PieceColor.Black, new Position(4, 7)));

            WhiteKing.AtackedPiece = BlackKing;
            BlackKing.AtackedPiece = WhiteKing;

            InsertRichRow(PieceColor.White, 0);
            InsertPawnRow(PieceColor.White, 1);
            InsertEmptyRow(2);
            InsertEmptyRow(3);
            InsertEmptyRow(4);
            InsertEmptyRow(5);
            InsertPawnRow(PieceColor.Black, 6);
            InsertRichRow(PieceColor.Black, 7);
        }
Beispiel #4
0
        public void Setup()
        {
            //Defaults


            pawnLocationUnderTest  = 1;
            pawnPlayerIDUnderTest  = 1;
            pawnLocationUnderTest2 = 1;
            pawnPlayerIDUnderTest2 = 2;

            eel1TopLocationUnderTest    = 16;
            eel1BottomLocationUnderTest = 11;

            escalator1TopLocationUnderTest    = 18;
            escalator1BottomLocationUnderTest = 14;

            eel2TopLocationUnderTest    = 28;
            eel2BottomLocationUnderTest = 24;

            escalator2TopLocationUnderTest    = 27;
            escalator2BottomLocationUnderTest = 22;


            //Mock Pawn
            var mockedPawn = new Mock <IPawn>();

            mockedPawn.Setup(p => p.location)
            .Returns(() => pawnLocationUnderTest);
            mockedPawn.Setup(p => p.type)
            .Returns(() => EntityType.Pawn);
            mockedPawn.Setup(p => p.playerID)
            .Returns(() => pawnPlayerIDUnderTest);

            var mockedPawn2 = new Mock <IPawn>();

            mockedPawn2.Setup(p => p.location)
            .Returns(() => pawnLocationUnderTest2);
            mockedPawn2.Setup(p => p.type)
            .Returns(() => EntityType.Pawn);
            mockedPawn2.Setup(p => p.playerID)
            .Returns(() => pawnPlayerIDUnderTest2);

            pawnsUnderTest = new List <IPawn>();
            pawnsUnderTest.Add(mockedPawn.Object);
            pawnsUnderTest.Add(mockedPawn2.Object);

            //Mock Eel
            var eelEntity = new Mock <IEntity>();

            eelEntity.Setup(e => e.top_location)
            .Returns(() => eel1TopLocationUnderTest);
            eelEntity.Setup(e => e.bottom_location)
            .Returns(() => eel1BottomLocationUnderTest);
            eelEntity.Setup(e => e.type)
            .Returns(() => EntityType.Eel);

            //Mock Escalator
            var escalatorEntity = new Mock <IEntity>();

            escalatorEntity.Setup(e => e.top_location)
            .Returns(() => escalator1TopLocationUnderTest);
            escalatorEntity.Setup(e => e.bottom_location)
            .Returns(() => escalator1BottomLocationUnderTest);
            escalatorEntity.Setup(e => e.type)
            .Returns(() => EntityType.Escalator);

            //Mock Eel2
            var eel2Entity = new Mock <IEntity>();

            eel2Entity.Setup(e => e.top_location)
            .Returns(() => eel2TopLocationUnderTest);
            eel2Entity.Setup(e => e.bottom_location)
            .Returns(() => eel2BottomLocationUnderTest);
            eel2Entity.Setup(e => e.type)
            .Returns(() => EntityType.Eel);

            //Mock Escalator2
            var escalator2Entity = new Mock <IEntity>();

            escalator2Entity.Setup(e => e.top_location)
            .Returns(() => escalator2TopLocationUnderTest);
            escalator2Entity.Setup(e => e.bottom_location)
            .Returns(() => escalator2BottomLocationUnderTest);
            escalator2Entity.Setup(e => e.type)
            .Returns(() => EntityType.Escalator);

            //List
            entitiesUnderTest = new List <IEntity>();
            entitiesUnderTest.Add(eelEntity.Object);
            entitiesUnderTest.Add(escalatorEntity.Object);
            entitiesUnderTest.Add(eel2Entity.Object);
            entitiesUnderTest.Add(escalator2Entity.Object);

            Creator = () =>
            {
                var result = new ClassicBoard();
                result.Entities = entitiesUnderTest;
                result.Pawns    = pawnsUnderTest;
                return(result);
            };
        }