public void AddStartLine(TsvLine line) { foreach (var field in line.Fields) { AddField(field); } }
protected override void ConvertLine(LuaTextWriter luaWriter, TsvLine line) { if (line.Fields.Any() && !line.Fields.First().Value.StartsWith("SOURCE")) { var firstField = line.Fields.First(); if (firstField.StartsWith("FOLLOWER:")) { var def = new FollowerBonusDefinition(); foreach (var field in line.Fields) { def.AddField(field); } def.Dump(luaWriter); luaWriter.Write("\n"); return; } if (firstField.StartsWith("MASTERBONUSRACE:")) { var def = new FolloweeBonusDefinition(); foreach (var field in line.Fields) { def.AddField(field); } def.Dump(luaWriter); luaWriter.Write("\n"); return; } } base.ConvertLine(luaWriter, line); }
protected override void ConvertLine(LuaTextWriter luaWriter, TsvLine line) { void FinishKit() { _startingKit?.Dump(luaWriter); luaWriter.Write("\n"); _startingKit = null; } var firstField = line.Fields.First(); if (firstField.TryRemovePrefix("REGION:", out var region)) { FinishKit(); _requiredRegion = region.Value; return; } if (firstField.TryRemovePrefix("STARTPACK:", out _)) { FinishKit(); _startingKit = new StartingKitDefinition(_requiredRegion); _startingKit.AddStartLine(line); return; } if (!firstField.StartsWith("SOURCE")) { Debug.Assert(_startingKit != null, nameof(_startingKit) + " != null"); _startingKit.AddLine(line); return; } base.ConvertLine(luaWriter, line); }
protected virtual void ConvertLine(LuaTextWriter luaWriter, TsvLine line) { var firstValue = line.Fields.First(); if (State == null && firstValue.StartsWith("SOURCE")) { luaWriter.Write("SetSource("); SourceDefinition.Parse(line.Fields).Dump(luaWriter); luaWriter.Write(")\n"); return; } throw new ParseFailedException(firstValue, $"Unknown field {firstValue.Value} seen in state {State}"); }
protected override void ConvertLine(LuaTextWriter luaWriter, TsvLine line) { if (line.Fields.Any() && !line.Fields.First().Value.StartsWith("SOURCE")) { var def = new T(); foreach (var field in line.Fields) { def.AddField(field); } def.Dump(luaWriter); luaWriter.Write("\n"); return; } base.ConvertLine(luaWriter, line); }
protected override void ConvertLine(LuaTextWriter luaWriter, TsvLine line) { var firstField = line.Fields.First(); switch (State) { case "classStart": Debug.Assert(_classDefinition != null); if (!firstField.StartsWith("CLASS:")) { State = "class"; goto case "class"; } _classDefinition.AddLine(line); return; case "class": Debug.Assert(_classDefinition != null); if (firstField.StartsWith("CLASS:")) { _classDefinition.Dump(luaWriter); luaWriter.Write("\n"); _classDefinition = null; State = null; goto default; } _classDefinition.AddLine(line); return; default: if (firstField.StartsWith("CLASS:")) { var name = firstField.SplitTuple(':').right; State = "classStart"; _classDefinition = new ClassDefinition(name.Value); _classDefinition.AddLine(line); return; } break; } base.ConvertLine(luaWriter, line); }
protected override void ConvertLine(LuaTextWriter luaWriter, TsvLine line) { var firstField = line.Fields.First(); if (firstField.StartsWith("FACTDEF")) { var def = new FactDefinition(); foreach (var field in line.Fields) { def.AddField(field); } def.Dump(luaWriter); luaWriter.Write("\n"); return; } if (firstField.TryRemovePrefix("DEFAULTVARIABLEVALUE:", out var defVar)) { var(v, value) = defVar.SplitTuple('|'); luaWriter.Write($"SetDefaultVariableValue(\"{v.Value}\", \"{value.Value}\")\n"); return; } if (firstField.StartsWith("FUNCTION:")) { var def = new FunctionDefinition(); foreach (var field in line.Fields) { def.AddField(field); } def.Dump(luaWriter); luaWriter.Write("\n"); return; } if (firstField.StartsWith("FACTSETDEF")) { // Ignoring this one for now return; } base.ConvertLine(luaWriter, line); }
public void AddLine(TsvLine line) { void Add <T>() where T : StartingKitLine, new() { var l = new T(); foreach (var field in line.Fields) { l.AddField(field); } _lines.Add(l); } var field = line.Fields.First(); if (field.TryRemovePrefix("RACE:", out field)) { Add <RaceStartingKitLine>(); return; } if (field.TryRemovePrefix("NAME:", out field)) { Add <NameStartingKitLine>(); return; } if (field.TryRemovePrefix("GENDER:", out field)) { Add <GenderStartingKitLine>(); return; } if (field.TryRemovePrefix("AGE:", out field)) { Add <AgeStartingKitLine>(); return; } if (field.TryRemovePrefix("ALIGN:", out field)) { Add <AlignStartingKitLine>(); return; } if (field.TryRemovePrefix("STAT:", out field)) { Add <StatStartingKitLine>(); return; } if (field.TryRemovePrefix("CLASS:", out field)) { Add <ClassLevelStartingKitLine>(); return; } if (field.TryRemovePrefix("SKILL:", out field)) { Add <SkillStartingKitLine>(); return; } if (field.TryRemovePrefix("DEITY:", out field)) { Add <DeityStartingKitLine>(); return; } if (field.TryRemovePrefix("DOMAIN:", out field)) { Add <DomainStartingKitLine>(); return; } if (field.TryRemovePrefix("PROF:", out field)) { Add <ProficiencyStartingKitLine>(); return; } if (field.TryRemovePrefix("ABILITY:", out field)) { Add <AbilityStartingKitLine>(); return; } if (field.TryRemovePrefix("LEVELABILITY:", out field)) { Add <LevelAbilityStartingKitLine>(); return; } if (field.TryRemovePrefix("TEMPLATE:", out field)) { Add <TemplateStartingKitLine>(); return; } if (field.TryRemovePrefix("FUNDS:", out field)) { Add <FundsStartingKitLine>(); return; } if (field.TryRemovePrefix("GEAR:", out field)) { Add <GearStartingKitLine>(); return; } if (field.TryRemovePrefix("TABLE:", out field)) { Add <TableStartingKitLine>(); return; } if (field.TryRemovePrefix("SPELLS:", out field)) { Add <SpellsStartingKitLine>(); return; } if (field.TryRemovePrefix("SELECT:", out field)) { Add <SelectStartingKitLine>(); return; } if (field.TryRemovePrefix("LANGBONUS:", out field)) { Add <LanguageStartingKitLine>(); return; } throw new ParseFailedException(field, "Unable to parse line."); }
public void NextLine() { line.Add(current); current = new TsvLine(); }