Skip to content

Commit

Permalink
Merge pull request #306 from ben/reroll-button
Browse files Browse the repository at this point in the history
Reroll button in oracle-draw chat cards
  • Loading branch information
ben authored Apr 24, 2022
2 parents b3e97bc + cf509fb commit 6b2f842
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## In progress

- Refactor some CSS ([#305](https://github.com/ben/foundry-ironsworn/pull/305))
- Add a "reroll" button to oracle-roll chat cards ([#306](https://github.com/ben/foundry-ironsworn/pull/306))

## 1.10.47

Expand Down
10 changes: 10 additions & 0 deletions src/module/chat/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class IronswornChatCard {
html.find('.ironsworn__sojourn__extra__roll').on('click', (ev) => this._sojournExtra.call(this, ev))
html.find('.ironsworn__paytheprice__roll').on('click', (ev) => this._payThePriceExtra.call(this, ev))
html.find('.starforged__oracle__roll').on('click', (ev) => this._sfOracleRoll.call(this, ev))
html.find('.starforged__oracle__reroll').on('click', (ev) => this._sfOracleReroll.call(this, ev))
}

async _moveNavigate(ev: JQuery.ClickEvent) {
Expand Down Expand Up @@ -238,6 +239,15 @@ export class IronswornChatCard {
rollAndDisplayOracleResult(table)
}

async _sfOracleReroll(ev: JQuery.ClickEvent) {
ev.preventDefault()
const pack = game.packs.get('foundry-ironsworn.starforgedoracles')
const parent = $(ev.target).parent('.table-draw')
const tableId = parent.data('table-id')
const table = await pack?.getDocument(tableId) as any | undefined
rollAndDisplayOracleResult(table)
}

async replaceSelectorWith(el: HTMLElement, selector: string, newContent: string) {
const parent = $(el).parents('.message-content')
parent.find(selector).html(newContent)
Expand Down
1 change: 1 addition & 0 deletions system/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"Vow": "Vow",
"Vows": "Vows",
"Progress": "Progress",
"Reroll": "Reroll",
"Moves": "Moves",
"Session": "Session",
"Connection": "Connection",
Expand Down
4 changes: 4 additions & 0 deletions system/templates/chat/oracle-roll.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ table: RollTable {parent: null, pack: 'foundry-ironsworn.starforgedoracles', dat
</tbody>
</table>

<button class="starforged__oracle__reroll">
<i class="fas fa-undo-alt"></i>
{{localize 'IRONSWORN.Reroll'}}
</button>
</div>

0 comments on commit 6b2f842

Please sign in to comment.