Exemplo n.º 1
0
        public void Field_CheckValidPosition()
        {
            var table = new Tabletop(new Size(5, 5));

            //check all positions and extra boundaries
            for (int i = 0; i < table.TableSize.Width; i++)
            {
                for (int j = 0; j < table.TableSize.Height; j++)
                {
                    Assert.IsTrue(table.IsValidPosition(new Point {
                        X = i, Y = j
                    }));
                    Assert.IsFalse(table.IsValidPosition(new Point {
                        X = -1, Y = j
                    }));
                    Assert.IsFalse(table.IsValidPosition(new Point {
                        X = i, Y = -1
                    }));
                    Assert.IsFalse(table.IsValidPosition(new Point {
                        X = table.TableSize.Width, Y = j
                    }));
                    Assert.IsFalse(table.IsValidPosition(new Point {
                        X = i, Y = table.TableSize.Height
                    }));
                }
            }
        }
Exemplo n.º 2
0
    static void Main(string[] args)
    {
        Tabletop t = new Tabletop(7.5, 8.03);

        t.Display();
        Console.ReadLine();
    }
Exemplo n.º 3
0
        public DiningTable()
        {
            LegOne = new TableLeg()
            {
                height = 2 * 3, radius = 10
            };
            LegTwo = new TableLeg()
            {
                height = 1, radius = 5
            };

            MoreLegs.Add(new TableLeg()
            {
                height = 4
            });
            MoreLegs.Add(new TableLeg()
            {
                height = 10
            });

            Tabletop = new Tabletop()
            {
                length = 200, width = 12, thickness = 3
            };
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Tabletop obj = new Tabletop(4.5, 7.5);

            obj.Display();
            Console.ReadLine();
        }
Exemplo n.º 5
0
        public void Robot_TestMultipleMovement_RobotReportsCorrectLocation()
        {
            Robot          robot     = new Robot();
            Tabletop       table     = new Tabletop(5, 5);
            RobotCommander commander = new RobotCommander();

            PlaceCommand place = new PlaceCommand(robot, table);

            place.Direction = "North";
            MoveCommand  move  = new MoveCommand(robot, table);
            RightCommand right = new RightCommand(robot);
            LeftCommand  left  = new LeftCommand(robot);


            commander.Commands.Enqueue(place);
            commander.Commands.Enqueue(move);
            commander.Commands.Enqueue(move);
            commander.Commands.Enqueue(right);
            commander.Commands.Enqueue(move);
            commander.Commands.Enqueue(left);
            commander.Commands.Enqueue(left);

            commander.ExecuteCommands();

            Assert.Equal(Facing.West, robot.Direction);
            Assert.Equal(2, robot.Position.Y);
            Assert.Equal(1, robot.Position.X);
        }
Exemplo n.º 6
0
        public void Robot_TestUndoWhenWhenRobotIsStuckAgainstSouthWall_RobotReportsOrignalPosition()
        {
            Robot          robot     = new Robot();
            Tabletop       table     = new Tabletop(5, 5);
            RobotCommander commander = new RobotCommander();

            PlaceCommand place = new PlaceCommand(robot, table);

            place.Direction = "North";
            MoveCommand  move  = new MoveCommand(robot, table);
            RightCommand right = new RightCommand(robot);
            LeftCommand  left  = new LeftCommand(robot);


            commander.Commands.Enqueue(place);
            commander.Commands.Enqueue(right);
            commander.Commands.Enqueue(right);
            commander.Commands.Enqueue(move);

            commander.ExecuteCommands();
            commander.UndoCommands(1);

            Assert.Equal(0, robot.Position.Y);
            Assert.Equal(0, robot.Position.X);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Rectangle Rect = new Rectangle();

            Rect.setWidth(5);
            Rect.setHeight(7);
            Rect.getArea()


            Tabletop t = new Tabletop(4.5, 7.5);

            t.Display();
        }
Exemplo n.º 8
0
        public async Task Connect(string roomCode, RoomBase room, NavigationManager navManager, IJSRuntime jsRuntime, Tabletop tabletop)
        {
            JSRuntime         = jsRuntime;
            NavigationManager = navManager;
            RoomCode          = roomCode;
            Room     = room;
            Tabletop = tabletop;
            bool newConnection = false;

            if (!Networker.IsConnected)
            {
                newConnection = true;
                await Networker.Connect(NavigationManager.ToAbsoluteUri("/gamehub"));
            }

            if (Networker.IsConnected)
            {
                if (!newConnection)
                {
                    MessageReset();
                }
                Networker.hubConnection.On("Error:RoomNotFound", Redirect);
                Networker.hubConnection.On("Error:PlayerNotFound", Redirect);

                Networker.hubConnection.On <bool, List <PlayerEntity>, string, bool, List <Image> >("Sync:TabletopInfo", Room.SyncTabletop);
                Networker.hubConnection.On <List <Entity> >("Sync:CombatOrder", Room.UpdateCombatOrder);

                Networker.hubConnection.On <string>("Set:PlayerUID", UpdateUID);
                Networker.hubConnection.On <bool, string, string>("Set:PlayerStatus", Room.UpdatePlayerStatus);
                Networker.hubConnection.On <Message>("Set:Message", Room.RenderMessage);

                Networker.hubConnection.On("Player:Kick", HandleKick);

                Networker.hubConnection.On <String, string, int[], int, int[], List <Cell>, bool, bool>("Tabletop:LoadImage", Room.RenderTabletopFromImage);
                Networker.hubConnection.On("Tabletop:Clear", Room.ClearTabletop);
                Networker.hubConnection.On <List <PlayerEntity> >("Tabletop:RenderPlayerEntities", Room.RenderPlayerEntities);
                Networker.hubConnection.On <List <Creature> >("Tabletop:RenderCreatureEntities", Room.RenderCreatureEntities);
                Networker.hubConnection.On <List <NPC> >("Tabletop:RenderNPCEntities", Room.RenderNPCEntities);
                Networker.hubConnection.On <int, string>("Tabletop:SyncCells", Room.SyncCells);
                Networker.hubConnection.On <string, int[]>("Tabletop:UpdateEntityPosition", UpdateEntityPosition);
                Networker.hubConnection.On <bool>("Tabletop:UpdateLock", Room.UpdateLock);
                Networker.hubConnection.On <Image>("Tabletop:LoadPopupImage", RenderPopupImage);
                Networker.hubConnection.On <bool>("Tabletop:ToggleVisibility", Room.SetTabletopVisibility);
                Networker.hubConnection.On <List <Light> >("Tabletop:RenderLightEntities", Room.RenderLightEntities);
                Networker.hubConnection.On <bool>("Tabletop:UpdateDiceRolls", Room.UpdateDiceRolls);

                Networker.hubConnection.On <string>("Notification:PlayerConnected", ConnectedNotification);
                Networker.hubConnection.On <string, string>("Notification:PlayerDisconnected", DisconnectedNotification);
                Networker.hubConnection.On <string>("Notification:PlayerReconnected", ReconnectedNotification);
                Networker.hubConnection.On <string>("Notification:PlayerKicked", KickNotification);
                Networker.hubConnection.On("Notification:TakeTurn", TakeTurnNotification);
                Networker.hubConnection.On("Notification:OnDeck", OnDeckNotification);
                Networker.hubConnection.On <string>("Notification:EntityOnDeck", EntityOnDeckNotification);
                Networker.hubConnection.On <int, int>("Notification:Ping", Room.RenderPing);
                Networker.hubConnection.On <int, string, string, string>("Notification:Roll", Room.RenderRollNotification);

                Networker.hubConnection.On <string>("Entity:RenderDeathCelebration", RenderDeathCelebration);
                Networker.hubConnection.On <Entity, string>("Entity:UpdateCondition", Room.UpdateEntityCondition);
                Networker.hubConnection.On <Entity>("Entity:ToggleVisibility", Room.UpdateEntityVisibility);
                Networker.hubConnection.On <string, int>("Entity:UpdateFoV", Room.UpdateEntityFoV);
            }

            if (newConnection && Networker.IsConnected)
            {
                string uid = await JSRuntime.InvokeAsync <string>("GetPlayerUID");

                Tabletop.UID = uid;
                if (String.IsNullOrEmpty(uid))
                {
                    Redirect();
                }
                else
                {
                    await Networker.hubConnection.SendAsync("Player:Resync", RoomCode, uid);
                }
            }

            await Networker.hubConnection.SendAsync("Player:GetStatus");

            await Networker.hubConnection.SendAsync("Player:SyncTabletopInfo");
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Triangle t = new Tabletop(4.5, 7.5);

            t.Display();
        }