Skip to content

Commit

Permalink
initial oracle support
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleHeihin committed Oct 10, 2023
1 parent 09cdc53 commit 100eaa9
Show file tree
Hide file tree
Showing 13 changed files with 67,693 additions and 50,949 deletions.
3 changes: 2 additions & 1 deletion Ironsworn-Starforged/Ironsworn-starforged.css
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,7 @@
.charsheet .asset input.border-bottom {
border-bottom-color: #4c4d4f;
padding: 0;
background: transparent;
}
.charsheet .asset-write-in input,
.charsheet .asset-ability-write-in input {
Expand Down Expand Up @@ -2496,7 +2497,7 @@
}
.charsheet td.oracle-roll {
padding-left: 0.5em;
width: 3em;
width: 3.4em;
}
.charsheet th.oracle-column-head.oracle-roll {
white-space: nowrap;
Expand Down
47,740 changes: 18,709 additions & 29,031 deletions Ironsworn-Starforged/Ironsworn-starforged.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Ironsworn-Starforged/src/app/components/assets/assets.styl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ div
&.border-bottom
border-bottom-color #4C4D4F
padding 0
background transparent

.asset-write-in input,
.asset-ability-write-in input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mixin movePreviewFactory(move, options)
if move.Oracle
.move-oracle-container
- let btnText = `Roll the ${move.Name} oracle`
- var moveOracle = oracles.find(group => { return group.Name === 'Move' }).Oracles.find(oracle => { return oracle.Name === move.Name })
- var moveOracle = oracles.find(group => { return group.Name === 'Moves' }).Oracles.find(oracle => { return oracle.Name === move.Name })
if moveOracle.Table
+oracleSingleButton(moveOracle, btnText)
+oracleTable(moveOracle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mixin oracleMultiSubTable(oracle, header=false)


mixin oracleSubTable(subOracle, header=true)
table.oracle-table.oracle-subtable(id=subOracle.id)
table.oracle-table.oracle-subtable(id=subOracle.$id)
if (subOracle.Description)
caption.oracle-description!=subOracle.Description
if (header===true)
Expand All @@ -74,44 +74,51 @@ mixin oracleTableRow(table, row, index)
function rangeString(initChance, finalChance) {
return (initChance === finalChance) ? finalChance : `${initChance}-${finalChance}`;
};
function resultString(row) {
let detailsKeys = ["Assets", "Details"];
let detailsStrings = [];
detailsKeys.forEach(key => {
if (row[key]) {
if (key === "Assets") {
row[key] = row[key].map(item => item.toUpperCase());
}
detailsStrings.push(row[key])
};
});
let detailString;
if (detailsStrings.length > 0) {
detailsStrings = detailsStrings.flat(2);
detailString = `(${detailsStrings.join(", ")})`;
};
const result = `${row.Description}${detailString ? " " + detailString : ""}`;
return result;
}
let ranges = [];
if (Array.isArray(row.Chance)) {
row.Chance.forEach((chance, chanceIndex) => {
if (chance === 0) {
ranges.push(`—`)
}
else
{const initChance = (index === 0) ? chance - (chance - 1) : table[index - 1].Chance[chanceIndex] + 1;
const finalChance = chance;
ranges.push(rangeString(initChance, finalChance));}
})
}
else {
const initChance = (index === 0) ? row.Chance - (row.Chance - 1) : table[index - 1].Chance + 1;
const finalChance = row.Chance;
ranges.push(rangeString(initChance, finalChance));
}
//- function resultString(row) {
//- let detailsKeys = ["Assets", "Details"];
//- let detailsStrings = [];
//- detailsKeys.forEach(key => {
//- if (row[key]) {
//- if (key === "Assets") {
//- row[key] = row[key].map(item => item.toUpperCase());
//- }
//- detailsStrings.push(row[key])
//- };
//- });
//- let detailString;
//- if (detailsStrings.length > 0) {
//- detailsStrings = detailsStrings.flat(2);
//- detailString = `(${detailsStrings.join(", ")})`;
//- };
//- const result = `${row.Description}${detailString ? " " + detailString : ""}`;
//- return result;
//- }
let ranges = [];
//- if (Array.isArray(row.Chance)) {
//- row.Chance.forEach((chance, chanceIndex) => {
//- if (chance === 0) {
//- ranges.push(`—`)
//- }
//- else {
//- //- const initChance = (index === 0) ? chance - (chance - 1) : table[index - 1].Chance[chanceIndex] + 1;
//- //- const finalChance = chance;
//- const initChance = (index === 0) ? chance - (chance - 1) : table[index - 1].Chance[chanceIndex] + 1;
//- const finalChance = chance;
//- ranges.push(rangeString(initChance, finalChance));
//- }
//- })
//- }
//- else {
//- const initChance = (index === 0) ? row.Chance - (row.Chance - 1) : table[index - 1].Chance + 1;
//- const finalChance = row.Chance;
const initChance = row.Floor;
const finalChance = row.Ceiling;
ranges.push(rangeString(initChance, finalChance));
//- }
tr.oracle-row
each range in ranges
td.oracle-roll!=range
td.oracle-result!=resultString(row)
//- td.oracle-result!=resultString(row)
td.oracle-result(data-i18n=row.$id)!=translation[row.$id]

Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ mixin oracleRollGroup(group)
.oracle
if (oracle.Tables)
- let buttonLabel = oracle['Display name']||oracle.Name
+oracleSubtablesListGroupItem(oracle.id, buttonLabel, oracle.Tables)
+oracleSubtablesListGroupItem(oracle.$id, buttonLabel, oracle.Tables)
else
+oracleRollBtn(oracle.id, oracle['Display name']||oracle.Name)
+oracleRollBtn(oracle.$id, oracle['Display name']||oracle.Name)
if group.Subcategories
each subCategory in group.Subcategories
- const buttonLabel = subCategory['Display name']||subCategory.Name
.oracle.oracle-subcategory
+oracleSubtablesListGroupItem(subCategory.id, buttonLabel, subCategory.Oracles)

mixin oraclePreview(oracle, groupName)
input(class=`${oracle.id} hide-element` type='radio' name=`attr_oracle_preview` value=oracle.id)
div(class=`${oracle.id} showhide oracle-table-preview surface` id=oracle.id)
input(class=`${oracle.$id} hide-element` type='radio' name=`attr_oracle_preview` value=oracle.$id)
div(class=`${oracle.$id} showhide oracle-table-preview surface` id=oracle.$id)
- let nameString = oracle['Display name'] && oracle['Display name'].match(/ - /i) ? oracle['Display name'].replace(/ - /i, ": ") : `${groupName}: ${oracle['Display name']||oracle.Name}`
.oracle-title=nameString
if oracle.Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ tr.oracle-row td
td.oracle-roll
// width: 20%
padding-left 0.5em
width 3em
width 3.4em

th.oracle-column-head.oracle-roll
white-space nowrap
Expand Down
Loading

0 comments on commit 100eaa9

Please sign in to comment.