public void ModelFacade_MoveToLocation() { LocationModel workingLM = gs.GetLM(); Assert.AreEqual(locations[18].ParseToString(), workingLM.GetCurentLocation().ParseToString(), "Location should be location 19"); Assert.IsTrue(mf.ChangeLocation(gs, 20), "Moving to 20 should be successful"); Assert.AreEqual(locations[19].ParseToString(), workingLM.GetCurentLocation().ParseToString(), "Location should now be location 20"); Assert.IsFalse(mf.ChangeLocation(gs, 20), "Moving to 20 should be unsuccessful"); Assert.AreEqual(locations[19].ParseToString(), workingLM.GetCurentLocation().ParseToString(), "Location should still be location 20"); Assert.IsTrue(mf.ChangeLocation(gs, 21), "Moving to 21 should be successful"); Assert.AreEqual(21, workingLM.GetCurentLocation().GetLocationID(), "Location should now be location 21"); }
/// <summary> /// Changes the current location dependant on if the new location has been visisted previously or not /// </summary> /// <param name="locationID">The location to move to</param> /// <returns>Bool representing if the location was a visited one or not</returns> private bool PerformMove(int locationID) { if (mf.LocationVisited(gs, locationID)) { // Thread 1 - Change location var task1 = Task.Factory.StartNew(() => { mf.ChangeLocation(gs, locationID); }); // Main Thread - Animate movement gameView.AnimateFrames(null); Task.WaitAll(task1); delayEndAnimation(); return(true); } else { // Thread 1 - Recalculate Difficulty var task1 = Task.Factory.StartNew(() => { dc.UpdatePlayerStatus(gs.Clone() as GameState); dc.UpdateStatusTracker(); }); // Thread 2 - Change location var task2 = Task.Factory.StartNew(() => { mf.ChangeLocation(gs, locationID); }); // Main Thread - Animate movement gameView.AnimateFrames(null); Task.WaitAll(task1, task2); delayEndAnimation(); return(false); } }