private void StockShop() { var weapons = GatewayProvider.All <Weapon>(); var masterwork = weapons.Select(x => new MasterworkWeapon(x)); var magical = weapons.Select(x => new MagicWeapon(x, Randomly.Range(1, 6))); var total = weapons.Concat <IWeapon>(masterwork).Concat <IWeapon>(magical); StockShop(total); }
public void Execute(Settlement settlement) { var count = Randomly.Range(5, 15); for (int i = 0; i < count; i++) { settlement.Add(buildings.ChooseOne()); } }
private async Task StartGameIfReady() { if (await _service.GetIsGameReady().ConfigureAwait(false)) { var game = await _service.GetGame().ConfigureAwait(false); var chooserId = Randomly.Pick(game.Player1, game.Player2).PlayerId; PlayNextRound(chooserId, game); } }
public Wand Process() { // choose from available spell Lists. var list = spellLists.Where(x => classes.Any(cls => x.Matches(cls))).ChooseOne(); var spellLevel = Randomly.Range(list.GetLowestSpellLevel(), list.GetHighestSpellLevel()); var spellName = list.GetAllSpells(spellLevel).ChooseOne(); var spell = spells.Find(spellName); var value = 75000 * (spellLevel) * (spellLevel + spellLevel - 1); var wand = new Wand(spell, 50, value); return(wand); }
public void Initialize(ComponentContainer components) { if (Randomly.TrueFalse()) { bondedFamiliar = this.familiars.ChooseOne(); components.Add(bondedFamiliar); } else { bondedItem = this.items.ChooseOne(); components.Get <Inventory>().EquipItem(bondedItem); } }
private bool ChoosesPositiveEnergy(CharacterAlignment alignment) { if (alignment.IsGood()) { return(true); } if (alignment.IsEvil()) { return(false); } return(Randomly.TrueFalse()); }
public void Execute(Settlement settlement) { var strategy = settlement.Get <SettlementStrategy>(); int target = Randomly.Range(strategy.MinimumPopulation, strategy.MaximumPopulation); for (int count = 0; count < target; count++) { var inhabitantStrategy = GatewayProvider.Find <CharacterStrategy>("inhabitant"); var designer = GatewayProvider.Find <CharacterDesigner>(inhabitantStrategy.Designer); var inhabitant = new CharacterSheet(inhabitantStrategy); designer.ExecuteStep(inhabitant); settlement.AddInhabitant(inhabitant); } }
public string ChooseOne() { var max = Tokens.Values.Sum(); var v = Randomly.Range(0, max); var idx = 0f; foreach (var t in Tokens) { idx += t.Value; if (v < idx) { return(t.Key); } } return(Tokens.Last().Key); }
public List <int> GetScores() { var availablePoints = this.Points; var divider = 0.6f; List <int> scores = new List <int>(); // First Identify whether to have zero, one or two stats as dumps int dumps = Randomly.Range(1, this.MaxDumpStats); for (int i = 0; i < dumps; i++) { var select = this.PointCosts.NegativeCosts().ChooseOne(); scores.Add(select); availablePoints -= this.PointCosts.PointCosts[select]; } // use 1/2 of points available at each buy point rounded up while (availablePoints > 0) { var spendPoints = availablePoints * divider; var closest = this.PointCosts.ClosestValue(spendPoints.Ceiling()); var cost = this.PointCosts.PointCosts[closest]; availablePoints -= cost; scores.Add(closest); } //Set Rest of values to Zero Cost while (scores.Count < 6) { scores.Add(PointCosts.ZeroCost()); } return(scores); }
/// <summary> /// Creates the last name. /// </summary> /// <returns>The last name.</returns> public string CreateLastName() { return(this.BuildNameFromSyllables(this.GetLastNameSyllables(), Randomly.Range(1, 5))); }
/// <summary> /// Rolls the die. This generates a random number from 1 to SidesCount. /// A d4 would generate either 1, 2, 3, 4 /// </summary> /// <returns>The value of the roll</returns> public int Roll() { this.LastRoll = Randomly.Range(1, this.MaximumValue); return(this.LastRoll); }
public T ChooseRandomly() { var value = Randomly.Range(1, maxValue); return(GetOption(value)); }