public void MoveByRoadOrSea(GameState g, LocationDetail goingTo, UserInterface ui) { Logger.WriteToDebugLog("Moving Dracula to a new location"); Logger.WriteToDebugLog("Remembering that Dracula is moving from a location of type " + CurrentLocation.Type); LocationType previousLocationType = CurrentLocation.Type; if (PossibleMoves.Count() == 0) { Logger.WriteToDebugLog("SOMEHOW DRACULA IS TRYING TO MOVE WHEN HE HAS NO POSSIBLE MOVES"); } try { Logger.WriteToDebugLog("Dracula is moving from " + CurrentLocation.Name + " to " + goingTo.Name); CurrentLocation = goingTo; } catch (ArgumentOutOfRangeException) { ui.TellUser("Dracula tried to do something illegal"); Logger.WriteToDebugLog("DRACULA TRIED TO DO SOMETHING ILLEGAL"); } Logger.WriteToDebugLog("Adding " + CurrentLocation.Name + " to the head of the trail"); LocationTrail.Insert(0, CurrentLocation); MovePowersAlongTrail(); CheckBloodLossAtSea(previousLocationType, g.NameOfHunterAlly()); Logger.WriteToDebugLog("Checking if Dracula is in Castle Dracula"); if (CurrentLocation.Type == LocationType.Castle) { Logger.WriteToDebugLog("Revealing Castle Dracula"); CurrentLocation.IsRevealed = true; if (LocationWhereHideWasUsed != null) { if (LocationWhereHideWasUsed.Type == LocationType.Castle) { Logger.WriteToDebugLog("Also revealing Hide as it was used at Castle Dracula"); RevealHide(ui); } } } }
internal void drawGameState(GameState g) { // top line, trail headers, time header, Dracula blood and Vampire track header, Catacombs header, Dracula cards header Console.WriteLine("6th 5th 4th 3rd 2nd 1st Time Blood Vampires Catacombs Events"); // second line, trail cards, time, Dracula blood, Vampires, Catacombs cards, Events // trail cards for (int i = 5; i >= 0; i--) { if (i + 1 > g.TrailLength()) { Console.Write(" "); } else { g.DrawLocationAtTrailIndex(i); } } string timeOfDay = g.TimeOfDay(); switch (timeOfDay) { case "Dawn": Console.ForegroundColor = ConsoleColor.DarkYellow; break; case "Noon": Console.ForegroundColor = ConsoleColor.Yellow; break; case "Dusk": Console.ForegroundColor = ConsoleColor.DarkYellow; break; case "Twilight": Console.ForegroundColor = ConsoleColor.Cyan; break; case "Midnight": Console.ForegroundColor = ConsoleColor.Blue; break; case "Small Hours": Console.ForegroundColor = ConsoleColor.Cyan; break; } // time of day Console.Write(" " + timeOfDay); Console.ForegroundColor = ConsoleColor.Red; for (int i = 0; i < (12 - timeOfDay.Length); i++) { Console.Write(" "); } // Dracula blood Console.Write(g.DraculaBloodLevel()); Console.ResetColor(); for (int i = 0; i < (9 - g.DraculaBloodLevel().ToString().Length); i++) { Console.Write(" "); } // Vampire tracker Console.Write(Math.Max(0, g.VampireTracker())); for (int i = 0; i < (10 - g.VampireTracker().ToString().Length); i++) { Console.Write(" "); } Console.ForegroundColor = ConsoleColor.Red; // Catacombs cards for (int i = 0; i < 3; i++) { if (!g.LocationIsEmptyAtCatacombIndex(i)) { if (g.LocationIsRevealedAtCatacombIndex(i)) { Console.Write(g.LocationAbbreviationAtCatacombIndex(i) + " "); } else { Console.Write("### "); } } else { Console.Write(" "); } } Console.ResetColor(); // Events Console.WriteLine(" " + g.NumberOfEventCardsInDraculaHand()); // third line power cards, Console.ForegroundColor = ConsoleColor.DarkGreen; string tempString; // power cards for (int counter = 5; counter > -1; counter--) { tempString = " "; for (int i = 0; i < g.NumberOfDraculaPowers(); i++) { if (g.DraculaPowerAtPowerIndexIsAtLocationIndex(i, counter) && g.DraculaPowerNameAtPowerIndex(i) != "Hide" && g.DraculaPowerNameAtPowerIndex(i) != "Dark Call" && g.DraculaPowerNameAtPowerIndex(i) != "Feed") { tempString = g.DraculaPowerNameAtPowerIndex(i).Substring(0, 3).ToUpper() + " "; } } Console.Write(tempString); } Console.ForegroundColor = ConsoleColor.Red; Console.Write(" "); // first Catacombs encounters for (int i = 0; i < 3; i++) { if (!g.LocationIsEmptyAtCatacombIndex(i)) { if (g.NumberOfEncountersAtLocationAtCatacombIndex(i) > 0) { g.DrawEncounterAtCatacombIndex(i); } } else { Console.Write(" "); } } Console.WriteLine(""); // fourth line trail encounters, ally headers, second Catacomb encounters // trail encounters for (int i = 5; i > -1; i--) { if (i + 1 > g.TrailLength()) { Console.Write(" "); } else { g.DrawEncounterAtTrailIndex(i); } } Console.ResetColor(); // ally headers Console.Write(" Dracula's Ally Hunters' Ally"); // second Catacomb encounters for (int i = 0; i < 3; i++) { if (!g.LocationIsEmptyAtCatacombIndex(i)) { if (g.NumberOfEncountersAtLocationAtCatacombIndex(i) > 0) { g.DrawEncounterAtCatacombIndex(i, true); } } else { Console.Write(" "); } } Console.WriteLine(""); // fifth line, ally names Console.Write(" "); Console.ResetColor(); if (g.DraculaHasAlly()) { Console.Write(g.NameOfDraculaAlly().Substring(0, 3).ToUpper()); } else { Console.Write(" "); } Console.Write(" "); if (g.HuntersHaveAlly()) { Console.Write(g.NameOfHunterAlly().Substring(0, 3).ToUpper()); } else { Console.Write(" "); } Console.ResetColor(); Console.WriteLine(""); // sixth line, nothing Console.WriteLine(""); // seventh line, resolve header Console.WriteLine(" Resolve"); // eighth line, resolve value Console.WriteLine(" " + Math.Max(0, g.ResolveTracker())); }
public void DoDoubleBackMove(GameState g, LocationDetail goingTo, UserInterface ui) { Logger.WriteToDebugLog("Remembering that Dracula is moving from a location of type " + CurrentLocation.Type); LocationType previousLocationType = CurrentLocation.Type; bool doublingBackToCatacombs = false; int doubleBackIndex = LocationTrail.FindIndex(location => location == goingTo); if (doubleBackIndex > -1) { Logger.WriteToDebugLog("Doubling back to a location in the trail"); if (doubleBackIndex > 0) { if (LocationTrail[doubleBackIndex - 1].Name == "Hide") { Logger.WriteToDebugLog("Dracula Doubled Back to " + goingTo + " and Hide is the next card in the trail"); ui.TellUser("Dracula Doubled Back to a location where he previously used Hide (position " + (doubleBackIndex - 1) + ")"); RevealHide(doubleBackIndex - 1, ui); } else if (doubleBackIndex > 1) { if (LocationTrail[doubleBackIndex - 1].Type == LocationType.Power && LocationTrail[doubleBackIndex - 2].Name == "Hide") { Logger.WriteToDebugLog("Dracula Doubled Back to " + goingTo + " and Hide is the next card in the trail, after " + LocationTrail[doubleBackIndex - 1].Name); ui.TellUser("Dracula Doubled Back to a location where he previously used Hide (position " + (doubleBackIndex - 1) + ")"); RevealHide(doubleBackIndex - 2, ui); } else if (doubleBackIndex > 2) { if (LocationTrail[doubleBackIndex - 1].Type == LocationType.Power && LocationTrail[doubleBackIndex - 2].Type == LocationType.Power && LocationTrail[doubleBackIndex - 3].Name == "Hide") { Logger.WriteToDebugLog("Dracula Doubled Back to " + goingTo + " and Hide is the next card in the trail, after " + LocationTrail[doubleBackIndex - 1].Name + " and " + LocationTrail[doubleBackIndex - 2].Name); ui.TellUser("Dracula Doubled Back to a location where he previously used Hide (position " + (doubleBackIndex - 1) + ")"); RevealHide(doubleBackIndex - 3, ui); } } } } else { Logger.WriteToDebugLog("TRIED TO DOUBLE BACK TO A LOCATION WHEN THERE ARE NONE IN THE LIST"); } } else { Logger.WriteToDebugLog("Doubling back to a location in the Catacombs"); doublingBackToCatacombs = true; } int doubleBackLocation = LocationTrail.FindIndex(loc => loc == goingTo); // move location to the front of the trail Logger.WriteToDebugLog("Temporarily holding " + goingTo.Name); if (doublingBackToCatacombs) { Logger.WriteToDebugLog("Removing " + goingTo.Name + " from the Catacombs"); Catacombs[Array.IndexOf(Catacombs, goingTo)] = null; EncounterDetail encounterToDiscard = logic.DecideWhichCatacombsEncounterToDiscard(g, goingTo, ui); goingTo.Encounters.Remove(encounterToDiscard); g.AddEncounterToEncounterPool(encounterToDiscard); } else { Logger.WriteToDebugLog("Removing " + goingTo.Name + " from the trail"); LocationTrail.Remove(goingTo); } Logger.WriteToDebugLog("Putting " + goingTo.Name + " back at the head of the trail"); LocationTrail.Insert(0, goingTo); Logger.WriteToDebugLog("Dracula's current location is now " + CurrentLocation.Name); CurrentLocation = LocationTrail[0]; Logger.WriteToGameLog("Dracula Doubled Back to " + CurrentLocation.Name + " from " + (doublingBackToCatacombs ? " the Catacombs" : " his trail")); // move the power cards that are in the trail for (int i = 0; i < Powers.Count(); i++) { if (Powers[i].positionInTrail == doubleBackLocation) { Logger.WriteToDebugLog("Moving Double Back power position to the head of the trail"); Powers[i].positionInTrail = 0; } else if (Powers[i].positionInTrail < doubleBackLocation) { Logger.WriteToDebugLog("Moving power " + Powers[i].name + " position further along the trail"); Powers[i].positionInTrail++; } } CheckBloodLossAtSea(previousLocationType, g.NameOfHunterAlly()); }