Monday, December 31, 2012

Notoriously Databased v0.41

After a couple more play sessions there have been some more bugs to squish, some wierd strategies to rebalance and some UI recommendations to help smooth out the game's flow.

First off the list was to fix an abuse of the win condition by popping yourself over the notoriety limit for 2 turns in succession. I was sure i'd covered this by checking for a wipe on the winning turn, but it needed a check for wipes on the turn before as well to catch this devious little strat.

The turn submission screen also now has a notoriety list to help gauge where you are in relation to the notoriety limit and others. this has added a bit more informaiton at your fingertips to make your choice for next turn, but has also turned the submission screen into somewhat of a knowledge store for the game too. The recommendation to place the story on there is most likely as a response from relying more and more on the informaiton at hand rather than really reading and digesting exactly what's going on in the region.

To add the story to the submission screen I wanted to try a partial view so that the same information could be displayed there as well as in its current location. Because the view has already been set up I didn't think it would be too hard to turn it into a partial view.

It turns out that there are a number of different ways of making a partial view. What i really wanted was to call the same action that currently exists as it has a ViewModel and custom data gathering script already in place and a major part of what I didn't want to replicate, so calling the partial view using @Html.Action was the way to go.

After a couple of tests it turned out to be a fairly simple change:
 - Replicate CharacterCurrentStory into PartialCharacterCurrentStory in both the controller and view
 - Set PartialCharacterCurrentStory controller to return a PartialViewResult
 - Strip down PartialCharacterCurrentStory view to only show the table of messages fit for both views.
 - Strip down the old CharacterCurrentStory view to only show the headings and page setup
 - Call the PartialCharacterCurrentStory using @Html.Action()
 - Add the same call to the character submission
 - Strip down the old CharacterCurrentStory controller to only pass in the current character rather than the stories. 
 - Lock down PartialCharacterCurrentStory to only be called as a child action (probably not required, but handy to know)

Here's the end result for the controller:
        public ViewResult CharacterCurrentStory(int charID)
        {
            Character currentChar = db.Characters.Where(i => i.CharacterID == charID).SingleOrDefault();
            return View(currentChar);
        }


        [ChildActionOnly]
        public PartialViewResult PartialCharacterCurrentStory(int charID)
        {
            Character currentChar = db.Characters.Where(i => i.CharacterID == charID).SingleOrDefault();
            int currentStoryTurn = (int)db.Storys.Where(i => i.CharacterID == charID && (i.Turn.GameID == currentChar.GameID)).OrderByDescending(u => u.TurnID).FirstOrDefault().TurnID;
            var storys = db.Storys.Include("Character").Include("Turn").Where(i => i.TurnID == currentStoryTurn && (i.CharacterID == charID || i.isPublic == 1));
            return PartialView(storys.ToList());
        }