Skip to content

Commit

Permalink
Merge pull request #13145 from clevett/pendragon-2.5
Browse files Browse the repository at this point in the history
Pendragon 3.0 by Chaosium
  • Loading branch information
NorWhal authored Aug 1, 2024
2 parents 41dca93 + 3ef6c24 commit 6f17473
Show file tree
Hide file tree
Showing 40 changed files with 1,463 additions and 278 deletions.
2 changes: 1 addition & 1 deletion Pendragon6thEdition/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pendragon6thedition",
"version": "2.4.2",
"version": "3.0.0",
"description": "You need to run npm start to get the compilers going.",
"dependencies": {
"20": "^3.1.9",
Expand Down
111 changes: 61 additions & 50 deletions Pendragon6thEdition/pendragon.css
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ div.sheet-attacks input[name="attr_damage"],
div.sheet-attacks span[name*="damage"] {
text-align: center; }

div.sheet-attacks div.sheet-table.sheet-brawling div.sheet-header,
div.sheet-attacks div.sheet-table.sheet-brawling div.sheet-body div.sheet-row {
grid-template-columns: 2fr 1fr 5em 2.5em; }
div.sheet-attacks div.sheet-table.sheet-damage div.sheet-header,
div.sheet-attacks div.sheet-table.sheet-damage div.sheet-body div.sheet-row {
grid-template-columns: 2fr 1fr 2.5em; }

div.sheet-attacks div.sheet-repeating-container div.sheet-row,
div.sheet-attacks div.sheet-repeating-container div.sheet-header {
Expand All @@ -407,6 +407,14 @@ div.sheet-attacks label[data-i18n-title="other skill"] {
div.sheet-attacks input[name="attr_skill"][value*="other"] + label {
visibility: visible; }

div.sheet-attacks select[name="attr_skill"] {
margin-left: -5px; }

div.sheet-attacks h3,
div.sheet-attacks span[data-i18n*="brawling"],
div.sheet-attacks span[name*="damage"] {
color: #000; }

div.sheet-character div.sheet-horse input[type="text"],
div.sheet-character div.sheet-horse input[type="number"] {
text-align: center;
Expand Down Expand Up @@ -465,8 +473,22 @@ div.sheet-character div.sheet-squire div.sheet-skill {
div.sheet-character div.sheet-squire input[name="attr_squire_age"] {
text-align: center; }

div.sheet-character div.sheet-equipment input[name="attr_category"] {
font-weight: bold; }
div.sheet-character div.sheet-squire div.sheet-notes {
grid-template-columns: 1fr 10px;
padding: 1% 2%; }
div.sheet-character div.sheet-squire div.sheet-notes input.sheet-flag,
div.sheet-character div.sheet-squire div.sheet-notes span.sheet-pictos {
grid-area: 1/2/2/3; }
div.sheet-character div.sheet-squire div.sheet-notes textarea,
div.sheet-character div.sheet-squire div.sheet-notes span.sheet-display {
grid-area: 1/1/2/2; }

div.sheet-character div.sheet-equipment span[name="attr_value"],
div.sheet-character div.sheet-equipment input[name="attr_value"] {
text-align: center; }

div.sheet-character div.sheet-equipment div.sheet-col {
grid-template-rows: min-content 1fr; }

div.sheet-character div.sheet-equipment div.sheet-2autocolumn {
align-content: end; }
Expand All @@ -475,6 +497,9 @@ div.sheet-character div.sheet-equipment span[name="attr_equipment"],
div.sheet-character div.sheet-equipment span[name="attr_category"] {
min-height: 20px; }

div.sheet-character div.sheet-equipment div.sheet-category {
grid-template-columns: 3fr 1fr; }

div.sheet-character div.sheet-equipment div.sheet-repeating-container div.sheet-flags {
grid-template-columns: 1fr 25px; }

Expand All @@ -495,6 +520,9 @@ div.sheet-character div.sheet-characteristics div.sheet-core {
grid-auto-flow: column;
grid-column-gap: 2%; }

div.sheet-character div.sheet-characteristics span {
color: #000; }

div.sheet-character h2 {
text-overflow: ellipsis;
width: fit-content; }
Expand Down Expand Up @@ -779,25 +807,18 @@ div.sheet-table {
/* TABLE
============================= */
div.sheet-shield {
height: 50px;
width: 50px;
border-radius: 50% 50% 50% 50% / 12% 12% 88% 88%;
border: 5px solid #240202;
border-radius: 50% 50% 50% 50% / 12% 12% 88% 88%; }
div.sheet-shield label,
div.sheet-shield span {
align-items: center;
display: grid;
font-weight: bold;
height: 100%;
justify-content: center;
text-align: center;
width: 100%; }
div.sheet-shield:hover span,
height: 50px;
width: 50px; }
div.sheet-shield input[type="number"] {
display: none; }
div.sheet-shield:hover input[type="number"] {
display: inline;
background-color: #fffde7; }
font-weight: bolder;
width: 3em; }
div.sheet-shield input[type="number"]:placeholder-shown, div.sheet-shield input[type="number"]:hover {
background-color: #fffde7; }
div.sheet-shield input[type="number"]::-webkit-outer-spin-button, div.sheet-shield input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0; }

/* ROLL TEMPLATE STYLE
----------------------------- */
Expand Down Expand Up @@ -906,43 +927,33 @@ div.sheet-repeating-container div.sheet-notes {
font-family: "pictos";
z-index: 100;
position: absolute;
left: 85%; }
right: 1.5%; }

/* DRAG & DROP
============================= */
.sheet-dropzone.active-drop-target.dropping {
opacity: 0.5;
transition: opacity 0.15s ease-in-out;
-moz-transition: opacity 0.15s ease-in-out;
-webkit-transition: opacity 0.15s ease-in-out;
background-color: transparent; }
background-color: transparent;
opacity: 0.5;
transition: opacity 0.15s ease-in-out; }

.sheet-compendium_warning,
.sheet-monster_confirm {
.sheet-compendium_warning {
display: none; }

.sheet-dropzone.active-drop-target.dropping ~ .sheet-compendium_warning,
.sheet-monster_confirm_flag[value="1"] ~ .sheet-monster_confirm {
display: block;
position: fixed;
top: 50%;
.sheet-dropzone.active-drop-target.dropping ~ .sheet-compendium_warning {
position: absolute;
background: white;
left: 50%;
z-index: 100;
border: 2px solid black;
width: 300px;
border-radius: 0.5em;
border: 2px solid #000;
box-shadow: 0 0 50px #000;
display: block;
height: 100px;
text-align: center;
margin: -70px 0 0 -170px; }

.charsheet input.sheet-licensedsheet[value="1"] ~ .sheet-compendium_warning,
.charsheet input.sheet-licensedsheet[value="1"] ~ .sheet-monster_confirm {
position: absolute !important;
padding: 2em 0 !important;
left: 50%;
margin: -70px 0 0 -170px;
min-height: max-content;
box-shadow: 0 0 50px #000;
border: 2px solid #000 !important;
border-radius: 0.5em; }

.sheet-dropzone.active-drop-target.dropping ~ .sheet-compendium_warning span {
line-height: 100px; }
padding: 2em;
text-align: center;
top: 50%;
width: 300px;
z-index: 100; }
639 changes: 595 additions & 44 deletions Pendragon6thEdition/pendragon.html

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/get_rep_update.js
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;
};
24 changes: 24 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/handle_horse.js
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);
};
4 changes: 4 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/handle_item.js
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);
};
7 changes: 7 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/handle_squire.js
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);
};
4 changes: 4 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/handle_weapon.js
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);
};
28 changes: 28 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/helpers.js
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;
};
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 Pendragon6thEdition/src/js/drag_and_drop/reset_skill_list.js
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 Pendragon6thEdition/src/js/drag_and_drop/roll_20_attribute.js
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;
};
44 changes: 44 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/update_attack.js
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;
};
13 changes: 13 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/update_item.js
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;
};
5 changes: 5 additions & 0 deletions Pendragon6thEdition/src/js/drag_and_drop/update_section.js
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);
};
Loading

0 comments on commit 6f17473

Please sign in to comment.