当前位置: 首页>>代码示例>>C#>>正文


C# Dice.Pick方法代码示例

本文整理汇总了C#中Dice.Pick方法的典型用法代码示例。如果您正苦于以下问题:C# Dice.Pick方法的具体用法?C# Dice.Pick怎么用?C# Dice.Pick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dice的用法示例。


在下文中一共展示了Dice.Pick方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        internal override void Run(Character character, Dice dice)
        {
            character.LongTermBenefits.MayEnrollInSchool = false;

            character.AddHistory($"Entered University at age {character.Age}");

            var skillChoices = new SkillTemplateCollection();
            skillChoices.Add("Admin");
            skillChoices.Add("Advocate");
            skillChoices.Add("Animals", "Training");
            skillChoices.Add("Animals", "Veterinary");
            skillChoices.AddRange(SpecialtiesFor("Art"));
            skillChoices.Add("Astrogation");
            skillChoices.AddRange(SpecialtiesFor("Electronics"));
            skillChoices.AddRange(SpecialtiesFor("Engineer"));
            skillChoices.AddRange(SpecialtiesFor("Language"));
            skillChoices.Add("Medic");
            skillChoices.Add("Navigation");
            skillChoices.AddRange(SpecialtiesFor("Profession"));
            skillChoices.AddRange(SpecialtiesFor("Science"));

            //Remove skills we already have at level 1
            skillChoices.RemoveOverlap(character.Skills, 1);

            var skillA = dice.Pick(skillChoices);
            character.Skills.Add(skillA, 1);

            //Remove skills we already have at level 0
            skillChoices.RemoveOverlap(character.Skills, 0);

            var skillB = dice.Pick(skillChoices);
            character.Skills.Add(skillB);

            character.Age += 4;
            character.Education += 1;
            character.EducationHistory = new EducationHistory();
            character.EducationHistory.Name = "University";

            Book.PreCareerEvents(character, dice, skillA.Name, skillB.Name);

            var graduation = dice.D(2, 6) + character.IntellectDM + character.CurrentTermBenefits.GraduationDM;
            if (graduation < 7)
            {
                character.AddHistory("Dropped out of university.");
                character.EducationHistory.Status = "Failed";
            }
            else
            {
                int bonus;
                if (graduation >= 11)
                {
                    character.EducationHistory.Status = "Honors";
                    character.AddHistory($"Graduated with honors at age {character.Age}.");
                    bonus = 2;
                }
                else
                {
                    character.EducationHistory.Status = "Graduated";
                    character.AddHistory($"Graduated at age {character.Age}.");
                    bonus = 1;
                }

                character.Education += 2;

                character.Skills.Increase(skillA, 1);
                character.Skills.Increase(skillB, 1);

                character.NextTermBenefits.FreeCommissionRoll = true;
                character.NextTermBenefits.CommissionDM = bonus;
                character.LongTermBenefits.EnlistmentDM.Add("Agent", bonus);
                character.LongTermBenefits.EnlistmentDM.Add("Army", bonus);
                character.LongTermBenefits.EnlistmentDM.Add("Corporate", bonus);
                character.LongTermBenefits.EnlistmentDM.Add("Journalist", bonus);
                character.LongTermBenefits.EnlistmentDM.Add("Marines", bonus);
                character.LongTermBenefits.EnlistmentDM.Add("Navy", bonus);
                character.LongTermBenefits.EnlistmentDM.Add("Scholar", bonus);
                character.LongTermBenefits.EnlistmentDM.Add("Scouts", bonus);
            }
        }
开发者ID:Grauenwolf,项目名称:TravellerTools,代码行数:79,代码来源:University.cs

示例2: Event

        internal override void Event(Character character, Dice dice)
        {
            switch (dice.D(2, 6))
            {
                case 2:
                    Mishap(character, dice);
                    character.NextTermBenefits.MusterOut = false;
                    return;
                case 3:
                    if (dice.D(2) == 1)
                    {
                        character.AddHistory("Refused to perform research that goes against your conscience.");
                    }
                    else
                    {
                        character.AddHistory($"Agreed to perform research that goes against your conscience. Gain {dice.D(3)} Enemies.");
                        character.BenefitRolls += 1;

                        var skillList = new SkillTemplateCollection(SpecialtiesFor("Science"));
                        character.Skills.Increase(dice.Pick(skillList));
                        character.Skills.Increase(dice.Pick(skillList)); //pick 2

                    }
                    return;
                case 4:
                    character.AddHistory("Assigned to work on a secret project for a patron or organisation.");
                    {
                        var skillList = new SkillTemplateCollection();
                        skillList.Add("Medic");
                        skillList.AddRange(SpecialtiesFor("Science"));
                        skillList.AddRange(SpecialtiesFor("Engineer"));
                        skillList.AddRange(SpecialtiesFor("Electronics"));
                        skillList.Add("Investigate");
                        skillList.RemoveOverlap(character.Skills, 1);
                        if (skillList.Count > 0)
                            character.Skills.Add(dice.Choose(skillList), 1);
                    }
                    return;
                case 5:
                    character.AddHistory($"Win a prestigious prize for your work.");
                    character.BenefitRollDMs.Add(1);
                    return;
                case 6:
                    character.AddHistory("Advanced training in a specialist field.");
                    if (dice.RollHigh(character.EducationDM, 8))
                    {
                        var skillList = new SkillTemplateCollection(RandomSkills);
                        skillList.RemoveOverlap(character.Skills, 1);
                        if (skillList.Count > 0)
                            character.Skills.Add(dice.Choose(skillList), 1);
                    }

                    return;
                case 7:
                    LifeEvent(character, dice);
                    return;
                case 8:
                    {
                        if (dice.D(2) == 1)
                        {
                            if (dice.RollHigh(character.Skills.BestSkillLevel("Deception", "Admin"), 8))
                            {
                                character.AddHistory("Cheated in some fashion, advancing your career and research by stealing another’s work, using an alien device, taking a shortcut and so forth.");
                                character.BenefitRollDMs.Add(2);
                                dice.Choose(character.Skills).Level += 1;
                            }
                            else
                            {
                                character.AddHistory("Caught cheating in some fashion, advancing your career and research by stealing another’s work, using an alien device, taking a shortcut and so forth.");
                                character.BenefitRolls += -1;
                                Mishap(character, dice);
                            }
                            character.AddHistory("Gain an Enemy");
                        }
                        else
                        {
                            character.AddHistory("Refuse to join a cheat in some fashion.");
                        }

                    }
                    return;
                case 9:
                    character.AddHistory("Make a breakthrough in your field.");
                    character.CurrentTermBenefits.AdvancementDM += 2;
                    return;
                case 10:
                    character.AddHistory("Entangled in a bureaucratic or legal morass that distracts you from your work.");
                    {
                        var skillList = new SkillTemplateCollection();
                        skillList.Add("Admin");
                        skillList.Add("Advocate");
                        skillList.Add("Persuade");
                        skillList.Add("Diplomat");
                        skillList.RemoveOverlap(character.Skills, 1);
                        if (skillList.Count > 0)
                            character.Skills.Add(dice.Choose(skillList), 1);
                    }
                    return;
                case 11:
                    character.AddHistory("Work for an eccentric but brilliant mentor, who becomes an Ally.");
//.........这里部分代码省略.........
开发者ID:Grauenwolf,项目名称:TravellerTools,代码行数:101,代码来源:Scholar.cs


注:本文中的Dice.Pick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。