Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Generate Notes for Skills #1363

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ app/**/*.js.map
electron-builder.env
*.map
publishSettings.json
.idea

.env*

Expand Down
1 change: 1 addition & 0 deletions app/Schema/Config/Config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface RawConfig {
equipmentGroupVisibilityFilter: number
sheetCheckAttributeValueVisibility?: boolean
sheetUseParchment?: boolean
sheetGenerateNotes?: boolean
sheetZoomFactor?: number
enableActiveItemHints: boolean
locale?: string
Expand Down
3 changes: 3 additions & 0 deletions app/Schema/Config/Config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
"sheetUseParchment": {
"type": "boolean"
},
"sheetGenerateNotes": {
"type": "boolean"
},
"sheetZoomFactor": {
"type": "number"
},
Expand Down
2 changes: 2 additions & 0 deletions src/App/Actions/IOActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const requestConfigSave: ReduxAction<Promise<boolean>> =
Just (UISSA.sheetCheckAttributeValueVisibility (uiSettingsState)),
sheetUseParchment:
Just (UISSA.sheetUseParchment (uiSettingsState)),
sheetGenerateNotes:
Just (UISSA.sheetGenerateNotes (uiSettingsState)),
sheetZoomFactor:
UISSA.sheetZoomFactor (uiSettingsState),
theme: Just (UISSA.theme (uiSettingsState)),
Expand Down
10 changes: 9 additions & 1 deletion src/App/Actions/SheetActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SWITCH_SHEET_ATTR_VALUE_VISIBILITY, SWITCH_SHEET_USE_PARCHMENT, SET_SHEET_ZOOM_FACTOR } from "../Constants/ActionTypes"
import { SWITCH_SHEET_ATTR_VALUE_VISIBILITY, SWITCH_SHEET_USE_PARCHMENT, SWITCH_SHEET_GENERATE_NOTES, SET_SHEET_ZOOM_FACTOR } from "../Constants/ActionTypes"

export interface SwitchSheetAttributeValueVisibilityAction {
type: SWITCH_SHEET_ATTR_VALUE_VISIBILITY
Expand All @@ -16,6 +16,14 @@ export const switchUseParchment = (): SwitchSheetUseParchmentAction => ({
type: SWITCH_SHEET_USE_PARCHMENT,
})

export interface SwitchSheetGenerateNotesAction {
type: SWITCH_SHEET_GENERATE_NOTES
}

export const switchGenerateNotes = (): SwitchSheetGenerateNotesAction => ({
type: SWITCH_SHEET_GENERATE_NOTES,
})

export interface SetSheetZoomFactor {
type: SET_SHEET_ZOOM_FACTOR
payload: {
Expand Down
3 changes: 3 additions & 0 deletions src/App/Constants/ActionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,9 @@ export type SWITCH_SHEET_ATTR_VALUE_VISIBILITY = "SWITCH_SHEET_ATTR_VALUE_VISIBI
export const SWITCH_SHEET_USE_PARCHMENT = "SWITCH_SHEET_USE_PARCHMENT"
export type SWITCH_SHEET_USE_PARCHMENT = "SWITCH_SHEET_USE_PARCHMENT"

export const SWITCH_SHEET_GENERATE_NOTES = "SWITCH_SHEET_GENERATE_NOTES"
export type SWITCH_SHEET_GENERATE_NOTES = "SWITCH_SHEET_GENERATE_NOTES"

export const SET_SHEET_ZOOM_FACTOR = "SET_SHEET_ZOOM_FACTOR"
export type SET_SHEET_ZOOM_FACTOR = "SET_SHEET_ZOOM_FACTOR"

Expand Down
6 changes: 5 additions & 1 deletion src/App/Containers/SheetsContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getConditions, getSkillPages, getSkillsByGroup, getStates } from "../Se
import { getAllSkills } from "../Selectors/skillsSelectors"
import { getCantripsForSheet, getSpellsForSheet } from "../Selectors/spellsSelectors"
import { getAvatar, getCurrentHeroName, getCurrentSex, getProfile, getPurse, getSpecialAbilities, getWikiBooks, getWikiSpecialAbilities } from "../Selectors/stateSelectors"
import { getSheetCheckAttributeValueVisibility, getSheetUseParchment, getSheetZoomFactor } from "../Selectors/uisettingsSelectors"
import { getSheetCheckAttributeValueVisibility, getSheetUseParchment, getSheetGenerateNotes, getSheetZoomFactor } from "../Selectors/uisettingsSelectors"
import { requestExportHeroAsRptok } from "../Utilities/MapToolExporter"
import { pipe } from "../Utilities/pipe"
import { mapGetToMaybeSlice, mapGetToSlice } from "../Utilities/SelectorsUtils"
Expand Down Expand Up @@ -56,6 +56,7 @@ const mapStateToProps = (state: AppStateRecord, ownProps: SheetsOwnProps): Sheet
items: getAllItems (state),
pet: getPet (state),
useParchment: getSheetUseParchment (state),
generateNotes: getSheetGenerateNotes (state),
zoomFactor: getSheetZoomFactor (state),
purse: getPurse (state),
totalPrice: getTotalPrice (state),
Expand Down Expand Up @@ -98,6 +99,9 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, ownProps: SheetsOwnProps) =
switchUseParchment () {
dispatch (SheetActions.switchUseParchment ())
},
switchGenerateNotes () {
dispatch (SheetActions.switchGenerateNotes ())
},
setSheetZoomFactor (zoomFactor: number) {
dispatch (SheetActions.setSheetZoomFactor (zoomFactor))
},
Expand Down
2 changes: 2 additions & 0 deletions src/App/Models/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface Config {
equipmentGroupVisibilityFilter: EquipmentGroup
sheetCheckAttributeValueVisibility: Maybe<boolean>
sheetUseParchment: Maybe<boolean>
sheetGenerateNotes: Maybe<boolean>
sheetZoomFactor: number
enableActiveItemHints: boolean
locale: Maybe<string>
Expand Down Expand Up @@ -202,6 +203,7 @@ export const Config =
equipmentGroupVisibilityFilter: EquipmentGroup.MeleeWeapons,
sheetCheckAttributeValueVisibility: Just (false),
sheetUseParchment: Just (false),
sheetGenerateNotes: Just (false),
sheetZoomFactor: 100,
enableActiveItemHints: false,
locale: Nothing,
Expand Down
2 changes: 2 additions & 0 deletions src/App/Models/UISettingsState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface UISettingsState {
enableActiveItemHints: boolean
sheetCheckAttributeValueVisibility: boolean
sheetUseParchment: boolean
sheetGenerateNotes: boolean
sheetZoomFactor: number
theme: Theme
enableEditingHeroAfterCreationPhase: boolean
Expand Down Expand Up @@ -61,6 +62,7 @@ export const UISettingsState =
enableActiveItemHints: false,
sheetCheckAttributeValueVisibility: false,
sheetUseParchment: false,
sheetGenerateNotes: false,
sheetZoomFactor: 100,
theme: Theme.Dark,
enableEditingHeroAfterCreationPhase: false,
Expand Down
41 changes: 41 additions & 0 deletions src/App/Models/View/Affection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { fromDefault } from "../../../Data/Record"

export interface Affection {
"@@name": "Affection"
name: string
active: boolean
fp: number
qs: number
bonus: number
bonusOnAttribute: {
CH: number
KL: number
}
penalty: number
penaltyOnAttribute: {
CH: number
KL: number
}
situative: boolean
}

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const Affection =
fromDefault ("Affection")
<Affection> ({
name: "",
active: false,
fp: 0,
qs: 0,
bonus: 0,
bonusOnAttribute: {
CH: 0,
KL: 0,
},
penalty: 0,
penaltyOnAttribute: {
CH: 0,
KL: 0,
},
situative: false,
})
38 changes: 38 additions & 0 deletions src/App/Models/View/SkillWithActivations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { fromDefault, Record } from "../../../Data/Record"
import { List } from "../../../Data/List"
import { pipe } from "../../Utilities/pipe"
import { SkillDependent } from "../ActiveEntries/SkillDependent"
import { Skill } from "../Wiki/Skill"
import { Application } from "../Wiki/sub/Application"
import { Affection } from "./Affection"

export interface SkillWithActivations {
"@@name": "SkillWithActivations"
wikiEntry: Record<Skill>
stateEntry: Record<SkillDependent>
activeAffection: Record<Affection>
activeApplicationAffections: List<Record<Affection>>
activeApplications: List<Record<Application>>
}

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const SkillWithActivations =
fromDefault ("SkillWithActivations")
<SkillWithActivations> ({
wikiEntry: Skill .default,
stateEntry: SkillDependent .default,
activeAffection: Affection .default,
activeApplicationAffections: List .empty,
activeApplications: List .empty,
})

export const SkillWithActivationsA_ = {
id: pipe (SkillWithActivations.A.wikiEntry, Skill.A.id),
name: pipe (SkillWithActivations.A.wikiEntry, Skill.A.name),
check: pipe (SkillWithActivations.A.wikiEntry, Skill.A.check),
ic: pipe (SkillWithActivations.A.wikiEntry, Skill.A.ic),
encumbrance: pipe (SkillWithActivations.A.wikiEntry, Skill.A.encumbrance),
gr: pipe (SkillWithActivations.A.wikiEntry, Skill.A.gr),
value: pipe (SkillWithActivations.A.stateEntry, SkillDependent.A.value),
dependencies: pipe (SkillWithActivations.A.stateEntry, SkillDependent.A.dependencies),
}
1 change: 1 addition & 0 deletions src/App/Models/Wiki/L10n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export const L10n =
"sheets.dialogs.rptoksaveerror.message": "",
"sheets.showattributevalues": "",
"sheets.useparchment": "",
"sheets.generatenotes": "",
"sheets.zoomfactor": "",
"sheets.charactersheet": "",
"sheets.attributemodifiers.title": "",
Expand Down
3 changes: 3 additions & 0 deletions src/App/Models/Wiki/Skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { List } from "../../../Data/List"
import { Maybe, Nothing } from "../../../Data/Maybe"
import { fromDefault, Record } from "../../../Data/Record"
import { Category } from "../../Constants/Categories"
import { Affection } from "./sub/Affection"
import { Application } from "./sub/Application"
import { Erratum } from "./sub/Errata"
import { SourceLink } from "./sub/SourceLink"
Expand All @@ -18,6 +19,7 @@ export interface Skill {
encumbranceDescription: Maybe<string>
gr: number
ic: number
affections: List<Affection>
applications: List<Record<Application>>
applicationsInput: Maybe<string>
uses: List<Record<Use>>
Expand All @@ -42,6 +44,7 @@ export const Skill =
encumbranceDescription: Nothing,
gr: 0,
ic: 0,
affections: List.empty,
applications: List.empty,
applicationsInput: Nothing,
uses: List.empty,
Expand Down
40 changes: 40 additions & 0 deletions src/App/Models/Wiki/sub/Affection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { fromDefault } from "../../../../Data/Record"

export interface Affection {
"@@name": "Affection"
id: string

fp: number
qs: number
bonus: number
bonusOnAttribute: {
CH: number
KL: number
}
penalty: number
penaltyOnAttribute: {
CH: number
KL: number
}
situative: boolean
}

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const Affection =
fromDefault ("Affection")
<Affection> ({
id: "",
fp: 0,
qs: 0,
bonus: 0,
bonusOnAttribute: {
CH: 0,
KL: 0,
},
penalty: 0,
penaltyOnAttribute: {
CH: 0,
KL: 0,
},
situative: false,
})
4 changes: 4 additions & 0 deletions src/App/Models/Wiki/sub/Application.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { List } from "../../../../Data/List"
import { Maybe, Nothing } from "../../../../Data/Maybe"
import { fromDefault, Record } from "../../../../Data/Record"
import { RequireActivatable } from "../prerequisites/ActivatableRequirement"
import { Affection } from "./Affection"

export interface Application {
"@@name": "Application"
id: number
name: string
prerequisite: Maybe<Record<RequireActivatable>>
affections: List<Affection>
}

// eslint-disable-next-line @typescript-eslint/no-redeclare
Expand All @@ -16,4 +19,5 @@ export const Application =
id: 0,
name: "",
prerequisite: Nothing,
affections: List.empty,
})
7 changes: 6 additions & 1 deletion src/App/Reducers/uiSettingsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ReceiveInitialDataAction } from "../Actions/InitializationActions"
import { SetLiturgicalChantsSortOrderAction } from "../Actions/LiturgicalChantActions"
import { SetProfessionsGroupVisibilityFilterAction, SetProfessionsSortOrderAction, SetProfessionsVisibilityFilterAction } from "../Actions/ProfessionActions"
import { SetRacesSortOrderAction } from "../Actions/RaceActions"
import { SwitchSheetAttributeValueVisibilityAction, SwitchSheetUseParchmentAction, SetSheetZoomFactor } from "../Actions/SheetActions"
import { SwitchSheetAttributeValueVisibilityAction, SwitchSheetUseParchmentAction, SwitchSheetGenerateNotesAction, SetSheetZoomFactor } from "../Actions/SheetActions"
import { SetSkillsSortOrderAction, SwitchSkillRatingVisibilityAction } from "../Actions/SkillActions"
import { SetSpecialAbilitiesSortOrderAction } from "../Actions/SpecialAbilitiesActions"
import { SetSpellsSortOrderAction } from "../Actions/SpellsActions"
Expand Down Expand Up @@ -41,6 +41,7 @@ type Action = ReceiveInitialDataAction
| SwitchSkillRatingVisibilityAction
| SwitchSheetAttributeValueVisibilityAction
| SwitchSheetUseParchmentAction
| SwitchSheetGenerateNotesAction
| SetSheetZoomFactor
| SetThemeAction
| SwitchEnableEditingHeroAfterCreationPhaseAction
Expand Down Expand Up @@ -120,6 +121,8 @@ export const uiSettingsReducer =
fromMaybe (false) (CA.sheetCheckAttributeValueVisibility (config)),
sheetUseParchment:
fromMaybe (false) (CA.sheetUseParchment (config)),
sheetGenerateNotes:
fromMaybe (false) (CA.sheetGenerateNotes (config)),
sheetZoomFactor:
CA.sheetZoomFactor (config),
theme: fromMaybe (Theme.Dark) (CA.theme (config)),
Expand All @@ -140,6 +143,8 @@ export const uiSettingsReducer =
return over (UISettingsStateL.sheetCheckAttributeValueVisibility) (not)
case ActionTypes.SWITCH_SHEET_USE_PARCHMENT:
return over (UISettingsStateL.sheetUseParchment) (not)
case ActionTypes.SWITCH_SHEET_GENERATE_NOTES:
return over (UISettingsStateL.sheetGenerateNotes) (not)
case ActionTypes.SET_SHEET_ZOOM_FACTOR:
return set (UISettingsStateL.sheetZoomFactor) (action.payload.zoomFactor)

Expand Down
8 changes: 4 additions & 4 deletions src/App/Selectors/sheetSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Record } from "../../Data/Record"
import { fst, isTuple, Pair, snd } from "../../Data/Tuple"
import { upd1, upd2 } from "../../Data/Tuple/Update"
import { ConditionId } from "../Constants/Ids.gen"
import { SkillCombinedA_ } from "../Models/View/SkillCombined"
import { SkillWithActivationsA_ } from "../Models/View/SkillWithActivations"
import { Condition } from "../Models/Wiki/Condition"
import { Skill } from "../Models/Wiki/Skill"
import { State } from "../Models/Wiki/State"
Expand All @@ -19,7 +19,7 @@ import { pipe, pipe_ } from "../Utilities/pipe"
import { filterByAvailability } from "../Utilities/RulesUtils"
import { sortRecordsByName } from "../Utilities/sortBy"
import { getRuleBooksEnabled } from "./rulesSelectors"
import { getAllSkills } from "./skillsSelectors"
import { getSkillsWithActivations } from "./skillsSelectors"
import { getWiki, getWikiSkills } from "./stateSelectors"

const CA = Condition.A
Expand Down Expand Up @@ -53,8 +53,8 @@ export const getStates = createMaybeSelector (
)

export const getSkillsByGroup = createMaybeSelector (
getAllSkills,
fmap (groupByKey (SkillCombinedA_.gr))
getSkillsWithActivations,
fmap (groupByKey (SkillWithActivationsA_.gr))
)

export const getSkillPages = createMaybeSelector (
Expand Down
Loading