Exemple #1
0
        //                                                                                     GAME LOBBY
        public ActionResult GameLobby(FormCollection collection)
        {
            string id = Session.SessionID;

            ViewBag.Id = id;
            GameLobby thisLobby = FindGameLobby(FindUser(id).InGameId.ToString());

            // start game button pressed
            if (collection["formType"] == "newGame")
            {
                GameInstruction instruction = CreateGameInstruction(thisLobby);
                GameStateModel  model       = UpdateGame(instruction);
                //flag game as started
                thisLobby.Started = true;
                //go to game page
                return(View("Game", model));
            }
            //auto redirect when game starts
            if (collection["poke"] == "refresh")
            {
                if (!GameStarted(collection["gameId"]))
                {
                    return(View(thisLobby));
                    //return new HttpStatusCodeResult(304, "Not Modified"); does not work with explorer
                }
                else
                {
                    return(View("Game", SettlersOfCatan.FindGame(thisLobby.Id)));
                }
            }
            // joined lobby successfully
            return(View(thisLobby));
        }
Exemple #2
0
        //                                                                                     SANDBOX
        public ActionResult Sandbox()
        {
            ViewBag.Id         = Session.SessionID;
            ViewBag.Settlement = @"\\Content\\Images\\doodad\\Settlement.png"; //not in use
            ViewBag.City       = @"\\Content\\Images\\doodad\\City.png";       //not in use
            //set up fake game for testing
            //   ----- FAKE DATA -----
            GameInstruction instruction = new GameInstruction();

            instruction.Type          = GameInstruction.InstructionType.newGame;
            instruction.GameId        = Guid.NewGuid();
            instruction.BoardTemplate = BoardState.BoardOptions.tutorial;

            //populate game with players
            instruction.NewGamePlayers   = new List <string>();
            instruction.NewGamePlayersId = new List <string>();

            instruction.NewGamePlayers.Add("Frodo");
            instruction.NewGamePlayersId.Add(Session.SessionID);

            instruction.NewGamePlayers.Add("Sam");
            instruction.NewGamePlayersId.Add(Session.SessionID);

            instruction.NewGamePlayers.Add("Gandalf");
            instruction.NewGamePlayersId.Add(Session.SessionID);

            instruction.NewGamePlayers.Add("Gimli");
            instruction.NewGamePlayersId.Add(Session.SessionID);
            //   ----- FAKE DATA END -----

            GameStateModel model = UpdateGame(instruction);

            return(View("Game", model));
        }
Exemple #3
0
 void Start()
 {
     scoreManager  = GameObject.FindGameObjectWithTag("Manager").GetComponent <ScoreManager>();
     gis           = GameObject.FindGameObjectWithTag("GetIn").GetComponent <GameInstruction>();
     renderer      = GetComponent <SpriteRenderer>();
     deltaMovement = new Vector2(0f, 0f);
 }
Exemple #4
0
        private GameInstruction NormalGameInstruction(FormCollection collection)
        {
            GameInstruction result = new GameInstruction()
            {
            };

            result.Type   = GameInstruction.InstructionType.normal;
            result.GameId = FindUser(Session.SessionID).InGameId;
            if (collection["setup"] == "true")
            {
                result.RoadChange.Add(Convert.ToInt32(collection["roadChange"]));
                result.SettlementChange.Add(Convert.ToInt32(collection["settlementChange"]));
                result.StartingResources = Convert.ToBoolean(collection["collectResources"]);
            }
            return(result);
        }
Exemple #5
0
        public void LongestRoadLength_()
        {
            // Arrange
            GameInstruction gameInstruction = new GameInstruction();
            GameStateModel  game            = new GameStateModel(gameInstruction);

            //game.ActivePlayer = new Player("player1", "id1");

            game.ActivePlayer.Inventory.Brick = 3;
            PlayerAction pa = new PlayerAction(game);

            // Act
            pa.BuildRoad(23);

            // Assert
            Assert.AreEqual(2, game.ActivePlayer.Inventory.Brick);
        }
Exemple #6
0
        private GameInstruction CreateGameInstruction(GameLobby gameLobby)
        {
            List <User> tempList = new List <User>();

            tempList.AddRange(Randomize(gameLobby.Participants));
            gameLobby.Participants.Clear();
            gameLobby.Participants.AddRange(tempList);
            GameInstruction result = new GameInstruction
            {
                Type          = GameInstruction.InstructionType.newGame,
                GameId        = gameLobby.Id,
                BoardTemplate = gameLobby.Template
            };

            //populate game with players
            result.NewGamePlayers   = new List <string>();
            result.NewGamePlayersId = new List <string>();
            for (int i = 0; i < gameLobby.Participants.Count; i++)
            {
                result.NewGamePlayers.Add(gameLobby.Participants[i].Name);
                result.NewGamePlayersId.Add(gameLobby.Participants[i].Id);
            }
            return(result);
        }
Exemple #7
0
 void Start()
 {
     scoreManager = GameObject.FindGameObjectWithTag("Manager").GetComponent<ScoreManager>();
     gis = GameObject.FindGameObjectWithTag("GetIn").GetComponent<GameInstruction>();
     renderer = GetComponent<SpriteRenderer>();
     deltaMovement = new Vector2(0f,0f);
 }
Exemple #8
0
        public override void Move(MoveType mtype, float value, bool frameFactor, GameInstruction instruction)
        {
            WantNext next = new WantNext();
            next.type = mtype;
            next.value = value;
            next.frameFactor = frameFactor;
            next.instruction = instruction;

            wantNext.Enqueue(next);
        }
Exemple #9
0
 private GameStateModel UpdateGame(GameInstruction instruction)
 {
     return(SettlersOfCatan.ExecuteInstruction(instruction));
 }
 public abstract void Move(MoveType mtype, float value, bool frameFactor, GameInstruction instruction);
Exemple #11
0
 public override void Move(MoveType mtype, float value, bool frameFactor, GameInstruction instruction)
 {
     throw new NotImplementedException();
 }