예제 #1
0
        public override void AddField(TextSpan field)
        {
            var(k, v) = field.SplitTuple(':');

            switch (k.Value)
            {
            case "SPELLSTAT":
                SpellStat = v.Value;
                return;

            case "SPELLLIST":
                var(count, spells)   = v.SplitTuple('|');
                SpellListChoiceCount = Helpers.ParseInt(count);
                SpellListChoices     = spells.Split('|').Select(s => s.Value).ToList();
                return;
            }

            base.AddField(field);
        }
예제 #2
0
        public override void AddField(TextSpan field)
        {
            var(k, v) = field.SplitTuple(':');

            switch (k.Value)
            {
            case "CHOICE":
                var(kind, value) = v.SplitTuple('|');
                ChoiceKind       = kind.Value;
                ChoiceValue      = value.Value;
                return;

            case "COST":
                Cost = Helpers.ParseInt(v);
                return;
            }

            base.AddField(field);
        }
예제 #3
0
        public override void AddField(TextSpan field)
        {
            var(k, v) = field.SplitTuple(':');
            Helpers.CheckForMODorCOPYorCLEAR(v);

            switch (k.Value)
            {
            case "CAST":
                SpellsPerDay.Clear();
                SpellsPerDay.AddRange(v.Split(',').Select(Helpers.ParseInt).ToList());
                return;

            case "KNOWN":
                SpellsKnown.Clear();
                SpellsKnown.AddRange(v.Split(',').Select(Helpers.ParseInt).ToList());
                return;
            }

            base.AddField(field);
        }
예제 #4
0
        public StatModification(TextSpan value)
        {
            var(typeSpan, data) = value.SplitTuple('|');
            Type = typeSpan.Value switch
            {
                "LOCK" => StatModificationType.Lock,
                "UNLOCK" => StatModificationType.Unlock,
                "NONSTAT" => StatModificationType.NonStat,
                "STAT" => StatModificationType.Stat,
                "MINVALUE" => StatModificationType.MinValue,
                "MAXVALUE" => StatModificationType.MaxValue,
                _ => throw new ParseFailedException(typeSpan, "Unknown DEFINESTAT"),
            };
            TextSpan stat = data;

            switch (Type)
            {
            case StatModificationType.Lock:
            case StatModificationType.MinValue:
            case StatModificationType.MaxValue:
                TextSpan v;
                (stat, v) = data.SplitTuple('|');
                Stat      = stat.Value;
                Value     = v.Value;
                break;

            case StatModificationType.Unlock:
            case StatModificationType.NonStat:
            case StatModificationType.Stat:
                Value = null;
                Stat  = stat.Value;
                break;

            default:
                throw new InvalidOperationException("How did we get here?");
            }
        }
예제 #5
0
        private static bool TryParsePCCDataField(TextSpan field, DataSourceInfo sourceInfo)
        {
            var(k, v) = field.SplitTuple(':');
            switch (k.Value)
            {
            case "CAMPAIGN":
                sourceInfo.Name = v.Value;
                return(true);

            case "GAMEMODE":
                sourceInfo.GameMode = v.Value;
                return(true);

            case "BOOKTYPE":
                sourceInfo.BookTypes.AddRange(v.Value.Split('|'));
                return(true);

            case "COPYRIGHT":
                sourceInfo.Copyright += v.Value + "\\n";
                return(true);

            case "DESC":
                sourceInfo.Description = v.Value;
                return(true);

            case "GENRE":
                sourceInfo.Genre = v.Value;
                return(true);

            case "HELP":
                sourceInfo.HelpUrl = v.Value;
                return(true);

            case "INFOTEXT":
                sourceInfo.InfoText = v.Value;
                return(true);

            case "SETTING":
                sourceInfo.Setting = v.Value;
                return(true);

            case "ISMATURE":
                sourceInfo.IsMature = Helpers.ParseBool(v);
                return(true);

            case "ISOGL":
                sourceInfo.IsOGL = Helpers.ParseBool(v);
                return(true);

            case "SHOWINMENU":
                sourceInfo.ShowInMenu = Helpers.ParseBool(v);
                return(true);

            case "ISLICENSED":
                sourceInfo.IsLicensed = Helpers.ParseBool(v);
                return(true);

            case "LICENSE":
                if (v.StartsWith("FILE="))
                {
                    sourceInfo.LicenseFile = v.Substring("FILE=".Length).Value;
                }
                else
                {
                    sourceInfo.LicenseText = v.Value;
                }

                return(true);

            case "!PRECAMPAIGN":
                sourceInfo.Conditions.Add(CampaignCondition.Parse(true, v));
                return(true);

            case "PRECAMPAIGN":
                sourceInfo.Conditions.Add(CampaignCondition.Parse(false, v));
                return(true);

            case "PUBNAMELONG":
                sourceInfo.PublisherInfo.NameLong = v.Value;
                return(true);

            case "PUBNAMESHORT":
                sourceInfo.PublisherInfo.NameShort = v.Value;
                return(true);

            case "PUBNAMEWEB":
                sourceInfo.PublisherInfo.Url = v.Value;
                return(true);

            case "SOURCELONG":
                sourceInfo.SourceInfo.SourceLong = v.Value;
                return(true);

            case "SOURCESHORT":
                sourceInfo.SourceInfo.SourceShort = v.Value;
                return(true);

            case "SOURCEWEB":
                sourceInfo.SourceInfo.SourceWeb = v.Value;
                return(true);

            case "SOURCEDATE":
                sourceInfo.SourceInfo.SourceDate = v.Value;
                return(true);

            case "STATUS":
                sourceInfo.Status = v.Value.ToUpperInvariant() switch
                {
                    "TESTONLY" => DataSourceStatus.TestOnly,
                    "ALPHA" => DataSourceStatus.Alpha,
                    "BETA" => DataSourceStatus.Beta,
                    _ => DataSourceStatus.Release,
                };
                return(true);

            case "RANK":
                sourceInfo.Rank = Helpers.ParseInt(v);
                return(true);

            case "TYPE":
                sourceInfo.Types.AddRange(v.Value.Split('.'));
                return(true);

            case "URL":
                var parts = v.Value.Split('|');
                if (parts.Length != 3)
                {
                    throw new ParseFailedException(v, "Unable to parse PCC URL value");
                }

                sourceInfo.Links.Add((parts[0], parts[1], parts[2]));
                return(true);

            case "COVER":
                sourceInfo.CoverImage = v.Value;
                return(true);

            case "LOGO":
                sourceInfo.LogoImage = v.Value;
                return(true);

            case "KEY":
                return(true);

            default:
                return(false);
            }
        }
예제 #6
0
        public virtual void AddField(TextSpan field)
        {
            if (Condition.TryParse(field, out var condition))
            {
                Conditions.Add(condition);
                return;
            }

            var(k, v) = field.SplitTuple(':');

            switch (k.Value)
            {
            case "PROHIBITSPELL":
                ProhibitedSpells.Add(ProhibitedSpell.Parse(v));
                return;

            case "BONUS":
                Bonuses.Add(Bonus.Parse(v));
                return;

            case "DEFINE":
            {
                var parts = v.Split('|').ToArray();
                if (parts.Length != 2)
                {
                    throw new ParseFailedException(field, "Unable to parse variable definition.");
                }

                Definitions.Add(new VariableDefinition(parts[0].Value, Helpers.ParseInt(parts[1])));
                return;
            }

            case "ABILITY":
                Abilities.Add(AbilityReference.Parse(v));
                return;

            case "DOMAIN":
                Domains.Add(DomainReference.Parse(v));
                return;

            case "CSKILL":
                ClassSkills.AddRange(v.Value.Split('|'));
                return;

            case "SOURCEPAGE":
                SourcePage = v.Value;
                return;

            case "SPELLLEVEL":
                SpellLists.AddRange(SpellList.Parse(v));
                return;

            case "WEAPONBONUS":
                WeaponBonusProficiencySelections.Add(v.Value.Split('|').ToList());
                return;

            case "KIT":
                // we are ignoring this one
                return;

            case "ADD":
            {
                var(type, parameter) = v.SplitTuple('|');
                switch (type.Value)
                {
                case "SPELLCASTER":
                    AddedSpellCasterLevels.Add(AddedSpellCasterLevel.Parse(parameter));
                    return;
                }
                break;
            }
            }

            throw new ParseFailedException(field, $"Unknown field '{field.Value}'");
        }