public void Execute(IDice dice, Combatant attacker, Combatant defender, IList<CombatLogEntry> combatLog) { int attack = attacker.ToHitAttack; int defend = defender.ToHitDefense; var toHitThreshold = ((attack + ((attacker.Level - defender.Level) / 2)) / ((double)attack + defend)).ConstrainWithinBounds(0.20, 0.80); Debug.WriteLine("{0} has a {1:P0} chance to hit {2}", attacker.Name, toHitThreshold, defender.Name); if (dice.Random() < toHitThreshold) { var damage = Math.Max(1, attacker.GetAttackDamage(dice)); defender.LowerHealth(damage); combatLog.Add(new CombatLogEntryFromAction<Attack>(Name) { Text = string.Format("{0} hits {1} with {2} for {3} points!", attacker.Name, defender.Name, Name, damage), Attacker = attacker, CombatEffect = new CombatOutcome() { Damage = damage } }); } else { combatLog.Add( new CombatLogEntry { Text = string.Format("{0} attempts to hit {1} with {2} and fails miserably!", attacker.Name, defender.Name, Name), Attacker = attacker }); } }
public void WhenTokenMovesToSquare100_ThenPlayerWinsGame(GameEngine gameEngine, Player player, IDice dice, int diceRollResult, int positionBeforeMove) { "Given the token is on square 97" .x(() => { player = new Player(1, "Player 1", dice); int totalSquares = 100; gameEngine = new GameEngine(totalSquares); gameEngine.AddPlayer(player); gameEngine.Start(); gameEngine.MovePlayer(player, 96); }); "When the token is moved 3 spaces" .x(() => { gameEngine.MovePlayer(player, 3); }); "Then the token is on square 100" .x(() => { gameEngine.CurrentSquareForPlayer(player).Should().Be(100); }); "And the player has won the game" .x(() => { gameEngine.Winner.Should().Be(player); }); }
public Game(List <Player> players, List <RealState> properties, IDice dice = null) { this.dice = dice; this.properties = properties; this.players = players; this.Board = new Board(players, properties); }
public Utility(Int32 index, String name, Int32 cost, Int32 rent, IBanker banker, IEnumerable <Utility> utilities, IDice dice) : base(index, name, cost, rent, banker) { this.utilities = utilities; this.dice = dice; }
public DungeonController(GameWorld gameWorld, IDice dice, IWeaponFactory weaponFactory, IAsciiArtRepository asciiArtRepository) { _gameWorld = gameWorld; _dice = dice; _weaponFactory = weaponFactory; _asciiArtRepository = asciiArtRepository; }
private void RollStats() { // Create Instance of Dice Interface. _dice = new Adventurer(_username); Console.WriteLine("Let's roll your stats."); _adventurer.CharStats = new Dictionary <string, int>(); // Roll Each Stat, Add to Dictionary. int strength = _dice.StatRoll(); _adventurer.CharStats.Add("Strength", strength); int dexterity = _dice.StatRoll(); _adventurer.CharStats.Add("Dexterity", dexterity); int constitution = _dice.StatRoll(); _adventurer.CharStats.Add("Constitution", constitution); int wisdom = _dice.StatRoll(); _adventurer.CharStats.Add("Wisdom", wisdom); int intelligence = _dice.StatRoll(); _adventurer.CharStats.Add("Intelligence", intelligence); int charisma = _dice.StatRoll(); _adventurer.CharStats.Add("Charisma", charisma); }
public void WhenFightCalledAndDefenseFighterDoesNotDoCounterDamage_ThenNoDamageDoneToOffenseFighter() { // Arrange int villianHealth = 2; // Immortal, strong hero var mockHero = new Mock <ISuperPerson>(); mockHero.Setup(x => x.Name).Returns("Hero"); mockHero.Setup(x => x.Health).Returns(1000); mockHero.Setup(x => x.Strength).Returns(52); mockHero.Setup(x => x.Speed).Returns(100); mockHero.Setup(x => x.Resistance).Returns(100); mockHero.Setup(x => x.Intellect).Returns(100); mockHero.Setup(x => x.IsAlive).Returns(true); // Weak villian, dies on 2nd hit var mockVillian = new Mock <ISuperPerson>(); mockVillian.Setup(x => x.Name).Returns("Villian"); mockVillian.Setup(x => x.Health).Returns(() => villianHealth); mockVillian.Setup(x => x.Strength).Returns(0); mockVillian.Setup(x => x.Speed).Returns(0); mockVillian.Setup(x => x.Resistance).Returns(0); mockVillian.Setup(x => x.Intellect).Returns(0); mockVillian.Setup(x => x.IsAlive).Returns(() => villianHealth > 0); mockVillian.Setup(x => x.Damage(It.IsAny <int>())).Callback(() => { villianHealth -= 1; }); var mockDice = new Mock <IDice>(); // Ensure hero gets first hit mockDice.Setup(x => x.NumberOfSides).Returns(100); mockDice.SetupSequence(x => x.Roll()) .Returns(1) //coin toss (false) .Returns(1) //hero gets a hit .Returns(1) //villian failed to block .Returns(1) //villian fails to counter-damage .Returns(1) //villain misses .Returns(1) //hero gets a hit .Returns(1); //villian failed to block IDice dice = mockDice.Object; SlugFestFightStrategy target = new SlugFestFightStrategy(dice); ISuperPerson hero = mockHero.Object; ISuperPerson villian = mockVillian.Object; // Act target.StartFight(hero, villian); WaitForFightCompleted(target); // Note: Moq example of using Verify with Times.Exactly to count invocations // Assert mockHero.Verify(x => x.Damage(It.IsAny <int>()), Times.Never()); mockVillian.Verify(x => x.Damage(It.IsAny <int>()), Times.Exactly(2)); }
public static T RollRandom <T>(List <T> list, IDice dice, Predicate <T> predicate) where T : class { if (list is null) { throw new ArgumentNullException(nameof(list)); } if (dice is null) { throw new ArgumentNullException(nameof(dice)); } if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } var count = list.Count; var currentIndex = dice.Roll(0, count - 1); var foundIndex = list.FindIndex(currentIndex, predicate); if (foundIndex > -1) { return(list[foundIndex]); } if (foundIndex >= 0) { foundIndex = list.FindIndex(0, currentIndex, predicate); return(list[foundIndex]); } return(null); }
public static Dictionary <Int32, OwnableSpace> CreateRealEstate(IDice dice) { var realEstate = new Dictionary <Int32, OwnableSpace>(); realEstate.Add(BoardConstants.MEDITERANEAN_AVENUE, new Property("Mediteranean Avenue", 60, 2, GROUPING.PURPLE, 50, new[] { 10, 30, 90, 160, 250 })); realEstate.Add(BoardConstants.BALTIC_AVENUE, new Property("Baltic Avenue", 60, 4, GROUPING.PURPLE, 50, new[] { 20, 60, 180, 320, 450 })); realEstate.Add(BoardConstants.ORIENTAL_AVENUE, new Property("Oriental Avenue", 100, 6, GROUPING.LIGHT_BLUE, 50, new[] { 30, 90, 270, 400, 550 })); realEstate.Add(BoardConstants.VERMONT_AVENUE, new Property("Vermont Avenue", 100, 6, GROUPING.LIGHT_BLUE, 50, new[] { 30, 90, 270, 400, 550 })); realEstate.Add(BoardConstants.CONNECTICUT_AVENUE, new Property("Connecticut Avenue", 120, 8, GROUPING.LIGHT_BLUE, 50, new[] { 30, 90, 270, 400, 550 })); realEstate.Add(BoardConstants.ST_CHARLES_PLACE, new Property("St. Charles Place", 140, 10, GROUPING.PINK, 100, new[] { 50, 150, 450, 625, 750 })); realEstate.Add(BoardConstants.STATES_AVENUE, new Property("States Avenue", 140, 10, GROUPING.PINK, 100, new[] { 50, 150, 450, 625, 750 })); realEstate.Add(BoardConstants.VIRGINIA_AVENUE, new Property("Virginia Avenue", 160, 12, GROUPING.PINK, 100, new[] { 60, 180, 500, 700, 900 })); realEstate.Add(BoardConstants.ST_JAMES_PLACE, new Property("St. James Place", 180, 14, GROUPING.ORANGE, 100, new[] { 70, 200, 550, 750, 950 })); realEstate.Add(BoardConstants.TENNESSEE_AVENUE, new Property("Tennessee Avenue", 180, 14, GROUPING.ORANGE, 100, new[] { 70, 200, 550, 750, 950 })); realEstate.Add(BoardConstants.NEW_YORK_AVENUE, new Property("New York Avenue", 200, 16, GROUPING.ORANGE, 100, new[] { 80, 220, 600, 800, 1000 })); realEstate.Add(BoardConstants.KENTUCKY_AVENUE, new Property("Kentucky Avenue", 220, 18, GROUPING.RED, 150, new[] { 90, 250, 700, 875, 1050 })); realEstate.Add(BoardConstants.INDIANA_AVENUE, new Property("Indiana Avenue", 220, 18, GROUPING.RED, 150, new[] { 90, 250, 700, 875, 1050 })); realEstate.Add(BoardConstants.ILLINOIS_AVENUE, new Property("Illinois Avenue", 240, 20, GROUPING.RED, 150, new[] { 100, 300, 750, 925, 1100 })); realEstate.Add(BoardConstants.ATLANTIC_AVENUE, new Property("Atlantic Avenue", 260, 22, GROUPING.YELLOW, 150, new[] { 110, 330, 800, 975, 1150 })); realEstate.Add(BoardConstants.VENTNOR_AVENUE, new Property("Ventnor Avenue", 260, 22, GROUPING.YELLOW, 150, new[] { 110, 330, 800, 975, 1150 })); realEstate.Add(BoardConstants.MARVIN_GARDENS, new Property("Marvin Gardens", 280, 24, GROUPING.YELLOW, 150, new[] { 120, 360, 850, 1025, 1200 })); realEstate.Add(BoardConstants.PACIFIC_AVENUE, new Property("Pacific Avenue", 300, 26, GROUPING.GREEN, 200, new[] { 130, 390, 900, 1100, 1275 })); realEstate.Add(BoardConstants.NORTH_CAROLINA_AVENUE, new Property("North Carolina Avenue", 300, 26, GROUPING.GREEN, 200, new[] { 130, 390, 900, 1100, 1275 })); realEstate.Add(BoardConstants.PENNSYLVANIA_AVENUE, new Property("Pennsylvania Avenue", 320, 28, GROUPING.GREEN, 200, new[] { 150, 450, 1000, 1200, 1400 })); realEstate.Add(BoardConstants.PARK_PLACE, new Property("Park Place", 350, 35, GROUPING.DARK_BLUE, 200, new[] { 175, 500, 1100, 1300, 1500 })); realEstate.Add(BoardConstants.BOARDWALK, new Property("Boardwalk", 400, 50, GROUPING.DARK_BLUE, 200, new[] { 200, 600, 1400, 1700, 2000 })); realEstate.Add(BoardConstants.SHORT_LINE, new Railroad("Short Line")); realEstate.Add(BoardConstants.BandO_RAILROAD, new Railroad("B&O Railroad")); realEstate.Add(BoardConstants.PENNSYLVANIA_RAILROAD, new Railroad("Pennsylvania Railroad")); realEstate.Add(BoardConstants.READING_RAILROAD, new Railroad("Reading Railroad")); realEstate.Add(BoardConstants.WATER_WORKS, new Utility("Water Works", dice)); realEstate.Add(BoardConstants.ELECTRIC_COMPANY, new Utility("Electric Company", dice)); return(realEstate); }
public void Execute(IDice dice, Combatant attacker, Combatant defender, IList<CombatLogEntry> combatLog) { int attackerFleeRating = Math.Max(1, attacker.Level + attacker.Agility.GetStatModifier()); int defenderFleeRating = Math.Max(1, defender.Level + defender.Agility.GetStatModifier()); var toFleeThreshold = ((attackerFleeRating) / ((double)attackerFleeRating + defenderFleeRating)).ConstrainWithinBounds(0.20, 0.80); Debug.WriteLine("{0} has a {1:P0} chance to flee from {2}", attacker.Name, toFleeThreshold, defender.Name); if (dice.Random() < toFleeThreshold) { attacker.HasFledCombat = true; combatLog.Add(new CombatLogEntryFromAction<Flee>(Name) { Text = string.Format("{0} has fled the battle!", attacker.Name), Attacker = attacker, CombatEffect = CombatOutcome.Empty }); } else { combatLog.Add(new CombatLogEntryFromAction<Flee>(Name) { Text = string.Format("{0} attempts to flee but {1} gets in the way!", attacker.Name, defender.Name), Attacker = attacker, CombatEffect = CombatOutcome.Empty }); } }
public int RollDiceForPlayOrder(IDice dice) { dice.Roll(); this.PlayOrderDiceRoll = dice.Result; this.DiceRolledForPlayOrder = true; return(this.PlayOrderDiceRoll); }
public CombatLogEntry Use(IDice dice, Combatant combatant) { combatant.AddSpellToSpellBook(Spell); combatant.RemoveItemFromInventory(this); return null; }
public Utility(Int32 index, String name, Int32 cost, Int32 rent, IBanker banker, IEnumerable<Utility> utilities, IDice dice) : base(index, name, cost, rent, banker) { this.utilities = utilities; this.dice = dice; }
public void WhenTokenMoves4StepsFrom97_ThenTokenIsOn97(GameEngine gameEngine, Player player, IDice dice, int diceRollResult, int positionBeforeMove) { "Given the token is on square 97" .x(() => { player = new Player(1, "Player 1", dice); int totalSquares = 100; gameEngine = new GameEngine(totalSquares); gameEngine.AddPlayer(player); gameEngine.Start(); gameEngine.MovePlayer(player, 96); }); "When the token is moved 4 spaces" .x(() => { gameEngine.MovePlayer(player, 4); }); "Then the token is on square 97" .x(() => { gameEngine.CurrentSquareForPlayer(player).Should().Be(97); }); "And the player has not won the game" .x(() => { gameEngine.Winner.Should().Be(null); }); }
public GameSetup(Guid gameSetupId, Guid gameId, IList<Guid> players, IDice dice) { var startingPlayer = RollDiceUntilWinner(players, dice); var numberOfStartingInfantryUnits = GetStartingInfantryUnits(players.Count); RaiseEvent(new GameSetupStarted(gameSetupId, gameId, players, startingPlayer, Board.Clear(), numberOfStartingInfantryUnits)); }
public Game(IDice die1, IDice die2, IDice die3) { dice = new List<IDice>(); dice.Add(die1); dice.Add(die2); dice.Add(die3); }
public TurnResult Take(int turnOrder, IPlayer player, IBoard board, IDice dice) { return(new TurnResult() { TurnOrder = turnOrder, PlayerName = player.Name, StartingLocation = player.Location, EndingLocation = player.Location }); }
public void Use(Agent agent, Globe globe, IDice dice) { var highestBranchs = agent.Skills.OrderBy(x => x.Value) .Where(x => x.Value >= 1); var agentNameGenerator = globe.agentNameGenerator; if (highestBranchs.Any()) { var firstBranch = highestBranchs.First(); var agentDisciple = new Agent { Name = agentNameGenerator.Generate(Sex.Male, 1), Location = agent.Location, Realm = agent.Realm, Hp = 3 }; agentDisciple.Skills.Add(firstBranch.Key, firstBranch.Value / 2); globe.Agents.Add(agent); CacheHelper.AddAgentToCell(globe.AgentCells, agentDisciple.Location, agent); } else { globe.AgentCrisys++; } }
public Actor( string name, int armorClass, int currentHitPoints, int maxHitPoints, int temporaryHitPoints, int proficiency, int strength, int dexterity, int constitution, int intelligence, int wisdom, int charisma, IDice rollableDice, HitPoints.Factory hitPointsFactory, Abilities.Factory abilityScoreFactory) { if (hitPointsFactory == null) { throw new ArgumentNullException(nameof(hitPointsFactory)); } if (abilityScoreFactory == null) { throw new ArgumentNullException(nameof(abilityScoreFactory)); } _rollableDice = rollableDice ?? throw new ArgumentNullException(nameof(rollableDice)); Name = name ?? throw new ArgumentNullException(nameof(name)); ArmorClass = armorClass; Proficiency = proficiency; HitPoints = hitPointsFactory(currentHitPoints, maxHitPoints, temporaryHitPoints); AbilityScores = abilityScoreFactory(strength, dexterity, constitution, intelligence, wisdom, charisma); }
public void DefaultValues_DiceForArmorLevel_Level100() { IDice dice = defaultValue.DiceForArmorLevel(100); Assert.AreEqual(5, dice.Die); Assert.AreEqual(5011, dice.Sides); }
public void TestInitialize() { dice = new Dice(); banker = new Banker(); board = new Board(banker, dice); player = new Player("test"); owner = new Player("Owner"); banker.AddAccount(owner, 1500); railRoad1 = new RailRoadProperty(5, banker, "railRoad1", 200); railRoad2 = new RailRoadProperty(15, banker, "railRoad2", 200); railRoad3 = new RailRoadProperty(25, banker, "railRoad3", 200); railRoad4 = new RailRoadProperty(35, banker, "railRoad4", 200); var groupedSpaces = new List <IOwnableProperty>() { railRoad1, railRoad2, railRoad3, railRoad4 }; railRoad1.GroupedSpaces = groupedSpaces; railRoad2.GroupedSpaces = groupedSpaces; railRoad3.GroupedSpaces = groupedSpaces; railRoad4.GroupedSpaces = groupedSpaces; dice.Roll(); }
public void DefaultValues_DiceForWeaponLevel_Level1() { IDice dice = defaultValue.DiceForWeaponLevel(1); Assert.AreEqual(9, dice.Die); Assert.AreEqual(3, dice.Sides); }
public void Use(Agent agent, Globe globe, IDice dice) { if (globe.LocalitiesCells.TryGetValue(agent.Location, out var currentLocality)) { currentLocality.Population++; } }
/// <summary> /// Выбирает случайное значение из списка. /// </summary> /// <typeparam name="T"> Тип элементов списка. </typeparam> /// <param name="dice"> Кость, на основе которой делать случайный выбор. </param> /// <param name="list"> Список элементов, из которого выбирать элемент. </param> /// <param name="count">Количество выбранных значений. </param> /// <returns> Случайный элемент из списка. </returns> public static IEnumerable <T> RollFromList <T>(this IDice dice, IList <T> list, int count) { if (dice is null) { throw new ArgumentNullException(nameof(dice)); } if (list is null) { throw new ArgumentNullException(nameof(list)); } if (list.Count < count) { throw new ArgumentException("Требуемое количество должно быть не меньше размера списка.", nameof(count)); } var openList = new List <T>(list); for (var i = 0; i < count; i++) { var rolledItem = dice.RollFromList(openList); yield return(rolledItem); openList.Remove(rolledItem); } }
public void DefaultValues_DiceForTrapLevel_Level100() { IDice die = defaultValue.DiceForTrapLevel(100); Assert.AreEqual(2776, die.Die); Assert.AreEqual(4001, die.Sides); }
public void DefaultValues_DiceForTrapLevel_Level1() { IDice die = defaultValue.DiceForTrapLevel(1); Assert.AreEqual(40, die.Die); Assert.AreEqual(5, die.Sides); }
public PrisonGuard(Banker banker, IDice dice) { turnsInJailPerPlayer = new Dictionary<String, Int32>(); holdsGetOutOfJailFree = new List<String>(); this.banker = banker; this.dice = dice; }
public override int RollDice(IDice dice, int noOfDice = 2) { int rollResult = dice.Roll(noOfDice); Console.WriteLine("You have rolled " + rollResult); return(rollResult); }
public Players Create(IDice dice) { var players = new Players(_player1, _player2); players.SetupPlayersPositions(dice); return(players); }
/// <summary> /// Display the dice roll results in verbose format. /// Helpful in debugging dice expression strings. /// </summary> /// <param name="dice">Dice expression used</param> /// <param name="result">Dice results to display</param> /// <returns>Resulting display text.</returns> private string VerboseRollDisplay(IDice dice, DiceResult result) { StringBuilder output = new StringBuilder(); output.AppendFormat( "DiceRoll => {0}", this.diceConverter.Convert(result, typeof(string), null, "default")); output.AppendLine("==============================================="); output.AppendFormat(" DiceResult.DieRollerUsed: {0}\r\n", result.DieRollerUsed); output.AppendFormat(" DiceResult.NumberTerms: {0}\r\n", result.Results.Count); output.AppendLine(" Terms list:"); output.AppendLine(" ---------------------------"); foreach (TermResult term in result.Results) { output.AppendFormat(" TermResult.Type: {0}\r\n", term.Type); output.AppendFormat(" TermResult.IncludeInResult: {0}\r\n", term.AppliesToResultCalculation); output.AppendFormat(" TermResult.Scalar: {0}\r\n", term.Scalar); output.AppendFormat(" TermResult.Value: {0}\r\n", term.Value); output.AppendLine(); } output.AppendLine(" ---------------------------"); output.AppendFormat(" Total Roll: {0}\r\n", result.Value); return(output.ToString()); }
public void RoleDiceForeNumTest() { IDice dice = DiceFactory.CreateDice(4); int num = dice.RoleDiceForeNum(); Assert.NotEqual(0, num); }
public static Dictionary<Int32, OwnableSpace> CreateRealEstate(IDice dice) { var realEstate = new Dictionary<Int32, OwnableSpace>(); realEstate.Add(BoardConstants.MEDITERANEAN_AVENUE, new Property("Mediteranean Avenue", 60, 2, GROUPING.PURPLE, 50, new[] { 10, 30, 90, 160, 250 })); realEstate.Add(BoardConstants.BALTIC_AVENUE, new Property("Baltic Avenue", 60, 4, GROUPING.PURPLE, 50, new[] { 20, 60, 180, 320, 450 })); realEstate.Add(BoardConstants.ORIENTAL_AVENUE, new Property("Oriental Avenue", 100, 6, GROUPING.LIGHT_BLUE, 50, new[] { 30, 90, 270, 400, 550 })); realEstate.Add(BoardConstants.VERMONT_AVENUE, new Property("Vermont Avenue", 100, 6, GROUPING.LIGHT_BLUE, 50, new[] { 30, 90, 270, 400, 550 })); realEstate.Add(BoardConstants.CONNECTICUT_AVENUE, new Property("Connecticut Avenue", 120, 8, GROUPING.LIGHT_BLUE, 50, new[] { 30, 90, 270, 400, 550 })); realEstate.Add(BoardConstants.ST_CHARLES_PLACE, new Property("St. Charles Place", 140, 10, GROUPING.PINK, 100, new[] { 50, 150, 450, 625, 750 })); realEstate.Add(BoardConstants.STATES_AVENUE, new Property("States Avenue", 140, 10, GROUPING.PINK, 100, new[] { 50, 150, 450, 625, 750 })); realEstate.Add(BoardConstants.VIRGINIA_AVENUE, new Property("Virginia Avenue", 160, 12, GROUPING.PINK, 100, new[] { 60, 180, 500, 700, 900 })); realEstate.Add(BoardConstants.ST_JAMES_PLACE, new Property("St. James Place", 180, 14, GROUPING.ORANGE, 100, new[] { 70, 200, 550, 750, 950 })); realEstate.Add(BoardConstants.TENNESSEE_AVENUE, new Property("Tennessee Avenue", 180, 14, GROUPING.ORANGE, 100, new[] { 70, 200, 550, 750, 950 })); realEstate.Add(BoardConstants.NEW_YORK_AVENUE, new Property("New York Avenue", 200, 16, GROUPING.ORANGE, 100, new[] { 80, 220, 600, 800, 1000 })); realEstate.Add(BoardConstants.KENTUCKY_AVENUE, new Property("Kentucky Avenue", 220, 18, GROUPING.RED, 150, new[] { 90, 250, 700, 875, 1050 })); realEstate.Add(BoardConstants.INDIANA_AVENUE, new Property("Indiana Avenue", 220, 18, GROUPING.RED, 150, new[] { 90, 250, 700, 875, 1050 })); realEstate.Add(BoardConstants.ILLINOIS_AVENUE, new Property("Illinois Avenue", 240, 20, GROUPING.RED, 150, new[] { 100, 300, 750, 925, 1100 })); realEstate.Add(BoardConstants.ATLANTIC_AVENUE, new Property("Atlantic Avenue", 260, 22, GROUPING.YELLOW, 150, new[] { 110, 330, 800, 975, 1150 })); realEstate.Add(BoardConstants.VENTNOR_AVENUE, new Property("Ventnor Avenue", 260, 22, GROUPING.YELLOW, 150, new[] { 110, 330, 800, 975, 1150 })); realEstate.Add(BoardConstants.MARVIN_GARDENS, new Property("Marvin Gardens", 280, 24, GROUPING.YELLOW, 150, new[] { 120, 360, 850, 1025, 1200 })); realEstate.Add(BoardConstants.PACIFIC_AVENUE, new Property("Pacific Avenue", 300, 26, GROUPING.GREEN, 200, new[] { 130, 390, 900, 1100, 1275 })); realEstate.Add(BoardConstants.NORTH_CAROLINA_AVENUE, new Property("North Carolina Avenue", 300, 26, GROUPING.GREEN, 200, new[] { 130, 390, 900, 1100, 1275 })); realEstate.Add(BoardConstants.PENNSYLVANIA_AVENUE, new Property("Pennsylvania Avenue", 320, 28, GROUPING.GREEN, 200, new[] { 150, 450, 1000, 1200, 1400 })); realEstate.Add(BoardConstants.PARK_PLACE, new Property("Park Place", 350, 35, GROUPING.DARK_BLUE, 200, new[] { 175, 500, 1100, 1300, 1500 })); realEstate.Add(BoardConstants.BOARDWALK, new Property("Boardwalk", 400, 50, GROUPING.DARK_BLUE, 200, new[] { 200, 600, 1400, 1700, 2000 })); realEstate.Add(BoardConstants.SHORT_LINE, new Railroad("Short Line")); realEstate.Add(BoardConstants.BandO_RAILROAD, new Railroad("B&O Railroad")); realEstate.Add(BoardConstants.PENNSYLVANIA_RAILROAD, new Railroad("Pennsylvania Railroad")); realEstate.Add(BoardConstants.READING_RAILROAD, new Railroad("Reading Railroad")); realEstate.Add(BoardConstants.WATER_WORKS, new Utility("Water Works", dice)); realEstate.Add(BoardConstants.ELECTRIC_COMPANY, new Utility("Electric Company", dice)); return realEstate; }
public void Play(IDice dice) { var luckyScore = getLuckyScore(dice); foreach (var player in players) { bool win = false; for (int i = 0; i < player.CurrentBets.Count; i++) { if (player.CurrentBets[i].Chips.Amount % 5 != 0) { throw new InvalidOperationException(); } if (player.CurrentBets[i].Score == luckyScore) { win = true; player.Win(player.CurrentBets[i].Chips.Amount * 6); break; } } if (!win) { player.Lose(); } } }
public void WhenPlayerRolls4_ThenTokenShouldMove4Spaces(GameEngine gameEngine, Player player, IDice dice, int diceRollResult, int positionBeforeMove) { "Given the player rolls a 4" .x(() => { dice = A.Fake <IDice>(); A.CallTo(() => dice.Roll()).Returns(4); player = new Player(1, "Player 1", dice); int totalSquares = 100; gameEngine = new GameEngine(totalSquares); gameEngine.AddPlayer(player); gameEngine.Start(); }); "When they move their token" .x(() => { positionBeforeMove = gameEngine.CurrentSquareForPlayer(player); gameEngine.MovePlayer(player, player.RollDice()); }); "Then the token should move 4 space" .x(() => { int positionAfterMove = gameEngine.CurrentSquareForPlayer(player); int result = positionAfterMove - positionBeforeMove; result.Should().Be(4); }); }
public TaskHandler(IRealtor realtor, List<IPlayer> players, IMovementHandler movementHandler, IBanker banker, IDice dice) { this.movementHandler = movementHandler; this.players = players; this.banker = banker; this.dice = dice; }
public TownController(GameWorld gameWorld, ISaveGameRepository saveGameRepository, IAsciiArtRepository asciiArtRepository, IDice dice) { _gameWorld = gameWorld; _saveGameRepository = saveGameRepository; _asciiArtRepository = asciiArtRepository; _dice = dice; }
public void DefaultValues_DiceForWeaponLevel_Level100() { IDice dice = defaultValue.DiceForWeaponLevel(100); Assert.AreEqual(27, dice.Die); Assert.AreEqual(12539, dice.Sides); }
public PlayerCursor(List <Player> players, IDice dice) { Dice = dice; _players = players; _currentPlayer = 0; }
public Player(IToken token, IDice dice, IBoard board, IOutputStream outputStream) { _token = token; _dice = dice; _board = board; _outputStream = outputStream; }
public Queue <ICard> BuildChanceDeck(IDice dice) { var deck = new List <ICard>(); deck.Add(new MoveAndPassGoCard("Advance To Go", BoardConstants.GO, boardHandler)); deck.Add(new FlatCollectCard("Bank Pays You Dividend", 50, banker)); deck.Add(new MoveBackThreeCard(boardHandler)); deck.Add(new MoveToNearestUtilityCard(boardHandler, dice)); deck.Add(new GoToJailCard(jailHandler)); deck.Add(new FlatPayCard("Pay Poor Tax", 15, banker)); deck.Add(new MoveAndPassGoCard("Advance To St. Charles Place", BoardConstants.ST_CHARLES_PLACE, boardHandler)); deck.Add(new PayAllPlayersCard(players, banker)); deck.Add(new MoveToNearestRailroadCard(boardHandler)); deck.Add(new MoveToNearestRailroadCard(boardHandler)); deck.Add(new MoveAndPassGoCard("Take a Ride on the Reading", BoardConstants.READING_RAILROAD, boardHandler)); deck.Add(new MoveAndPassGoCard("Take a walk on the Boardwalk", BoardConstants.BOARDWALK, boardHandler)); deck.Add(new FlatCollectCard("Your Building And Loan Matures", 150, banker)); deck.Add(new MoveAndPassGoCard("Advance to Illinois Avenue", BoardConstants.ILLINOIS_AVENUE, boardHandler)); deck.Add(new GetOutOfJailFreeCard(jailHandler)); deck.Add(new HousesAndHotelsCard("Make General Repairs On All Your Property", 25, 100, realEstateHandler, banker)); var shuffledDeck = deck.OrderBy(x => random.Next()); return(new Queue <ICard>(shuffledDeck)); }
public void Use(Agent agent, Globe globe, IDice dice) { var highestBranchs = agent.Skills.OrderBy(x => x.Value) .Where(x => x.Value >= 1); if (highestBranchs.Any()) { var firstBranch = highestBranchs.First(); var agentDisciple = new Agent { Name = agent.Name + " disciple", Localtion = agent.Localtion, Realm = agent.Realm, Hp = 3 }; globe.Agents.Add(agent); Helper.AddAgentToCell(globe.AgentCells, agentDisciple.Localtion, agent); } else { globe.AgentCrisys++; } }
public TurnHandler(IDice dice, IBoardHandler boardHandler, IJailHandler jailHandler, IOwnableHandler realEstateHandler, IBanker banker) { this.dice = dice; this.boardHandler = boardHandler; this.jailHandler = jailHandler; this.realEstateHandler = realEstateHandler; this.banker = banker; }
public SpellBookController(GameWorld gameWorld, IAsciiArtRepository asciiArtRepository, IDice dice) { _gameWorld = gameWorld; _asciiArtRepository = asciiArtRepository; _dice = dice; _title = DefaultTitle; _information = DefaultInformation; }
public ChanceFactory(IBanker banker, IJailRoster jailRoster, GameBoard board, IDice dice) { this.banker = banker; this.jailRoster = jailRoster; this.board = board; this.dice = dice; }
public Turn(Int32 playerId, IDice dice, IJailRoster jailRoster, IBoard board) { this.playerId = playerId; this.dice = dice; this.jailRoster = jailRoster; this.board = board; this.locations = board.Locations; }
public void SetUp() { _enemyBar = new Lair(); _agent = new Agent(); _dice = MockRepository.GenerateStub<IDice>(); _mission = new InfiltrationMission(_dice); Arrange(); }
public InnController(GameWorld gameWorld, ISaveGameRepository saveGameRepository, IAsciiArtRepository asciiArtRepository, IDice dice) { _gameWorld = gameWorld; _saveGameRepository = saveGameRepository; _asciiArtRepository = asciiArtRepository; _dice = dice; _title = "Welcome to the Tolbooth Tavern. The food ain't great and the beds aren't soft. But it's the only Inn in town."; }
public TurnHandler(IJailer jailer, IBanker banker, IMovementHandler movementHandler, IDice dice, ICardHandler cardHandler) { this.jailer = jailer; this.banker = banker; this.movementHandler = movementHandler; this.dice = dice; this.cardHandler = cardHandler; }
public HighRollTurn(IPlayer player, IDice dice) { if (player == null) throw new ArgumentNullException(nameof(player)); if (dice == null) throw new ArgumentNullException(nameof(dice)); Player = player; this.dice = dice; }
public JailHandler(IDice dice, IBoardHandler boardHandler, IBanker banker) { this.dice = dice; this.boardHandler = boardHandler; this.banker = banker; turnsInJail = new Dictionary<IPlayer, Int16>(); cards = new Dictionary<GetOutOfJailFreeCard, IPlayer>(2); }
public Board Create(Banker banker, IEnumerable<String> players, IDice dice, PrisonGuard guard) { var board = new Board(players); var spaces = CreateSpaces(banker, board, dice, guard); board.SetSpaces(spaces); return board; }
public TraditionalLocationFactory(TraditionalBanker banker, IDice dice, TraditionalJailRoster jailRoster, IBoard board, CardDeckFactory cardDeckFactory) { this.banker = banker; this.dice = dice; this.jailRoster = jailRoster; this.board = board; this.cardDeckFactory = cardDeckFactory; }
public RollState(IGameTurn turn, IDice dice) { if (turn == null) throw new ArgumentNullException(nameof(turn)); if (dice == null) throw new ArgumentNullException(nameof(dice)); this.turn = turn; this.dice = dice; }
public void Freeze(IDice dice) { if (!played) { throw new Exception(); } rollableDices.Remove(dice); frozenDices.Add(dice); UpdateScore(); played = false; }
public void SetUp() { player = "Horse"; players = new List<String> { player }; banker = new Banker(players, 1500); var boardFactory = new BoardFactory(); dice = new LoadedDice(); var guard = new PrisonGuard(banker, dice); board = boardFactory.Create(banker, players, dice, guard); go = new Go(banker); }
public EffectOutcome Execute(IDice dice, Combatant attacker, Combatant defender) { var damage = (int) Math.Round(dice.Roll(Magnitude) * (1 + ((double)attacker.Intelligence.GetStatModifier() / 9)), MidpointRounding.AwayFromZero); defender.LowerHealth(damage); return new EffectOutcome() { Description = string.Format("{0} takes {1} points of damage!", defender.Name, damage), Damage = damage }; }
public void SetUp() { playerOneId = 0; playerTwoId = 1; dice = new FakeDice(new [] { new FakeRoll(7, 3) }); banker = new TraditionalBanker(new [] { playerOneId, playerTwoId }); var utilities = new List<Utility>(); electric = new Utility(12, "Electric Company", 150, 0, banker, utilities, dice); waterWorks = new Utility(28, "Water Works", 150, 0, banker, utilities, dice); utilities.AddRange(new Utility[] { electric, waterWorks }); }
public CombatEngine(GameWorld gameWorld, IMonsterFactory monsterFactory, ICombatantSelector combantSelector, IDice dice) { _gameWorld = gameWorld; _combantSelector = combantSelector; _dice = dice; _combatContext = new CombatContext(); _combatContext.Player = _gameWorld.Player; _combatContext.Monster = monsterFactory.CreateMonster(_gameWorld, _combatContext); _combatContext.Player.HasFledCombat = false; _combatContext.Monster.HasFledCombat = false; }
public Game(IEnumerable<String> players, IDice dice, Board board, PlayerTurnCounter turns, PrisonGuard guard) { CheckNumberOfPlayers(players); Players = players; this.dice = dice; this.board = board; this.turns = turns; this.guard = guard; ShufflePlayers(); }
public MonsterFactory(IWeaponFactory weaponFactory, ISpellFactory spellFactory, IItemFactory itemFactory, IMonsterDataRepository monsterDataRepository, IActionSelector actionSelector, IStatsGenerator statsGenerator, IDice dice) { this.weaponFactory = weaponFactory; this.spellFactory = spellFactory; this.itemFactory = itemFactory; _actionSelector = actionSelector; _statsGenerator = statsGenerator; _dice = dice; monsterArchetypes = monsterDataRepository.GetAllMonsterArchetypes().ToList(); monsterModifiers = monsterDataRepository.GetAllMonsterModifiers().ToList(); }