Exemplo n.º 1
0
        public void ModelFacade_CanAffordMove()
        {
            PCModel         workingPCM = gs.GetPCM();
            PlayerCharacter workingPC  = workingPCM.GetPC();

            Assert.AreEqual(80, workingPC.GetResource(PlayerCharacter.HEALTH), "Health should be 80");
            Assert.AreEqual(50, workingPC.GetResource(PlayerCharacter.HUNGER), "Hunger should be 50");
            Assert.AreEqual(60, workingPC.GetResource(PlayerCharacter.THIRST), "Thirst should be 60");
            Assert.AreEqual(70, workingPC.GetResource(PlayerCharacter.SANITY), "Sanity should be 70");
            Assert.IsTrue(mf.CanAffordMove(gs, ModelFacade.LOCATION_MOVE_COST), "Move should be possible");

            mf.ReduceResourcesByMoveCost(gs, ModelFacade.LOCATION_MOVE_COST);
            Assert.IsTrue(mf.CanAffordMove(gs, ModelFacade.LOCATION_MOVE_COST), "Move should be possible");
            mf.ReduceResourcesByMoveCost(gs, ModelFacade.LOCATION_MOVE_COST);
            Assert.IsTrue(mf.CanAffordMove(gs, ModelFacade.LOCATION_MOVE_COST), "Move should be possible");
            mf.ReduceResourcesByMoveCost(gs, ModelFacade.LOCATION_MOVE_COST);
            Assert.IsTrue(mf.CanAffordMove(gs, ModelFacade.LOCATION_MOVE_COST), "Move should be possible");
            mf.ReduceResourcesByMoveCost(gs, ModelFacade.LOCATION_MOVE_COST);

            Assert.IsFalse(mf.CanAffordMove(gs, ModelFacade.LOCATION_MOVE_COST), "Move should not be possible");
            Assert.AreEqual(80, workingPC.GetResource(PlayerCharacter.HEALTH), "Health should be 80");
            Assert.AreEqual(10, workingPC.GetResource(PlayerCharacter.HUNGER), "Hunger should be 10");
            Assert.AreEqual(20, workingPC.GetResource(PlayerCharacter.THIRST), "Thirst should be 20");
            Assert.AreEqual(70, workingPC.GetResource(PlayerCharacter.SANITY), "Sanity should be 70");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Change location to location provided
        /// </summary>
        /// <param name="locationID">Id of the location to change to</param>
        /// <returns>If the move was sucessful</returns>
        public bool ChangeLocation(int locationID)
        {
            bool visited = true;

            var cost = Convert.ToInt32(mf.CalculateMoveCost(gs, locationID));

            if (mf.GetCurrentLocation(gs) == locationID || !gameView.DrawYesNoOption("Are you sure you wish to move to this location?\n\nIt will cost you " + cost + " hunger and thirst"))
            {
                return(false);
            }
            else if (!mf.CanAffordMove(gs, cost) && gameView.DrawYesNoOption("You do not have sufficient resources. Do you wish to risk it all?"))
            {
                int risk = rnd.Next(1, 101);
                if (risk <= 25)
                {
                    visited = PerformMove(locationID);
                }
                else
                {
                    mf.ReduceResourcesByMoveCost(gs, cost);
                    return(false);
                }
            }
            else if (mf.CanAffordMove(gs, cost))
            {
                mf.ReduceResourcesByMoveCost(gs, cost);
                visited = PerformMove(locationID);
            }
            else
            {
                return(false);
            }
            if (mf.IsGameOver(gs) || IsEndLocation())
            {
                return(true);
            }
            delayEventCheck(visited);
            return(true);
        }