-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13145 from clevett/pendragon-2.5
Pendragon 3.0 by Chaosium
- Loading branch information
Showing
40 changed files
with
1,463 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
Pendragon6thEdition/src/js/drag_and_drop/get_rep_update.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const getRepUpdate = (attrs, row, page) => { | ||
let update = {}; | ||
|
||
attrs.forEach((attr) => { | ||
if (page?.[attr] ?? page?.data?.[attr]) { | ||
update[`${row}_${attr}`] = | ||
page[attr] ?? roll20Attribute(attr, page.data[attr]); | ||
} | ||
}); | ||
|
||
if (attrs.includes("notes")) { | ||
update[`${row}_flag`] = false; | ||
} | ||
|
||
return update; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const handle_horse = (page) => { | ||
const attrs = [ | ||
"armor", | ||
"charge_damage", | ||
"con", | ||
"damage", | ||
"dex", | ||
"hp", | ||
"move", | ||
"siz", | ||
"str", | ||
"type", | ||
]; | ||
const warHorseAttrs = attrs.map((attr) => `warhorse_${attr}`); | ||
let update = getStaticUpdate([...warHorseAttrs, "equestrian_notes"], page); | ||
update["warhorse_type"] = page.name; | ||
update["flag_equestrian_notes"] = false; | ||
|
||
if (!update["warhorse_charge_damage"]) { | ||
update["warhorse_charge_damage"] = "0"; | ||
} | ||
|
||
setAttrs(update); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const handle_item = (page, row) => { | ||
const update = update_item(page, row); | ||
setAttrs(update); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const handle_squire = (page) => { | ||
const attrs = ["squire_age", "squire_skill", "squire_notes"]; | ||
const update = getStaticUpdate(attrs, page); | ||
update["squire_name"] = page.name; | ||
update["flag_squire_notes"] = false; | ||
setAttrs(update); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const handle_weapon = (page) => { | ||
const update = update_attack(page); | ||
setAttrs(update); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const parseJSON = (jsonString) => { | ||
try { | ||
return JSON.parse(jsonString); | ||
} catch (e) { | ||
console.log(`Error parsing JSON: ${jsonString}`); | ||
return undefined; | ||
} | ||
}; | ||
|
||
const processDataArrays = (array, callback) => { | ||
const parsed = typeof array === "string" ? parseJSON(array) : array; | ||
const map = parsed.map((e) => callback(e)); | ||
return map.reduce((acc, val) => ({ ...acc, ...val })); | ||
}; | ||
|
||
const getRow = (section) => `repeating_${section}_${generateRowID()}`; | ||
|
||
const getStaticUpdate = (attrs, page) => { | ||
let update = {}; | ||
|
||
attrs.forEach((attr) => { | ||
if (page?.[attr] ?? page?.data?.[attr]) { | ||
update[attr] = page[attr] ?? roll20Attribute(attr, page.data[attr]); | ||
} | ||
}); | ||
|
||
return update; | ||
}; |
9 changes: 9 additions & 0 deletions
9
Pendragon6thEdition/src/js/drag_and_drop/reset_repeating_rows.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const resetRepeatingRows = (sections) => { | ||
sections.forEach((section) => { | ||
getSectionIDs(`repeating_${section}`, (ids) => { | ||
ids.forEach((id) => { | ||
removeRepeatingRow(`repeating_${section}_${id}`); | ||
}); | ||
}); | ||
}); | ||
}; |
13 changes: 13 additions & 0 deletions
13
Pendragon6thEdition/src/js/drag_and_drop/reset_skill_list.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const resetSkillList = (skills) => { | ||
const skillList = parseJSON(skills); | ||
const names = skillList.map(({ name }) => name.toLowerCase()); | ||
const update = {}; | ||
|
||
[...skills, ...combatSkills].forEach((skill) => { | ||
if (!names.includes(skill)) { | ||
update[skill] = 0; | ||
} | ||
}); | ||
|
||
setAttrs(update); | ||
}; |
7 changes: 7 additions & 0 deletions
7
Pendragon6thEdition/src/js/drag_and_drop/roll_20_attribute.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const roll20Attribute = (attr, value) => { | ||
if (attr === "skill") { | ||
return `@{${attrName(value)}}`; | ||
} | ||
|
||
return value; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const update_attack = (page) => { | ||
const row = getRow("attacks"); | ||
const attrs = ["name", "skill"]; | ||
|
||
const { damage, damage_type } = page.data; | ||
const update = getRepUpdate(attrs, row, page); | ||
|
||
const type = damage_type.toLowerCase(); | ||
|
||
const modifier = damage ? `+${damage}` : ""; | ||
if (["brawling", "character"].includes(type)) { | ||
const attr = `${type}_damage`; | ||
getAttrs([attr], (v) => { | ||
if (v) { | ||
setAttrs({ [`${row}_damage`]: `${v[attr]}${modifier}` }); | ||
} else { | ||
dropWarning(`Unknown damage type: ${damage_type}`); | ||
} | ||
}); | ||
} else if (["horse"].includes(type)) { | ||
getAttrs( | ||
["warhorse_charge_damage", "warhorse_damage"], | ||
({ warhorse_charge_damage, warhorse_damage }) => { | ||
if (warhorse_charge_damage || warhorse_damage) { | ||
const damage = warhorse_charge_damage || warhorse_damage; | ||
|
||
setAttrs({ | ||
[`${row}_damage`]: `${damage}${modifier}`, | ||
}); | ||
} else { | ||
dropWarning(`Could not get values for warhorse damage`); | ||
} | ||
} | ||
); | ||
} else if (damage) { | ||
update[`${row}_damage`] = damage; | ||
} | ||
|
||
console.table({ | ||
type, | ||
}); | ||
|
||
return update; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const update_item = (page, row) => { | ||
let update = getRepUpdate( | ||
["name", "value", "notes", "period_restriction"], | ||
row, | ||
page | ||
); | ||
|
||
if (page?.data?.["subcategory"]) { | ||
update[`${row}_category`] = page.data["subcategory"]; | ||
} | ||
|
||
return update; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const update_section = (page, section) => { | ||
const row = getRow(section); | ||
const attrs = ["name", "target_value"]; | ||
return getRepUpdate(attrs, row, page); | ||
}; |
Oops, something went wrong.