コード例 #1
0
        static void Main()
        {
            Random random   = new Random();
            bool   endSteps = false;

            Step[] stepOrder = new Step[]
            {
                Step.NPCorMonster,
                Step.Level,
                Step.Traits,
                Step.Size,
                Step.Hit_Points,
                Step.Resistances_Weaknesses,
                Step.Skills,
                Step.Armor_Class,
                Step.Strike_Attack_Bonus,
                Step.Strike_Damage,
                Step.Ability_Scores,
                Step.Perception,
                Step.Saves,
                Step.Spells,
                Step.Spell_DC_And_Attack_Bonus,
                Step.Area_Damage,
                Step.Gear,
                Step.End,
                Step.SaveToFile
            };

            int partyLevel = Program.GetMinMaxInt("Please enter the party's current level: ", MinMax.hasBoth, 1, 20);

            for (int step = 0; endSteps == false; step++)
            {
                if (step >= 0 && step < stepOrder.Length)
                {
                    Console.WriteLine("Step: " + stepOrder[step]);
                }

                if (step > 0)
                {
                    step = ContinueOrBack(stepOrder, step);
                }

                if (_creatureSaves.ContainsKey(stepOrder[step]))
                {
                    _creatureSaves.Remove(stepOrder[step]);
                }
                _creatureSaves.Add(stepOrder[step], CopyCreature(_creature));

                switch (stepOrder[step])
                {
                case Step.NPCorMonster:
                {
                    Console.WriteLine("Enter NPC or Monster to select a creature type, or press Enter to randomly select");
                    string userInput = GetValidString("NPC", "Monster", "");
                    switch (userInput.ToUpper())
                    {
                    case "NPC":
                        _creature.Type = CreatureType.NPC;
                        break;

                    case "Monster":
                        _creature.Type = CreatureType.Monster;
                        break;

                    case "":
                        _creature.Type = CreatureType.Any;
                        break;
                    }
                    break;
                }

                case Step.Level:
                {
                    ExecuteStep.LevelStep(random, _creature, partyLevel);
                    break;
                }

                case Step.Traits:
                {
                    string userInput = "";
                    do
                    {
                        ExecuteStep.TraitsStep(_creature, random);
                        Console.WriteLine("Press enter to continue or ADD to add another trait");
                        userInput = GetValidString("", "ADD");
                    } while (userInput.ToUpper() == "ADD");
                    break;
                }

                case Step.Size:
                {
                    ExecuteStep.SizeStep(_creature, random);
                    break;
                }

                case Step.Hit_Points:
                {
                    ExecuteStep.HitPointStep(_creature, random);
                    break;
                }

                case Step.Resistances_Weaknesses:
                {
                    Console.WriteLine("Press Enter to continue or NO to skip this step");
                    string userInput = GetValidString("", "NO");
                    if (userInput.ToUpper() != "NO")
                    {
                        ExecuteStep.ResistanceWeaknessStep(_creature, random);
                    }
                    break;
                }

                case Step.Skills:
                {
                    do
                    {
                        List <Degree> savedDegrees = CopyDegreeList(_creature.DegreeList);
                        ExecuteStep.SkillStep(_creature, random);
                        Console.WriteLine("Press ENTER to continue or BACK to erase previous skill");
                        string userInput = GetValidString("", "BACK");
                        if (userInput.ToUpper() == "BACK")
                        {
                            int latestSkillIndex = _creature.SkillPool.SelectedSkills.Count() - 1;
                            _creature.SkillPool.PossibleSkills.Add(_creature.SkillPool.SelectedSkills[latestSkillIndex].skillName);
                            _creature.SkillPool.PossibleSkills.Sort();
                            _creature.SkillPool.SelectedSkills.RemoveAt(latestSkillIndex);
                            _creature.DegreeList = CopyDegreeList(savedDegrees);
                        }
                    } while (_creature.SkillPool.SelectedSkills.Count < 6);
                    break;
                }

                case Step.Armor_Class:
                {
                    ExecuteStep.ArmorClassStep(_creature, random);
                    break;
                }

                case Step.Strike_Attack_Bonus:
                {
                    ExecuteStep.StrikeAttackStep(_creature, random);
                    break;
                }

                case Step.Strike_Damage:
                {
                    ExecuteStep.StrikeDamageStep(_creature, random);
                    break;
                }

                case Step.Ability_Scores:
                {
                    AbilityScoreEnum[] abilities = new AbilityScoreEnum[] { AbilityScoreEnum.Strength, AbilityScoreEnum.Dexterity, AbilityScoreEnum.Intelligence, AbilityScoreEnum.Wisdom, AbilityScoreEnum.Charisma };
                    foreach (AbilityScoreEnum ability in abilities)
                    {
                        string userInput = "";
                        do
                        {
                            List <Degree> saveDegrees = CopyDegreeList(_creature.DegreeList);
                            ExecuteStep.AbilityScoreStep(_creature, random, ability);
                            Console.WriteLine("Press ENTER to continue or BACK to redo the {0} score", ability);
                            userInput = GetValidString("", "BACK");
                            if (userInput.ToUpper() == "BACK")
                            {
                                _creature.DegreeList = CopyDegreeList(saveDegrees);
                            }
                        } while (userInput.ToUpper() == "BACK");
                    }
                    break;
                }

                case Step.Perception:
                {
                    ExecuteStep.PerceptionStep(_creature, random);
                    break;
                }

                case Step.Saves:
                {
                    SaveName[] saves = new SaveName[] { SaveName.Fortitude, SaveName.Reflex, SaveName.Will };
                    foreach (SaveName save in saves)
                    {
                        ExecuteStep.SavesStep(_creature, random, save);
                    }
                    break;
                }

                case Step.Spells:
                {
                    string[] spellTypes = new string[] { "Arcane", "Occult", "Primal", "Divine", "Focus", "NONE" };
                    Console.WriteLine("Press Enter to randomly select this creature's magic type or one of the following types:");
                    foreach (string type in spellTypes)
                    {
                        Console.WriteLine(type);
                    }
                    string[] validInputs = new string[spellTypes.Length + 1];
                    for (int i = 0; i < validInputs.Length; i++)
                    {
                        if (i == 0)

                        {
                            validInputs[i] = "";
                        }
                        else
                        {
                            validInputs[i] = spellTypes[i - 1];
                        }
                    }
                    string typeInput = GetValidString(validInputs);
                    if (typeInput == "")
                    {
                        if (random.Next(2) == 1)
                        {
                            typeInput = spellTypes[random.Next(spellTypes.Length)];
                        }
                        else
                        {
                            _creature.HasSpells = false;
                        }
                    }
                    if (typeInput.ToUpper() == "NONE")
                    {
                        _creature.HasSpells = false;
                    }
                    if (_creature.HasSpells)
                    {
                        ExecuteStep.SpellsStep(_creature, random, CapitalizeString(typeInput));
                    }
                    break;
                }

                case Step.Spell_DC_And_Attack_Bonus:
                {
                    if (!_creature.Spells.Any())
                    {
                        Console.WriteLine("No spells detected. Skipping step");
                    }
                    else
                    {
                        ExecuteStep.SpellStatsStep(_creature, random);
                    }
                    break;
                }

                case Step.Area_Damage:
                {
                    ExecuteStep.AreaDamageStep(_creature);
                    break;
                }

                case Step.Gear:
                {
                    Console.WriteLine("Press Enter to randomly determine if creature has gear or Y\\N:");
                    string userInput = GetValidString("", "Y", "N");
                    if (userInput == "" && random.Next(2) == 1)
                    {
                        userInput = "Y";
                    }
                    if (userInput.ToUpper() == "Y")
                    {
                        ExecuteStep.GearStep(_creature, random);
                    }
                    break;
                }

                case Step.End:
                {
                    ExecuteStep.EndStep(_creature);
                    break;
                }

                case Step.SaveToFile:
                {
                    Console.WriteLine("Would you like to save this creature? Y/N");
                    string saveOrNot = GetValidString("Y", "N");
                    if (saveOrNot.ToUpper() == "Y")
                    {
                        ExecuteStep.SaveToFileStep(_creature);
                    }
                    endSteps = true;
                    break;
                }

                default:
                {
                    Console.WriteLine("Step incomplete");
                    //endSteps = true;
                    break;
                }
                }
            }
        }