Skip to content

Commit

Permalink
Merge pull request #240 from DRincs-Productions/237-filter-one-time-c…
Browse files Browse the repository at this point in the history
…hoices-in-narratine-history

improve
  • Loading branch information
BlackRam-oss authored Oct 8, 2024
2 parents fc82595 + 66b8e22 commit 0ba35ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/managers/NarrationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,25 @@ export default class NarrationManager {
list[list.length - 1].inputValue = inputValue
}
if (dialoge || requiredChoices) {
let choices: HistoryChoiceMenuOption[] | undefined = requiredChoices?.map((choice) => {
let choices: HistoryChoiceMenuOption[] | undefined = requiredChoices?.map((choice, index) => {
let hidden: boolean = false
if (choice.oneTime && step.alreadyMadeChoices && step.alreadyMadeChoices.includes(index)) {
hidden = true
}
return {
text: choice.text,
type: choice.type,
isResponse: false
isResponse: false,
hidden: hidden,
}
})
// if all choices are hidden find onlyHaveNoChoice
if (choices && choices.every((choice) => choice.hidden)) {
let onlyHaveNoChoice = choices.find((choice) => choice.hidden === false)
if (onlyHaveNoChoice) {
onlyHaveNoChoice.hidden = false
}
}
list.push({
dialoge: dialoge,
playerMadeChoice: false,
Expand Down
4 changes: 4 additions & 0 deletions src/types/HistoryChoiceMenuOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ type HistoryChoiceMenuOption = {
* This choice is a response
*/
isResponse: boolean
/**
* The choice is hidden
*/
hidden: boolean
}

export default HistoryChoiceMenuOption

0 comments on commit 0ba35ca

Please sign in to comment.