コード例 #1
0
        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);
        }
コード例 #2
0
        public void Execute(Settlement settlement)
        {
            var count = Randomly.Range(5, 15);

            for (int i = 0; i < count; i++)
            {
                settlement.Add(buildings.ChooseOne());
            }
        }
コード例 #3
0
ファイル: GameHub.cs プロジェクト: WonkiDonk/leedshack2016
        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);
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
        private bool ChoosesPositiveEnergy(CharacterAlignment alignment)
        {
            if (alignment.IsGood())
            {
                return(true);
            }

            if (alignment.IsEvil())
            {
                return(false);
            }

            return(Randomly.TrueFalse());
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
            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);
            }
コード例 #9
0
        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);
        }
コード例 #10
0
 /// <summary>
 /// Creates the last name.
 /// </summary>
 /// <returns>The last name.</returns>
 public string CreateLastName()
 {
     return(this.BuildNameFromSyllables(this.GetLastNameSyllables(), Randomly.Range(1, 5)));
 }
コード例 #11
0
 /// <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);
 }
コード例 #12
0
        public T ChooseRandomly()
        {
            var value = Randomly.Range(1, maxValue);

            return(GetOption(value));
        }