Skip to content

INQCharacterImportParser.js

kyleady edited this page Jun 26, 2017 · 1 revision

Purpose

Can take the copy-pasted text from a pdf and parse it into an INQCharacter.js.

This is a very temperamental feature as character sheets in pdfs aren't always written the same, and pdfs don't always copy-paste in a reliable manner. You should always check the work after it is completed.

Usage

It is suggested that you do not use this prototype directly. Instead, let new INQCharacter() make use of it.

The string is first split by each line, denoted by <br>, and next split into labeled and unlabeled lines. The label is all of the text that comes that comes before the first colon of the line. Everything that comes after the colon is treated as the content.

  • Unlabeled lines

    • If an unlabeled line comes after a labeled line, it will be tacked onto the most recent labeled line.
    • If there is no labeled line to tack it onto and the line is numerical, it will parse it as follows
      • The first unlabled numerical line will be understood as the character's Characteristic Bonuses. They can be in parenthesis or not. Any bonuses not detailed or at 0 will be ignored. For example, 0 0 - (0) 8 would mean that this character has an Agility Bonus of 8 due to Unnatural Agility.
      • The second unlabeled numerical line will be understood as the character's Characteristics. The string - - will be interpreted as 0.
      • If only one numerical line was included, it will be understood as the character's Characteristics instead of their Characteristic Bonuses.
    • If none of the above criteria is met, the unlabled line will be ignored, likely being labels for all of the characteristics.
  • Labeled lines are interpreted by their labels.

    • Move[ment]: Expected to be #/#/#/# for Half, Full, Charge, and Run.
    • Total TB: This line is ignored as T Bonus can be calculated from the Characteristics and Characteristic Bonuses.
    • Armour: Expected to have one or more locations paired with numbers. The following locations are accepted.
      • Head
      • Arms
      • Body
      • Legs
      • All
    • Wounds: Expected to contain a single number.
    • Weapons: Uses INQLinkParser.js regex to separate out the individual weapons, then uses INQWeaponNoteParser to parse each weapon. It is assumed that all imported weapons are custom weapons that are unique to this character.
    • (Skills|Talents|Traits|Gear|Psychic Powers): Uses INQLinkParser.js regex to separate and store each item in the list.
    • If none of the patterns are met, the labeled line is saved as a Special Rule.

After the entire string is parsed, some adjustments are made.

  • Bonuses that were non-zero are used to calculate Unnatural Bonuses. For example, if a character's Ag Bonus was recorded as 8, but their Ag was 30, their Unnatural Agility would be recorded as 5, so that 3 + 5 = 8.
  • While Dark Heresy records the total damage of weapons including bonuses for Talents, Traits, Qualities, and Strength Bonus, I want just the base damage of the weapon. The following is accounted for:
    • Strength Bonus for Melee Weapons
    • The Fist Quality which doubles the Strength Bonus for Melee Weapons
    • Crushing Blow
    • Mighty Shot
  • Finally, Fatigue is calculated from the character's Toughness Bonus and Fate is calculated from the Touched by the Fates(X) Trait.

The following is an example character from FFG's Final Sanction Free Adventure.

WS BS S T Ag Int Per WP Fel
0 0 (12)
65 — 60 60 60 30 55 40 ––
Movement: 12/24/36/72
Wounds: 20
Skills: Awareness (Per), Climb (S), Dodge (Ag) +10, Swim
(S) +10.
Traits: Unnatural Strength (×2).
Armour: Reinforced Chitin (All 6).
Weapons: Rending Claws (2d10+12; Pen 5, Special).

Stealth: As masters of stalking their prey, Genestealers are
hard to spot even in open terrain. If a Genestealer moves at half
speed and does not attack, creatures must pass a Challenging
(+0) Awareness Test to detect its presence.
Rending Claws: The claws of a Genestealer are razor
sharp and a well placed blow can cut right through even the
toughest armours. When rolling to attack with this weapon,
if the attack roll results in two or more Degrees of Success,
double its Penetration

It was not quite a simple copy-paste. I had to do the following edits:

  • Put two zeroes before the (12) to signal that (12) was the third characteristic bonus.
  • Move Wounds: to a separate line from Movement:
  • Remove the line Special Rules, otherwise it would have been tacked onto the list of Weapons.

Requirements

Clone this wiki locally