本文整理汇总了C#中FuryOfDracula.GameLogic.GameState类的典型用法代码示例。如果您正苦于以下问题:C# GameState类的具体用法?C# GameState怎么用?C# GameState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameState类属于FuryOfDracula.GameLogic命名空间,在下文中一共展示了GameState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddBlueBackedCardToTrail
public List<PossibleTrailSlot[]> AddBlueBackedCardToTrail(GameState game, PossibleTrailSlot[] trail)
{
List<PossibleTrailSlot[]> newPossibilityTree = new List<PossibleTrailSlot[]>();
Location currentLocation = Location.Nowhere;
for (int i = 0; i < 6; i++)
{
if (trail[i].Location != Location.Nowhere)
{
currentLocation = trail[i].Location;
break;
}
}
List<PossibleTrailSlot> possibleCards = new List<PossibleTrailSlot>();
List<Location> possibleLocations = game.Map.LocationsConnectedBySeaTo(currentLocation);
foreach (Location location in possibleLocations)
{
if (!TrailContainsLocation(trail, location) && game.Map.TypeOfLocation(location) == LocationType.Sea && !game.LocationIsBlocked(location))
{
possibleCards.Add(new PossibleTrailSlot(location, Power.None, game.TimeOfDay, CardBack.Blue));
}
}
foreach (PossibleTrailSlot possibleCard in possibleCards)
{
PossibleTrailSlot[] newTrail = new PossibleTrailSlot[6];
for (int i = 5; i > 0; i--)
{
newTrail[i] = trail[i - 1];
}
newTrail[0] = possibleCard;
newPossibilityTree.Add(newTrail);
}
return newPossibilityTree;
}
开发者ID:UncleGus,项目名称:dracula,代码行数:33,代码来源:DecisionMaker.cs
示例2: AddEventCardToDraculaKnownCardsIfNotAlreadyKnown
/// <summary>
/// Checks if a given Event card is already known by Dracula to be in a given Hunter's hand and adds it if not
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="hunterRevealingCard">The Hunter revealing the card</param>
/// <param name="eventBeingRevealed">The Event being revealed</param>
/// <returns>The card corresponding to the Event revealed</returns>
private static EventCard AddEventCardToDraculaKnownCardsIfNotAlreadyKnown(GameState game,
HunterPlayer hunterRevealingCard, Event eventBeingRevealed)
{
var eventCardBeingRevealed =
hunterRevealingCard.EventsKnownToDracula.Find(card => card.Event == eventBeingRevealed);
if (eventCardBeingRevealed == null)
{
eventCardBeingRevealed = game.EventDeck.Find(card => card.Event == eventBeingRevealed);
game.EventDeck.Remove(eventCardBeingRevealed);
hunterRevealingCard.EventsKnownToDracula.Add(eventCardBeingRevealed);
}
return eventCardBeingRevealed;
}
开发者ID:UncleGus,项目名称:dracula,代码行数:20,代码来源:Program.cs
示例3: AddBlueBackedCardToAllPossibleTrails
public void AddBlueBackedCardToAllPossibleTrails(GameState game)
{
List<PossibleTrailSlot[]> newPossibilityTree = new List<PossibleTrailSlot[]>();
foreach (PossibleTrailSlot[] trail in PossibilityTree)
{
Location currentLocation = Location.Nowhere;
for (int i = 0; i < 6; i++)
{
if (trail[i].Location != Location.Nowhere)
{
currentLocation = trail[i].Location;
break;
}
}
List<PossibleTrailSlot> possibleCards = new List<PossibleTrailSlot>();
List<Location> possibleLocations = game.Map.LocationsConnectedBySeaTo(currentLocation);
foreach (Location location in possibleLocations)
{
if (!TrailContainsLocation(trail, location) && game.Map.TypeOfLocation(location) == LocationType.Sea && !game.LocationIsBlocked(location))
{
possibleCards.Add(new PossibleTrailSlot(location, Power.None, game.TimeOfDay, CardBack.Blue));
}
}
foreach (PossibleTrailSlot possibleCard in possibleCards)
{
PossibleTrailSlot[] newTrail = new PossibleTrailSlot[6];
for (int i = 5; i > 0; i--)
{
newTrail[i] = trail[i - 1];
}
newTrail[0] = possibleCard;
newPossibilityTree.Add(newTrail);
}
}
PossibilityTree = newPossibilityTree;
if (PossibilityTree.Count() == 0)
{
Console.WriteLine("Dracula stopped believing he exists after running AddBlueBackedCardToAllPossibleTrails");
PossibilityTree.Add(GetActualTrail(game));
}
}
开发者ID:UncleGus,项目名称:dracula,代码行数:41,代码来源:DecisionMaker.cs
示例4: DraculaIsPlayingSeduction
/// <summary>
/// Determines if Dracula is playing Seduction at the start of an Encounter
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="logic">The artificial intelligence component</param>
/// <returns>True if Dracula successfully plays Seduction</returns>
private static bool DraculaIsPlayingSeduction(GameState game, DecisionMaker logic)
{
if (logic.ChooseToPlaySeduction(game))
{
Console.WriteLine("Dracula is playing Seduction");
game.Dracula.DiscardEvent(Event.Seduction, game.EventDiscard);
if (HunterPlayingGoodLuckToCancelDraculaEvent(game, Event.Seduction, Event.Seduction, logic) > 0)
{
Console.WriteLine("Seduction cancelled");
return false;
}
return true;
}
return false;
}
开发者ID:UncleGus,项目名称:dracula,代码行数:21,代码来源:Program.cs
示例5: UseItem
/// <summary>
/// Resolves a Hunter using an Item outside of combat
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="itemName">The string to be converted to the Item being used</param>
/// <param name="hunterIndex">The string to be converted to the Hunter using the Item</param>
private static void UseItem(GameState game, string itemName, string hunterIndex)
{
var index = 0;
var hunterUsingItem = Hunter.Nobody;
if (int.TryParse(hunterIndex, out index))
{
hunterUsingItem = game.GetHunterFromInt(index);
}
var line = "";
while (hunterUsingItem == Hunter.Nobody && index != -1)
{
Console.WriteLine("Who is using an Item? {0}= {1}, {2}= {3}, {4}= {5}, {6}= {7} (-1 to cancel)",
(int)Hunter.LordGodalming, Hunter.LordGodalming.Name(), (int)Hunter.DrSeward,
Hunter.DrSeward.Name(), (int)Hunter.VanHelsing, Hunter.VanHelsing.Name(), (int)Hunter.MinaHarker,
Hunter.MinaHarker.Name());
line = Console.ReadLine();
if (int.TryParse(line, out index))
{
if (index == -1)
{
Console.WriteLine("Cancelled");
return;
}
hunterUsingItem = game.GetHunterFromInt(index);
Console.WriteLine(hunterUsingItem.Name());
}
else
{
Console.WriteLine("I didn't understand that");
}
}
var itemBeingUsed = Enumerations.GetItemFromString(itemName);
while (itemBeingUsed == Item.None && line.ToLower() != "cancel")
{
Console.WriteLine("What is the name of the Item being used?");
line = Console.ReadLine();
itemBeingUsed = Enumerations.GetItemFromString(line);
}
if (line.ToLower() == "cancel")
{
Console.WriteLine("Cancelled");
return;
}
switch (itemBeingUsed)
{
case Item.Dogs:
Console.WriteLine("Dogs is now face up in front of {0}", hunterUsingItem.Name());
game.Hunters[(int)hunterUsingItem].SetDogsFaceUp(true);
AddItemCardToDraculaKnownCardsIfNotAlreadyKnown(game, game.Hunters[(int)hunterUsingItem], Item.Dogs); break;
case Item.LocalRumors:
var trailIndex = -1;
Console.WriteLine(
"In which trail position (1-6) or Catacombs position (7-9) would you like to reveal an Encounter?");
while (trailIndex == -1)
{
if (int.TryParse(Console.ReadLine(), out trailIndex))
{
if (trailIndex < 1 || trailIndex > 9)
{
trailIndex = -1;
}
}
}
if (trailIndex < 7)
{
game.Dracula.RevealEncountersAtPositionInTrail(trailIndex - 1);
}
else
{
if (game.Dracula.Catacombs[trailIndex - 7] != null &&
game.Dracula.Catacombs[trailIndex - 7].EncounterTiles.Count() > 1)
{
var encounterIndex = -1;
while (encounterIndex == -1)
{
Console.WriteLine("Which Encounter would you like to reveal? 1 or 2");
if (int.TryParse(Console.ReadLine(), out encounterIndex))
{
if (encounterIndex < 1 || encounterIndex > 2)
{
encounterIndex = -1;
}
}
}
game.Dracula.RevealEncounterAtPositionInTrail(game, trailIndex - 1, encounterIndex - 1);
}
else
{
game.Dracula.RevealEncountersAtPositionInTrail(trailIndex - 1);
}
}
game.Hunters[(int)hunterUsingItem].DiscardItem(game, Item.LocalRumors);
DrawGameState(game); break;
case Item.HolyWater:
//.........这里部分代码省略.........
开发者ID:UncleGus,项目名称:dracula,代码行数:101,代码来源:Program.cs
示例6: LikelihoodOfHavingItemOfType_1ItemKnown_Returns1
public void LikelihoodOfHavingItemOfType_1ItemKnown_Returns1()
{
GameState game = new GameState();
ItemCard knife = game.ItemDeck.Find(card => card.Item == Item.Knife);
vanHelsing.DrawItemCard();
vanHelsing.ItemsKnownToDracula.Add(knife);
game.ItemDeck.Remove(knife);
Assert.AreEqual(1, vanHelsing.LikelihoodOfHavingItemOfType(game, Item.Knife));
}
开发者ID:UncleGus,项目名称:dracula,代码行数:9,代码来源:HunterPlayerTests.cs
示例7: SetupGroup
/// <summary>
/// Adds and removes people from the given Hunter's group
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="hunterIndex">A string to be converted to the Hunter with whom to set up a group</param>
private static void SetupGroup(GameState game, string hunterIndex)
{
var hunterFormingGroup = Hunter.Nobody;
int index;
if (int.TryParse(hunterIndex, out index))
{
hunterFormingGroup = game.GetHunterFromInt(index);
}
var line = "";
while (hunterFormingGroup == Hunter.Nobody && index != -1)
{
Console.WriteLine(
"Who is forming a group? {0}= {1}, {2}= {3}, {4}= {5} (Mina Harker cannot lead a group, -1 to cancel)",
(int)Hunter.LordGodalming, Hunter.LordGodalming.Name(), (int)Hunter.DrSeward,
Hunter.DrSeward.Name(), (int)Hunter.VanHelsing, Hunter.VanHelsing.Name());
line = Console.ReadLine();
if (int.TryParse(line, out index))
{
if (index == -1)
{
Console.WriteLine("Cancelled");
return;
}
if (index == 4)
{
Console.WriteLine("Mina Harker cannot lead a group, add her to someone else's group instead");
}
else
{
hunterFormingGroup = game.GetHunterFromInt(index);
Console.WriteLine(hunterFormingGroup.Name());
}
}
else
{
Console.WriteLine("I didn't understand that");
}
}
while (index != -1)
{
Console.WriteLine("These are the people in {0}'s group:", hunterFormingGroup.Name());
foreach (var h in game.Hunters[(int)hunterFormingGroup].HuntersInGroup)
{
if (h != hunterFormingGroup)
{
Console.WriteLine(h.Name());
}
}
var hunterToAddOrRemove = Hunter.Nobody;
while (hunterToAddOrRemove == Hunter.Nobody && index != -1)
{
Console.WriteLine(
"Who is joining or leaving {0}'s group? {1}= {2}, {3}= {4}, {5}= {6} (Lord Godalming must lead any group he is in, -1 to cancel)",
hunterFormingGroup.Name(), (int)Hunter.DrSeward, Hunter.DrSeward.Name(),
(int)Hunter.VanHelsing, Hunter.VanHelsing.Name(), (int)Hunter.MinaHarker,
Hunter.MinaHarker.Name());
line = Console.ReadLine();
if (int.TryParse(line, out index))
{
if (index == -1)
{
Console.WriteLine("Cancelled");
return;
}
if (index == 1)
{
Console.WriteLine("Lord Godalming must lead any group he is in");
}
else
{
hunterToAddOrRemove = game.GetHunterFromInt(index);
Console.WriteLine(hunterFormingGroup.Name());
}
}
else
{
Console.WriteLine("I didn't understand that");
}
}
if ((int)hunterToAddOrRemove < (int)hunterFormingGroup)
{
Console.WriteLine("{0} cannot join {1}'s group, instead add {1} to {0}'s group",
hunterToAddOrRemove.Name(), hunterFormingGroup.Name());
}
else if (hunterToAddOrRemove == hunterFormingGroup)
{
Console.WriteLine("{0} is already in his own group, of course!", hunterFormingGroup.Name());
}
else if (game.Hunters[(int)hunterFormingGroup].HuntersInGroup.Contains(hunterToAddOrRemove))
{
game.Hunters[(int)hunterFormingGroup].HuntersInGroup.Remove(hunterToAddOrRemove);
}
else
{
game.Hunters[(int)hunterFormingGroup].HuntersInGroup.Add(hunterToAddOrRemove);
//.........这里部分代码省略.........
开发者ID:UncleGus,项目名称:dracula,代码行数:101,代码来源:Program.cs
示例8: DrawGameState
/// <summary>
/// Draws the gamestate on the screen
/// </summary>
/// <param name="game">The GameState</param>
private static void DrawGameState(GameState game)
{
// line 1
Console.WriteLine("Trail Catacombs Time Vampires Resolve Dracula Ally Hunter Ally");
// line 2
for (var i = 5; i >= 0; i--)
{
if (game.Dracula.Trail[i] != null)
{
Console.ForegroundColor = game.Dracula.Trail[i].DraculaCards.First().Color;
if (game.Dracula.Trail[i].DraculaCards.First().IsRevealed)
{
Console.Write(game.Dracula.Trail[i].DraculaCards.First().Abbreviation + " ");
}
else
{
Console.Write("### ");
}
}
else
{
Console.Write(" ");
}
}
Console.Write(" ");
for (var i = 0; i < 3; i++)
{
if (game.Dracula.Catacombs[i] != null)
{
Console.ForegroundColor = game.Dracula.Catacombs[i].DraculaCards.First().Color;
if (game.Dracula.Catacombs[i].DraculaCards.First().IsRevealed)
{
Console.Write(game.Dracula.Catacombs[i].DraculaCards.First().Abbreviation + " ");
}
else
{
Console.Write("### ");
}
}
else
{
Console.Write(" ");
}
}
switch (game.TimeOfDay)
{
case TimeOfDay.Dawn:
case TimeOfDay.Dusk:
Console.ForegroundColor = ConsoleColor.DarkYellow; break;
case TimeOfDay.Noon:
Console.ForegroundColor = ConsoleColor.Yellow; break;
case TimeOfDay.Midnight:
Console.ForegroundColor = ConsoleColor.Blue; break;
case TimeOfDay.Twilight:
case TimeOfDay.SmallHours:
Console.ForegroundColor = ConsoleColor.DarkBlue; break;
}
Console.Write(" {0}", game.TimeOfDay.Name());
Console.ResetColor();
for (var i = game.TimeOfDay.Name().Length; i < 14; i++)
{
Console.Write(" ");
}
Console.Write(game.Vampires);
for (var i = game.Vampires.ToString().Length; i < 11; i++)
{
Console.Write(" ");
}
Console.Write(game.Resolve);
for (var i = game.Resolve.ToString().Length; i < 10; i++)
{
Console.Write(" ");
}
if (game.DraculaAlly != null)
{
Console.Write(game.DraculaAlly.Event.Name().Substring(0, 3).ToUpper());
}
else
{
Console.Write(" ");
}
Console.Write(" ");
if (game.HunterAlly != null)
{
Console.Write(game.HunterAlly.Event.Name().Substring(0, 3).ToUpper());
}
Console.WriteLine("");
// line 3
for (var i = 5; i >= 0; i--)
{
if (game.Dracula.Trail[i] != null && game.Dracula.Trail[i].DraculaCards.Count() > 1)
{
Console.ForegroundColor = game.Dracula.Trail[i].DraculaCards[1].Color;
if (game.Dracula.Trail[i].DraculaCards[1].IsRevealed)
{
Console.Write(game.Dracula.Trail[i].DraculaCards[1].Abbreviation + " ");
//.........这里部分代码省略.........
开发者ID:UncleGus,项目名称:dracula,代码行数:101,代码来源:Program.cs
示例9: LikelihoodOfHavingItemOfType_1UnknownItem_Returns5OutOf40
public void LikelihoodOfHavingItemOfType_1UnknownItem_Returns5OutOf40()
{
GameState game = new GameState();
vanHelsing.DrawItemCard();
Assert.AreEqual( 5F / 40F, vanHelsing.LikelihoodOfHavingItemOfType(game, Item.Knife));
}
开发者ID:UncleGus,项目名称:dracula,代码行数:6,代码来源:HunterPlayerTests.cs
示例10: DraculaIsPlayingWildHorses
/// <summary>
/// Determines if Dracula is playing Wild Horses at the start of a combat
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="logic">The artificial intelligence component</param>
/// <returns>True if Dracula successfully plays Wild Horses</returns>
private static bool DraculaIsPlayingWildHorses(GameState game, DecisionMaker logic)
{
if (logic.ChooseToPlayWildHorses(game))
{
Console.WriteLine("Dracula is playing Wild Horses to control your movement");
game.Dracula.DiscardEvent(Event.WildHorses, game.EventDiscard);
if (HunterPlayingGoodLuckToCancelDraculaEvent(game, Event.WildHorses, Event.WildHorses, logic) > 0)
{
Console.WriteLine("Wild Horses cancelled");
return false;
}
return true;
}
return false;
}
开发者ID:UncleGus,项目名称:dracula,代码行数:21,代码来源:Program.cs
示例11: DraculaLooksAtAllHuntersItems
/// <summary>
/// Handles the situation when a Hunter must reveal all Items to Dracula
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="victim">The Hunter revealing Items</param>
private static void DraculaLooksAtAllHuntersItems(GameState game, HunterPlayer victim)
{
game.ItemDeck.AddRange(victim.ItemsKnownToDracula);
victim.ItemsKnownToDracula.Clear();
for (var i = 0; i < victim.ItemCount; i++)
{
Console.WriteLine("What is the name of the Item being revealed?");
var itemRevealed = Item.None;
while (itemRevealed == Item.None)
{
itemRevealed = Enumerations.GetItemFromString(Console.ReadLine());
}
AddItemCardToDraculaKnownCards(game, victim, itemRevealed);
}
}
开发者ID:UncleGus,项目名称:dracula,代码行数:20,代码来源:Program.cs
示例12: DiscardUnknownItemFromHunter
/// <summary>
/// Asks the user to name an Item and then discards it from that Hunter
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="hunter">The Hunter discarding an Item</param>
private static bool DiscardUnknownItemFromHunter(GameState game, HunterPlayer hunter)
{
Console.WriteLine("Name the Item being discarded (cancel to cancel)");
var itemBeingDiscarded = Item.None;
var line = "";
while (itemBeingDiscarded == Item.None && line.ToLower() != "cancel")
{
line = Console.ReadLine();
itemBeingDiscarded = Enumerations.GetItemFromString(line);
}
if (line.ToLower() != "cancel")
{
hunter.DiscardItem(game, itemBeingDiscarded);
return true;
}
else
{
Console.WriteLine("No Item discarded");
return false;
}
}
开发者ID:UncleGus,项目名称:dracula,代码行数:26,代码来源:Program.cs
示例13: DraculaIsPlayingSensationalistPressToPreventRevealingLocation
/// <summary>
/// Checks if Dracula is playing Sensationalist Press to prevent a Location card from being revealed
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="location">The Location being revealed</param>
/// <param name="logic">The artificial intelligence component</param>
/// <returns>True if Dracula successfully plays Sensationalist Press</returns>
private static bool DraculaIsPlayingSensationalistPressToPreventRevealingLocation(GameState game,
Location location, DecisionMaker logic)
{
if (logic.ChooseToPlaySensationalistPress(game, location))
{
Console.WriteLine("Dracula is playing Sensationalist Press");
game.Dracula.DiscardEvent(Event.SensationalistPress, game.EventDiscard);
if (HunterPlayingGoodLuckToCancelDraculaEvent(game, Event.SensationalistPress, Event.SensationalistPress, logic) > 0)
{
Console.WriteLine("Sensationalist Press cancelled");
return false;
}
return true;
}
return false;
}
开发者ID:UncleGus,项目名称:dracula,代码行数:23,代码来源:Program.cs
示例14: UseHolyWaterOnHunter
/// <summary>
/// Resolves a Hunter using the Holy Water Item or the Holy Water font at St. Joseph & St. Mary
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="hunterReceivingHolyWater">The Hunter receiving the Holy Water effect</param>
private static void UseHolyWaterOnHunter(GameState game, Hunter hunterReceivingHolyWater)
{
if (hunterReceivingHolyWater == Hunter.MinaHarker)
{
Console.WriteLine("Mina's bite cannot be cured");
return;
}
Console.WriteLine("Roll a die and enter the result");
var dieRoll = 0;
while (dieRoll == 0)
{
if (int.TryParse(Console.ReadLine(), out dieRoll))
{
if (dieRoll < 1 || dieRoll > 7)
{
dieRoll = 0;
}
}
}
switch (dieRoll)
{
case 1:
Console.WriteLine("{0} loses 2 health", hunterReceivingHolyWater.Name());
game.Hunters[(int)hunterReceivingHolyWater].AdjustHealth(-2);
CheckForHunterDeath(game); break;
case 2:
case 3:
case 4:
Console.WriteLine("Nothing happens"); break;
case 5:
case 6:
Console.WriteLine("{0} is cured of a Bite", hunterReceivingHolyWater.Name());
game.Hunters[(int)hunterReceivingHolyWater].AdjustBites(-1); break;
}
}
开发者ID:UncleGus,项目名称:dracula,代码行数:40,代码来源:Program.cs
示例15: UseHolyWaterAtHospital
private static void UseHolyWaterAtHospital(GameState game, string hunterIndex)
{
var hunterUsingHolyWater = Hunter.Nobody;
int index = -2;
if (int.TryParse(hunterIndex, out index))
{
hunterUsingHolyWater = game.GetHunterFromInt(index);
}
var line = "";
while (hunterUsingHolyWater == Hunter.Nobody && index != -1)
{
Console.WriteLine("Who is using the Holy Water font? {0}= {1}, {2}= {3}, {4}= {5}, {6}= {7} (-1 to cancel)",
(int)Hunter.LordGodalming, Hunter.LordGodalming.Name(), (int)Hunter.DrSeward,
Hunter.DrSeward.Name(), (int)Hunter.VanHelsing, Hunter.VanHelsing.Name(), (int)Hunter.MinaHarker,
Hunter.MinaHarker.Name());
line = Console.ReadLine();
if (int.TryParse(line, out index))
{
if (index < -1 || index > 4)
{
index = -2;
}
if (index == -1)
{
Console.WriteLine("Cancelled");
return;
}
hunterUsingHolyWater = game.GetHunterFromInt(index);
Console.WriteLine(hunterUsingHolyWater.Name());
}
else
{
Console.WriteLine("I didn't understand that");
}
}
UseHolyWaterOnHunter(game, hunterUsingHolyWater);
}
开发者ID:UncleGus,项目名称:dracula,代码行数:37,代码来源:Program.cs
示例16: DiscardUnknownEventFromHunter
/// <summary>
/// Asks the user to name an Event and then discards it from that Hunter
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="hunter">The Hunter discarding an Event</param>
private static void DiscardUnknownEventFromHunter(GameState game, HunterPlayer hunter)
{
Console.WriteLine("Name the Event being discarded");
var eventBeingDiscarded = Event.None;
while (eventBeingDiscarded == Event.None)
{
eventBeingDiscarded = Enumerations.GetEventFromString(Console.ReadLine());
}
hunter.DiscardEvent(game, eventBeingDiscarded);
}
开发者ID:UncleGus,项目名称:dracula,代码行数:15,代码来源:Program.cs
示例17: TradeCardsBetweenHunters
private static void TradeCardsBetweenHunters(GameState game, string firstHunterIndex, string secondHunterIndex)
{
var firstHunterTrading = Hunter.Nobody;
int index = -2;
if (int.TryParse(firstHunterIndex, out index))
{
firstHunterTrading = game.GetHunterFromInt(index);
}
var line = "";
while (firstHunterTrading == Hunter.Nobody && index != -1)
{
Console.WriteLine("Who is trading? {0}= {1}, {2}= {3}, {4}= {5}, {6}= {7} (-1 to cancel)",
(int)Hunter.LordGodalming, Hunter.LordGodalming.Name(), (int)Hunter.DrSeward,
Hunter.DrSeward.Name(), (int)Hunter.VanHelsing, Hunter.VanHelsing.Name(), (int)Hunter.MinaHarker,
Hunter.MinaHarker.Name());
line = Console.ReadLine();
if (int.TryParse(line, out index))
{
if (index < -1 || index > 4)
{
index = -2;
}
if (index == -1)
{
Console.WriteLine("Cancelled");
return;
}
firstHunterTrading = game.GetHunterFromInt(index);
Console.WriteLine(firstHunterTrading.Name());
}
else
{
Console.WriteLine("I didn't understand that");
}
}
var secondHunterTrading = Hunter.Nobody;
index = -2;
if (int.TryParse(secondHunterIndex, out index))
{
secondHunterTrading = game.GetHunterFromInt(index);
}
line = "";
while (secondHunterTrading == Hunter.Nobody && index != -1)
{
Console.WriteLine("Who else is trading? {0}= {1}, {2}= {3}, {4}= {5}, {6}= {7} (-1 to cancel)",
(int)Hunter.LordGodalming, Hunter.LordGodalming.Name(), (int)Hunter.DrSeward,
Hunter.DrSeward.Name(), (int)Hunter.VanHelsing, Hunter.VanHelsing.Name(), (int)Hunter.MinaHarker,
Hunter.MinaHarker.Name());
line = Console.ReadLine();
if (int.TryParse(line, out index))
{
if (index < -1 || index > 4)
{
index = -2;
}
if (index == -1)
{
Console.WriteLine("Cancelled");
return;
}
secondHunterTrading = game.GetHunterFromInt(index);
Console.WriteLine(secondHunterTrading.Name());
}
else
{
Console.WriteLine("I didn't understand that");
}
}
line = "";
int answer = -1;
while (answer < 0)
{
Console.WriteLine("How many Items does {0} now have?", firstHunterTrading.Name());
Int32.TryParse(line, out answer);
}
game.Hunters[(int)firstHunterTrading].SetItemCount(answer);
line = "";
answer = -1;
while (answer < 0)
{
Console.WriteLine("How many Items does {0} now have?", secondHunterTrading.Name());
Int32.TryParse(line, out answer);
}
game.Hunters[(int)secondHunterTrading].SetItemCount(answer);
var allKnownItems = new List<ItemCard>();
allKnownItems.AddRange(game.Hunters[(int)firstHunterTrading].ItemsKnownToDracula);
allKnownItems.AddRange(game.Hunters[(int)secondHunterTrading].ItemsKnownToDracula);
var allPartiallyKnownItems = new List<ItemCard>();
allPartiallyKnownItems.AddRange(game.Hunters[(int)firstHunterTrading].ItemsPartiallyKnownToDracula);
allPartiallyKnownItems.AddRange(game.Hunters[(int)secondHunterTrading].ItemsPartiallyKnownToDracula);
var allItemChances = new List<float>();
allItemChances.AddRange(game.Hunters[(int)firstHunterTrading].PartiallyKnownItemChances);
allItemChances.AddRange(game.Hunters[(int)secondHunterTrading].PartiallyKnownItemChances);
var newAllPartiallyKnownItems = new List<ItemCard>();
var newAllItemChances = new List<float>();
index = -1;
foreach (var i in allPartiallyKnownItems)
{
index++;
if (!newAllPartiallyKnownItems.Any(card => card.Item == i.Item))
//.........这里部分代码省略.........
开发者ID:UncleGus,项目名称:dracula,代码行数:101,代码来源:Program.cs
示例18: SpendResolve
/// <summary>
/// For spending a Resolve point by a Hunter
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="resolveName">A string to be converted to the ResolveAbility being used</param>
/// <param name="hunterIndex">A string to be converted to the Hunter spending Resolve</param>
/// <param name="logic">The artificial intelligence component</param>
private static void SpendResolve(GameState game, string resolveName, string hunterIndex, DecisionMaker logic)
{
var hunterSpendingResolve = Hunter.Nobody;
int index = -2;
if (int.TryParse(hunterIndex, out index))
{
hunterSpendingResolve = game.GetHunterFromInt(index);
}
var line = "";
while (hunterSpendingResolve == Hunter.Nobody && index != -1)
{
Console.WriteLine("Who is spending resolve? {0}= {1}, {2}= {3}, {4}= {5}, {6}= {7} (-1 to cancel)",
(int)Hunter.LordGodalming, Hunter.LordGodalming.Name(), (int)Hunter.DrSeward,
Hunter.DrSeward.Name(), (int)Hunter.VanHelsing, Hunter.VanHelsing.Name(), (int)Hunter.MinaHarker,
Hunter.MinaHarker.Name());
line = Console.ReadLine();
if (int.TryParse(line, out index))
{
if (index < -1 || index > 4)
{
index = -2;
}
if (index == -1)
{
Console.WriteLine("Cancelled");
return;
}
hunterSpendingResolve = game.GetHunterFromInt(index);
Console.WriteLine(hunterSpendingResolve.Name());
}
else
{
Console.WriteLine("I didn't understand that");
}
}
var ability = Enumerations.GetResolveAbilityFromString(resolveName);
while (ability == ResolveAbility.None && line.ToLower() != "cancel")
{
Console.WriteLine("What resolve ability is {0} using?", hunterSpendingResolve.Name());
line = Console.ReadLine();
if (line.ToLower() == "cancel")
{
Console.WriteLine("Cancelled");
return;
}
ability = Enumerations.GetResolveAbilityFromString(line);
}
switch (ability)
{
case ResolveAbility.NewspaperReports:
PlayNewsPaperReports(game, hunterSpendingResolve, logic);
break;
case ResolveAbility.InnerStrength:
PlayInnerStrength(game, hunterSpendingResolve);
break;
case ResolveAbility.SenseOfEmergency:
PlaySenseOfEmergency(game, hunterSpendingResolve, logic);
break;
}
game.AdjustResolve(-1);
}
开发者ID:UncleGus,项目名称:dracula,代码行数:68,代码来源:Program.cs
示例19: DraculaIsPlayingTrap
/// <summary>
/// Determines if Dracula is playing Trap against a Hunter at the start of a combat
/// </summary>
/// <param name="game">The GameState</param>
/// <param name="huntersInvolved">The list of Hunters involved in the combat</param>
/// <param name="opponent">The Opponent</param>
/// <param name="logic">The artificial intelligence component</param>
/// <returns>True if Dracula successfully plays Trap</returns>
private static bool DraculaIsPlayingTrap(GameState game, List<HunterPlayer> huntersInvolved, Opponent opponent,
DecisionMaker logic)
{
if (logic.ChooseToPlayTrap(game, huntersInvolved, opponent))
{
Console.WriteLine("Dracula is playing Trap");
game.Dracula.DiscardEvent(Event.Trap, game.EventDiscard);
if (HunterPlayingGoodLuckToCancelDraculaEvent(game, Event.Trap, Event.Trap, logic) > 0)
{
Console.WriteLine("Trap cancelled");
return false;
}
return true;
}
return false;
}
开发者ID:UncleGus,项目名称:dracula,代码行数:24,代码来源:Program.cs
示例20: DisplayState
/// <summary>
/// Provides details about various aspects of the gamestate that are not otherwise displayed on the screen
/// </summary>
/// <param name="game">The GameState</param>
private static void DisplayState(GameState game, string argument1, DecisionMaker logic)
{
Console.WriteLine("The state of the game:");
foreach (var h in game.Hunters)
{
if (h != null)
{
Console.WriteLine("{0} is in {1} with {2} Items and {3} Events, on {4} health with {5} bites{6}",
h.Hunter.Name(), h.CurrentLocation.Name(), h.ItemCount, h.EventCount, h.Health, h.BiteCount, h.HasDogsFaceUp ? " and has Dogs face up" : "");
if (h.EncountersInFrontOfPlayer.Any())
{
Console.Write("These Encounter tiles are in front of {0}: ", h.Hunter.Name());
foreach (EncounterTile enc in h.EncountersInFrontOfPlayer)
{
Console.Write("{0}, ", enc.Encounter.Name());
}
Console.WriteLine("");
}
if (h.ItemsKnownToDracula.Any() && argument1 == "debug")
{
Console.Write("These Items held by {0} are known to Dracula: ", h.Hunter.Name());
foreach (var i in h.ItemsKnownToDracula)
{
Console.Write("{0}, ", i.Item.Name());
}
Console.WriteLine("");
}
if (h.EventsKnownToDracula.Any() && argument1 == "debug")
{
Console.Write("These Events held by {0} are known to Dracula: ", h.Hunter.Name());
|
请发表评论