Compare commits

...
Author SHA1 Message Date
Elytherion b0dec717e1 Changed everything to not use Data.Internals anymore 2019-07-02 19:17:53 +02:00
Elytherion f5122b777c Switched to real ES Modules in JS files 2019-07-02 17:38:13 +02:00
Elytherion 2725bcab20 Fixed background scaling 2019-07-02 15:46:52 +02:00
Elytherion 9e1bcd17e0 Fixed wiki and made wiki selectable 2019-07-02 15:21:00 +02:00
Elytherion 46fbca62a1 Fixed InlineWiki entries 2019-07-02 00:58:48 +02:00
Elytherion 6c682ed351 Fixed generated weight and added weight and size calc strings to inputs 2019-06-30 14:50:31 +02:00
Elytherion 631b818788 Fixed weight calculation 2019-06-30 13:43:31 +02:00
Elytherion 5163f7acda Fixed restricted blessings and unfamiliar spell selection in rcp option selections 2019-06-30 11:53:39 +02:00
Elytherion 8ed6fd9cad Fixed equipment wiki "weight" => "price" 2019-06-29 16:33:54 +02:00
Elytherion 3ca5b7dd62 Added 18+ badge for rule books with explicit content 2019-06-26 02:21:45 +02:00
Elytherion 34b4f10758 Fixed some bugs and changed layout of languages on sheet to two-column layout 2019-06-26 01:38:45 +02:00
Elytherion 671a02e12f Fixed first issues with character sheet 2019-06-25 20:15:53 +02:00
Elytherion d7eac0796b Further work on property knowledges on character sheet 2019-06-20 23:12:56 +02:00
Lukas Obermann 899bd204c3 Worked on aspects and properties on character sheet 2019-06-18 22:22:57 +02:00
Elytherion f360e37c98 Fixed filtering select option lists by activated rule books 2019-06-17 15:36:26 +02:00
Elytherion dc1b3e0563 Added new traditions to lower AE and lower AP max for magical advantages settings 2019-06-17 15:17:19 +02:00
Elytherion b1da3c00a7 Fixed shown professions in wiki 2019-06-17 02:26:41 +02:00
Elytherion bf167f86a2 Added selection of unfamiliar spell to RCP options 2019-06-17 01:53:32 +02:00
Elytherion c3448f0e72 Added blessed tradition "Numinorukult" 2019-06-16 23:53:28 +02:00
Elytherion 6c9789eb71 Fixed import user data from older versions 2019-06-16 00:40:26 +02:00
Elytherion cfd3d3e1f4 - Fixed "Tradition (Animisten)"
- Fixed only show equipment groups when available
2019-06-15 23:36:22 +02:00
Elytherion 0bdedc159a - Fixed "Zauberalchimisten" activation
- Fixed "Variante" and "Adaption" selection cost
2019-06-11 22:07:35 +02:00
Elytherion 8005326471 Finished taking guild mage selection into account for EL restriction 2019-06-11 14:38:33 +02:00
Elytherion bc7ae2e5ed - Refactored how to get if a spell/cantrip is unfamiliar
- Added hint for unfamiliar spells
- Added hint for strongly recommended adv/dis
2019-06-11 02:57:11 +02:00
Elytherion ebc978ed80 Fixed "Körperliche Auffälligkeit" input bug 2019-06-11 00:45:22 +02:00
Elytherion 3510597c98 Fixed guild mage tradition spell selection 2019-06-10 23:53:54 +02:00
Elytherion 5a9ae2b660 Increased version number 2019-06-10 17:11:10 +02:00
Elytherion 087d42e8b2 Fixed traditions and aspects in InlineWiki 2019-06-10 17:07:19 +02:00
Elytherion 85af75143e Fixed dropdown 2019-06-10 17:00:32 +02:00
Elytherion 54d2edc422 - Professions are now filtered by profession variant when searching
- Added option to delete avatar
2019-06-10 15:12:57 +02:00
Elytherion efcbe56346 Show both advantage and disadvantage related AP when adding them 2019-06-10 13:23:19 +02:00
Elytherion 987b670c1d Added mutiple selections options and generics to Dropdown 2019-06-08 12:21:51 +02:00
Elytherion 5951a8eccc Fixed Property Focus selection 2019-06-07 23:55:38 +02:00
Elytherion 97c2d3b221 Fixed excluding guild-magic spells from tradition selection 2019-06-06 23:20:10 +02:00
Elytherion 925000da72 Added more logs to insider build script 2019-06-05 00:14:01 +02:00
Elytherion efb8a14be7 Fixed filtering cantrips by selected rule books 2019-06-05 00:10:05 +02:00
Elytherion 34e606d497 Fixed scripts and languages after hero creation,
fixed deleting heroes,
fixed magical tradition ids,
fixed Skill Specialization
2019-06-04 23:52:05 +02:00
Elytherion 0418de82f4 Removed debug prints from last commit 2019-06-04 18:45:26 +02:00
Elytherion 1479887733 Fixed Property Knowledge,
added copying tables to insider build script,
worked on list performance
2019-06-04 18:42:30 +02:00
Elytherion 326f93de13 Fixed issues with filtering and issues and perf for sorting longer lists 2019-06-04 01:12:31 +02:00
Lukas Obermann 052fafa715 Merge pull request #12 from Elytherion/hero-data-rework
Hero State Rework & Haskell-style data classes
2019-06-02 16:46:23 +02:00
Elytherion d50fd3cbf8 Fixed merge remainings 2019-06-02 16:37:38 +02:00
Elytherion dd5437f04a Fixed merge conficts 2019-06-02 16:35:22 +02:00
Lukas Obermann 5d8e3a940c Merge pull request #15 from Elytherion/rework-revisited
Haskell-like Data Structures Revision
2019-06-02 16:24:19 +02:00
Lukas Obermann 3ee4ad5e73 Spped improvements for compareLocale 2019-06-02 16:13:41 +02:00
Lukas Obermann ec375bf4b4 Fixed saving config,
handle combat style techniques,
cost for spell variants before addition and
correct handling for primary attribute prerequisites
2019-05-31 02:42:16 +02:00
Lukas Obermann 64f0fa3573 Fixed custom cost for disadvantages and for levels 2019-05-28 17:22:04 +02:00
Elytherion edc3d8414c Fixed extended SAs and adding AP 2019-05-28 01:16:56 +02:00
Lukas Obermann 23fbd7c2ae Increased version number 2019-05-27 15:45:13 +02:00
Lukas Obermann daa5a65078 Fixed AP calculation for spells and liturgical chants 2019-05-27 15:05:51 +02:00
Elytherion 09b766f54c Fixed auto updater 2019-05-27 01:30:08 +02:00
Elytherion 75aecee8d2 Finished alpha 10 2019-05-27 01:14:05 +02:00
Elytherion e0b69b5dc3 Finished first test build 2019-05-26 14:36:55 +02:00
Elytherion 11de828e64 - Fixed equipment view
- Added dropdown for hero-specific locale selection
- Added dropdown for guild mage unf. spell selection
- Fixed save hero
- Partially fixed special ability sort
2019-05-26 03:29:12 +02:00
Lukas Obermann a0ac981794 Fixed level prerequisite validation 2019-05-25 22:02:30 +02:00
Lukas Obermann f49e0286f0 Fixed inactive view utils 2019-05-24 11:33:32 +02:00
Lukas Obermann 6a4f1e9395 Worked on options for activating Activatables 2019-05-23 15:31:46 +02:00
Elytherion 72ec84532e Fixed basic disabled for adding activatables 2019-05-22 01:09:07 +02:00
Lukas Obermann 86fd134ecf Worked on adding activatables
Issue with "disabled" still exists
2019-05-21 23:56:23 +02:00
Lukas Obermann b3223ef4f2 Worked on skill style SAs and inactive validation 2019-05-21 18:22:51 +02:00
Elytherion 9af1e82a3a Started fixing issues with Activatables 2019-05-21 01:54:50 +02:00
Lukas Obermann 57b7d80dd6 Fixed IO 2019-05-20 21:32:27 +02:00
Elytherion ed5bad6716 Finished fixing regexs, started working on fixing Activatables 2019-05-20 01:59:16 +02:00
Lukas Obermann f8b7608aa1 Started fixing parsing issues caused by wrong regexs 2019-05-19 21:27:10 +02:00
Lukas Obermann 9139567bd3 Started fixing semantic bugs/problems 2019-05-19 00:49:55 +02:00
Lukas Obermann 71a486025f Fixed toSourceLinks 2019-05-18 00:40:49 +02:00
Lukas Obermann 58045802c0 Refactoring in terms of compiler errors complete 2019-05-18 00:31:57 +02:00
Lukas Obermann 980ec9ea0d Finished wiki and inline wiki view refactorings 2019-05-17 13:57:16 +02:00
Elytherion ef0c46aacf Refactored skill, special ability and spell views 2019-05-17 00:24:41 +02:00
Lukas Obermann 3a6e81d550 Further work on skills 2019-05-16 19:44:33 +02:00
Lukas Obermann 747942590f Started working on skills view 2019-05-16 19:14:19 +02:00
Lukas Obermann 6df7b27453 Finished refactoring character sheets 2019-05-16 18:49:12 +02:00
Lukas Obermann 1b4a8b12d7 Fixed AttributeModsListItem 2019-05-16 14:38:11 +02:00
Lukas Obermann 92f08b45b8 Finished refactoring skills sheet 2019-05-16 14:34:27 +02:00
Lukas Obermann 992d2a88d9 Worked on skill sheet refactoring #2 2019-05-16 11:32:21 +02:00
Lukas Obermann 05b509a38c Started refactoring of skills sheet 2019-05-16 10:58:10 +02:00
Elytherion 85823dfc6b Refactored liturgical chants and main sheets 2019-05-16 00:31:42 +02:00
Elytherion 50c5580448 Finished combat sheet refactoring 2019-05-15 23:16:49 +02:00
Elytherion b1913e5fef Finished CombatSheetArmor view 2019-05-15 00:22:37 +02:00
Lukas Obermann 70b472fdb2 Worked on belongings and combat sheets 2019-05-14 22:53:56 +02:00
Lukas Obermann 089556b4f9 Finished RCP option selection and rules views 2019-05-14 16:09:10 +02:00
Lukas Obermann 6365dfbb10 Worked on RCP option selection views #2 2019-05-14 14:25:24 +02:00
Elytherion 349b15ddcb Refactored first part of RCP option selection views 2019-05-14 11:40:12 +02:00
Lukas Obermann b9c4c9aa1e Finished races view 2019-05-13 18:08:23 +02:00
Lukas Obermann 8588958093 Fixed select profession action to handle isVariantRequired 2019-05-12 23:18:55 +02:00
Lukas Obermann cf63d30b5e Fixed profile/personal data view 2019-05-12 23:08:56 +02:00
Lukas Obermann 4a124d44f3 Finished pet and profession views 2019-05-12 22:00:56 +02:00
Lukas Obermann 485d726fe0 Finished liturgical chant and pact views 2019-05-10 09:23:27 +02:00
Elytherion 542dc0b4ee Worked on liturgical chants view #2 2019-05-10 00:18:47 +02:00
Lukas Obermann 2997484367 Worked on liturgical chants 2019-05-09 14:44:19 +02:00
Lukas Obermann 6a295859ab Finished InlineWiki rework 2019-05-09 12:14:17 +02:00
Lukas Obermann 9039c830e3 Finished WikiRaceInfo 2019-05-09 12:02:21 +02:00
Lukas Obermann d8f9f14290 Finished WikiProfessionInfo refactoring 2019-05-09 10:32:45 +02:00
Elytherion ea42597fd9 Worked on WikiProfessionInfo #3 2019-05-09 00:54:27 +02:00
Elytherion 6886239c35 More work on WikiProfessionInfo #2 2019-05-08 01:30:20 +02:00
Lukas Obermann 358d0b7742 Worked on WikiProfessionInfo 2019-05-07 18:33:20 +02:00
Elytherion 615f299690 Finished combineSpells function 2019-05-07 01:05:23 +02:00
Lukas Obermann 7210b5e3fe Worked on WikiProfessionInfo 2019-05-06 00:16:50 +02:00
Lukas Obermann 594230b862 Finished WikiEquipmentInfo 2019-05-05 03:05:51 +02:00
Lukas Obermann 89839ec5f8 Finished WikiCultureInfo 2019-05-04 18:49:37 +02:00
Lukas Obermann a1bc654167 WikiCultureInfo WIP 2019-05-03 13:37:46 +02:00
Elytherion f1de09eccc Finished WikiActivatableInfo refactoring 2019-05-02 18:48:54 +02:00
Lukas Obermann 2242c8e149 Worked on WikiActivatableInfo 2019-05-02 11:19:51 +02:00
Elytherion 7deaad58f7 A little more work on WikiActivatableInfo 2019-05-02 01:23:54 +02:00
Elytherion d2665d9a94 Started with main inline wiki and fixed app start 2019-05-01 00:59:22 +02:00
Lukas Obermann 7d0b263b40 Further work on inline wiki components 2019-04-30 20:32:36 +02:00
Elytherion 20fd0c144f Started converting WikiApplications 2019-04-30 01:11:15 +02:00
Elytherion 4a2066f02a Fixed validator and completed table parsing 2019-04-30 00:38:30 +02:00
Lukas Obermann 4a00a72366 Added care for empty columns in tables 2019-04-29 17:29:10 +02:00
Lukas Obermann 3890131f52 Added traceN 2019-04-28 13:52:42 +02:00
Elytherion 80b8d674c4 Fixed more bugs in table validator 2019-04-28 00:52:32 +02:00
Elytherion 9f7f87d201 Tried to fix broken app 2019-04-26 22:35:19 +02:00
Elytherion 9af73489fe Finished refactoring hit zone armor view 2019-04-26 22:01:39 +02:00
Elytherion d42263fe79 - Fixed equipment view
- Fixed table validation
- Included new table scheme entry ("or"-chants) in validator
2019-04-26 21:31:47 +02:00
Elytherion f11c3691df Updated dependencies 2019-04-25 01:45:56 +02:00
Elytherion 4e15a9f2d7 Fixed Electron 2019-04-25 01:07:32 +02:00
Elytherion 547ff1b2a0 Trying to implement table scheme changes
Electron does not seem to work, though...
2019-04-25 00:39:20 +02:00
Elytherion 91d403c5c7 Fixed Electron warnings 2019-04-23 20:49:27 +02:00
Elytherion 08a20e4b1c Fixed table validator once more 2019-04-23 18:17:52 +02:00
Lukas Obermann 6e5dd776df Started fixing issues with profession table 2019-04-20 02:47:32 +02:00
Lukas Obermann 605ced76b6 Fixed table validator 2019-04-19 20:28:42 +02:00
Lukas Obermann ffcc462ae4 Updated build scripts to use programmatic API 2019-04-19 12:57:07 +02:00
Elytherion 5e4a230c1b Fixed missing bugs to run the table validator 2019-04-18 11:37:52 +02:00
Elytherion 1a45767b9e Fixed all module imports 2019-04-17 23:55:48 +02:00
Lukas Obermann 0296ca7a23 Worked on combat techniques view 2019-04-16 16:09:52 +02:00
Lukas Obermann dad8362e30 Finished attributes view 2019-04-16 15:44:14 +02:00
Elytherion 2772265e42 Finished activatable view, started with attributes 2019-04-16 00:14:33 +02:00
Elytherion 00ea546d19 - Finished activatable utils
- Started working on specific views
2019-04-15 02:25:49 +02:00
Lukas Obermann 33101b86f3 Finished Views/Universal 2019-04-14 12:19:45 +02:00
Elytherion 44c3bf6146 Started working on View/Containers 2019-04-13 00:33:05 +02:00
Elytherion be2dafd33d Fixed circular dependencies, dirty but fixed 2019-04-12 22:41:54 +02:00
Elytherion 88c28f28a9 Tries to fix test issues 2019-04-12 13:45:06 +02:00
Elytherion 9603cbd42b Save cache before close 2019-04-12 12:33:27 +02:00
Elytherion 980d8e5fd8 Started to try new version
Probably circular dependencies causing bugs
2019-04-11 21:32:06 +02:00
Elytherion bb48c9103a Started implementing cache and update on start 2019-04-11 15:28:50 +02:00
Elytherion c4a8e5466a FInished AP Map selectors 2019-04-11 13:46:46 +02:00
Elytherion ec2a0f8016 Started to work on runtime map cache 2019-04-10 23:44:12 +02:00
Elytherion a8f5b2cccf Started work on cache and updater 2019-04-10 02:45:13 +02:00
Elytherion 98f4dadc28 - Switched to Promise-based IO
- Added programmatic script for builder
2019-04-09 23:53:16 +02:00
Elytherion 4029d3bd1b Started to change IO handling to Promise-based 2019-04-09 13:43:00 +02:00
Elytherion add882214d Finished reducers and utils 2019-04-09 02:19:58 +02:00
Elytherion 77610dbea2 Finished applyRCPSelectionsReducer 2019-04-08 21:54:10 +02:00
Elytherion 9d862f5dfe Further work on appyRCPSelectionsReducer 2019-04-07 18:17:57 +02:00
Elytherion 95eedcf1f5 Added culture language insertion 2019-04-05 13:47:33 +02:00
Elytherion e3fa242137 Added a few blank lines 2019-04-04 23:53:43 +02:00
Elytherion e80472ec3c Started work on remaining reducers 2019-04-04 16:44:50 +02:00
Elytherion 6b716421c0 Fixed createMapSelector 2019-04-04 00:59:52 +02:00
Elytherion 59e810ed10 Prisms done, although not good 2019-04-02 19:45:09 +02:00
Elytherion 4d7e7bfc8d Added multiple modules needed for prisms 2019-04-02 01:28:19 +02:00
Elytherion 8839dde1d7 Tries to get Traversals and Prisms right 2019-04-01 21:46:00 +02:00
Elytherion 11aa811898 Further work on spellsSelectors 2019-04-01 02:08:01 +02:00
Elytherion e9c051fb3f Started with spellsSelectors 2019-03-31 22:02:51 +02:00
Elytherion 52b32c38bc Finished rcpSelectors 2019-03-30 21:15:04 +01:00
Elytherion c8734d2c0f Changed accessor property names 2019-03-28 22:42:03 +01:00
Elytherion 9282e2d5a8 Worked on rcpSelectors 2019-03-28 22:21:51 +01:00
Elytherion 8c5feff31d Further work on selectors 2019-03-28 00:19:28 +01:00
Elytherion 4b75403aeb Worked on selectors for Activatables 2019-03-25 03:00:25 +01:00
Elytherion 4c92a8ada1 Started work on selectors 2019-03-23 17:35:09 +01:00
Elytherion b8c1692b5a Fixed casing issues and added iterator to List 2019-03-23 03:06:20 +01:00
Elytherion ee3458cb62 Finished actions 2019-03-23 02:17:23 +01:00
Elytherion 813ea4395f Further work on actions, AP utils and added IO 2019-03-22 23:57:56 +01:00
Elytherion 0e5dc2e4cd Finished DisAdvActions, further work on actions 2019-03-22 01:19:34 +01:00
Elytherion de5aa61d4b Finished reducers and started work on actions 2019-03-21 01:36:40 +01:00
Elytherion f4b500f335 More work on reducers 2019-03-18 20:56:44 +01:00
Elytherion abf8c1ce81 Started working on new state tree format 2019-03-14 19:10:30 +01:00
Elytherion 1b1d957193 Moved missing files to new locations 2019-03-13 15:06:16 +01:00
Elytherion 430c9424c4 Fix react-dom vulnerability 2019-03-13 03:19:42 +01:00
Lukas Obermann 7b83a813e2 Merge pull request #16 from Elytherion/bugfix/linux-glibc-electron-issue
Updated packages
2019-03-13 03:16:32 +01:00
Elytherion 19792f4968 Changed e-mail to support@optolith.app 2019-03-13 03:15:19 +01:00
Elytherion 5da008576f Fixed update button for Linux 2019-03-13 01:33:52 +01:00
Elytherion c9655deca0 Changed name to Optolith
Enabled auto-update support on Linux
Changed update server
2019-03-12 18:52:31 +01:00
Lukas Obermann 30e955f18a Delete i18n.ts
Duplicate
2019-03-12 18:14:38 +01:00
Elytherion 2c58174f22 Updated packages 2019-03-12 15:55:00 +01:00
Elytherion 71dd6298ac A lot of restructurings for old code files 2019-03-12 15:33:29 +01:00
Elytherion 1292ace4c7 Updated L10n fields 2019-03-02 02:45:35 +01:00
Elytherion 8b12040baf Reworked activatableInactiveValidationUtils,
combined fromBoth and fromBinary into Pair
2019-02-27 12:48:34 +01:00
Elytherion e675a29ea4 Finished activatableInactiveUtils 2019-02-12 23:36:46 +01:00
Elytherion fa143c8c27 Fixed tests 2019-02-11 21:38:35 +01:00
Elytherion 31aba242c8 Revert: Extraxt Foldable, Monad and Applicative functions into own files 2019-02-11 21:22:58 +01:00
Lukas Obermann a74a323571 Merge pull request #7 from Elytherion/severe-bugs-1.0.1
Severe bugs 1.0.1
2018-04-16 00:09:41 +02:00
1170 changed files with 65935 additions and 61617 deletions
+3
View File
@@ -7,5 +7,8 @@ npm-debug.log*
.rpt2_cache
.esm-cache
app/**/*.js
app/**/*.js.map
!app/index.js
/installer/
electron-builder.env
app/Database/**/*.xlsx
+9
View File
@@ -1,3 +1,12 @@
# 1.0.3
- Renamed Optolyth to Optolith to be in line with all other locations where the name occurs.
## Linux
- Fixed glibc-related issue.
- Moved from tar.gz to AppImage to provide auto-update support.
# 1.0.2
- Fixed issue with rendering list items of advantages/disadvantages/special abilities.
+6 -2
View File
@@ -2,9 +2,10 @@
<html>
<head>
<meta charset="utf-8">
<title>Optolyth</title>
<title>Optolith</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline'">
<link href="main.css" rel="stylesheet">
<link href="favicon.png" rel="icon" type="image/png" size="267x267">
@@ -12,6 +13,9 @@
<body>
<div id="bodywrapper"></div>
<script>require('./entry.js')</script>
<script>
require = require('esm')(module)
require('./entry.js')
</script>
</body>
</html>
+2
View File
@@ -0,0 +1,2 @@
require = require('esm')(module)
require('./main.js')
+1 -1
View File
File diff suppressed because one or more lines are too long
+89
View File
@@ -0,0 +1,89 @@
// @ts-check
const builder = require ("electron-builder")
module.exports = {
buildWindows:
() => {
console.log ("Building Optolith for Windows...")
builder
.build ({ config, targets: builder.Platform.WINDOWS.createTarget () })
.then (() => console.log ("Optolith Build for Windows successful."))
.catch (err => console.error (err))
},
buildLinux:
() => {
console.log ("Building Optolith for Linux...")
builder
.build ({ config, targets: builder.Platform.LINUX.createTarget () })
.then (() => console.log ("Optolith Build for Linux successful."))
.catch (err => console.error (err))
},
buildMac:
() => {
console.log ("Building Optolith for Linux...")
builder
.build ({ config, targets: builder.Platform.MAC.createTarget () })
.then (() => console.log ("Optolith Build for Linux successful."))
.catch (err => console.error (err))
},
}
/**
* @type {import ("electron-builder") .Configuration}
*/
const config = {
appId: "lukasobermann.optolith",
productName: "Optolith",
copyright: "This product was created under a license. Das Schwarze Auge and its logo as well as Aventuria, Dere, Myranor, Riesland, Tharun and Uthuria and their logos are trademarks of Significant GbR. The title and contents of this book are protected under the copyright laws of the United States of America. No part of this publication may be reproduced, stored in retrieval systems or transmitted, in any form or by any means, whether electronic, mechanical, photocopy, recording, or otherwise, without prior written consent by Ulisses Spiele GmbH, Waldems. This publication includes material that is protected under copyright laws by Ulisses Spiele and/or other authors. Such material is used under the Community Content Agreement for the SCRIPTORIUM AVENTURIS. All other original materials in this work is copyright 2017-present by Lukas Obermann and published under the Community Content Agreement for the SCRIPTORIUM AVENTURIS.",
files: [
"app/**/*",
"CHANGELOG.md"
],
win: {
target: [
{
target: "nsis",
arch: [
"x64",
"ia32"
]
}
],
icon: "app/icon.ico",
artifactName: "OptolithSetup_${version}.${ext}"
},
nsis: {
perMachine: true,
differentialPackage: true
},
linux: {
category: "RolePlaying",
executableName: "Optolith",
icon: "app",
target: [
{
target: "AppImage",
arch: [
"x64"
]
}
],
artifactName: "Optolith_${version}_${arch}.${ext}"
},
mac: {
category: "public.app-category.role-playing-games",
type: "distribution",
icon: "app/icon.icns",
target: "default",
artifactName: "Optolith_${version}.${ext}"
},
publish: {
provider: "generic",
url: "http://update.optolith.app/${os}",
channel: "latest"
},
}
+109
View File
@@ -0,0 +1,109 @@
// @ts-check
const builder = require ("electron-builder")
const { promises: { copyFile }, existsSync } = require ("fs")
const { join } = require ("path")
const src_dir = join ("..", "..", "OneDrive", "TDE app", "data" , "insider")
const copyL10nTable =
async locale => {
const src = join (src_dir, `TDE5_${locale}.xlsx`)
if (existsSync (src)) {
await copyFile (src, join ("app", "Database", locale, "l10n.xlsx"))
console.log (`"TDE5_${locale}.xlsx" copied to "${join (locale, "l10n.xlsx")}"!`)
}
}
const copyTables =
async () => {
await copyFile (join (src_dir, `TDE5.xlsx`), join ("app", "Database", "univ.xlsx"))
console.log (`"TDE5.xlsx" copied to "univ.xlsx"!`)
await copyL10nTable ("de-DE")
await copyL10nTable ("en-US")
await copyL10nTable ("nl-BE")
await copyL10nTable ("fr-FR")
}
module.exports = {
buildWindows:
async () => {
console.log ("Copy most recent tables...")
await copyTables ()
console.log ("Building Optolith Insider for Windows...")
builder
.build ({ config, targets: builder.Platform.WINDOWS.createTarget () })
.then (() => console.log ("Optolith Insider Build for Windows successful."))
.catch (err => console.error (err))
},
buildLinux:
async () => {
console.log ("Copy most recent tables...")
await copyTables ()
console.log ("Building Optolith Insider for Linux...")
builder
.build ({ config, targets: builder.Platform.LINUX.createTarget () })
.then (() => console.log ("Optolith Insider Build for Linux successful."))
.catch (err => console.error (err))
},
}
/**
* @type {import ("electron-builder") .Configuration}
*/
const config = {
appId: "lukasobermann.optolithinsider",
productName: "Optolith Insider",
copyright: "This product was created under a license. Das Schwarze Auge and its logo as well as Aventuria, Dere, Myranor, Riesland, Tharun and Uthuria and their logos are trademarks of Significant GbR. The title and contents of this book are protected under the copyright laws of the United States of America. No part of this publication may be reproduced, stored in retrieval systems or transmitted, in any form or by any means, whether electronic, mechanical, photocopy, recording, or otherwise, without prior written consent by Ulisses Spiele GmbH, Waldems. This publication includes material that is protected under copyright laws by Ulisses Spiele and/or other authors. Such material is used under the Community Content Agreement for the SCRIPTORIUM AVENTURIS. All other original materials in this work is copyright 2017-present by Lukas Obermann and published under the Community Content Agreement for the SCRIPTORIUM AVENTURIS.",
directories: {
output: "dist/insider"
},
files: [
"app/**/*",
"CHANGELOG.md"
],
asarUnpack: "app/Database/**/*",
win: {
target: [
{
target: "nsis",
arch: [
"x64",
"ia32"
]
}
],
icon: "app/icon.ico",
artifactName: "OptolithInsiderSetup_${version}.${ext}"
},
nsis: {
perMachine: true,
differentialPackage: true
},
linux: {
category: "RolePlaying",
executableName: "OptolithInsider",
icon: "app",
target: [
{
target: "AppImage",
arch: [
"x64"
]
}
],
artifactName: "OptolithInsider_${version}.${ext}"
},
publish: {
provider: "generic",
url: "http://update.optolith.app/insider/${os}",
channel: "latest"
},
}
+1
View File
@@ -0,0 +1 @@
require ("./buildInsider.js") .buildLinux ()
+1
View File
@@ -0,0 +1 @@
require ("./buildInsider.js") .buildWindows ()
+1
View File
@@ -0,0 +1 @@
require ("./build.js") .buildLinux ()
+1
View File
@@ -0,0 +1 @@
require ("./build.js") .buildMac ()
+18
View File
@@ -0,0 +1,18 @@
import { writeFile } from 'fs';
import sass from 'sass';
sass .render (
{ file: 'src/Main.scss', outputStyle: 'compressed' },
(err, result) => {
if (err) {
throw err;
}
writeFile ('app/main.css', result.css, err => {
if (err) {
throw err;
}
console.log('SCSS successfully bundled!');
})
})
+1
View File
@@ -0,0 +1 @@
require ("./build.js") .buildWindows ()
-17
View File
@@ -1,17 +0,0 @@
import fs from 'fs';
import sass from 'node-sass';
sass.render({
file: 'src/Main.scss',
outputStyle: 'compressed'
}, (err, result) => {
if (err) {
throw err;
}
fs.writeFile('app/main.css', result.css, err => {
if (err) {
throw err;
}
console.log('SCSS successfully bundled!');
});
});
-53
View File
@@ -1,53 +0,0 @@
{
"appId": "lukasobermann.optolith",
"productName": "Optolith",
"copyright": "This product was created under a license. Das Schwarze Auge and its logo as well as Aventuria, Dere, Myranor, Riesland, Tharun and Uthuria and their logos are trademarks of Significant GbR. The title and contents of this book are protected under the copyright laws of the United States of America. No part of this publication may be reproduced, stored in retrieval systems or transmitted, in any form or by any means, whether electronic, mechanical, photocopy, recording, or otherwise, without prior written consent by Ulisses Spiele GmbH, Waldems. This publication includes material that is protected under copyright laws by Ulisses Spiele and/or other authors. Such material is used under the Community Content Agreement for the SCRIPTORIUM AVENTURIS. All other original materials in this work is copyright 2017-present by Lukas Obermann and published under the Community Content Agreement for the SCRIPTORIUM AVENTURIS.",
"files": [
"app/**/*",
"CHANGELOG.md"
],
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
],
"icon": "app/icon.ico",
"artifactName": "OptolithSetup_${version}.${ext}"
},
"nsis": {
"perMachine": true,
"differentialPackage": true
},
"linux": {
"category": "RolePlaying",
"executableName": "Optolith",
"icon": "app",
"target": [
{
"target": "tar.gz",
"arch": [
"x64",
"ia32"
]
}
],
"artifactName": "Optolith_${version}_${arch}.${ext}"
},
"mac": {
"category": "public.app-category.role-playing-games",
"type": "distribution",
"icon": "app/icon.icns",
"target": "default",
"artifactName": "Optolith_${version}.${ext}"
},
"publish": {
"provider": "generic",
"url": "http://update.optolith.app/${os}",
"channel": "latest"
}
}
-48
View File
@@ -1,48 +0,0 @@
{
"appId": "lukasobermann.optolith",
"productName": "Optolith",
"copyright": "This product was created under a license. Das Schwarze Auge and its logo as well as Aventuria, Dere, Myranor, Riesland, Tharun and Uthuria and their logos are trademarks of Significant GbR. The title and contents of this book are protected under the copyright laws of the United States of America. No part of this publication may be reproduced, stored in retrieval systems or transmitted, in any form or by any means, whether electronic, mechanical, photocopy, recording, or otherwise, without prior written consent by Ulisses Spiele GmbH, Waldems. This publication includes material that is protected under copyright laws by Ulisses Spiele and/or other authors. Such material is used under the Community Content Agreement for the SCRIPTORIUM AVENTURIS. All other original materials in this work is copyright 2017-present by Lukas Obermann and published under the Community Content Agreement for the SCRIPTORIUM AVENTURIS.",
"files": [
"app/**/*",
"CHANGELOG.md"
],
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
],
"icon": "app/icon.ico",
"artifactName": "OptolithInsiderSetup_${version}.${ext}"
},
"nsis": {
"perMachine": true,
"differentialPackage": true
},
"linux": {
"category": "RolePlaying",
"executableName": "OptolithInsider",
"icon": "app",
"target": [
{
"target": "AppImage",
"arch": [
"x64"
]
}
],
"artifactName": "OptolithInsider_${version}_${arch}.${ext}"
},
"appImage": {
"license": "LICENSE"
},
"publish": {
"provider": "generic",
"url": "http://update.optolith.app/insider/${os}",
"channel": "alpha"
}
}
+3394 -3616
View File
File diff suppressed because it is too large Load Diff
+47 -54
View File
@@ -1,7 +1,7 @@
{
"name": "optolith",
"productName": "Optolith",
"version": "1.1.0-alpha.2",
"productName": "Optolith Insider",
"version": "1.1.0-alpha.17",
"description": "A generator for heroes for the P&P-RPG 'The Dark Eye'.",
"author": {
"name": "Lukas Obermann",
@@ -9,75 +9,68 @@
},
"homepage": "https://github.com/Elytherion/tdeheroes",
"license": "GPL-3.0",
"main": "app/main.js",
"main": "app/index.js",
"dependencies": {
"classnames": "2.2.5",
"classnames": "2.2.6",
"electron-localshortcut": "3.1.0",
"electron-log": "2.2.12",
"electron-updater": "4.0.5",
"electron-window-state": "4.1.1",
"esm": "3.2.4",
"ramda": "0.26.1",
"react": "16.2.0",
"electron-log": "3.0.5",
"electron-updater": "4.0.6",
"electron-window-state": "5.0.3",
"esm": "3.2.25",
"react": "16.8.6",
"react-custom-scrollbars": "4.2.1",
"react-dom": "16.2.0",
"react-markdown": "3.1.1",
"react-portal": "3.2.0",
"react-progress-arc": "1.0.7",
"react-redux": "5.0.7",
"react-dom": "16.8.6",
"react-markdown": "4.0.8",
"react-portal": "4.2.0",
"react-redux": "6.0.1",
"react-textfit": "1.1.0",
"redux": "4.0.0",
"redux-thunk": "2.2.0",
"remark-breaks": "1.0.0",
"reselect": "3.0.1",
"semver": "5.4.1",
"redux": "4.0.1",
"redux-thunk": "2.3.0",
"remark-breaks": "1.0.2",
"reselect": "4.0.0",
"semver": "6.0.0",
"styled-components": "4.2.0",
"tslib": "1.9.3",
"xlsx": "0.10.9"
"xlsx": "0.14.2"
},
"devDependencies": {
"@types/classnames": "0.0.32",
"@types/electron-window-state": "2.0.31",
"@types/jest": "22.2.3",
"@types/lodash": "4.14.88",
"@types/node": "7.0.49",
"@types/node-sass": "3.10.32",
"@types/ramda": "0.25.48",
"@types/react": "16.0.28",
"@types/react-custom-scrollbars": "4.0.1",
"@types/react-dom": "16.0.3",
"@types/react-portal": "3.0.3",
"@types/react-redux": "5.0.16",
"@types/semver": "5.4.0",
"electron": "4.0.0",
"electron-builder": "20.38.5",
"elm": "0.19.0-bugfix2",
"@types/classnames": "2.2.7",
"@types/jest": "24.0.11",
"@types/node": "11.13.7",
"@types/react": "16.8.14",
"@types/react-custom-scrollbars": "4.0.5",
"@types/react-dom": "16.8.4",
"@types/react-portal": "4.0.2",
"@types/react-redux": "7.0.8",
"@types/semver": "6.0.0",
"@types/styled-components": "4.1.15",
"electron": "5.0.2",
"electron-builder": "20.40.2",
"eslint": "4.19.1",
"eslint-plugin-tslint": "2.1.0",
"eslint-plugin-typescript": "0.12.0",
"jest": "23.6.0",
"jsdoc": "3.5.5",
"node-sass": "4.11.0",
"ts-jest": "23.10.5",
"tslint": "5.12.1",
"jest": "24.7.1",
"madge": "3.4.4",
"sass": "1.20.1",
"ts-jest": "24.0.2",
"tslint": "5.14.0",
"tslint-eslint-rules": "5.4.0",
"typescript": "3.3.1",
"typescript": "3.4.5",
"typescript-eslint-parser": "16.0.0",
"typescript-tslint-plugin": "0.3.1"
},
"scripts": {
"build": "electron-builder --config -lw",
"buildTest": "electron-builder --config electron-builder.test.json -lw",
"buildTestLinux": "electron-builder --config electron-builder.test.json -l",
"buildDir": "electron-builder --config electron-builder.test.json --dir",
"buildMac": "build --config electron-builder.json -m",
"buildMacTest": "build --config electron-builder.test.json -m",
"buildInsiderWin": "node ./buildInsiderWin.js",
"buildInsiderLinux": "node ./buildInsiderLinux.js",
"buildWin": "node ./buildWin.js",
"buildLinux": "node ./buildLinux.js",
"buildMac": "node ./buildMac.js",
"buildCss": "node --experimental-modules buildSass.mjs",
"compile": "tsc",
"watch": "tsc --watch",
"bundle": "node --max-old-space-size=2048 ./node_modules/typescript/lib/tsc.js",
"start": "electron .",
"bundle_l10ns": "node -r @std/esm src/data/buildAllLocales.mjs",
"bundle_data": "node -r @std/esm src/data/buildData.mjs",
"bundle_css": "node --experimental-modules bundleSass.mjs",
"test": "jest"
"test": "jest",
"circ": "madge -c ./src"
},
"repository": {},
"jest": {
+47
View File
@@ -0,0 +1,47 @@
import { remote } from "electron";
import { Just, Nothing } from "../../Data/Maybe";
import { L10nRecord } from "../Models/Wiki/L10n";
import { getIsHeroSection } from "../Selectors/uilocationSelectors";
import { TabId } from "../Utilities/LocationUtils";
import { isDialogOpen } from "../Utilities/SubwindowsUtils";
import { ReduxAction } from "./Actions";
import { saveHero } from "./HerolistActions";
import { redo, undo } from "./HistoryActions";
import { requestClose } from "./IOActions";
import { setTab } from "./LocationActions";
import { openSettings } from "./SubwindowsActions";
export const undoAccelerator = (): ReduxAction => (dispatch, getState) => {
if (!isDialogOpen () && getIsHeroSection (getState ())) {
dispatch (undo ())
}
}
export const redoAccelerator = (): ReduxAction => (dispatch, getState) => {
if (!isDialogOpen () && getIsHeroSection (getState ())) {
dispatch (redo ())
}
}
export const saveHeroAccelerator = (l10n: L10nRecord): ReduxAction =>
(dispatch, getState) => {
if (!isDialogOpen () && getIsHeroSection (getState ())) {
dispatch (saveHero (l10n) (Nothing))
}
}
export const backAccelerator = (): ReduxAction => (dispatch, getState) => {
if (!isDialogOpen () && getIsHeroSection (getState ())) {
dispatch (setTab (TabId.Herolist))
}
}
export const openSettingsAccelerator = (): ReduxAction => dispatch => {
if (!isDialogOpen ()) {
dispatch (openSettings ())
}
}
export const quitAccelerator: ReduxAction = dispatch => {
dispatch (requestClose (Just (remote.app.quit)))
}
+12
View File
@@ -0,0 +1,12 @@
import { Action, AnyAction } from "redux";
import { ThunkAction, ThunkDispatch } from "redux-thunk";
import { Record } from "../../Data/Record";
import { AppState } from "../Reducers/appReducer";
export type ReduxAction<R = void, D extends Action = AnyAction> =
ThunkAction<R, Record<AppState>, undefined, D>
export type ReduxActions<R = void, D extends Action = AnyAction> = ReduxAction<R, D> | D
export type ReduxDispatch<A extends Action = AnyAction> =
ThunkDispatch<Record<AppState>, undefined, A>
+43
View File
@@ -0,0 +1,43 @@
import { clipboard } from "electron";
import { ActionTypes } from "../Constants/ActionTypes";
import { Alert } from "../Models/Hero/heroTypeHelpers";
import { L10nRecord } from "../Models/Wiki/L10n";
import { translate } from "../Utilities/I18n";
export interface AddAlertAction {
type: ActionTypes.ADD_ALERT
payload: Alert
}
export const addAlert = (options: Alert): AddAlertAction => ({
type: ActionTypes.ADD_ALERT,
payload: options,
})
export const addErrorAlert = (l10n: L10nRecord) => (options: Alert): AddAlertAction => {
const buttons: Alert["buttons"] = [
{
label: translate (l10n) ("copy"),
dispatchOnClick: () => clipboard.writeText (options.message),
},
{
label: translate (l10n) ("ok"),
},
]
return {
type: ActionTypes.ADD_ALERT,
payload: {
...options,
buttons,
},
}
}
export interface RemoveAlertAction {
type: ActionTypes.REMOVE_ALERT
}
export const removeAlert = (): RemoveAlertAction => ({
type: ActionTypes.REMOVE_ALERT,
})
+388
View File
@@ -0,0 +1,388 @@
import { fmapF } from "../../Data/Functor";
import { List } from "../../Data/List";
import { bind, bindF, fromJust, isNothing, join, liftM2 } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { ActionTypes } from "../Constants/ActionTypes";
import { HeroModel } from "../Models/Hero/HeroModel";
import { L10nRecord } from "../Models/Wiki/L10n";
import { getAvailableAPMap } from "../Selectors/adventurePointsSelectors";
import { getIsInCharacterCreation } from "../Selectors/phaseSelectors";
import { getAddedArcaneEnergyPoints, getAddedKarmaPoints, getAddedLifePoints, getCurrentHeroPresent, getWikiAttributes } from "../Selectors/stateSelectors";
import { getMissingAP } from "../Utilities/AdventurePoints/adventurePointsUtils";
import { getIncreaseAP } from "../Utilities/AdventurePoints/improvementCostUtils";
import { translate, translateP } from "../Utilities/I18n";
import { getAreSufficientAPAvailableForIncrease } from "../Utilities/Increasable/increasableUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { ReduxAction } from "./Actions";
import { addAlert } from "./AlertActions";
export interface AddAttributePointAction {
type: ActionTypes.ADD_ATTRIBUTE_POINT
payload: {
id: string;
}
}
export const addAttributePoint = (l10n: L10nRecord) => (id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const wiki_attributes = getWikiAttributes (state)
const mhero = getCurrentHeroPresent (state)
const mhero_attributes = fmapF (mhero) (HeroModel.A.attributes)
const missingAPForInc =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (getAreSufficientAPAvailableForIncrease (getIsInCharacterCreation (state))
(bind (mhero_attributes)
(lookup (id))))
(lookup (id) (wiki_attributes)),
join
)
if (isNothing (missingAPForInc)) {
dispatch<AddAttributePointAction> ({
type: ActionTypes.ADD_ATTRIBUTE_POINT,
payload: {
id,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAPForInc))),
}))
}
}
export interface RemoveAttributePointAction {
type: ActionTypes.REMOVE_ATTRIBUTE_POINT
payload: {
id: string;
}
}
export const removeAttributePoint = (id: string): RemoveAttributePointAction => ({
type: ActionTypes.REMOVE_ATTRIBUTE_POINT,
payload: {
id,
},
})
export interface AddLifePointAction {
type: ActionTypes.ADD_LIFE_POINT
}
export const addLifePoint = (l10n: L10nRecord): ReduxAction => (dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
const missingAP =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (pipe (
// get AP for added points
getIncreaseAP (4),
// AP are passed to result and result finally gets the available AP
getMissingAP (getIsInCharacterCreation (state))))
(getAddedLifePoints (state)),
join
)
if (isNothing (missingAP)) {
dispatch<AddLifePointAction> ({
type: ActionTypes.ADD_LIFE_POINT,
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAP))),
}))
}
}
export interface AddArcaneEnergyPointAction {
type: ActionTypes.ADD_ARCANE_ENERGY_POINT
}
export const addArcaneEnergyPoint = (l10n: L10nRecord): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
const missingAP =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (pipe (
// get AP for added points
getIncreaseAP (4),
// AP are passed to result and result finally gets the available AP
getMissingAP (getIsInCharacterCreation (state))))
(getAddedArcaneEnergyPoints (state)),
join
)
if (isNothing (missingAP)) {
dispatch<AddArcaneEnergyPointAction> ({
type: ActionTypes.ADD_ARCANE_ENERGY_POINT,
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAP))),
}))
}
}
export interface AddKarmaPointAction {
type: ActionTypes.ADD_KARMA_POINT
}
export const addKarmaPoint = (l10n: L10nRecord): ReduxAction => (dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
const missingAP =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (pipe (
// get AP for added points
getIncreaseAP (4),
// AP are passed to result and result finally gets the available AP
getMissingAP (getIsInCharacterCreation (state))))
(getAddedKarmaPoints (state)),
join
)
if (isNothing (missingAP)) {
dispatch<AddKarmaPointAction> ({
type: ActionTypes.ADD_KARMA_POINT,
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAP))),
}))
}
}
export interface RemoveLifePointAction {
type: ActionTypes.REMOVE_LIFE_POINT
}
export const removeLifePoint = (): RemoveLifePointAction => ({
type: ActionTypes.REMOVE_LIFE_POINT,
})
export interface RemoveArcaneEnergyPointAction {
type: ActionTypes.REMOVE_ARCANE_ENERGY_POINT
}
export const removeArcaneEnergyPoint = (): RemoveArcaneEnergyPointAction => ({
type: ActionTypes.REMOVE_ARCANE_ENERGY_POINT,
})
export interface RemoveKarmaPointAction {
type: ActionTypes.REMOVE_KARMA_POINT
}
export const removeKarmaPoint = (): RemoveKarmaPointAction => ({
type: ActionTypes.REMOVE_KARMA_POINT,
})
export interface AddBoughtBackAEPointAction {
type: ActionTypes.ADD_BOUGHT_BACK_AE_POINT
}
export const addBoughtBackAEPoint = (l10n: L10nRecord): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
const missingAP =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
bindF (getMissingAP (getIsInCharacterCreation (state))
(2))
)
if (isNothing (missingAP)) {
dispatch<AddBoughtBackAEPointAction> ({
type: ActionTypes.ADD_BOUGHT_BACK_AE_POINT,
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAP))),
}))
}
}
export interface AddLostLPPointAction {
type: ActionTypes.ADD_LOST_LP_POINT
}
export const addLostLPPoint = (): AddLostLPPointAction => ({
type: ActionTypes.ADD_LOST_LP_POINT,
})
export interface RemoveLostLPPointAction {
type: ActionTypes.REMOVE_LOST_LP_POINT
}
export const removeLostLPPoint = (): RemoveLostLPPointAction => ({
type: ActionTypes.REMOVE_LOST_LP_POINT,
})
export interface AddLostLPPointsAction {
type: ActionTypes.ADD_LOST_LP_POINTS
payload: {
value: number;
}
}
export const addLostLPPoints = (value: number): AddLostLPPointsAction => ({
type: ActionTypes.ADD_LOST_LP_POINTS,
payload: {
value,
},
})
export interface RemoveBoughtBackAEPointAction {
type: ActionTypes.REMOVE_BOUGHT_BACK_AE_POINT
}
export const removeBoughtBackAEPoint = (): RemoveBoughtBackAEPointAction => ({
type: ActionTypes.REMOVE_BOUGHT_BACK_AE_POINT,
})
export interface AddLostAEPointAction {
type: ActionTypes.ADD_LOST_AE_POINT
}
export const addLostAEPoint = (): AddLostAEPointAction => ({
type: ActionTypes.ADD_LOST_AE_POINT,
})
export interface RemoveLostAEPointAction {
type: ActionTypes.REMOVE_LOST_AE_POINT
}
export const removeLostAEPoint = (): RemoveLostAEPointAction => ({
type: ActionTypes.REMOVE_LOST_AE_POINT,
})
export interface AddLostAEPointsAction {
type: ActionTypes.ADD_LOST_AE_POINTS
payload: {
value: number;
}
}
export const addLostAEPoints = (value: number): AddLostAEPointsAction => ({
type: ActionTypes.ADD_LOST_AE_POINTS,
payload: {
value,
},
})
export interface AddBoughtBackKPPointAction {
type: ActionTypes.ADD_BOUGHT_BACK_KP_POINT
}
export const addBoughtBackKPPoint = (l10n: L10nRecord): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
const missingAP =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
bindF (getMissingAP (getIsInCharacterCreation (state))
(2))
)
if (isNothing (missingAP)) {
dispatch<AddBoughtBackKPPointAction> ({
type: ActionTypes.ADD_BOUGHT_BACK_KP_POINT,
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAP))),
}))
}
}
export interface RemoveBoughtBackKPPointAction {
type: ActionTypes.REMOVE_BOUGHT_BACK_KP_POINT
}
export const removeBoughtBackKPPoint = (): RemoveBoughtBackKPPointAction => ({
type: ActionTypes.REMOVE_BOUGHT_BACK_KP_POINT,
})
export interface AddLostKPPointAction {
type: ActionTypes.ADD_LOST_KP_POINT
}
export const addLostKPPoint = (): AddLostKPPointAction => ({
type: ActionTypes.ADD_LOST_KP_POINT,
})
export interface RemoveLostKPPointAction {
type: ActionTypes.REMOVE_LOST_KP_POINT
}
export const removeLostKPPoint = (): RemoveLostKPPointAction => ({
type: ActionTypes.REMOVE_LOST_KP_POINT,
})
export interface AddLostKPPointsAction {
type: ActionTypes.ADD_LOST_KP_POINTS
payload: {
value: number;
}
}
export const addLostKPPoints = (value: number): AddLostKPPointsAction => ({
type: ActionTypes.ADD_LOST_KP_POINTS,
payload: {
value,
},
})
export interface SetAdjustmentIdAction {
type: ActionTypes.SET_ATTRIBUTE_ADJUSTMENT_SELECTION_ID
payload: {
id: string;
}
}
export const setAdjustmentId = (id: string): SetAdjustmentIdAction => ({
type: ActionTypes.SET_ATTRIBUTE_ADJUSTMENT_SELECTION_ID,
payload: {
id,
},
})
+100
View File
@@ -0,0 +1,100 @@
import { List } from "../../Data/List";
import { bind, bindF, fromJust, isNothing, join, liftM2 } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { ActionTypes } from "../Constants/ActionTypes";
import { HeroModel } from "../Models/Hero/HeroModel";
import { L10nRecord } from "../Models/Wiki/L10n";
import { getAvailableAPMap } from "../Selectors/adventurePointsSelectors";
import { getIsInCharacterCreation } from "../Selectors/phaseSelectors";
import { getCombatTechniques, getCurrentHeroPresent, getWikiCombatTechniques } from "../Selectors/stateSelectors";
import { translate, translateP } from "../Utilities/I18n";
import { getAreSufficientAPAvailableForIncrease } from "../Utilities/Increasable/increasableUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { ReduxAction } from "./Actions";
import { addAlert } from "./AlertActions";
export interface AddCombatTechniquePointAction {
type: ActionTypes.ADD_COMBATTECHNIQUE_POINT
payload: {
id: string;
}
}
export const addCombatTechniquePoint = (l10n: L10nRecord) => (id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero_combat_techniques = getCombatTechniques (state)
const wiki_combat_techniques = getWikiCombatTechniques (state)
const mhero = getCurrentHeroPresent (state)
const missingAPForInc =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (getAreSufficientAPAvailableForIncrease (getIsInCharacterCreation (state))
(bind (mhero_combat_techniques)
(lookup (id))))
(lookup (id) (wiki_combat_techniques)),
join
)
if (isNothing (missingAPForInc)) {
dispatch<AddCombatTechniquePointAction> ({
type: ActionTypes.ADD_COMBATTECHNIQUE_POINT,
payload: {
id,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAPForInc))),
}))
}
}
export interface RemoveCombatTechniquePointAction {
type: ActionTypes.REMOVE_COMBATTECHNIQUE_POINT
payload: {
id: string;
}
}
export const removeCombatTechniquePoint = (id: string): RemoveCombatTechniquePointAction => ({
type: ActionTypes.REMOVE_COMBATTECHNIQUE_POINT,
payload: {
id,
},
})
export interface SetCombatTechniquesSortOrderAction {
type: ActionTypes.SET_COMBATTECHNIQUES_SORT_ORDER
payload: {
sortOrder: string;
}
}
export const setCombatTechniquesSortOrder =
(sortOrder: string): SetCombatTechniquesSortOrderAction => ({
type: ActionTypes.SET_COMBATTECHNIQUES_SORT_ORDER,
payload: {
sortOrder,
},
})
export interface SetCombatTechniquesFilterTextAction {
type: ActionTypes.SET_COMBAT_TECHNIQUES_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setCombatTechniquesFilterText =
(filterText: string): SetCombatTechniquesFilterTextAction => ({
type: ActionTypes.SET_COMBAT_TECHNIQUES_FILTER_TEXT,
payload: {
filterText,
},
})
@@ -1,18 +1,18 @@
import { ActionTypes } from '../constants/ActionTypes';
import { ActionTypes } from "../Constants/ActionTypes";
export interface SwitchEnableActiveItemHintsAction {
type: ActionTypes.SWITCH_ENABLE_ACTIVE_ITEM_HINTS;
type: ActionTypes.SWITCH_ENABLE_ACTIVE_ITEM_HINTS
}
export const switchEnableActiveItemHints = (): SwitchEnableActiveItemHintsAction => ({
type: ActionTypes.SWITCH_ENABLE_ACTIVE_ITEM_HINTS,
});
})
export interface SetThemeAction {
type: ActionTypes.SET_THEME;
type: ActionTypes.SET_THEME
payload: {
theme: string;
};
}
}
export const setTheme = (theme: string): SetThemeAction => ({
@@ -20,21 +20,21 @@ export const setTheme = (theme: string): SetThemeAction => ({
payload: {
theme,
},
});
})
export interface SwitchEnableEditingHeroAfterCreationPhaseAction {
type: ActionTypes.SWITCH_ENABLE_EDITING_HERO_AFTER_CREATION_PHASE;
type: ActionTypes.SWITCH_ENABLE_EDITING_HERO_AFTER_CREATION_PHASE
}
export const switchEnableEditingHeroAfterCreationPhase =
(): SwitchEnableEditingHeroAfterCreationPhaseAction => ({
type: ActionTypes.SWITCH_ENABLE_EDITING_HERO_AFTER_CREATION_PHASE,
});
})
export interface SwitchEnableAnimationsAction {
type: ActionTypes.SWITCH_ENABLE_ANIMATIONS;
type: ActionTypes.SWITCH_ENABLE_ANIMATIONS
}
export const switchEnableAnimations = (): SwitchEnableAnimationsAction => ({
type: ActionTypes.SWITCH_ENABLE_ANIMATIONS,
});
})
@@ -1,65 +1,65 @@
import { ActionTypes } from '../constants/ActionTypes';
import { ActionTypes } from "../Constants/ActionTypes";
export interface SelectCultureAction {
type: ActionTypes.SELECT_CULTURE;
type: ActionTypes.SELECT_CULTURE
payload: {
id: string;
};
}
}
export const selectCulture = (id: string): SelectCultureAction => ({
type: ActionTypes.SELECT_CULTURE,
payload: {
id
}
});
id,
},
})
export interface SetCulturesSortOrderAction {
type: ActionTypes.SET_CULTURES_SORT_ORDER;
type: ActionTypes.SET_CULTURES_SORT_ORDER
payload: {
sortOrder: string;
};
}
}
export const setSortOrder = (sortOrder: string): SetCulturesSortOrderAction => ({
type: ActionTypes.SET_CULTURES_SORT_ORDER,
payload: {
sortOrder
}
});
sortOrder,
},
})
export interface SetCulturesVisibilityFilterAction {
type: ActionTypes.SET_CULTURES_VISIBILITY_FILTER;
type: ActionTypes.SET_CULTURES_VISIBILITY_FILTER
payload: {
filter: string;
};
}
}
export const setVisibilityFilter = (filter: string): SetCulturesVisibilityFilterAction => ({
type: ActionTypes.SET_CULTURES_VISIBILITY_FILTER,
payload: {
filter
}
});
filter,
},
})
export interface SwitchCultureValueVisibilityAction {
type: ActionTypes.SWITCH_CULTURE_VALUE_VISIBILITY;
type: ActionTypes.SWITCH_CULTURE_VALUE_VISIBILITY
}
export const switchValueVisibilityFilter = (): SwitchCultureValueVisibilityAction => ({
type: ActionTypes.SWITCH_CULTURE_VALUE_VISIBILITY
});
type: ActionTypes.SWITCH_CULTURE_VALUE_VISIBILITY,
})
export interface SetCulturesFilterTextAction {
type: ActionTypes.SET_CULTURES_FILTER_TEXT;
type: ActionTypes.SET_CULTURES_FILTER_TEXT
payload: {
filterText: string;
};
}
}
export const setFilterText = (filterText: string): SetCulturesFilterTextAction => ({
type: ActionTypes.SET_CULTURES_FILTER_TEXT,
payload: {
filterText
}
});
filterText,
},
})
+507
View File
@@ -0,0 +1,507 @@
import { fmap, fmapF } from "../../Data/Functor";
import { over, set } from "../../Data/Lens";
import { List, subscriptF, uncons } from "../../Data/List";
import { altF_, bind, bindF, elem, ensure, fromJust, isJust, join, Just, liftM2, Maybe, Nothing } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { Record } from "../../Data/Record";
import { fst, Pair, PairP1_, snd } from "../../Data/Tuple";
import { ActionTypes } from "../Constants/ActionTypes";
import { ActivatableActivationEntryType } from "../Models/Actions/ActivatableActivationEntryType";
import { ActivatableActivationOptions } from "../Models/Actions/ActivatableActivationOptions";
import { ActivatableDeactivationEntryType } from "../Models/Actions/ActivatableDeactivationEntryType";
import { ActivatableDeactivationOptions, ActivatableDeactivationOptionsL } from "../Models/Actions/ActivatableDeactivationOptions";
import { ActivatableDependent } from "../Models/ActiveEntries/ActivatableDependent";
import { ActiveObject } from "../Models/ActiveEntries/ActiveObject";
import { ActiveObjectWithIdL, toActiveObjectWithId } from "../Models/ActiveEntries/ActiveObjectWithId";
import { HeroModel, HeroModelRecord } from "../Models/Hero/HeroModel";
import { ActivatableNameCost, ActivatableNameCostSafeCost } from "../Models/View/ActivatableNameCost";
import { Advantage, isAdvantage } from "../Models/Wiki/Advantage";
import { Disadvantage, isDisadvantage } from "../Models/Wiki/Disadvantage";
import { L10nRecord } from "../Models/Wiki/L10n";
import { Race } from "../Models/Wiki/Race";
import { RaceVariant } from "../Models/Wiki/RaceVariant";
import { getAPObjectMap } from "../Selectors/adventurePointsSelectors";
import { getIsInCharacterCreation } from "../Selectors/phaseSelectors";
import { getCurrentRace, getCurrentRaceVariant } from "../Selectors/rcpSelectors";
import { getCurrentHeroPresent, getWiki } from "../Selectors/stateSelectors";
import { getNameCost } from "../Utilities/Activatable/activatableActiveUtils";
import { isBlessedOrMagical } from "../Utilities/Activatable/checkActivatableUtils";
import { convertPerTierCostToFinalCost } from "../Utilities/AdventurePoints/activatableCostUtils";
import { getDisAdvantagesSubtypeMax, getMissingAPForDisAdvantage, MissingAPForDisAdvantage } from "../Utilities/AdventurePoints/adventurePointsUtils";
import { translate, translateP } from "../Utilities/I18n";
import { negate, subtract } from "../Utilities/mathUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { misNumberM } from "../Utilities/typeCheckUtils";
import { getWikiEntry } from "../Utilities/WikiUtils";
import { ReduxAction, ReduxDispatch } from "./Actions";
import { addAlert } from "./AlertActions";
/**
* Advantages and disadvantages might not only be added or removed due to not
* enough AP but also due to limitations regarding AP spent on advantages,
* disadvantages or subtypes thereof (blessed, magical). This function ensures
* that the appropiate error message is displayed if an entry cannot be added or
* removed.
*
* If the addition or removal is valid, the passed `successFn` will be called.
*/
const handleMissingAPForDisAdvantage =
(l10n: L10nRecord) =>
(success: () => void) =>
(hero: HeroModelRecord) =>
(missing_ap: Record<MissingAPForDisAdvantage>) =>
(is_blessed_or_magical: Pair<boolean, boolean>) =>
(is_disadvantage: boolean) =>
(dispatch: ReduxDispatch) => {
const totalMissing = MissingAPForDisAdvantage.AL.totalMissing (missing_ap)
const mainMissing = MissingAPForDisAdvantage.AL.mainMissing (missing_ap)
const subMissing = MissingAPForDisAdvantage.AL.subMissing (missing_ap)
if (isJust (totalMissing)) {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (totalMissing))),
}))
}
else if (isJust (mainMissing)) {
const type = is_disadvantage
? translate (l10n) ("disadvantages")
: translate (l10n) ("advantages")
dispatch (addAlert ({
title: translateP (l10n) ("reachedlimit") (List (type)),
message: translateP (l10n)
("reachedaplimit")
(List<string | number> (fromJust (mainMissing), 80, type)),
}))
}
else if (isJust (subMissing)) {
const ap = getDisAdvantagesSubtypeMax (snd (is_blessed_or_magical)) (hero)
const type = is_disadvantage
? fst (is_blessed_or_magical)
? translate (l10n) ("blesseddisadvantages")
: translate (l10n) ("magicaldisadvantages")
: fst (is_blessed_or_magical)
? translate (l10n) ("blessedadvantages")
: translate (l10n) ("magicaladvantages")
dispatch (addAlert ({
title: translateP (l10n) ("reachedlimit") (List (type)),
message: translateP (l10n)
("reachedaplimit")
(List<string | number> (fromJust (subMissing), ap, type)),
}))
}
else {
success ()
}
}
export interface ActivateDisAdvAction {
type: ActionTypes.ACTIVATE_DISADV
payload: Pair<Record<ActivatableActivationOptions>, Record<ActivatableActivationEntryType>>
}
/**
* Add an advantage or disadvantage with the provided activation properties
* (`args`).
*/
export const addDisAdvantage =
(l10n: L10nRecord) =>
(args: Record<ActivatableActivationOptions>): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
if (isJust (mhero)) {
const hero = fromJust (mhero)
const current_id = ActivatableActivationOptions.AL.id (args)
const current_cost = ActivatableActivationOptions.AL.cost (args)
const mwiki_entry =
bind (getWikiEntry (getWiki (state)) (current_id))
(ensure ((x): x is Record<Advantage> | Record<Disadvantage> =>
isAdvantage (x) || isDisadvantage (x)))
const mhero_entry =
bind (mwiki_entry)
(x => lookup (current_id)
(isAdvantage (x)
? HeroModel.AL.advantages (hero)
: HeroModel.AL.disadvantages (hero)))
if (isJust (mwiki_entry)) {
const wiki_entry = fromJust (mwiki_entry)
const is_disadvantage = isDisadvantage (wiki_entry)
const entryType = isBlessedOrMagical (wiki_entry)
const mmissingAPForDisAdvantage =
fmapF (join (getAPObjectMap (HeroModel.A.id (hero)) (state, { l10n })))
(ap => getMissingAPForDisAdvantage (getIsInCharacterCreation (state))
(entryType)
(is_disadvantage)
(hero)
(ap)
(current_cost))
const successFn = () => {
const color: Maybe<Pair<number, number>> =
current_id === "DISADV_45"
&& elem<string | number> (1) (ActivatableActivationOptions.AL.selectOptionId1 (args))
? Just (Pair (19, 24)) // (eyeColor, hairColor)
: Nothing
dispatch<ActivateDisAdvAction> ({
type: ActionTypes.ACTIVATE_DISADV,
payload:
Pair (
args,
ActivatableActivationEntryType ({
eyeColor: fmapF (color) (fst),
hairColor: fmapF (color) (snd),
isBlessed: fst (entryType),
isDisadvantage: is_disadvantage,
isMagical: snd (entryType),
heroEntry: mhero_entry,
wikiEntry: wiki_entry,
})
),
})
}
if (isJust (mmissingAPForDisAdvantage)) {
handleMissingAPForDisAdvantage (l10n)
(successFn)
(hero)
(fromJust (mmissingAPForDisAdvantage))
(entryType)
(is_disadvantage)
(dispatch)
}
}
}
}
export interface DeactivateDisAdvAction {
type: ActionTypes.DEACTIVATE_DISADV
payload: Pair<Record<ActivatableDeactivationOptions>, Record<ActivatableDeactivationEntryType>>
}
/**
* Remove an advantage or disadvantage with the provided activation properties
* (`args`).
*/
export const removeDisAdvantage =
(l10n: L10nRecord) =>
(args: Record<ActivatableDeactivationOptions>): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
if (isJust (mhero)) {
const hero = fromJust (mhero)
const current_id = ActivatableDeactivationOptions.AL.id (args)
const current_index = ActivatableDeactivationOptions.AL.index (args)
const current_cost = ActivatableDeactivationOptions.AL.cost (args)
const negativeCost = current_cost * -1 // the entry should be removed
const mwiki_entry =
bind (getWikiEntry (getWiki (state)) (current_id))
(ensure ((x): x is Record<Advantage> | Record<Disadvantage> =>
isAdvantage (x) || isDisadvantage (x)))
const mhero_entry =
bind (mwiki_entry)
(x => lookup (current_id)
(isAdvantage (x)
? HeroModel.AL.advantages (hero)
: HeroModel.AL.disadvantages (hero)))
if (isJust (mwiki_entry) && isJust (mhero_entry)) {
const wiki_entry = fromJust (mwiki_entry)
const hero_entry = fromJust (mhero_entry)
const is_disadvantage = isDisadvantage (wiki_entry)
const entryType = isBlessedOrMagical (wiki_entry)
const mmissingAPForDisAdvantage =
fmapF (join (getAPObjectMap (HeroModel.A.id (hero)) (state, { l10n })))
(ap => getMissingAPForDisAdvantage (getIsInCharacterCreation (state))
(entryType)
(is_disadvantage)
(hero)
(ap)
(negativeCost))
const successFn = () => {
const color: Maybe<Pair<number, number>> =
current_id === "DISADV_45"
&& elem (1)
(pipe_ (
hero_entry,
ActivatableDependent.A.active,
subscriptF (current_index),
bindF (ActiveObject.A.sid),
misNumberM
))
? bind (getCurrentRace (state))
(race => {
const mrace_var = getCurrentRaceVariant (state)
const p = Pair (
pipe (
Race.AL.eyeColors,
altF_ (() => bind (mrace_var) (RaceVariant.AL.eyeColors)),
bindF (uncons),
fmap (fst)
)
(race),
pipe (
Race.AL.hairColors,
altF_ (() => bind (mrace_var) (RaceVariant.AL.hairColors)),
bindF (uncons),
fmap (fst)
)
(race)
)
return liftM2 (Pair as PairP1_) <number, number> (fst (p)) (snd (p))
})
: Nothing
dispatch<DeactivateDisAdvAction> ({
type: ActionTypes.DEACTIVATE_DISADV,
payload:
Pair (
over (ActivatableDeactivationOptionsL.cost) (negate) (args),
ActivatableDeactivationEntryType ({
eyeColor: fmapF (color) (fst),
hairColor: fmapF (color) (snd),
isBlessed: fst (entryType),
isDisadvantage: is_disadvantage,
isMagical: snd (entryType),
heroEntry: hero_entry,
wikiEntry: wiki_entry,
})
),
})
}
if (isJust (mmissingAPForDisAdvantage)) {
handleMissingAPForDisAdvantage (l10n)
(successFn)
(hero)
(fromJust (mmissingAPForDisAdvantage))
(entryType)
(is_disadvantage)
(dispatch)
}
}
}
}
export interface SetDisAdvLevelAction {
type: ActionTypes.SET_DISADV_TIER
payload: Pair<
{ id: string; index: number; tier: number },
Record<ActivatableDeactivationEntryType>
>
}
/**
* Change the current level of an advantage or disadvantage.
*/
export const setDisAdvantageLevel =
(l10n: L10nRecord) =>
(current_id: string) =>
(current_index: number) =>
(next_level: number): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
if (isJust (mhero)) {
const hero = fromJust (mhero)
const mwiki_entry =
bind (getWikiEntry (getWiki (state)) (current_id))
(ensure ((x): x is Record<Advantage> | Record<Disadvantage> =>
isAdvantage (x) || isDisadvantage (x)))
const mhero_entry =
bind (mwiki_entry)
(x => lookup (current_id)
(isAdvantage (x)
? HeroModel.AL.advantages (hero)
: HeroModel.AL.disadvantages (hero)))
const mactive_entry =
pipe (
bindF (pipe (
ActivatableDependent.A.active,
subscriptF (current_index)
)),
fmap (toActiveObjectWithId (current_index) (current_id))
)
(mhero_entry)
if (isJust (mwiki_entry) && isJust (mhero_entry) && isJust (mactive_entry)) {
const wiki_entry = fromJust (mwiki_entry)
const active_entry = fromJust (mactive_entry)
const wiki = getWiki (state)
const getCostBorder =
(isEntryToAdd: boolean) =>
pipe (
getNameCost (isEntryToAdd)
(l10n)
(wiki)
(hero),
fmap (pipe (
convertPerTierCostToFinalCost (false) (l10n),
ActivatableNameCost.A.finalCost as
(x: Record<ActivatableNameCostSafeCost>) => number
))
)
const previousCost =
getCostBorder (false) (active_entry)
const nextCost =
getCostBorder (true) (set (ActiveObjectWithIdL.tier)
(Just (next_level))
(active_entry))
const mdiff_cost = liftM2 (subtract) (nextCost) (previousCost)
if (isJust (mdiff_cost)) {
const diff_cost = fromJust (mdiff_cost)
const is_disadvantage = isDisadvantage (wiki_entry)
const entryType = isBlessedOrMagical (wiki_entry)
const mmissingAPForDisAdvantage =
fmapF (join (getAPObjectMap (HeroModel.A.id (hero)) (state, { l10n })))
(ap => getMissingAPForDisAdvantage (getIsInCharacterCreation (state))
(entryType)
(is_disadvantage)
(hero)
(ap)
(diff_cost))
const successFn = () => {
dispatch<SetDisAdvLevelAction> ({
type: ActionTypes.SET_DISADV_TIER,
payload:
Pair (
{
id: current_id,
tier: next_level,
index: current_index,
},
ActivatableDeactivationEntryType ({
eyeColor: Nothing,
hairColor: Nothing,
isBlessed: fst (entryType),
isDisadvantage: is_disadvantage,
isMagical: snd (entryType),
heroEntry: fromJust (mhero_entry),
wikiEntry: wiki_entry,
})
),
})
}
if (isJust (mmissingAPForDisAdvantage)) {
handleMissingAPForDisAdvantage (l10n)
(successFn)
(hero)
(fromJust (mmissingAPForDisAdvantage))
(entryType)
(is_disadvantage)
(dispatch)
}
}
}
}
}
export interface SwitchDisAdvRatingVisibilityAction {
type: ActionTypes.SWITCH_DISADV_RATING_VISIBILITY
}
export const switchRatingVisibility = (): SwitchDisAdvRatingVisibilityAction => ({
type: ActionTypes.SWITCH_DISADV_RATING_VISIBILITY,
})
export interface SetActiveAdvantagesFilterTextAction {
type: ActionTypes.SET_ADVANTAGES_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setActiveAdvantagesFilterText =
(filterText: string): SetActiveAdvantagesFilterTextAction => ({
type: ActionTypes.SET_ADVANTAGES_FILTER_TEXT,
payload: {
filterText,
},
})
export interface SetInactiveAdvantagesFilterTextAction {
type: ActionTypes.SET_INACTIVE_ADVANTAGES_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setInactiveAdvantagesFilterText =
(filterText: string): SetInactiveAdvantagesFilterTextAction => ({
type: ActionTypes.SET_INACTIVE_ADVANTAGES_FILTER_TEXT,
payload: {
filterText,
},
})
export interface SetActiveDisadvantagesFilterTextAction {
type: ActionTypes.SET_DISADVANTAGES_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setActiveDisadvantagesFilterText =
(filterText: string): SetActiveDisadvantagesFilterTextAction => ({
type: ActionTypes.SET_DISADVANTAGES_FILTER_TEXT,
payload: {
filterText,
},
})
export interface SetInactiveDisadvantagesFilterTextAction {
type: ActionTypes.SET_INACTIVE_DISADVANTAGES_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setInactiveDisadvantagesFilterText =
(filterText: string): SetInactiveDisadvantagesFilterTextAction => ({
type: ActionTypes.SET_INACTIVE_DISADVANTAGES_FILTER_TEXT,
payload: {
filterText,
},
})
File diff suppressed because it is too large Load Diff
+229
View File
@@ -0,0 +1,229 @@
import { tryIO } from "../../Control/Exception";
import { fmap } from "../../Data/Functor";
import { List } from "../../Data/List";
import { fromJust, isJust, Maybe } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { OrderedSet } from "../../Data/OrderedSet";
import { runIO } from "../../System/IO";
import { ActionTypes } from "../Constants/ActionTypes";
import { HeroModel } from "../Models/Hero/HeroModel";
import { ExperienceLevel } from "../Models/Wiki/ExperienceLevel";
import { L10nRecord } from "../Models/Wiki/L10n";
import { heroReducer } from "../Reducers/heroReducer";
import { getHeroes, getWikiExperienceLevels } from "../Selectors/stateSelectors";
import { translate, translateP } from "../Utilities/I18n";
import { getNewIdByDate } from "../Utilities/IDUtils";
import { pipe_ } from "../Utilities/pipe";
import { ReduxAction } from "./Actions";
import { addAlert } from "./AlertActions";
import { requestAllHeroesSave, requestHeroDeletion, requestHeroExport, requestHeroSave } from "./IOActions";
export interface SetHerolistSortOrderAction {
type: ActionTypes.SET_HEROLIST_SORT_ORDER
payload: {
sortOrder: string;
}
}
export const setHerolistSortOrder = (sortOrder: string): SetHerolistSortOrderAction => ({
type: ActionTypes.SET_HEROLIST_SORT_ORDER,
payload: {
sortOrder,
},
})
export interface SetHerolistFilterTextAction {
type: ActionTypes.SET_HEROLIST_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setHerolistFilterText = (filterText: string): SetHerolistFilterTextAction => ({
type: ActionTypes.SET_HEROLIST_FILTER_TEXT,
payload: {
filterText,
},
})
export interface SetHerolistVisibilityFilterAction {
type: ActionTypes.SET_HEROLIST_VISIBILITY_FILTER
payload: {
filterOption: string;
}
}
export const setHerolistVisibilityFilter =
(filterOption: string): SetHerolistVisibilityFilterAction => ({
type: ActionTypes.SET_HEROLIST_VISIBILITY_FILTER,
payload: {
filterOption,
},
})
export interface CreateHeroAction {
type: ActionTypes.CREATE_HERO
payload: {
l10n: L10nRecord;
id: string;
name: string;
sex: "m" | "f";
el: string;
enableAllRuleBooks: boolean;
enabledRuleBooks: OrderedSet<string>;
totalAp: number;
}
}
export const createHero =
(l10n: L10nRecord) =>
(name: string) =>
(sex: "m" | "f") =>
(el: string) =>
(enableAllRuleBooks: boolean) =>
(enabledRuleBooks: OrderedSet<string>): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const maybeSelectedExperienceLevel = lookup (el) (getWikiExperienceLevels (state))
if (isJust (maybeSelectedExperienceLevel)) {
const selectedExperienceLevel = fromJust (maybeSelectedExperienceLevel)
const totalAp = ExperienceLevel.A.ap (selectedExperienceLevel)
dispatch<CreateHeroAction> ({
type: ActionTypes.CREATE_HERO,
payload: {
l10n,
id: `H_${getNewIdByDate ()}`,
name,
sex,
el,
enableAllRuleBooks,
enabledRuleBooks,
totalAp,
},
})
}
}
export interface LoadHeroAction {
type: ActionTypes.LOAD_HERO
payload: {
id: string;
}
}
export const loadHero = (id: string): LoadHeroAction => ({
type: ActionTypes.LOAD_HERO,
payload: {
id,
},
})
export const saveHeroes =
(l10n: L10nRecord): ReduxAction =>
dispatch => {
pipe_ (
dispatch (requestAllHeroesSave (l10n)),
tryIO,
fmap (fmap (() => dispatch (addAlert ({
message: translate (l10n) ("allsaved"),
})))),
runIO
)
}
export interface SaveHeroAction {
type: ActionTypes.SAVE_HERO
payload: {
id: string;
}
}
export const saveHero =
(l10n: L10nRecord) =>
(id: Maybe<string>): ReduxAction =>
dispatch => {
pipe_ (
dispatch (requestHeroSave (l10n) (id)),
tryIO,
fmap (fmap (fmap (save_id => dispatch<SaveHeroAction> ({
type: ActionTypes.SAVE_HERO,
payload: {
id: save_id, // specified by param or currently open
},
})))),
runIO
)
}
export const exportHeroValidate =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
dispatch =>
dispatch (requestHeroExport (l10n) (id))
export interface DeleteHeroAction {
type: ActionTypes.DELETE_HERO
payload: {
id: string;
}
}
const deleteHero = (id: string): DeleteHeroAction => ({
type: ActionTypes.DELETE_HERO,
payload: {
id,
},
})
export const deleteHeroValidate =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const heroes = getHeroes (state)
const mhero = lookup (id) (heroes)
if (isJust (mhero)) {
const hero = fromJust (mhero)
const resolve: ReduxAction = futureDispatch => {
futureDispatch (deleteHero (id))
runIO (tryIO (futureDispatch (requestHeroDeletion (l10n) (id))))
}
// @ts-ignore
dispatch (addAlert ({
title: translateP (l10n)
("deletehero")
(List (pipe_ (hero, heroReducer.A_.present, HeroModel.A.name))),
message: translate (l10n) ("deletehero.text"),
confirm: {
resolve,
},
confirmYesNo: true,
}))
}
}
export interface DuplicateHeroAction {
type: ActionTypes.DUPLICATE_HERO
payload: {
id: string;
newId: string;
}
}
export const duplicateHero = (id: string): DuplicateHeroAction => {
const newId = `H_${getNewIdByDate ()}`
return {
type: ActionTypes.DUPLICATE_HERO,
payload: {
id,
newId,
},
}
}
+28
View File
@@ -0,0 +1,28 @@
import { ActionTypes } from "../Constants/ActionTypes";
import { WikiModel } from "../Models/Wiki/WikiModel";
import { getWikiBooks } from "../Selectors/stateSelectors";
import { ReduxAction } from "./Actions";
export interface UndoAction {
type: ActionTypes.UNDO
payload: {
books: WikiModel["books"];
}
}
export const undo = (): ReduxAction => (dispatch, getState) => {
dispatch ({
type: ActionTypes.UNDO,
payload: {
books: getWikiBooks (getState ()),
},
})
}
export interface RedoAction {
type: ActionTypes.REDO
}
export const redo = (): RedoAction => ({
type: ActionTypes.REDO,
})
+684
View File
@@ -0,0 +1,684 @@
// tslint:disable-next-line:no-implicit-dependencies
import { ProgressInfo } from "builder-util-runtime";
import { ipcRenderer, remote } from "electron";
// tslint:disable-next-line:no-implicit-dependencies
import { UpdateInfo } from "electron-updater";
import * as fs from "fs";
import { extname, join } from "path";
import { tryIO } from "../../Control/Exception";
import { and } from "../../Data/Bool";
import { Either, fromLeft, isLeft, isRight, second } from "../../Data/Either";
import { eitherToMaybe, fromLeft_, fromRight_ } from "../../Data/Either/Extra";
import { cnst, flip } from "../../Data/Function";
import { fmap, fmapF } from "../../Data/Functor";
import { List, notNull } from "../../Data/List";
import { altF_, bind, bindF, ensure, fromJust, fromMaybe, isJust, Just, listToMaybe, Maybe, maybe, maybeToUndefined, Nothing } from "../../Data/Maybe";
import { any, keysSet, lookup, lookupF, mapMaybe, OrderedMap } from "../../Data/OrderedMap";
import { differenceF, map } from "../../Data/OrderedSet";
import { Record, StringKeyObject, toObject } from "../../Data/Record";
import { fst, Pair } from "../../Data/Tuple";
import { IO, readFile, runIO, writeFile } from "../../System/IO";
import { ActionTypes } from "../Constants/ActionTypes";
import { IdPrefixes } from "../Constants/IdPrefixes";
import { HeroModel } from "../Models/Hero/HeroModel";
import { User } from "../Models/Hero/heroTypeHelpers";
import { L10n, L10nRecord } from "../Models/Wiki/L10n";
import { WikiModel } from "../Models/Wiki/WikiModel";
import { heroReducer } from "../Reducers/heroReducer";
import { UISettingsState } from "../Reducers/uiSettingsReducer";
import { getAPObjectMap } from "../Selectors/adventurePointsSelectors";
import { user_data_path } from "../Selectors/envSelectors";
import { getCurrentHeroId, getHeroes, getLocaleId, getLocaleMessages, getUsers, getWiki } from "../Selectors/stateSelectors";
import { getUISettingsState } from "../Selectors/uisettingsSelectors";
import { APCache, deleteCache, forceCacheIsAvailable, insertAppStateCache, insertCacheMap, insertHeroesCache, readCache, toAPCache, writeCache } from "../Utilities/Cache";
import { translate, translateP } from "../Utilities/I18n";
import { getNewIdByDate, prefixId } from "../Utilities/IDUtils";
import { bytify, getSystemLocale, NothingIO, showOpenDialog, showSaveDialog, windowPrintToPDF } from "../Utilities/IOUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { convertHeroesForSave, convertHeroForSave } from "../Utilities/Raw/convertHeroForSave";
import { parseTables } from "../Utilities/Raw/parseTable";
import { RawConfig, RawHero, RawHerolist } from "../Utilities/Raw/RawData";
import { isBase64Image } from "../Utilities/RegexUtils";
import { readUpdate, writeUpdate } from "../Utilities/Update";
import { ReduxAction } from "./Actions";
import { addAlert } from "./AlertActions";
// const getInstalledResourcesPath = (): string => remote.app.getAppPath ()
const loadDatabase =
(locale: string): ReduxAction<Either<string, Pair<Record<L10n>, Record<WikiModel>>>> =>
dispatch => {
console.log ("Parsing tables ...")
const res = parseTables (locale)
if (isLeft (res)) {
console.error (`Table parse error: ${fromLeft_ (res)}`)
dispatch (addAlert ({
message: fromLeft_ (res),
title: "Error",
}))
}
else {
console.log ("Tables parsed")
}
return res
}
const loadConfig = () =>
pipe_ (
join (user_data_path, "config.json"),
readFile,
tryIO,
fmap (pipe (eitherToMaybe, fmap (JSON.parse as (x: string) => RawConfig)))
)
const loadHeroes = () =>
pipe_ (
join (user_data_path, "heroes.json"),
readFile,
tryIO,
fmap (pipe (eitherToMaybe, fmap (JSON.parse as (x: string) => RawHerolist)))
)
interface InitialData {
tables: Pair<Record<L10n>, Record<WikiModel>>
heroes: Maybe<RawHerolist>
defaultLocale: string
config: Maybe<RawConfig>
cache: Maybe<OrderedMap<string, APCache>>
}
export interface ReceiveInitialDataAction {
type: ActionTypes.RECEIVE_INITIAL_DATA
payload: InitialData
}
export const requestInitialData: ReduxAction<IO<void>> = dispatch =>
fmapF (dispatch (getInitialData))
(data => {
if (isRight (data)) {
dispatch (receiveInitialData (fromRight_ (data)))
dispatch ((dispatch2, getState) => {
insertAppStateCache (getState ())
insertHeroesCache (getHeroes (getState ()))
const mcache = fromRight_ (data) .cache
if (isJust (mcache)) {
const cache = fromJust (mcache)
insertCacheMap (cache)
pipe_ (
cache,
keysSet,
differenceF (keysSet (getHeroes (getState ()))),
map (id => {
forceCacheIsAvailable (id)
(getState ())
({ l10n: fst (fromRight_ (data) .tables) })
return id
})
)
}
dispatch2 (endLoadingState ())
})
}
else {
dispatch (addAlert ({
title: "Error loading database",
message: fromLeft ("") (data),
}))
}
})
export interface EndLoadingState {
type: ActionTypes.END_LOADING_STATE
}
export const endLoadingState = () => ({
type: ActionTypes.END_LOADING_STATE,
})
export const getInitialData: ReduxAction<IO<Either<string, InitialData>>> =
dispatch => {
const defaultLocale = getSystemLocale ()
return pipe_ (
readUpdate,
IO.bindF (did_update =>
did_update
? IO.then (deleteCache ()) (writeUpdate (false))
: writeUpdate (false)),
IO.thenF (IO.liftM3 ((mconfig: Maybe<RawConfig>) =>
(mheroes: Maybe<StringKeyObject<RawHero>>) =>
(mcache: Maybe<OrderedMap<string, APCache>>) =>
second ((tables: Pair<Record<L10n>, Record<WikiModel>>):
InitialData =>
({
tables,
heroes: mheroes,
defaultLocale,
config: mconfig,
cache: mcache,
}))
(dispatch (
loadDatabase (
fromMaybe (defaultLocale)
(bind (mconfig) (c => Maybe (c.locale)))
)
)))
(loadConfig ())
(loadHeroes ())
(readCache))
)
}
export const receiveInitialData = (data: InitialData): ReceiveInitialDataAction => ({
type: ActionTypes.RECEIVE_INITIAL_DATA,
payload: data,
})
const UISSA = UISettingsState.A
export const requestConfigSave =
(l10n: L10nRecord): ReduxAction<IO<boolean>> =>
(dispatch, getState) => {
const state = getState ()
const uiSettingsState = getUISettingsState (state)
const data: RawConfig = {
...toObject (uiSettingsState),
meleeItemTemplatesCombatTechniqueFilter:
maybeToUndefined (UISSA.meleeItemTemplatesCombatTechniqueFilter (uiSettingsState)),
rangedItemTemplatesCombatTechniqueFilter:
maybeToUndefined (UISSA.rangedItemTemplatesCombatTechniqueFilter (uiSettingsState)),
locale: maybeToUndefined (getLocaleId (state)),
}
return pipe_ (
join (user_data_path, "config.json"),
flip (writeFile) (JSON.stringify (data)),
tryIO,
fmap (res => {
if (isLeft (res)) {
dispatch (addAlert ({
message: `${
translate (l10n) ("saveconfigerror")
} (${
translate (l10n) ("errorcode")
}: ${
JSON.stringify (fromLeft_ (res))
})`,
title: translate (l10n) ("error"),
}))
return false
}
return true
})
)
}
export const requestAllHeroesSave =
(l10n: L10nRecord): ReduxAction<IO<boolean>> =>
(dispatch, getState) => {
const state = getState ()
const wiki = getWiki (state)
const heroes = getHeroes (state)
const users = getUsers (state)
const data = convertHeroesForSave (wiki) (l10n) (users) (heroes)
return pipe_ (
join (user_data_path, "heroes.json"),
flip (writeFile) (JSON.stringify (data)),
tryIO,
fmap (res => {
if (isLeft (res)) {
dispatch (addAlert ({
message: `${
translate (l10n) ("saveheroeserror")
} (${
translate (l10n) ("errorcode")
}: ${
JSON.stringify (fromLeft_ (res))
})`,
title: translate (l10n) ("error"),
}))
return false
}
return true
})
)
}
const requestSaveAll = (l10n: L10nRecord): ReduxAction<IO<boolean>> =>
dispatch => {
const configSavedDone = dispatch (requestConfigSave (l10n))
const heroesSavedDone = dispatch (requestAllHeroesSave (l10n))
return IO.liftM2 (and) (configSavedDone) (heroesSavedDone)
}
export const requestSaveCache =
(l10n: L10nRecord): ReduxAction<IO<Either<Error, void>>> =>
(_, getState) =>
pipe_ (
getState (),
getHeroes,
mapMaybe (pipe (
heroReducer.A.present,
HeroModel.A.id,
id => getAPObjectMap (id) (getState (), { l10n }),
Maybe.join,
fmap (toAPCache)
)),
writeCache
)
export const requestHeroSave =
(l10n: L10nRecord) =>
(mcurrent_id: Maybe<string>): ReduxAction<IO<Maybe<string>>> =>
(dispatch, getState) => {
const state = getState ()
const wiki = getWiki (state)
const heroes = getHeroes (state)
const users = getUsers (state)
const mhero =
pipe_ (
mcurrent_id,
altF_ (() => getCurrentHeroId (state)),
bindF (lookupF (heroes)),
fmap (pipe (heroReducer.A_.present, convertHeroForSave (wiki) (l10n) (users)))
)
if (isJust (mhero)) {
const hero = fromJust (mhero)
return IO.bind (loadHeroes ())
(msaved_heroes =>
pipe_ (
join (user_data_path, "heroes.json"),
flip (writeFile) (JSON.stringify (maybe ({ [hero.id]: hero })
((savedHeroes: RawHerolist) => ({
...savedHeroes,
[hero.id]: hero,
}))
(msaved_heroes))),
tryIO,
fmap (res => {
if (isLeft (res)) {
dispatch (addAlert ({
message: `${
translate (l10n) ("saveheroeserror")
} (${
translate (l10n) ("errorcode")
}: ${
JSON.stringify (fromLeft_ (res))
})`,
title: translate (l10n) ("error"),
}))
return Nothing
}
else {
dispatch (addAlert ({
title: translate (l10n) ("herosaved"),
message: "",
}))
return Just (hero .id)
}
})
))
}
return IO (cnst (Promise.resolve (Nothing)))
}
export const requestHeroDeletion =
(l10n: L10nRecord) =>
(id: string): ReduxAction<IO<boolean>> =>
dispatch => {
return IO.bind (loadHeroes ())
(msaved_heroes =>
pipe_ (
join (user_data_path, "heroes.json"),
flip (writeFile) (JSON.stringify (
maybe<RawHerolist> ({})
((savedHeroes: RawHerolist) => {
const {
[id]: _,
...other
} = savedHeroes
return other
})
(msaved_heroes))),
tryIO,
fmap (res => {
if (isLeft (res)) {
dispatch (addAlert ({
message: `${
translate (l10n) ("saveheroeserror")
} (${
translate (l10n) ("errorcode")
}: ${
JSON.stringify (fromLeft_ (res))
})`,
title: translate (l10n) ("error"),
}))
return false
}
return true
})
))
}
export const requestHeroExport =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const wiki = getWiki (state)
const heroes = getHeroes (state)
const users = getUsers (state)
const mhero =
pipe_ (
heroes,
lookup (id),
fmap (pipe (
heroReducer.A_.present,
convertHeroForSave (wiki) (l10n) (users),
hero => {
// Embed the avatar image file
if (
typeof hero.avatar === "string"
&& hero.avatar.length > 0
&& !isBase64Image (hero.avatar)
) {
const preparedUrl = hero.avatar.replace (/file:[\\\/]+/, "")
if (fs.existsSync (preparedUrl)) {
const prefix = `data:image/${extname (hero.avatar).slice (1)}base64,`
const file = fs.readFileSync (preparedUrl)
const fileString = file.toString ("base64")
return {
...hero,
avatar: prefix + fileString,
}
}
}
return hero
}
))
)
if (isJust (mhero)) {
const hero = fromJust (mhero)
pipe_ (
showSaveDialog ({
title: translate (l10n) ("exportheroasjson"),
filters: [
{ name: "JSON", extensions: ["json"] },
],
defaultPath: hero.name.replace (/\//, "\/"),
}),
IO.bindF (flip (writeFile) (JSON.stringify (hero))),
tryIO,
fmap (res => {
if (isRight (res)) {
dispatch (addAlert ({
message: translate (l10n) ("herosaved"),
}))
}
else {
dispatch (addAlert ({
message: `${
translate (l10n) ("exportheroerror")
} (${
translate (l10n) ("errorcode")
}: ${
JSON.stringify (fromLeft_ (res))
})`,
title: translate (l10n) ("error"),
}))
}
}),
runIO
)
}
}
export interface ReceiveImportedHeroAction {
type: ActionTypes.RECEIVE_IMPORTED_HERO
payload: {
data: RawHero;
player?: User;
}
}
export const loadImportedHero =
(l10n: L10nRecord): ReduxAction<IO<Maybe<RawHero>>> =>
dispatch => {
return pipe_ (
showOpenDialog ({ filters: [{ name: "JSON", extensions: ["json"] }] }),
IO.bindF (pipe (
listToMaybe,
bindF (ensure (x => extname (x) === ".json")),
maybe<IO<Maybe<Either<Error, string>>>> (NothingIO)
(pipe (readFile, tryIO, fmap (Just)))
)),
fmap (bindF (res => {
if (isRight (res)) {
return Just ((JSON.parse as (x: string) => RawHero) (fromRight_ (res)))
}
dispatch (addAlert ({
message: `${
translate (l10n) ("importheroerror")
} (${
translate (l10n) ("errorcode")
}: ${
JSON.stringify (fromLeft_ (res))
})`,
title: translate (l10n) ("error"),
}))
return Nothing
}))
)
}
export const requestHeroImport =
(l10n: L10nRecord): ReduxAction =>
dispatch => runIO (fmapF (dispatch (loadImportedHero (l10n)))
(fmap (x => dispatch (receiveHeroImport (x)))))
export const receiveHeroImport = (raw: RawHero): ReceiveImportedHeroAction => {
const newId = prefixId (IdPrefixes.HERO) (getNewIdByDate ())
const { player, avatar, ...other } = raw
const data: RawHero = {
...other,
id: newId,
avatar: avatar !== undefined
&& avatar.length > 0
&& (isBase64Image (avatar) || fs.existsSync (avatar.replace (/file:[\\\/]+/, "")))
? avatar
: undefined,
}
return {
type: ActionTypes.RECEIVE_IMPORTED_HERO,
payload: {
data,
player,
},
}
}
const isAnyHeroUnsaved = pipe (getHeroes, any (pipe (heroReducer.A.past, notNull)))
const close =
(l10n: L10nRecord) =>
(unsaved: boolean) =>
(f: Maybe<() => void>): ReduxAction =>
dispatch => pipe_ (
dispatch (requestSaveCache (l10n)),
IO.thenF (dispatch (requestSaveAll (l10n))),
fmap (all_saved => {
if (all_saved) {
dispatch (addAlert ({
message: translate (l10n) (unsaved ? "everythingelsesaved" : "allsaved"),
onClose () {
if (isJust (f)) {
fromJust (f) ()
}
remote .getCurrentWindow () .close ()
},
}))
}
}),
runIO
)
export const requestClose =
(optionalCall: Maybe<() => void>): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const safeToExit = !isAnyHeroUnsaved (state)
const ml10n = getLocaleMessages (state)
if (isJust (ml10n)) {
const l10n = fromJust (ml10n)
if (safeToExit) {
dispatch (close (l10n) (false) (optionalCall))
}
else {
dispatch (addAlert ({
title: translate (l10n) ("unsavedactions"),
message: translate (l10n) ("unsavedactions.text"),
confirm: {
resolve: close (l10n) (false) (optionalCall),
reject: close (l10n) (true) (optionalCall),
},
confirmYesNo: true,
}))
}
}
}
export const requestPrintHeroToPDF =
(l10n: L10nRecord): ReduxAction =>
dispatch =>
pipe_ (
windowPrintToPDF ({
marginsType: 1,
pageSize: "A4",
printBackground: true,
}),
fmap (flip (writeFile)),
IO.bindF (IO.bind (showSaveDialog ({
title: translate (l10n) ("printcharactersheettopdf"),
filters: [
{ name: "PDF", extensions: ["pdf"] },
],
}))),
tryIO,
fmap (res => {
if (isRight (res)) {
dispatch (addAlert ({
message: translate (l10n) ("pdfsaved"),
}))
}
else {
dispatch (addAlert ({
message:
`${translate (l10n) ("printcharactersheettopdf")}`
+ ` (${translate (l10n) ("errorcode")}: `
+ `${JSON.stringify (fromLeft_ (res))})`,
title: translate (l10n) ("error"),
}))
}
}),
runIO
)
export interface SetUpdateDownloadProgressAction {
type: ActionTypes.SET_UPDATE_DOWNLOAD_PROGRESS
payload?: ProgressInfo
}
export const setUpdateDownloadProgress =
(info?: ProgressInfo): SetUpdateDownloadProgressAction => ({
type: ActionTypes.SET_UPDATE_DOWNLOAD_PROGRESS,
payload: info,
})
export const updateAvailable =
(l10n: L10nRecord) =>
(info: UpdateInfo): ReduxAction =>
async dispatch => {
const startDownloadingUpdate: ReduxAction = futureDispatch => {
futureDispatch (setUpdateDownloadProgress ({
total: 0,
delta: 0,
transferred: 0,
percent: 0,
bytesPerSecond: 0,
}))
ipcRenderer.send ("download-update")
}
const size = info.files.reduce ((sum, { size: fileSize = 0 }) => sum + fileSize, 0)
// @ts-ignore
dispatch (addAlert ({
message: size > 0
? translateP (l10n)
("newversionavailable.textwithsize")
(List (info.version, bytify (L10n.A.id (l10n)) (size)))
: translateP (l10n) ("newversionavailable.text") (List (info.version)),
title: translate (l10n) ("newversionavailable"),
buttons: [
{
label: translate (l10n) ("update"),
dispatchOnClick: startDownloadingUpdate,
},
{
label: translate (l10n) ("cancel"),
},
],
}))
}
export const updateNotAvailable = (l10n: L10nRecord): ReduxAction => async dispatch => {
dispatch (addAlert ({
message: translate (l10n) ("nonewversionavailable.text"),
title: translate (l10n) ("nonewversionavailable"),
}))
}
@@ -1,163 +1,163 @@
import { ActionTypes } from '../constants/ActionTypes';
import { ActionTypes } from "../Constants/ActionTypes";
const AppDispatcher = { dispatch (obj: any) { return obj; }};
const AppDispatcher = { dispatch (obj: any) { return obj } }
export function load () {
AppDispatcher.dispatch ({
type: ActionTypes.LOAD_RAW_INGAME_DATA
});
type: ActionTypes.LOAD_RAW_INGAME_DATA,
})
}
export function previousPhase () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_PREVIOUS_PHASE
});
type: ActionTypes.INGAME_PREVIOUS_PHASE,
})
}
export function nextPhase () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_NEXT_PHASE
});
type: ActionTypes.INGAME_NEXT_PHASE,
})
}
export function cast () {
AppDispatcher.dispatch ({
type: ActionTypes.UPDATE_INGAME_CAST
});
type: ActionTypes.UPDATE_INGAME_CAST,
})
}
export function stopCast () {
AppDispatcher.dispatch ({
type: ActionTypes.CANCEL_INGAME_CAST
});
type: ActionTypes.CANCEL_INGAME_CAST,
})
}
export function useEndurance (id: string) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_USE_ENDURANCE,
id
});
id,
})
}
export function useAction (id: string) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_USE_ACTION,
id
});
id,
})
}
export function useFreeAction (id: string) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_USE_FREE_ACTION,
id
});
id,
})
}
export function activateFighter () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_ACTIVATE_FIGHTER
});
type: ActionTypes.INGAME_ACTIVATE_FIGHTER,
})
}
export function deactivateFighter () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_DEACTIVATE_FIGHTER
});
type: ActionTypes.INGAME_DEACTIVATE_FIGHTER,
})
}
export function edit (id: string) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_EDIT_START,
id
});
id,
})
}
export function editValue (tag: string, value: string) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_EDIT_UPDATE_VALUE,
tag,
value
});
value,
})
}
export function editCast (value: string) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_EDIT_UPDATE_CAST_VALUE,
value
});
value,
})
}
export function editDuplicate (value: string) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_EDIT_UPDATE_DUPLICATE_VALUE,
value
});
value,
})
}
export function closeEdit () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_EDIT_END
});
type: ActionTypes.INGAME_EDIT_END,
})
}
export function addFighter () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_ADD_FIGHTER
});
type: ActionTypes.INGAME_ADD_FIGHTER,
})
}
export function duplicateFighter () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_DUPLICATE_FIGHTER
});
type: ActionTypes.INGAME_DUPLICATE_FIGHTER,
})
}
export function removeFighter () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_REMOVE_FIGHTER
});
type: ActionTypes.INGAME_REMOVE_FIGHTER,
})
}
export function resetAll () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_RESET_ALL
});
type: ActionTypes.INGAME_RESET_ALL,
})
}
export function resetPhases () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_RESET_PHASES
});
type: ActionTypes.INGAME_RESET_PHASES,
})
}
export function resetHealth () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_RESET_HEALTH
});
type: ActionTypes.INGAME_RESET_HEALTH,
})
}
export function setOnline (value: string) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_UPDATE_ONLINE_LINK,
value
});
value,
})
}
export function save () {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_SAVE
});
type: ActionTypes.INGAME_SAVE,
})
}
export function _save () {
return {
type: ActionTypes.INGAME_SAVE
};
type: ActionTypes.INGAME_SAVE,
}
}
export function switchOption (option: boolean) {
AppDispatcher.dispatch ({
type: ActionTypes.INGAME_SWITCH_OPTION,
option
});
option,
})
}
+230
View File
@@ -0,0 +1,230 @@
import { fmapF } from "../../Data/Functor";
import { List } from "../../Data/List";
import { bind, bindF, fromJust, isNothing, join, liftM2 } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { ActionTypes } from "../Constants/ActionTypes";
import { HeroModel } from "../Models/Hero/HeroModel";
import { L10nRecord } from "../Models/Wiki/L10n";
import { LiturgicalChant } from "../Models/Wiki/LiturgicalChant";
import { getAvailableAPMap } from "../Selectors/adventurePointsSelectors";
import { getIsInCharacterCreation } from "../Selectors/phaseSelectors";
import { getCurrentHeroPresent, getLiturgicalChants, getWikiLiturgicalChants } from "../Selectors/stateSelectors";
import { getMissingAP } from "../Utilities/AdventurePoints/adventurePointsUtils";
import { getICMultiplier } from "../Utilities/AdventurePoints/improvementCostUtils";
import { translate, translateP } from "../Utilities/I18n";
import { getAreSufficientAPAvailableForIncrease } from "../Utilities/Increasable/increasableUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { ReduxAction } from "./Actions";
import { addAlert } from "./AlertActions";
export interface ActivateLiturgicalChantAction {
type: ActionTypes.ACTIVATE_LITURGY
payload: {
id: string;
}
}
export const addLiturgicalChant =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const wiki_liturgical_chants = getWikiLiturgicalChants (state)
const mhero = getCurrentHeroPresent (state)
const missingAPForInc =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (getMissingAP (getIsInCharacterCreation (state)))
(fmapF (lookup (id) (wiki_liturgical_chants))
(pipe (LiturgicalChant.A.ic, getICMultiplier))),
join
)
if (isNothing (missingAPForInc)) {
dispatch<ActivateLiturgicalChantAction> ({
type: ActionTypes.ACTIVATE_LITURGY,
payload: {
id,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAPForInc))),
}))
}
}
export interface ActivateBlessingAction {
type: ActionTypes.ACTIVATE_BLESSING
payload: {
id: string;
}
}
export const addBlessing =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
const missingAP =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
bindF (getMissingAP (getIsInCharacterCreation (state))
(1))
)
if (isNothing (missingAP)) {
dispatch<ActivateBlessingAction> ({
type: ActionTypes.ACTIVATE_BLESSING,
payload: {
id,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAP))),
}))
}
}
export interface DeactivateLiturgyAction {
type: ActionTypes.DEACTIVATE_LITURGY
payload: {
id: string;
}
}
export const removeLiturgicalChant = (id: string): DeactivateLiturgyAction => ({
type: ActionTypes.DEACTIVATE_LITURGY,
payload: {
id,
},
})
export interface DeactivateBlessingAction {
type: ActionTypes.DEACTIVATE_BLESSING
payload: {
id: string;
}
}
export const removeBlessing = (id: string): DeactivateBlessingAction => ({
type: ActionTypes.DEACTIVATE_BLESSING,
payload: {
id,
},
})
export interface AddLiturgicalChantPointAction {
type: ActionTypes.ADD_LITURGY_POINT
payload: {
id: string;
}
}
export const addLiturgicalChantPoint =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero_liturgical_chants = getLiturgicalChants (state)
const wiki_liturgical_chants = getWikiLiturgicalChants (state)
const mhero = getCurrentHeroPresent (state)
const missingAPForInc =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (getAreSufficientAPAvailableForIncrease (getIsInCharacterCreation (state))
(bind (mhero_liturgical_chants)
(lookup (id))))
(lookup (id) (wiki_liturgical_chants)),
join
)
if (isNothing (missingAPForInc)) {
dispatch<AddLiturgicalChantPointAction> ({
type: ActionTypes.ADD_LITURGY_POINT,
payload: {
id,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAPForInc))),
}))
}
}
export interface RemoveLiturgicalChantPointAction {
type: ActionTypes.REMOVE_LITURGY_POINT
payload: {
id: string;
}
}
export const removeLiturgicalChantPoint = (id: string): RemoveLiturgicalChantPointAction => ({
type: ActionTypes.REMOVE_LITURGY_POINT,
payload: {
id,
},
})
export interface SetLiturgicalChantsSortOrderAction {
type: ActionTypes.SET_LITURGIES_SORT_ORDER
payload: {
sortOrder: string;
}
}
export const setLiturgicalChantsSortOrder =
(sortOrder: string): SetLiturgicalChantsSortOrderAction => ({
type: ActionTypes.SET_LITURGIES_SORT_ORDER,
payload: {
sortOrder,
},
})
export interface SetActiveLiturgicalChantsFilterTextAction {
type: ActionTypes.SET_LITURGICAL_CHANTS_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setActiveLiturgicalChantsFilterText =
(filterText: string): SetActiveLiturgicalChantsFilterTextAction => ({
type: ActionTypes.SET_LITURGICAL_CHANTS_FILTER_TEXT,
payload: {
filterText,
},
})
export interface SetInactiveLiturgicalChantsFilterTextAction {
type: ActionTypes.SET_INACTIVE_LITURGICAL_CHANTS_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setInactiveLiturgicalChantsFilterText =
(filterText: string): SetInactiveLiturgicalChantsFilterTextAction => ({
type: ActionTypes.SET_INACTIVE_LITURGICAL_CHANTS_FILTER_TEXT,
payload: {
filterText,
},
})
+20
View File
@@ -0,0 +1,20 @@
import { fromMaybe, isNothing, Maybe } from "../../Data/Maybe";
import { ActionTypes } from "../Constants/ActionTypes";
import { getSystemLocale } from "../Utilities/IOUtils";
export interface SetLocaleAction {
type: ActionTypes.SET_LOCALE
payload: {
locale: string;
localeType: "default" | "set";
}
}
export const setLocale =
(locale: Maybe<string>): SetLocaleAction => ({
type: ActionTypes.SET_LOCALE,
payload: {
locale: fromMaybe (getSystemLocale ()) (locale),
localeType: isNothing (locale) ? "default" : "set",
},
})
+25
View File
@@ -0,0 +1,25 @@
import { ActionTypes } from "../Constants/ActionTypes";
import { isDialogOpen } from "../Selectors/subwindowsSelectors";
import { TabId } from "../Utilities/LocationUtils";
import { ReduxAction } from "./Actions";
export interface SetTabAction {
type: ActionTypes.SET_TAB
payload: {
tab: TabId;
}
}
export const setTab = (tab: TabId): SetTabAction => ({
type: ActionTypes.SET_TAB,
payload: {
tab,
},
})
export const showAbout: ReduxAction = (dispatch, getState) => {
const alert = isDialogOpen (getState ())
if (!alert) {
dispatch (setTab (TabId.Imprint))
}
}
@@ -1,11 +1,11 @@
import { ActionTypes } from '../constants/ActionTypes';
import { Maybe } from '../utils/dataUtils';
import { Maybe } from "../../Data/Maybe";
import { ActionTypes } from "../Constants/ActionTypes";
export interface SetPactCategoryAction {
type: ActionTypes.SET_PACT_CATEGORY;
type: ActionTypes.SET_PACT_CATEGORY
payload: {
category: Maybe<number>;
};
}
}
export const setPactCategory = (category: Maybe<number>): SetPactCategoryAction => ({
@@ -13,13 +13,13 @@ export const setPactCategory = (category: Maybe<number>): SetPactCategoryAction
payload: {
category,
},
});
})
export interface SetPactLevelAction {
type: ActionTypes.SET_PACT_LEVEL;
type: ActionTypes.SET_PACT_LEVEL
payload: {
level: number;
};
}
}
export const setPactLevel = (level: number): SetPactLevelAction => ({
@@ -27,13 +27,13 @@ export const setPactLevel = (level: number): SetPactLevelAction => ({
payload: {
level,
},
});
})
export interface SetTargetTypeAction {
type: ActionTypes.SET_TARGET_TYPE;
type: ActionTypes.SET_TARGET_TYPE
payload: {
type: number;
};
}
}
export const setPactTargetType = (type: number): SetTargetTypeAction => ({
@@ -41,13 +41,13 @@ export const setPactTargetType = (type: number): SetTargetTypeAction => ({
payload: {
type,
},
});
})
export interface SetTargetDomainAction {
type: ActionTypes.SET_TARGET_DOMAIN;
type: ActionTypes.SET_TARGET_DOMAIN
payload: {
domain: number | string;
};
}
}
export const setPactTargetDomain = (domain: number | string): SetTargetDomainAction => ({
@@ -55,13 +55,13 @@ export const setPactTargetDomain = (domain: number | string): SetTargetDomainAct
payload: {
domain,
},
});
})
export interface SetTargetNameAction {
type: ActionTypes.SET_TARGET_NAME;
type: ActionTypes.SET_TARGET_NAME
payload: {
name: string;
};
}
}
export const setPactTargetName = (name: string): SetTargetNameAction => ({
@@ -69,4 +69,4 @@ export const setPactTargetName = (name: string): SetTargetNameAction => ({
payload: {
name,
},
});
})
@@ -1,81 +1,85 @@
import { PetInstance } from '../App/Models/Hero/heroTypeHelpers';
import { getNewId } from '../App/Utils/IDUtils';
import { ActionTypes } from '../constants/ActionTypes';
import { getPets } from '../selectors/stateSelectors';
import { AsyncAction } from '../types/actions';
import { Record } from '../utils/dataUtils';
import { fromJust, isJust, Just } from "../../Data/Maybe";
import { keys, OrderedMap } from "../../Data/OrderedMap";
import { Record } from "../../Data/Record";
import { ActionTypes } from "../Constants/ActionTypes";
import { IdPrefixes } from "../Constants/IdPrefixes";
import { Pet } from "../Models/Hero/Pet";
import { getPets } from "../Selectors/stateSelectors";
import { getNewId, prefixId } from "../Utilities/IDUtils";
import { pipe } from "../Utilities/pipe";
import { ReduxAction } from "./Actions";
const getNewIdFromCurrentPets: (x: Just<OrderedMap<string, Record<Pet>>>) => string =
pipe (fromJust, keys, getNewId, prefixId (IdPrefixes.PET))
export interface AddPetAction {
type: ActionTypes.ADD_PET;
type: ActionTypes.ADD_PET
payload: {
newId: string;
};
}
}
export const addPet: AsyncAction = (dispatch, getState) => {
getPets (getState ()) .fmap (
pets => {
const newId = `PET_${getNewId (pets.keys ())}`;
export const addPet: ReduxAction =
(dispatch, getState) => {
const mpets = getPets (getState ())
if (isJust (mpets)) {
const newId = getNewIdFromCurrentPets (mpets)
return dispatch<AddPetAction> ({
type: ActionTypes.ADD_PET,
payload: {
newId,
},
});
})
}
)
};
return undefined
}
export interface CreatePetAction {
type: ActionTypes.CREATE_PET;
type: ActionTypes.CREATE_PET
}
export const createPet = (): CreatePetAction => ({
type: ActionTypes.CREATE_PET,
});
})
export interface ClosePetEditorAction {
type: ActionTypes.CLOSE_PET_EDITOR;
type: ActionTypes.CLOSE_PET_EDITOR
}
export const closePetEditor = (): ClosePetEditorAction => ({
type: ActionTypes.CLOSE_PET_EDITOR,
});
})
export interface SavePetAction {
type: ActionTypes.SAVE_PET;
type: ActionTypes.SAVE_PET
}
export const savePet = (): SavePetAction => ({
type: ActionTypes.SAVE_PET,
});
})
export interface EditPetAction {
type: ActionTypes.EDIT_PET;
payload: {
pet: Record<PetInstance>;
};
}
export const editPet = (id: string): AsyncAction => (dispatch, getState) => {
getPets (getState ()) .bind (
pets => pets .lookup (id) .fmap (
pet => dispatch<EditPetAction> ({
type: ActionTypes.EDIT_PET,
payload: {
pet,
},
})
)
);
};
export interface RemovePetAction {
type: ActionTypes.REMOVE_PET;
type: ActionTypes.EDIT_PET
payload: {
id: string;
};
}
}
export const editPet = (id: string): EditPetAction => ({
type: ActionTypes.EDIT_PET,
payload: {
id,
},
})
export interface RemovePetAction {
type: ActionTypes.REMOVE_PET
payload: {
id: string;
}
}
export const removePet = (id: string): RemovePetAction => ({
@@ -83,13 +87,13 @@ export const removePet = (id: string): RemovePetAction => ({
payload: {
id,
},
});
})
export interface SetPetsSortOrderAction {
type: ActionTypes.SET_PETS_SORT_ORDER;
type: ActionTypes.SET_PETS_SORT_ORDER
payload: {
sortOrder: string;
};
}
}
export const setPetsSortOrder = (sortOrder: string): SetPetsSortOrderAction => ({
@@ -97,13 +101,13 @@ export const setPetsSortOrder = (sortOrder: string): SetPetsSortOrderAction => (
payload: {
sortOrder,
},
});
})
export interface SetPetAvatarAction {
type: ActionTypes.SET_PET_AVATAR;
type: ActionTypes.SET_PET_AVATAR
payload: {
path: string;
};
}
}
export const setPetAvatar = (path: string): SetPetAvatarAction => ({
@@ -111,13 +115,13 @@ export const setPetAvatar = (path: string): SetPetAvatarAction => ({
payload: {
path,
},
});
})
export interface SetPetNameAction {
type: ActionTypes.SET_PET_NAME;
type: ActionTypes.SET_PET_NAME
payload: {
name: string;
};
}
}
export const setPetName = (name: string): SetPetNameAction => ({
@@ -125,13 +129,13 @@ export const setPetName = (name: string): SetPetNameAction => ({
payload: {
name,
},
});
})
export interface SetPetSizeAction {
type: ActionTypes.SET_PET_SIZE;
type: ActionTypes.SET_PET_SIZE
payload: {
size: string;
};
}
}
export const setPetSize = (size: string): SetPetSizeAction => ({
@@ -139,13 +143,13 @@ export const setPetSize = (size: string): SetPetSizeAction => ({
payload: {
size,
},
});
})
export interface SetPetTypeAction {
type: ActionTypes.SET_PET_TYPE;
type: ActionTypes.SET_PET_TYPE
payload: {
type: string;
};
}
}
export const setPetType = (type: string): SetPetTypeAction => ({
@@ -153,13 +157,13 @@ export const setPetType = (type: string): SetPetTypeAction => ({
payload: {
type,
},
});
})
export interface SetPetSpentApAction {
type: ActionTypes.SET_PET_SPENT_AP;
type: ActionTypes.SET_PET_SPENT_AP
payload: {
spentAp: string;
};
}
}
export const setPetSpentAp = (spentAp: string): SetPetSpentApAction => ({
@@ -167,13 +171,13 @@ export const setPetSpentAp = (spentAp: string): SetPetSpentApAction => ({
payload: {
spentAp,
},
});
})
export interface SetPetTotalApAction {
type: ActionTypes.SET_PET_TOTAL_AP;
type: ActionTypes.SET_PET_TOTAL_AP
payload: {
totalAp: string;
};
}
}
export const setPetTotalAp = (totalAp: string): SetPetTotalApAction => ({
@@ -181,13 +185,13 @@ export const setPetTotalAp = (totalAp: string): SetPetTotalApAction => ({
payload: {
totalAp,
},
});
})
export interface SetPetCourageAction {
type: ActionTypes.SET_PET_COURAGE;
type: ActionTypes.SET_PET_COURAGE
payload: {
courage: string;
};
}
}
export const setPetCourage = (courage: string): SetPetCourageAction => ({
@@ -195,13 +199,13 @@ export const setPetCourage = (courage: string): SetPetCourageAction => ({
payload: {
courage,
},
});
})
export interface SetPetSagacityAction {
type: ActionTypes.SET_PET_SAGACITY;
type: ActionTypes.SET_PET_SAGACITY
payload: {
sagacity: string;
};
}
}
export const setPetSagacity = (sagacity: string): SetPetSagacityAction => ({
@@ -209,13 +213,13 @@ export const setPetSagacity = (sagacity: string): SetPetSagacityAction => ({
payload: {
sagacity,
},
});
})
export interface SetPetIntuitionAction {
type: ActionTypes.SET_PET_INTUITION;
type: ActionTypes.SET_PET_INTUITION
payload: {
intuition: string;
};
}
}
export const setPetIntuition = (intuition: string): SetPetIntuitionAction => ({
@@ -223,13 +227,13 @@ export const setPetIntuition = (intuition: string): SetPetIntuitionAction => ({
payload: {
intuition,
},
});
})
export interface SetPetCharismaAction {
type: ActionTypes.SET_PET_CHARISMA;
type: ActionTypes.SET_PET_CHARISMA
payload: {
charisma: string;
};
}
}
export const setPetCharisma = (charisma: string): SetPetCharismaAction => ({
@@ -237,13 +241,13 @@ export const setPetCharisma = (charisma: string): SetPetCharismaAction => ({
payload: {
charisma,
},
});
})
export interface SetPetDexterityAction {
type: ActionTypes.SET_PET_DEXTERITY;
type: ActionTypes.SET_PET_DEXTERITY
payload: {
dexterity: string;
};
}
}
export const setPetDexterity = (dexterity: string): SetPetDexterityAction => ({
@@ -251,13 +255,13 @@ export const setPetDexterity = (dexterity: string): SetPetDexterityAction => ({
payload: {
dexterity,
},
});
})
export interface SetPetAgilityAction {
type: ActionTypes.SET_PET_AGILITY;
type: ActionTypes.SET_PET_AGILITY
payload: {
agility: string;
};
}
}
export const setPetAgility = (agility: string): SetPetAgilityAction => ({
@@ -265,13 +269,13 @@ export const setPetAgility = (agility: string): SetPetAgilityAction => ({
payload: {
agility,
},
});
})
export interface SetPetConstitutionAction {
type: ActionTypes.SET_PET_CONSTITUTION;
type: ActionTypes.SET_PET_CONSTITUTION
payload: {
constitution: string;
};
}
}
export const setPetConstitution = (constitution: string): SetPetConstitutionAction => ({
@@ -279,13 +283,13 @@ export const setPetConstitution = (constitution: string): SetPetConstitutionActi
payload: {
constitution,
},
});
})
export interface SetPetStrengthAction {
type: ActionTypes.SET_PET_STRENGTH;
type: ActionTypes.SET_PET_STRENGTH
payload: {
strength: string;
};
}
}
export const setPetStrength = (strength: string): SetPetStrengthAction => ({
@@ -293,13 +297,13 @@ export const setPetStrength = (strength: string): SetPetStrengthAction => ({
payload: {
strength,
},
});
})
export interface SetPetLpAction {
type: ActionTypes.SET_PET_LP;
type: ActionTypes.SET_PET_LP
payload: {
lp: string;
};
}
}
export const setPetLp = (lp: string): SetPetLpAction => ({
@@ -307,13 +311,13 @@ export const setPetLp = (lp: string): SetPetLpAction => ({
payload: {
lp,
},
});
})
export interface SetPetAeAction {
type: ActionTypes.SET_PET_AE;
type: ActionTypes.SET_PET_AE
payload: {
ae: string;
};
}
}
export const setPetAe = (ae: string): SetPetAeAction => ({
@@ -321,13 +325,13 @@ export const setPetAe = (ae: string): SetPetAeAction => ({
payload: {
ae,
},
});
})
export interface SetPetSpiAction {
type: ActionTypes.SET_PET_SPI;
type: ActionTypes.SET_PET_SPI
payload: {
spi: string;
};
}
}
export const setPetSpi = (spi: string): SetPetSpiAction => ({
@@ -335,13 +339,13 @@ export const setPetSpi = (spi: string): SetPetSpiAction => ({
payload: {
spi,
},
});
})
export interface SetPetTouAction {
type: ActionTypes.SET_PET_TOU;
type: ActionTypes.SET_PET_TOU
payload: {
tou: string;
};
}
}
export const setPetTou = (tou: string): SetPetTouAction => ({
@@ -349,13 +353,13 @@ export const setPetTou = (tou: string): SetPetTouAction => ({
payload: {
tou,
},
});
})
export interface SetPetProAction {
type: ActionTypes.SET_PET_PRO;
type: ActionTypes.SET_PET_PRO
payload: {
pro: string;
};
}
}
export const setPetPro = (pro: string): SetPetProAction => ({
@@ -363,13 +367,13 @@ export const setPetPro = (pro: string): SetPetProAction => ({
payload: {
pro,
},
});
})
export interface SetPetIniAction {
type: ActionTypes.SET_PET_INI;
type: ActionTypes.SET_PET_INI
payload: {
ini: string;
};
}
}
export const setPetIni = (ini: string): SetPetIniAction => ({
@@ -377,13 +381,13 @@ export const setPetIni = (ini: string): SetPetIniAction => ({
payload: {
ini,
},
});
})
export interface SetPetMovAction {
type: ActionTypes.SET_PET_MOV;
type: ActionTypes.SET_PET_MOV
payload: {
mov: string;
};
}
}
export const setPetMov = (mov: string): SetPetMovAction => ({
@@ -391,13 +395,13 @@ export const setPetMov = (mov: string): SetPetMovAction => ({
payload: {
mov,
},
});
})
export interface SetPetAttackAction {
type: ActionTypes.SET_PET_ATTACK;
type: ActionTypes.SET_PET_ATTACK
payload: {
attack: string;
};
}
}
export const setPetAttack = (attack: string): SetPetAttackAction => ({
@@ -405,13 +409,13 @@ export const setPetAttack = (attack: string): SetPetAttackAction => ({
payload: {
attack,
},
});
})
export interface SetPetAtAction {
type: ActionTypes.SET_PET_AT;
type: ActionTypes.SET_PET_AT
payload: {
at: string;
};
}
}
export const setPetAt = (at: string): SetPetAtAction => ({
@@ -419,13 +423,13 @@ export const setPetAt = (at: string): SetPetAtAction => ({
payload: {
at,
},
});
})
export interface SetPetPaAction {
type: ActionTypes.SET_PET_PA;
type: ActionTypes.SET_PET_PA
payload: {
pa: string;
};
}
}
export const setPetPa = (pa: string): SetPetPaAction => ({
@@ -433,13 +437,13 @@ export const setPetPa = (pa: string): SetPetPaAction => ({
payload: {
pa,
},
});
})
export interface SetPetDpAction {
type: ActionTypes.SET_PET_DP;
type: ActionTypes.SET_PET_DP
payload: {
dp: string;
};
}
}
export const setPetDp = (dp: string): SetPetDpAction => ({
@@ -447,13 +451,13 @@ export const setPetDp = (dp: string): SetPetDpAction => ({
payload: {
dp,
},
});
})
export interface SetPetReachAction {
type: ActionTypes.SET_PET_REACH;
type: ActionTypes.SET_PET_REACH
payload: {
reach: string;
};
}
}
export const setPetReach = (reach: string): SetPetReachAction => ({
@@ -461,13 +465,13 @@ export const setPetReach = (reach: string): SetPetReachAction => ({
payload: {
reach,
},
});
})
export interface SetPetActionsAction {
type: ActionTypes.SET_PET_ACTIONS;
type: ActionTypes.SET_PET_ACTIONS
payload: {
actions: string;
};
}
}
export const setPetActions = (actions: string): SetPetActionsAction => ({
@@ -475,13 +479,13 @@ export const setPetActions = (actions: string): SetPetActionsAction => ({
payload: {
actions,
},
});
})
export interface SetPetSkillsAction {
type: ActionTypes.SET_PET_SKILLS;
type: ActionTypes.SET_PET_SKILLS
payload: {
skills: string;
};
}
}
export const setPetSkills = (skills: string): SetPetSkillsAction => ({
@@ -489,13 +493,13 @@ export const setPetSkills = (skills: string): SetPetSkillsAction => ({
payload: {
skills,
},
});
})
export interface SetPetAbilitiesAction {
type: ActionTypes.SET_PET_ABILITIES;
type: ActionTypes.SET_PET_ABILITIES
payload: {
abilities: string;
};
}
}
export const setPetAbilities = (abilities: string): SetPetAbilitiesAction => ({
@@ -503,13 +507,13 @@ export const setPetAbilities = (abilities: string): SetPetAbilitiesAction => ({
payload: {
abilities,
},
});
})
export interface SetPetNotesAction {
type: ActionTypes.SET_PET_NOTES;
type: ActionTypes.SET_PET_NOTES
payload: {
notes: string;
};
}
}
export const setPetNotes = (notes: string): SetPetNotesAction => ({
@@ -517,4 +521,4 @@ export const setPetNotes = (notes: string): SetPetNotesAction => ({
payload: {
notes,
},
});
})
+148
View File
@@ -0,0 +1,148 @@
import { fromJust, isJust, liftM3, listToMaybe, Maybe, Nothing } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { Record } from "../../Data/Record";
import { ActionTypes } from "../Constants/ActionTypes";
import { Selections } from "../Models/Hero/heroTypeHelpers";
import { Culture } from "../Models/Wiki/Culture";
import { Profession } from "../Models/Wiki/Profession";
import { ProfessionVariant } from "../Models/Wiki/ProfessionVariant";
import { Race } from "../Models/Wiki/Race";
import { WikiModel, WikiModelRecord } from "../Models/Wiki/WikiModel";
import { AppState } from "../Reducers/appReducer";
import { getCurrentCulture, getCurrentProfession, getCurrentProfessionVariant, getCurrentRace } from "../Selectors/rcpSelectors";
import { getWiki } from "../Selectors/stateSelectors";
import { pipe_ } from "../Utilities/pipe";
import { ReduxAction } from "./Actions";
export interface SelectProfessionAction {
type: ActionTypes.SELECT_PROFESSION
payload: {
id: string;
var_id: Maybe<string>;
}
}
export const selectProfession =
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ();
const mselected_prof = pipe_ (state, AppState.A.wiki, WikiModel.A.professions, lookup (id))
if (isJust (mselected_prof)) {
const selected_prof = fromJust (mselected_prof)
dispatch<SelectProfessionAction> ({
type: ActionTypes.SELECT_PROFESSION,
payload: {
id,
var_id:
Profession.A.isVariantRequired (selected_prof)
? listToMaybe (Profession.A.variants (selected_prof))
: Nothing,
},
})
}
}
interface SelectionsAndWikiEntries extends Selections {
race: Record<Race>
culture: Record<Culture>
profession: Record<Profession>
professionVariant: Maybe<Record<ProfessionVariant>>
wiki: WikiModelRecord
}
export interface SetSelectionsAction {
type: ActionTypes.ASSIGN_RCP_OPTIONS
payload: SelectionsAndWikiEntries
}
export const setSelections =
(selections: Selections): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
liftM3 ((r: Record<Race>) => (c: Record<Culture>) => (p: Record<Profession>) =>
dispatch<SetSelectionsAction> ({
type: ActionTypes.ASSIGN_RCP_OPTIONS,
payload: {
...selections,
race: r,
culture: c,
profession: p,
professionVariant: getCurrentProfessionVariant (state),
wiki: getWiki (state),
},
}))
(getCurrentRace (state))
(getCurrentCulture (state))
(getCurrentProfession (state))
}
export interface SetProfessionsSortOrderAction {
type: ActionTypes.SET_PROFESSIONS_SORT_ORDER
payload: {
sortOrder: string;
}
}
export const setProfessionsSortOrder = (sortOrder: string): SetProfessionsSortOrderAction => ({
type: ActionTypes.SET_PROFESSIONS_SORT_ORDER,
payload: {
sortOrder,
},
})
export interface SetProfessionsVisibilityFilterAction {
type: ActionTypes.SET_PROFESSIONS_VISIBILITY_FILTER
payload: {
filter: string;
}
}
export const setProfessionsVisibilityFilter =
(filter: string): SetProfessionsVisibilityFilterAction => ({
type: ActionTypes.SET_PROFESSIONS_VISIBILITY_FILTER,
payload: {
filter,
},
})
export interface SetProfessionsGroupVisibilityFilterAction {
type: ActionTypes.SET_PROFESSIONS_GROUP_VISIBILITY_FILTER
payload: {
filter: number;
}
}
export const setProfessionsGroupVisibilityFilter =
(filter: number): SetProfessionsGroupVisibilityFilterAction => ({
type: ActionTypes.SET_PROFESSIONS_GROUP_VISIBILITY_FILTER,
payload: {
filter,
},
})
export interface SwitchProfessionsExpansionVisibilityFilterAction {
type: ActionTypes.SWITCH_PROFESSIONS_EXPANSION_VISIBILITY_FILTER
}
export const switchProfessionsExpansionVisibilityFilter =
(): SwitchProfessionsExpansionVisibilityFilterAction => ({
type: ActionTypes.SWITCH_PROFESSIONS_EXPANSION_VISIBILITY_FILTER,
})
export interface SetProfessionsFilterTextAction {
type: ActionTypes.SET_PROFESSIONS_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setProfessionsFilterText = (filterText: string): SetProfessionsFilterTextAction => ({
type: ActionTypes.SET_PROFESSIONS_FILTER_TEXT,
payload: {
filterText,
},
})
@@ -1,16 +1,16 @@
import { ActionTypes } from '../constants/ActionTypes';
import { Maybe } from '../utils/dataUtils';
import { Maybe } from "../../Data/Maybe";
import { ActionTypes } from "../Constants/ActionTypes";
export interface SelectProfessionVariantAction {
type: ActionTypes.SELECT_PROFESSION_VARIANT;
type: ActionTypes.SELECT_PROFESSION_VARIANT
payload: {
id: Maybe<string>;
};
}
}
export const selectProfessionVariant = (id: Maybe<string>): SelectProfessionVariantAction => ({
type: ActionTypes.SELECT_PROFESSION_VARIANT,
payload: {
id
}
});
id,
},
})
@@ -1,16 +1,16 @@
import * as RCPUtils from '../App/Utils/rcpUtils';
import { ActionTypes } from '../constants/ActionTypes';
import { isAlbino } from '../selectors/activatableSelectors';
import { getCurrentRace, getCurrentRaceVariant } from '../selectors/rcpSelectors';
import { getSize, getWeight } from '../selectors/stateSelectors';
import { AsyncAction } from '../types/actions';
import { Just, Maybe, Nothing } from '../utils/dataUtils';
import { fromJust, fromMaybe, isJust, Just, Maybe, Nothing } from "../../Data/Maybe";
import { ActionTypes } from "../Constants/ActionTypes";
import { isAlbino } from "../Selectors/activatableSelectors";
import { getCurrentRace, getCurrentRaceVariant } from "../Selectors/rcpSelectors";
import { getSize, getWeight } from "../Selectors/stateSelectors";
import * as RCPUtils from "../Utilities/rcpUtils";
import { ReduxAction } from "./Actions";
export interface SetHeroNameAction {
type: ActionTypes.SET_HERO_NAME;
type: ActionTypes.SET_HERO_NAME
payload: {
name: string;
};
}
}
export const setHeroName = (name: string): SetHeroNameAction => ({
@@ -18,13 +18,13 @@ export const setHeroName = (name: string): SetHeroNameAction => ({
payload: {
name,
},
});
})
export interface SetCustomProfessionNameAction {
type: ActionTypes.SET_CUSTOM_PROFESSION_NAME;
type: ActionTypes.SET_CUSTOM_PROFESSION_NAME
payload: {
name: string;
};
}
}
export const setCustomProfessionName = (name: string): SetCustomProfessionNameAction => ({
@@ -32,13 +32,13 @@ export const setCustomProfessionName = (name: string): SetCustomProfessionNameAc
payload: {
name,
},
});
})
export interface SetHeroAvatarAction {
type: ActionTypes.SET_HERO_AVATAR;
type: ActionTypes.SET_HERO_AVATAR
payload: {
url: string;
};
}
}
export const setHeroAvatar = (path: string): SetHeroAvatarAction => ({
@@ -46,13 +46,21 @@ export const setHeroAvatar = (path: string): SetHeroAvatarAction => ({
payload: {
url: path,
},
});
})
export interface DeleteHeroAvatarAction {
type: ActionTypes.DELETE_HERO_AVATAR
}
export const deleteHeroAvatar = (): DeleteHeroAvatarAction => ({
type: ActionTypes.DELETE_HERO_AVATAR,
})
export interface SetFamilyAction {
type: ActionTypes.SET_FAMILY;
type: ActionTypes.SET_FAMILY
payload: {
family: string;
};
}
}
export const setFamily = (family: string): SetFamilyAction => ({
@@ -60,13 +68,13 @@ export const setFamily = (family: string): SetFamilyAction => ({
payload: {
family,
},
});
})
export interface SetPlaceOfBirthAction {
type: ActionTypes.SET_PLACEOFBIRTH;
type: ActionTypes.SET_PLACEOFBIRTH
payload: {
placeofbirth: string;
};
}
}
export const setPlaceOfBirth = (placeofbirth: string): SetPlaceOfBirthAction => ({
@@ -74,13 +82,13 @@ export const setPlaceOfBirth = (placeofbirth: string): SetPlaceOfBirthAction =>
payload: {
placeofbirth,
},
});
})
export interface SetDateOfBirthAction {
type: ActionTypes.SET_DATEOFBIRTH;
type: ActionTypes.SET_DATEOFBIRTH
payload: {
dateofbirth: string;
};
}
}
export const setDateOfBirth = (dateofbirth: string): SetDateOfBirthAction => ({
@@ -88,13 +96,13 @@ export const setDateOfBirth = (dateofbirth: string): SetDateOfBirthAction => ({
payload: {
dateofbirth,
},
});
})
export interface SetAgeAction {
type: ActionTypes.SET_AGE;
type: ActionTypes.SET_AGE
payload: {
age: string;
};
}
}
export const setAge = (age: string): SetAgeAction => ({
@@ -102,13 +110,13 @@ export const setAge = (age: string): SetAgeAction => ({
payload: {
age,
},
});
})
export interface SetHairColorAction {
type: ActionTypes.SET_HAIRCOLOR;
type: ActionTypes.SET_HAIRCOLOR
payload: {
haircolor: number;
};
}
}
export const setHairColor = (haircolor: number): SetHairColorAction => ({
@@ -116,13 +124,13 @@ export const setHairColor = (haircolor: number): SetHairColorAction => ({
payload: {
haircolor,
},
});
})
export interface SetEyeColorAction {
type: ActionTypes.SET_EYECOLOR;
type: ActionTypes.SET_EYECOLOR
payload: {
eyecolor: number;
};
}
}
export const setEyeColor = (eyecolor: number): SetEyeColorAction => ({
@@ -130,14 +138,14 @@ export const setEyeColor = (eyecolor: number): SetEyeColorAction => ({
payload: {
eyecolor,
},
});
})
export interface SetSizeAction {
type: ActionTypes.SET_SIZE;
type: ActionTypes.SET_SIZE
payload: {
size: string;
weight: Maybe<string>;
};
}
}
export const setSize = (size: string) => (weight: Maybe<string>): SetSizeAction => ({
@@ -146,14 +154,14 @@ export const setSize = (size: string) => (weight: Maybe<string>): SetSizeAction
size,
weight,
},
});
})
export interface SetWeightAction {
type: ActionTypes.SET_WEIGHT;
type: ActionTypes.SET_WEIGHT
payload: {
size: Maybe<string>;
weight: string;
};
}
}
export const setWeight = (weight: string) => (size: Maybe<string>): SetWeightAction => ({
@@ -162,76 +170,76 @@ export const setWeight = (weight: string) => (size: Maybe<string>): SetWeightAct
size,
weight,
},
});
})
export const rerollHairColor = (): AsyncAction => (dispatch, getState) => {
const state = getState ();
const race = getCurrentRace (state);
const raceVariant = getCurrentRaceVariant (state);
export const rerollHairColor: ReduxAction =
(dispatch, getState) => {
const state = getState ()
const race = getCurrentRace (state)
const raceVariant = getCurrentRaceVariant (state)
const maybeHairColor = RCPUtils.rerollHairColor (race, raceVariant);
const mhair_color = RCPUtils.rerollHairColor (race) (raceVariant)
if (Maybe.isJust (maybeHairColor)) {
dispatch (setHairColor (Maybe.fromJust (maybeHairColor)));
}
};
export const rerollEyeColor = (): AsyncAction => (dispatch, getState) => {
const state = getState ();
const race = getCurrentRace (state);
const raceVariant = getCurrentRaceVariant (state);
const isAlbinoVar = Maybe.fromMaybe (false) (isAlbino (state));
const maybeEyeColor = RCPUtils.rerollEyeColor (race, raceVariant, isAlbinoVar);
if (Maybe.isJust (maybeEyeColor)) {
dispatch (setEyeColor (Maybe.fromJust (maybeEyeColor)));
}
};
export const rerollSize = (): AsyncAction => (dispatch, getState) => {
const state = getState ();
const race = getCurrentRace (state);
const raceVariant = getCurrentRaceVariant (state);
const maybePrevSize = getSize (state);
const maybeWeight = getWeight (state);
const maybeNewSize = RCPUtils.rerollSize (race, raceVariant);
if (Maybe.isJust (maybeNewSize)) {
if (Maybe.isJust (maybePrevSize) && Maybe.isJust (maybeWeight)) {
const newWeight = RCPUtils.getWeightForRerolledSize (
Maybe.fromJust (maybeWeight),
Maybe.fromJust (maybePrevSize),
Maybe.fromJust (maybeNewSize)
);
dispatch (setSize (Maybe.fromJust (maybeNewSize)) (Just (newWeight)));
}
else {
dispatch (setSize (Maybe.fromJust (maybeNewSize)) (Nothing ()));
if (isJust (mhair_color)) {
dispatch (setHairColor (fromJust (mhair_color)))
}
}
};
export const rerollWeight = (): AsyncAction => (dispatch, getState) => {
const state = getState ();
const race = getCurrentRace (state);
const raceVariant = getCurrentRaceVariant (state);
const prevSize = getSize (state);
export const rerollEyeColor: ReduxAction = (dispatch, getState) => {
const state = getState ()
const race = getCurrentRace (state)
const raceVariant = getCurrentRaceVariant (state)
const isAlbinoVar = fromMaybe (false) (isAlbino (state))
const { weight, size } = RCPUtils.rerollWeight (race, raceVariant, prevSize);
const meye_color = RCPUtils.rerollEyeColor (isAlbinoVar) (race) (raceVariant)
if (Maybe.isJust (weight)) {
dispatch (setWeight (Maybe.fromJust (weight)) (size));
if (isJust (meye_color)) {
dispatch (setEyeColor (fromJust (meye_color)))
}
}
export const rerollSize: ReduxAction =
(dispatch, getState) => {
const state = getState ()
const race = getCurrentRace (state)
const raceVariant = getCurrentRaceVariant (state)
const mprev_size = getSize (state)
const mweight = getWeight (state)
const mnew_size = RCPUtils.rerollSize (race) (raceVariant)
if (isJust (mnew_size)) {
if (isJust (mprev_size) && isJust (mweight)) {
const new_weight = RCPUtils.getWeightForRerolledSize (fromJust (mweight))
(fromJust (mprev_size))
(fromJust (mnew_size))
dispatch (setSize (fromJust (mnew_size)) (Just (new_weight)))
}
else {
dispatch (setSize (fromJust (mnew_size)) (Nothing))
}
}
}
export const rerollWeight: ReduxAction =
(dispatch, getState) => {
const state = getState ()
const race = getCurrentRace (state)
const prevSize = getSize (state)
const { weight, size } = RCPUtils.rerollWeight (prevSize) (race)
if (isJust (weight)) {
dispatch (setWeight (fromJust (weight)) (size))
}
}
};
export interface SetTitleAction {
type: ActionTypes.SET_TITLE;
type: ActionTypes.SET_TITLE
payload: {
title: string;
};
}
}
export const setTitle = (title: string): SetTitleAction => ({
@@ -239,13 +247,13 @@ export const setTitle = (title: string): SetTitleAction => ({
payload: {
title,
},
});
})
export interface SetSocialStatusAction {
type: ActionTypes.SET_SOCIALSTATUS;
type: ActionTypes.SET_SOCIALSTATUS
payload: {
socialstatus: number;
};
}
}
export const setSocialStatus = (socialstatus: number): SetSocialStatusAction => ({
@@ -253,13 +261,13 @@ export const setSocialStatus = (socialstatus: number): SetSocialStatusAction =>
payload: {
socialstatus,
},
});
})
export interface SetCharacteristicsAction {
type: ActionTypes.SET_CHARACTERISTICS;
type: ActionTypes.SET_CHARACTERISTICS
payload: {
characteristics: string;
};
}
}
export const setCharacteristics = (characteristics: string): SetCharacteristicsAction => ({
@@ -267,13 +275,13 @@ export const setCharacteristics = (characteristics: string): SetCharacteristicsA
payload: {
characteristics,
},
});
})
export interface SetOtherInfoAction {
type: ActionTypes.SET_OTHERINFO;
type: ActionTypes.SET_OTHERINFO
payload: {
otherinfo: string;
};
}
}
export const setOtherInfo = (otherinfo: string): SetOtherInfoAction => ({
@@ -281,13 +289,13 @@ export const setOtherInfo = (otherinfo: string): SetOtherInfoAction => ({
payload: {
otherinfo,
},
});
})
export interface SetCultureAreaKnowledge {
type: ActionTypes.SET_CULTURE_AREA_KNOWLEDGE;
type: ActionTypes.SET_CULTURE_AREA_KNOWLEDGE
payload: {
cultureAreaKnowledge: string;
};
}
}
export const setCultureAreaKnowledge = (cultureAreaKnowledge: string): SetCultureAreaKnowledge => ({
@@ -295,21 +303,21 @@ export const setCultureAreaKnowledge = (cultureAreaKnowledge: string): SetCultur
payload: {
cultureAreaKnowledge,
},
});
})
export interface EndHeroCreationAction {
type: ActionTypes.END_HERO_CREATION;
type: ActionTypes.END_HERO_CREATION
}
export const endHeroCreation = (): EndHeroCreationAction => ({
type: ActionTypes.END_HERO_CREATION,
});
})
export interface AddAdventurePointsAction {
type: ActionTypes.ADD_ADVENTURE_POINTS;
type: ActionTypes.ADD_ADVENTURE_POINTS
payload: {
amount: number;
};
}
}
export const addAdventurePoints = (amount: number): AddAdventurePointsAction => ({
@@ -317,4 +325,18 @@ export const addAdventurePoints = (amount: number): AddAdventurePointsAction =>
payload: {
amount,
},
});
})
export interface SetHeroLocaleAction {
type: ActionTypes.SET_HERO_LOCALE
payload: {
locale: string;
}
}
export const setHeroLocale = (locale: string): SetHeroLocaleAction => ({
type: ActionTypes.SET_HERO_LOCALE,
payload: {
locale,
},
})
@@ -1,68 +1,68 @@
import { ActionTypes } from '../constants/ActionTypes';
import { Maybe } from '../utils/dataUtils';
import { Maybe } from "../../Data/Maybe";
import { ActionTypes } from "../Constants/ActionTypes";
export interface SelectRaceAction {
type: ActionTypes.SELECT_RACE;
type: ActionTypes.SELECT_RACE
payload: {
id: string;
variantId: Maybe<string>;
};
}
}
export const selectRace = (id: string) => (variantId: Maybe<string>): SelectRaceAction => ({
type: ActionTypes.SELECT_RACE,
payload: {
id,
variantId
}
});
variantId,
},
})
export interface SetRaceVariantAction {
type: ActionTypes.SET_RACE_VARIANT;
type: ActionTypes.SET_RACE_VARIANT
payload: {
id: string;
};
}
}
export const setRaceVariant = (id: string): SetRaceVariantAction => ({
type: ActionTypes.SET_RACE_VARIANT,
payload: {
id
}
});
id,
},
})
export interface SetRacesSortOrderAction {
type: ActionTypes.SET_RACES_SORT_ORDER;
type: ActionTypes.SET_RACES_SORT_ORDER
payload: {
sortOrder: string;
};
}
}
export const setRacesSortOrder = (sortOrder: string): SetRacesSortOrderAction => ({
type: ActionTypes.SET_RACES_SORT_ORDER,
payload: {
sortOrder
}
});
sortOrder,
},
})
export interface SwitchRaceValueVisibilityAction {
type: ActionTypes.SWITCH_RACE_VALUE_VISIBILITY;
type: ActionTypes.SWITCH_RACE_VALUE_VISIBILITY
}
export const switchRaceValueVisibilityFilter = (): SwitchRaceValueVisibilityAction => ({
type: ActionTypes.SWITCH_RACE_VALUE_VISIBILITY
});
type: ActionTypes.SWITCH_RACE_VALUE_VISIBILITY,
})
export interface SetRacesFilterTextAction {
type: ActionTypes.SET_RACES_FILTER_TEXT;
type: ActionTypes.SET_RACES_FILTER_TEXT
payload: {
filterText: string;
};
}
}
export const setFilterText = (filterText: string): SetRacesFilterTextAction => ({
type: ActionTypes.SET_RACES_FILTER_TEXT,
payload: {
filterText
}
});
filterText,
},
})
@@ -1,10 +1,10 @@
import { ActionTypes } from '../constants/ActionTypes';
import { ActionTypes } from "../Constants/ActionTypes";
export interface SetHigherParadeValuesAction {
type: ActionTypes.SET_HIGHER_PARADE_VALUES;
type: ActionTypes.SET_HIGHER_PARADE_VALUES
payload: {
value: number;
};
}
}
export const setHigherParadeValues = (value: number): SetHigherParadeValuesAction => ({
@@ -12,29 +12,29 @@ export const setHigherParadeValues = (value: number): SetHigherParadeValuesActio
payload: {
value,
},
});
})
export interface SwitchAttributeValueLimitAction {
type: ActionTypes.SWITCH_ATTRIBUTE_VALUE_LIMIT;
type: ActionTypes.SWITCH_ATTRIBUTE_VALUE_LIMIT
}
export const switchAttributeValueLimit = (): SwitchAttributeValueLimitAction => ({
type: ActionTypes.SWITCH_ATTRIBUTE_VALUE_LIMIT,
});
})
export interface SwitchEnableAllRuleBooksAction {
type: ActionTypes.SWITCH_ENABLE_ALL_RULE_BOOKS;
type: ActionTypes.SWITCH_ENABLE_ALL_RULE_BOOKS
}
export const switchEnableAllRuleBooks = (): SwitchEnableAllRuleBooksAction => ({
type: ActionTypes.SWITCH_ENABLE_ALL_RULE_BOOKS,
});
})
export interface SwitchEnableRuleBookAction {
type: ActionTypes.SWITCH_ENABLE_RULE_BOOK;
type: ActionTypes.SWITCH_ENABLE_RULE_BOOK
payload: {
id: string;
};
}
}
export const switchEnableRuleBook = (id: string): SwitchEnableRuleBookAction => ({
@@ -42,13 +42,13 @@ export const switchEnableRuleBook = (id: string): SwitchEnableRuleBookAction =>
payload: {
id,
},
});
})
export interface SwitchEnableLanguageSpecializationsAction {
type: ActionTypes.SWITCH_ENABLE_LANGUAGE_SPECIALIZATIONS;
type: ActionTypes.SWITCH_ENABLE_LANGUAGE_SPECIALIZATIONS
}
export const switchEnableLanguageSpecializations =
(): SwitchEnableLanguageSpecializationsAction => ({
type: ActionTypes.SWITCH_ENABLE_LANGUAGE_SPECIALIZATIONS,
});
})
@@ -1,9 +1,9 @@
import { ActionTypes } from '../constants/ActionTypes';
import { ActionTypes } from "../Constants/ActionTypes";
export interface SwitchSheetAttributeValueVisibilityAction {
type: ActionTypes.SWITCH_SHEET_ATTRIBUTE_VALUE_VISIBILITY;
type: ActionTypes.SWITCH_SHEET_ATTRIBUTE_VALUE_VISIBILITY
}
export const switchAttributeValueVisibility = (): SwitchSheetAttributeValueVisibilityAction => ({
type: ActionTypes.SWITCH_SHEET_ATTRIBUTE_VALUE_VISIBILITY
});
type: ActionTypes.SWITCH_SHEET_ATTRIBUTE_VALUE_VISIBILITY,
})
+108
View File
@@ -0,0 +1,108 @@
import { List } from "../../Data/List";
import { bind, bindF, fromJust, isNothing, join, liftM2 } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { ActionTypes } from "../Constants/ActionTypes";
import { HeroModel } from "../Models/Hero/HeroModel";
import { L10nRecord } from "../Models/Wiki/L10n";
import { getAvailableAPMap } from "../Selectors/adventurePointsSelectors";
import { getIsInCharacterCreation } from "../Selectors/phaseSelectors";
import { getCurrentHeroPresent, getSkills, getWikiSkills } from "../Selectors/stateSelectors";
import { translate, translateP } from "../Utilities/I18n";
import { getAreSufficientAPAvailableForIncrease } from "../Utilities/Increasable/increasableUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { ReduxAction } from "./Actions";
import { addAlert } from "./AlertActions";
export interface AddSkillPointAction {
type: ActionTypes.ADD_TALENT_POINT
payload: {
id: string;
}
}
export const addSkillPoint =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero_skills = getSkills (state)
const wiki_skills = getWikiSkills (state)
const mhero = getCurrentHeroPresent (state)
const missingAPForInc =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (getAreSufficientAPAvailableForIncrease (getIsInCharacterCreation (state))
(bind (mhero_skills)
(lookup (id))))
(lookup (id) (wiki_skills)),
join
)
if (isNothing (missingAPForInc)) {
dispatch<AddSkillPointAction> ({
type: ActionTypes.ADD_TALENT_POINT,
payload: {
id,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAPForInc))),
}))
}
}
export interface RemoveSkillPointAction {
type: ActionTypes.REMOVE_TALENT_POINT
payload: {
id: string;
}
}
export const removeSkillPoint = (id: string): RemoveSkillPointAction => ({
type: ActionTypes.REMOVE_TALENT_POINT,
payload: {
id,
},
})
export interface SetSkillsSortOrderAction {
type: ActionTypes.SET_TALENTS_SORT_ORDER
payload: {
sortOrder: string;
}
}
export const setSkillsSortOrder = (sortOrder: string): SetSkillsSortOrderAction => ({
type: ActionTypes.SET_TALENTS_SORT_ORDER,
payload: {
sortOrder,
},
})
export interface SwitchSkillRatingVisibilityAction {
type: ActionTypes.SWITCH_TALENT_RATING_VISIBILITY
}
export const switchSkillRatingVisibility = (): SwitchSkillRatingVisibilityAction => ({
type: ActionTypes.SWITCH_TALENT_RATING_VISIBILITY,
})
export interface SetSkillsFilterTextAction {
type: ActionTypes.SET_SKILLS_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setSkillsFilterText = (filterText: string): SetSkillsFilterTextAction => ({
type: ActionTypes.SET_SKILLS_FILTER_TEXT,
payload: {
filterText,
},
})
+302
View File
@@ -0,0 +1,302 @@
import { fmap } from "../../Data/Functor";
import { set } from "../../Data/Lens";
import { List, subscriptF } from "../../Data/List";
import { bind, bindF, ensure, fromJust, isJust, isNothing, join, Just, liftM2, Maybe } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { Record } from "../../Data/Record";
import { Pair } from "../../Data/Tuple";
import { ActionTypes } from "../Constants/ActionTypes";
import { ActivatableActivationOptions } from "../Models/Actions/ActivatableActivationOptions";
import { ActivatableDeactivationOptions } from "../Models/Actions/ActivatableDeactivationOptions";
import { ActivatableDependent } from "../Models/ActiveEntries/ActivatableDependent";
import { ActiveObjectWithIdL, toActiveObjectWithId } from "../Models/ActiveEntries/ActiveObjectWithId";
import { HeroModel } from "../Models/Hero/HeroModel";
import { ActivatableNameCost, ActivatableNameCostSafeCost } from "../Models/View/ActivatableNameCost";
import { L10nRecord } from "../Models/Wiki/L10n";
import { isSpecialAbility, SpecialAbility } from "../Models/Wiki/SpecialAbility";
import { getAvailableAPMap } from "../Selectors/adventurePointsSelectors";
import { getIsInCharacterCreation } from "../Selectors/phaseSelectors";
import { getCurrentHeroPresent, getWiki } from "../Selectors/stateSelectors";
import { getNameCost } from "../Utilities/Activatable/activatableActiveUtils";
import { convertPerTierCostToFinalCost } from "../Utilities/AdventurePoints/activatableCostUtils";
import { getMissingAP } from "../Utilities/AdventurePoints/adventurePointsUtils";
import { translate, translateP } from "../Utilities/I18n";
import { subtract } from "../Utilities/mathUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { getWikiEntry } from "../Utilities/WikiUtils";
import { ReduxAction } from "./Actions";
import { addAlert } from "./AlertActions";
export interface ActivateSpecialAbilityAction {
type: ActionTypes.ACTIVATE_SPECIALABILITY
payload: Pair<
Record<ActivatableActivationOptions>,
Pair<Record<SpecialAbility>, Maybe<Record<ActivatableDependent>>>
>
}
/**
* Add a special ability with the provided activation properties (`args`).
*/
export const addSpecialAbility =
(l10n: L10nRecord) =>
(args: Record<ActivatableActivationOptions>): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
if (isJust (mhero)) {
const current_id = ActivatableActivationOptions.AL.id (args)
const current_cost = ActivatableActivationOptions.AL.cost (args)
const mwiki_entry =
bind (getWikiEntry (getWiki (state)) (current_id))
(ensure (isSpecialAbility))
const mhero_entry =
lookup (current_id)
(HeroModel.AL.specialAbilities (fromJust (mhero)))
if (isJust (mwiki_entry)) {
const wiki_entry = fromJust (mwiki_entry)
const mmissingAP =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
bindF (getMissingAP (getIsInCharacterCreation (state))
(current_cost))
)
if (isNothing (mmissingAP)) {
dispatch<ActivateSpecialAbilityAction> ({
type: ActionTypes.ACTIVATE_SPECIALABILITY,
payload: Pair (args, Pair (wiki_entry, mhero_entry)),
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (mmissingAP))),
}))
}
}
}
}
export interface DeactivateSpecialAbilityAction {
type: ActionTypes.DEACTIVATE_SPECIALABILITY
payload: Pair<
Record<ActivatableDeactivationOptions>,
Pair<Record<SpecialAbility>, Record<ActivatableDependent>>
>
}
/**
* Remove a special ability with the provided activation properties
* (`args`).
*/
export const removeSpecialAbility =
(args: Record<ActivatableDeactivationOptions>): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
if (isJust (mhero)) {
const hero = fromJust (mhero)
const current_id = ActivatableDeactivationOptions.AL.id (args)
const mwiki_entry =
bind (getWikiEntry (getWiki (state)) (current_id))
(ensure (isSpecialAbility))
const mhero_entry =
lookup (current_id)
(HeroModel.AL.specialAbilities (hero))
if (isJust (mwiki_entry) && isJust (mhero_entry)) {
const wiki_entry = fromJust (mwiki_entry)
const hero_entry = fromJust (mhero_entry)
dispatch<DeactivateSpecialAbilityAction> ({
type: ActionTypes.DEACTIVATE_SPECIALABILITY,
payload: Pair (args, Pair (wiki_entry, hero_entry)),
})
}
}
}
export interface SetSpecialAbilityTierAction {
type: ActionTypes.SET_SPECIALABILITY_TIER
payload: Pair<
{ id: string; index: number; tier: number },
Pair<Record<SpecialAbility>, Record<ActivatableDependent>>
>
}
/**
* Change the current level of a special ability.
*/
export const setSpecialAbilityLevel =
(l10n: L10nRecord) =>
(current_id: string) =>
(current_index: number) =>
(next_level: number): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
if (isJust (mhero)) {
const hero = fromJust (mhero)
const mwiki_entry =
bind (getWikiEntry (getWiki (state)) (current_id))
(ensure (isSpecialAbility))
const mhero_entry =
lookup (current_id)
(HeroModel.AL.specialAbilities (hero))
const mactive_entry =
pipe (
bindF (pipe (
ActivatableDependent.A.active,
subscriptF (current_index)
)),
fmap (toActiveObjectWithId (current_index) (current_id))
)
(mhero_entry)
if (isJust (mwiki_entry) && isJust (mhero_entry) && isJust (mactive_entry)) {
const wiki_entry = fromJust (mwiki_entry)
const active_entry = fromJust (mactive_entry)
const wiki = getWiki (state)
const getCostBorder =
(isEntryToAdd: boolean) =>
pipe (
getNameCost (isEntryToAdd)
(l10n)
(wiki)
(hero),
fmap (pipe (
convertPerTierCostToFinalCost (false) (l10n),
ActivatableNameCost.A.finalCost as
(x: Record<ActivatableNameCostSafeCost>) => number
))
)
const previousCost =
getCostBorder (false) (active_entry)
const nextCost =
getCostBorder (true) (set (ActiveObjectWithIdL.tier)
(Just (next_level))
(active_entry))
const mdiff_cost = liftM2 (subtract) (nextCost) (previousCost)
if (isJust (mdiff_cost)) {
const diff_cost = fromJust (mdiff_cost)
const mmissingAP =
pipe_ (
mhero,
bindF (pipe (
HeroModel.A.id,
hero_id => getAvailableAPMap (hero_id) (state, { l10n })
)),
join,
bindF (getMissingAP (getIsInCharacterCreation (state))
(diff_cost))
)
if (isNothing (mmissingAP)) {
dispatch<SetSpecialAbilityTierAction> ({
type: ActionTypes.SET_SPECIALABILITY_TIER,
payload: Pair (
{
id: current_id,
tier: next_level,
index: current_index,
},
Pair (wiki_entry, fromJust (mhero_entry))
),
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (mmissingAP))),
}))
}
}
}
}
}
export interface SetSpecialAbilitiesSortOrderAction {
type: ActionTypes.SET_SPECIALABILITIES_SORT_ORDER
payload: {
sortOrder: string;
}
}
export const setSpecialAbilitiesSortOrder =
(sortOrder: string): SetSpecialAbilitiesSortOrderAction => ({
type: ActionTypes.SET_SPECIALABILITIES_SORT_ORDER,
payload: {
sortOrder,
},
})
export interface SetActiveSpecialAbilitiesFilterTextAction {
type: ActionTypes.SET_SPECIAL_ABILITIES_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setActiveSpecialAbilitiesFilterText =
(filterText: string): SetActiveSpecialAbilitiesFilterTextAction => ({
type: ActionTypes.SET_SPECIAL_ABILITIES_FILTER_TEXT,
payload: {
filterText,
},
})
export interface SetInactiveSpecialAbilitiesFilterTextAction {
type: ActionTypes.SET_INACTIVE_SPECIAL_ABILITIES_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setInactiveSpecialAbilitiesFilterText =
(filterText: string): SetInactiveSpecialAbilitiesFilterTextAction => ({
type: ActionTypes.SET_INACTIVE_SPECIAL_ABILITIES_FILTER_TEXT,
payload: {
filterText,
},
})
export interface SetGuildMageUnfamiliarSpellIdAction {
type: ActionTypes.SET_TRADITION_GUILD_MAGE_UNFAMILIAR_SPELL_ID
payload: {
id: string;
}
}
export const setGuildMageUnfamiliarSpellId = (id: string): SetGuildMageUnfamiliarSpellIdAction => ({
type: ActionTypes.SET_TRADITION_GUILD_MAGE_UNFAMILIAR_SPELL_ID,
payload: {
id,
},
})
+249
View File
@@ -0,0 +1,249 @@
import { List } from "../../Data/List";
import { bind, bindF, fromJust, isJust, isNothing, join, liftM2 } from "../../Data/Maybe";
import { lookup } from "../../Data/OrderedMap";
import { Record } from "../../Data/Record";
import { ActionTypes } from "../Constants/ActionTypes";
import { HeroModel } from "../Models/Hero/HeroModel";
import { L10nRecord } from "../Models/Wiki/L10n";
import { Spell } from "../Models/Wiki/Spell";
import { getAvailableAPMap } from "../Selectors/adventurePointsSelectors";
import { getIsInCharacterCreation } from "../Selectors/phaseSelectors";
import { getCurrentHeroPresent, getSpells, getWikiSpells } from "../Selectors/stateSelectors";
import { getMissingAP } from "../Utilities/AdventurePoints/adventurePointsUtils";
import { getICMultiplier } from "../Utilities/AdventurePoints/improvementCostUtils";
import { translate, translateP } from "../Utilities/I18n";
import { getAreSufficientAPAvailableForIncrease } from "../Utilities/Increasable/increasableUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { ReduxAction } from "./Actions";
import { addAlert } from "./AlertActions";
export interface ActivateSpellAction {
type: ActionTypes.ACTIVATE_SPELL
payload: {
id: string;
wikiEntry: Record<Spell>;
}
}
export const addSpell =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const wiki_spells = getWikiSpells (state)
const mhero = getCurrentHeroPresent (state)
const mwiki_spell = lookup (id) (wiki_spells)
if (isJust (mwiki_spell)) {
const wiki_entry = fromJust (mwiki_spell)
const missingAPForInc =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
bindF (getMissingAP (getIsInCharacterCreation (state))
(pipe_ (wiki_entry, Spell.A.ic, getICMultiplier)))
)
if (isNothing (missingAPForInc)) {
dispatch<ActivateSpellAction> ({
type: ActionTypes.ACTIVATE_SPELL,
payload: {
id,
wikiEntry: wiki_entry,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAPForInc))),
}))
}
}
}
export interface ActivateCantripAction {
type: ActionTypes.ACTIVATE_CANTRIP
payload: {
id: string;
}
}
export const addCantrip =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero = getCurrentHeroPresent (state)
const missingAP =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
bindF (getMissingAP (getIsInCharacterCreation (state))
(1))
)
if (isNothing (missingAP)) {
dispatch<ActivateCantripAction> ({
type: ActionTypes.ACTIVATE_CANTRIP,
payload: {
id,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAP))),
}))
}
}
export interface DeactivateSpellAction {
type: ActionTypes.DEACTIVATE_SPELL
payload: {
id: string;
wikiEntry: Record<Spell>;
}
}
export const removeSpell =
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const wiki_spells = getWikiSpells (state)
const mwiki_spell = lookup (id) (wiki_spells)
if (isJust (mwiki_spell)) {
const wiki_entry = fromJust (mwiki_spell)
dispatch<DeactivateSpellAction> ({
type: ActionTypes.DEACTIVATE_SPELL,
payload: {
id,
wikiEntry: wiki_entry,
},
})
}
}
export interface DeactivateCantripAction {
type: ActionTypes.DEACTIVATE_CANTRIP
payload: {
id: string;
}
}
export const removeCantrip = (id: string): DeactivateCantripAction => ({
type: ActionTypes.DEACTIVATE_CANTRIP,
payload: {
id,
},
})
export interface AddSpellPointAction {
type: ActionTypes.ADD_SPELL_POINT
payload: {
id: string;
}
}
export const addSpellPoint =
(l10n: L10nRecord) =>
(id: string): ReduxAction =>
(dispatch, getState) => {
const state = getState ()
const mhero_spells = getSpells (state)
const wiki_spells = getWikiSpells (state)
const mhero = getCurrentHeroPresent (state)
const missingAPForInc =
pipe_ (
mhero,
bindF (pipe (HeroModel.A.id, hero_id => getAvailableAPMap (hero_id) (state, { l10n }))),
join,
liftM2 (getAreSufficientAPAvailableForIncrease (getIsInCharacterCreation (state))
(bind (mhero_spells)
(lookup (id))))
(lookup (id) (wiki_spells)),
join
)
if (isNothing (missingAPForInc)) {
dispatch<AddSpellPointAction> ({
type: ActionTypes.ADD_SPELL_POINT,
payload: {
id,
},
})
}
else {
dispatch (addAlert ({
title: translate (l10n) ("notenoughap"),
message: translateP (l10n) ("notenoughap.text") (List (fromJust (missingAPForInc))),
}))
}
}
export interface RemoveSpellPointAction {
type: ActionTypes.REMOVE_SPELL_POINT
payload: {
id: string;
}
}
export const removeSpellPoint = (id: string): RemoveSpellPointAction => ({
type: ActionTypes.REMOVE_SPELL_POINT,
payload: {
id,
},
})
export interface SetSpellsSortOrderAction {
type: ActionTypes.SET_SPELLS_SORT_ORDER
payload: {
sortOrder: string;
}
}
export const setSpellsSortOrder = (sortOrder: string): SetSpellsSortOrderAction => ({
type: ActionTypes.SET_SPELLS_SORT_ORDER,
payload: {
sortOrder,
},
})
export interface SetActiveSpellsFilterTextAction {
type: ActionTypes.SET_SPELLS_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setActiveSpellsFilterText = (filterText: string): SetActiveSpellsFilterTextAction => ({
type: ActionTypes.SET_SPELLS_FILTER_TEXT,
payload: {
filterText,
},
})
export interface SetInactiveSpellsFilterTextAction {
type: ActionTypes.SET_INACTIVE_SPELLS_FILTER_TEXT
payload: {
filterText: string;
}
}
export const setInactiveSpellsFilterText =
(filterText: string): SetInactiveSpellsFilterTextAction => ({
type: ActionTypes.SET_INACTIVE_SPELLS_FILTER_TEXT,
payload: {
filterText,
},
})
@@ -1,127 +1,127 @@
import { ActionTypes } from '../constants/ActionTypes';
import { ActionTypes } from "../Constants/ActionTypes";
export interface OpenEditPermanentEnergyAction {
type: ActionTypes.OPEN_EDIT_PERMANENT_ENERGY;
type: ActionTypes.OPEN_EDIT_PERMANENT_ENERGY
payload: {
energy: 'LP' | 'AE' | 'KP';
};
energy: "LP" | "AE" | "KP";
}
}
export const openEditPermanentEnergy =
(energy: 'LP' | 'AE' | 'KP'): OpenEditPermanentEnergyAction => ({
(energy: "LP" | "AE" | "KP"): OpenEditPermanentEnergyAction => ({
type: ActionTypes.OPEN_EDIT_PERMANENT_ENERGY,
payload: {
energy,
},
});
})
export interface CloseEditPermanentEnergyAction {
type: ActionTypes.CLOSE_EDIT_PERMANENT_ENERGY;
type: ActionTypes.CLOSE_EDIT_PERMANENT_ENERGY
}
export const closeEditPermanentEnergy = (): CloseEditPermanentEnergyAction => ({
type: ActionTypes.CLOSE_EDIT_PERMANENT_ENERGY,
});
})
export interface OpenAddPermanentEnergyLossAction {
type: ActionTypes.OPEN_ADD_PERMANENT_ENERGY_LOSS;
type: ActionTypes.OPEN_ADD_PERMANENT_ENERGY_LOSS
payload: {
energy: 'LP' | 'AE' | 'KP';
};
energy: "LP" | "AE" | "KP";
}
}
export const openAddPermanentEnergyLoss =
(energy: 'LP' | 'AE' | 'KP'): OpenAddPermanentEnergyLossAction => ({
(energy: "LP" | "AE" | "KP"): OpenAddPermanentEnergyLossAction => ({
type: ActionTypes.OPEN_ADD_PERMANENT_ENERGY_LOSS,
payload: {
energy,
},
});
})
export interface CloseAddPermanentEnergyLossAction {
type: ActionTypes.CLOSE_ADD_PERMANENT_ENERGY_LOSS;
type: ActionTypes.CLOSE_ADD_PERMANENT_ENERGY_LOSS
}
export const closeAddPermanentEnergyLoss = (): CloseAddPermanentEnergyLossAction => ({
type: ActionTypes.CLOSE_ADD_PERMANENT_ENERGY_LOSS,
});
})
export interface OpenCharacterCreatorAction {
type: ActionTypes.OPEN_CHARACTER_CREATOR;
type: ActionTypes.OPEN_CHARACTER_CREATOR
}
export const openCharacterCreator = (): OpenCharacterCreatorAction => ({
type: ActionTypes.OPEN_CHARACTER_CREATOR,
});
})
export interface CloseCharacterCreatorAction {
type: ActionTypes.CLOSE_CHARACTER_CREATOR;
type: ActionTypes.CLOSE_CHARACTER_CREATOR
}
export const closeCharacterCreator = (): CloseCharacterCreatorAction => ({
type: ActionTypes.CLOSE_CHARACTER_CREATOR,
});
})
export interface OpenSettingsAction {
type: ActionTypes.OPEN_SETTINGS;
type: ActionTypes.OPEN_SETTINGS
}
export const openSettings = (): OpenSettingsAction => ({
type: ActionTypes.OPEN_SETTINGS,
});
})
export interface CloseSettingsAction {
type: ActionTypes.CLOSE_SETTINGS;
type: ActionTypes.CLOSE_SETTINGS
}
export const closeSettings = (): CloseSettingsAction => ({
type: ActionTypes.CLOSE_SETTINGS,
});
})
export interface OpenAddAdventurePointsAction {
type: ActionTypes.OPEN_ADD_ADVENTURE_POINTS;
type: ActionTypes.OPEN_ADD_ADVENTURE_POINTS
}
export const openAddAdventurePoints = (): OpenAddAdventurePointsAction => ({
type: ActionTypes.OPEN_ADD_ADVENTURE_POINTS,
});
})
export interface CloseAddAdventurePointsAction {
type: ActionTypes.CLOSE_ADD_ADVENTURE_POINTS;
type: ActionTypes.CLOSE_ADD_ADVENTURE_POINTS
}
export const closeAddAdventurePoints = (): CloseAddAdventurePointsAction => ({
type: ActionTypes.CLOSE_ADD_ADVENTURE_POINTS,
});
})
export interface OpenEditCharacterAvatarAction {
type: ActionTypes.OPEN_EDIT_CHARACTER_AVATAR;
type: ActionTypes.OPEN_EDIT_CHARACTER_AVATAR
}
export const openEditCharacterAvatar = (): OpenEditCharacterAvatarAction => ({
type: ActionTypes.OPEN_EDIT_CHARACTER_AVATAR,
});
})
export interface CloseEditCharacterAvatarAction {
type: ActionTypes.CLOSE_EDIT_CHARACTER_AVATAR;
type: ActionTypes.CLOSE_EDIT_CHARACTER_AVATAR
}
export const closeEditCharacterAvatar = (): CloseEditCharacterAvatarAction => ({
type: ActionTypes.CLOSE_EDIT_CHARACTER_AVATAR,
});
})
export interface OpenEditPetAvatarAction {
type: ActionTypes.OPEN_EDIT_PET_AVATAR;
type: ActionTypes.OPEN_EDIT_PET_AVATAR
}
export const openEditPetAvatar = (): OpenEditPetAvatarAction => ({
type: ActionTypes.OPEN_EDIT_PET_AVATAR,
});
})
export interface CloseEditPetAvatarAction {
type: ActionTypes.CLOSE_EDIT_PET_AVATAR;
type: ActionTypes.CLOSE_EDIT_PET_AVATAR
}
export const closeEditPetAvatar = (): CloseEditPetAvatarAction => ({
type: ActionTypes.CLOSE_EDIT_PET_AVATAR,
});
})
@@ -1,11 +1,11 @@
import { ActionTypes } from '../constants/ActionTypes';
import { Maybe } from '../utils/dataUtils';
import { Maybe } from "../../Data/Maybe";
import { ActionTypes } from "../Constants/ActionTypes";
export interface SetWikiFilterAction {
type: ActionTypes.SET_WIKI_FILTER;
type: ActionTypes.SET_WIKI_FILTER
payload: {
filterText: string;
};
}
}
export const setWikiFilter = (filterText: string): SetWikiFilterAction => ({
@@ -13,13 +13,13 @@ export const setWikiFilter = (filterText: string): SetWikiFilterAction => ({
payload: {
filterText,
},
});
})
export interface SetWikiFilterAllAction {
type: ActionTypes.SET_WIKI_FILTER_ALL;
type: ActionTypes.SET_WIKI_FILTER_ALL
payload: {
filterText: string;
};
}
}
export const setWikiFilterAll = (filterText: string): SetWikiFilterAllAction => ({
@@ -27,13 +27,13 @@ export const setWikiFilterAll = (filterText: string): SetWikiFilterAllAction =>
payload: {
filterText,
},
});
})
export interface SetWikiCategory1Action {
type: ActionTypes.SET_WIKI_CATEGORY_1;
type: ActionTypes.SET_WIKI_CATEGORY_1
payload: {
category: string;
};
}
}
export const setWikiCategory1 = (category: string): SetWikiCategory1Action => ({
@@ -41,13 +41,13 @@ export const setWikiCategory1 = (category: string): SetWikiCategory1Action => ({
payload: {
category,
},
});
})
export interface SetWikiCategory2Action {
type: ActionTypes.SET_WIKI_CATEGORY_2;
type: ActionTypes.SET_WIKI_CATEGORY_2
payload: {
category: string;
};
}
}
export const setWikiCategory2 = (category: string): SetWikiCategory2Action => ({
@@ -55,13 +55,13 @@ export const setWikiCategory2 = (category: string): SetWikiCategory2Action => ({
payload: {
category,
},
});
})
export interface SetWikiProfessionsGroupAction {
type: ActionTypes.SET_WIKI_PROFESSIONS_GROUP;
type: ActionTypes.SET_WIKI_PROFESSIONS_GROUP
payload: {
group: Maybe<number>;
};
}
}
export const setWikiProfessionsGroup =
@@ -70,13 +70,13 @@ export const setWikiProfessionsGroup =
payload: {
group,
},
});
})
export interface SetWikiSkillsGroupAction {
type: ActionTypes.SET_WIKI_SKILLS_GROUP;
type: ActionTypes.SET_WIKI_SKILLS_GROUP
payload: {
group: Maybe<number>;
};
}
}
export const setWikiSkillsGroup = (group: Maybe<number>): SetWikiSkillsGroupAction => ({
@@ -84,13 +84,13 @@ export const setWikiSkillsGroup = (group: Maybe<number>): SetWikiSkillsGroupActi
payload: {
group,
},
});
})
export interface SetWikiCombatTechniquesGroupAction {
type: ActionTypes.SET_WIKI_COMBAT_TECHNIQUES_GROUP;
type: ActionTypes.SET_WIKI_COMBAT_TECHNIQUES_GROUP
payload: {
group: Maybe<number>;
};
}
}
export const setWikiCombatTechniquesGroup =
@@ -99,13 +99,13 @@ export const setWikiCombatTechniquesGroup =
payload: {
group,
},
});
})
export interface SetWikiSpecialAbilitiesGroupAction {
type: ActionTypes.SET_WIKI_SPECIAL_ABILITIES_GROUP;
type: ActionTypes.SET_WIKI_SPECIAL_ABILITIES_GROUP
payload: {
group: Maybe<number>;
};
}
}
export const setWikiSpecialAbilitiesGroup =
@@ -114,13 +114,13 @@ export const setWikiSpecialAbilitiesGroup =
payload: {
group,
},
});
})
export interface SetWikiSpellsGroupAction {
type: ActionTypes.SET_WIKI_SPELLS_GROUP;
type: ActionTypes.SET_WIKI_SPELLS_GROUP
payload: {
group: Maybe<number>;
};
}
}
export const setWikiSpellsGroup = (group: Maybe<number>): SetWikiSpellsGroupAction => ({
@@ -128,13 +128,13 @@ export const setWikiSpellsGroup = (group: Maybe<number>): SetWikiSpellsGroupActi
payload: {
group,
},
});
})
export interface SetWikiLiturgicalChantsGroupAction {
type: ActionTypes.SET_WIKI_LITURGICAL_CHANTS_GROUP;
type: ActionTypes.SET_WIKI_LITURGICAL_CHANTS_GROUP
payload: {
group: Maybe<number>;
};
}
}
export const setWikiLiturgicalChantsGroup =
@@ -143,13 +143,13 @@ export const setWikiLiturgicalChantsGroup =
payload: {
group,
},
});
})
export interface SetWikiItemTemplatesGroupAction {
type: ActionTypes.SET_WIKI_ITEM_TEMPLATES_GROUP;
type: ActionTypes.SET_WIKI_ITEM_TEMPLATES_GROUP
payload: {
group: Maybe<number>;
};
}
}
export const setWikiItemTemplatesGroup =
@@ -158,4 +158,4 @@ export const setWikiItemTemplatesGroup =
payload: {
group,
},
});
})
@@ -9,6 +9,8 @@ export enum ActionTypes {
RECEIVE_IMPORTED_HERO = "RECEIVE_IMPORTED_HERO",
RECEIVE_INITIAL_DATA = "RECEIVE_INITIAL_DATA",
END_LOADING_STATE = "END_LOADING_STATE",
SET_UPDATE_DOWNLOAD_PROGRESS = "SET_UPDATE_DOWNLOAD_PROGRESS",
REQUEST_LOGIN = "REQUEST_LOGIN",
@@ -67,6 +69,7 @@ export enum ActionTypes {
REQUEST_HERO_AVATAR = "REQUEST_HERO_AVATAR",
RECEIVE_HERO_AVATAR = "RECEIVE_HERO_AVATAR",
SET_HERO_AVATAR = "SET_HERO_AVATAR",
DELETE_HERO_AVATAR = "DELETE_HERO_AVATAR",
OPEN_EDIT_PERMANENT_ENERGY = "OPEN_EDIT_PERMANENT_ENERGY",
CLOSE_EDIT_PERMANENT_ENERGY = "CLOSE_EDIT_PERMANENT_ENERGY",
@@ -107,6 +110,7 @@ export enum ActionTypes {
ASSIGN_RCP_OPTIONS = "ASSIGN_RCP_OPTIONS",
SELECT_PROFESSION_VARIANT = "SELECT_PROFESSION_VARIANT",
SET_HERO_LOCALE = "SET_HERO_LOCALE",
SET_HERO_NAME = "SET_HERO_NAME",
SET_CUSTOM_PROFESSION_NAME = "SET_CUSTOM_PROFESSION_NAME",
SET_FAMILY = "SET_FAMILY",
@@ -188,6 +192,7 @@ export enum ActionTypes {
DEACTIVATE_SPECIALABILITY = "DEACTIVATE_SPECIALABILITY",
SET_SPECIALABILITY_TIER = "SET_SPECIALABILITY_TIER",
SET_SPECIALABILITIES_SORT_ORDER = "SET_SPECIALABILITIES_SORT_ORDER",
SET_TRADITION_GUILD_MAGE_UNFAMILIAR_SPELL_ID = "SET_TRADITION_GUILD_MAGE_UNFAMILIAR_SPELL_ID",
ADD_ITEM = "ADD_ITEM",
ADD_ITEM_TEMPLATE = "ADD_ITEM_TEMPLATE",
@@ -1,4 +1,4 @@
import { List } from "../Data/List";
import { List } from "../../Data/List";
export enum Categories {
ADVANTAGES = "ADVANTAGES",
@@ -9,8 +9,12 @@ export enum IdPrefixes {
CULTURES = "C",
DISADVANTAGES = "DISADV",
EXPERIENCE_LEVELS = "EL",
HERO = "H",
HIT_ZONE_ARMOR = "ARMORZONES",
ITEM = "ITEM",
ITEM_TEMPLATE = "ITEMTPL",
LITURGICAL_CHANTS = "LITURGY",
PET = "PET",
PROFESSION_VARIANTS = "PV",
PROFESSIONS = "P",
RACE_VARIANTS = "RV",
+69
View File
@@ -0,0 +1,69 @@
import { connect } from "react-redux";
import { join } from "../../Data/Maybe";
import { Record } from "../../Data/Record";
import { ReduxDispatch } from "../Actions/Actions";
import * as ConfigActions from "../Actions/ConfigActions";
import * as DisAdvActions from "../Actions/DisAdvActions";
import { ActivatableActivationOptions } from "../Models/Actions/ActivatableActivationOptions";
import { ActivatableDeactivationOptions } from "../Models/Actions/ActivatableDeactivationOptions";
import { HeroModel } from "../Models/Hero/HeroModel";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAdvantagesRating, getFilteredActiveAdvantages } from "../Selectors/activatableSelectors";
import { getAPObjectMap, getMagicalAdvantagesDisadvantagesAdventurePointsMaximum } from "../Selectors/adventurePointsSelectors";
import { getFilteredInactiveAdvantages } from "../Selectors/combinedActivatablesSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getAdvantages, getAdvantagesFilterText, getInactiveAdvantagesFilterText, getWikiAdvantages } from "../Selectors/stateSelectors";
import { getAdvantagesDisadvantagesCultureRatingVisibility, getEnableActiveItemHints } from "../Selectors/uisettingsSelectors";
import { Advantages, AdvantagesDispatchProps, AdvantagesOwnProps, AdvantagesStateProps } from "../Views/DisAdvantages/Advantages";
const mapStateToProps =
(state: AppStateRecord, ownProps: AdvantagesOwnProps): AdvantagesStateProps => ({
activeList: getFilteredActiveAdvantages (state, ownProps),
ap: join (getAPObjectMap (HeroModel.A.id (ownProps.hero)) (state, ownProps)),
deactiveList:
join (getFilteredInactiveAdvantages (HeroModel.A.id (ownProps.hero)) (state, ownProps)),
enableActiveItemHints: getEnableActiveItemHints (state),
isRemovingEnabled: getIsRemovingEnabled (state),
stateEntries: getAdvantages (state),
wikiEntries: getWikiAdvantages (state),
magicalMax: getMagicalAdvantagesDisadvantagesAdventurePointsMaximum (state),
rating: getAdvantagesRating (state),
showRating: getAdvantagesDisadvantagesCultureRatingVisibility (state),
filterText: getAdvantagesFilterText (state),
inactiveFilterText: getInactiveAdvantagesFilterText (state),
})
const mapDispatchToProps = (
dispatch: ReduxDispatch,
{ l10n: locale }: AdvantagesOwnProps
): AdvantagesDispatchProps => ({
switchRatingVisibility () {
dispatch (DisAdvActions.switchRatingVisibility ())
},
switchActiveItemHints () {
dispatch (ConfigActions.switchEnableActiveItemHints ())
},
addToList (args: Record<ActivatableActivationOptions>) {
dispatch (DisAdvActions.addDisAdvantage (locale) (args))
},
removeFromList (args: Record<ActivatableDeactivationOptions>) {
dispatch (DisAdvActions.removeDisAdvantage (locale) (args))
},
setLevel (id: string, index: number, level: number) {
dispatch (DisAdvActions.setDisAdvantageLevel (locale) (id) (index) (level))
},
setFilterText (filterText: string) {
dispatch (DisAdvActions.setActiveAdvantagesFilterText (filterText))
},
setInactiveFilterText (filterText: string) {
dispatch (DisAdvActions.setInactiveAdvantagesFilterText (filterText))
},
})
const connectAdvantages =
connect<AdvantagesStateProps, AdvantagesDispatchProps, AdvantagesOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const AdvantagesContainer = connectAdvantages (Advantages)
+24
View File
@@ -0,0 +1,24 @@
import { connect } from "react-redux";
import { Action, Dispatch } from "redux";
import * as AlertActions from "../Actions/AlertActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getCurrentAlert } from "../Selectors/stateSelectors";
import { Alerts, AlertsDispatchProps, AlertsOwnProps, AlertsStateProps } from "../Views/Alerts/Alerts";
const mapStateToProps = (state: AppStateRecord) => ({
options: getCurrentAlert (state),
})
const mapDispatchToProps = (dispatch: Dispatch<Action>) => ({
close () {
dispatch (AlertActions.removeAlert ())
},
dispatch,
})
const connectAlertsContainer =
connect<AlertsStateProps, AlertsDispatchProps, AlertsOwnProps, AppStateRecord> (
mapStateToProps, mapDispatchToProps
)
export const AlertsContainer = connectAlertsContainer (Alerts)
+50
View File
@@ -0,0 +1,50 @@
import { ipcRenderer, remote } from "electron";
import { connect } from "react-redux";
import { Action } from "redux";
import { Nothing } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as IOActions from "../Actions/IOActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getCurrentHeroPresent, getCurrentTab, getLocaleMessages } from "../Selectors/stateSelectors";
import { areAnimationsEnabled, getTheme } from "../Selectors/uisettingsSelectors";
import { App, AppDispatchProps, AppOwnProps, AppStateProps } from "../Views/App";
const mapStateToProps = (state: AppStateRecord): AppStateProps => ({
currentTab: getCurrentTab (state),
mhero: getCurrentHeroPresent (state),
l10n: getLocaleMessages (state),
theme: getTheme (state),
areAnimationsEnabled: areAnimationsEnabled (state),
platform: remote.process.platform,
})
const mapDispatchToProps = (dispatch: ReduxDispatch<Action>) => ({
minimize () {
remote.getCurrentWindow ().minimize ()
},
maximize () {
remote.getCurrentWindow ().maximize ()
},
restore () {
remote.getCurrentWindow ().unmaximize ()
},
close () {
dispatch (IOActions.requestClose (Nothing))
},
enterFullscreen () {
remote.getCurrentWindow ().setFullScreen (true)
},
leaveFullscreen () {
remote.getCurrentWindow ().setFullScreen (false)
},
checkForUpdates () {
ipcRenderer.send ("check-for-updates")
},
})
const connectApp = connect<AppStateProps, AppDispatchProps, AppOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const AppContainer = connectApp (App)
+121
View File
@@ -0,0 +1,121 @@
import { connect } from "react-redux";
import { fromJust, isJust, Maybe } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as AttributesActions from "../Actions/AttributesActions";
import * as SubwindowsActions from "../Actions/SubwindowsActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAdjustmentValue, getAttributesForView, getAttributeSum, getAvailableAdjustmentIds } from "../Selectors/attributeSelectors";
import { getDerivedCharacteristics } from "../Selectors/derivedCharacteristicsSelectors";
import { getMaxTotalAttributeValues } from "../Selectors/elSelectors";
import { getIsInCharacterCreation, getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getAddPermanentEnergy, getCurrentAttributeAdjustmentId, getEditPermanentEnergy } from "../Selectors/stateSelectors";
import { Attributes, AttributesDispatchProps, AttributesOwnProps, AttributesStateProps } from "../Views/Attributes/Attributes";
const mapStateToProps =
(state: AppStateRecord, ownProps: AttributesOwnProps): AttributesStateProps => ({
adjustmentValue: getAdjustmentValue (state),
attributes: getAttributesForView (state),
availableAttributeIds: getAvailableAdjustmentIds (state),
currentAttributeId: getCurrentAttributeAdjustmentId (state),
isInCharacterCreation: getIsInCharacterCreation (state),
isRemovingEnabled: getIsRemovingEnabled (state),
derived: getDerivedCharacteristics (state, ownProps),
maxTotalAttributeValues: getMaxTotalAttributeValues (state),
sum: getAttributeSum (state, ownProps),
getEditPermanentEnergy: getEditPermanentEnergy (state),
getAddPermanentEnergy: getAddPermanentEnergy (state),
})
const mapDispatchToProps = (
dispatch: ReduxDispatch,
{ l10n }: AttributesOwnProps
): AttributesDispatchProps => ({
addPoint: (id: string) => {
dispatch (AttributesActions.addAttributePoint (l10n) (id))
},
removePoint: (id: string) => {
dispatch (AttributesActions.removeAttributePoint (id))
},
addLifePoint: () => {
dispatch (AttributesActions.addLifePoint (l10n))
},
addArcaneEnergyPoint: () => {
dispatch (AttributesActions.addArcaneEnergyPoint (l10n))
},
addKarmaPoint: () => {
dispatch (AttributesActions.addKarmaPoint (l10n))
},
removeLifePoint: () => {
dispatch (AttributesActions.removeLifePoint ())
},
removeArcaneEnergyPoint: () => {
dispatch (AttributesActions.removeArcaneEnergyPoint ())
},
removeKarmaPoint: () => {
dispatch (AttributesActions.removeKarmaPoint ())
},
addLostLPPoint: () => {
dispatch (AttributesActions.addLostLPPoint ())
},
removeLostLPPoint: () => {
dispatch (AttributesActions.removeLostLPPoint ())
},
addLostLPPoints: (value: number) => {
dispatch (AttributesActions.addLostLPPoints (value))
},
addBoughtBackAEPoint: () => {
dispatch (AttributesActions.addBoughtBackAEPoint (l10n))
},
removeBoughtBackAEPoint: () => {
dispatch (AttributesActions.removeBoughtBackAEPoint ())
},
addLostAEPoint: () => {
dispatch (AttributesActions.addLostAEPoint ())
},
removeLostAEPoint: () => {
dispatch (AttributesActions.removeLostAEPoint ())
},
addLostAEPoints: (value: number) => {
dispatch (AttributesActions.addLostAEPoints (value))
},
addBoughtBackKPPoint: () => {
dispatch (AttributesActions.addBoughtBackKPPoint (l10n))
},
removeBoughtBackKPPoint: () => {
dispatch (AttributesActions.removeBoughtBackKPPoint ())
},
addLostKPPoint: () => {
dispatch (AttributesActions.addLostKPPoint ())
},
removeLostKPPoint: () => {
dispatch (AttributesActions.removeLostKPPoint ())
},
addLostKPPoints: (value: number) => {
dispatch (AttributesActions.addLostKPPoints (value))
},
openAddPermanentEnergyLoss: (energy: "LP" | "AE" | "KP") => {
dispatch (SubwindowsActions.openAddPermanentEnergyLoss (energy))
},
closeAddPermanentEnergyLoss: () => {
dispatch (SubwindowsActions.closeAddPermanentEnergyLoss ())
},
openEditPermanentEnergy: (energy: "LP" | "AE" | "KP") => {
dispatch (SubwindowsActions.openEditPermanentEnergy (energy))
},
closeEditPermanentEnergy: () => {
dispatch (SubwindowsActions.closeEditPermanentEnergy ())
},
setAdjustmentId: (id: Maybe<string>) => {
if (isJust (id)) {
dispatch (AttributesActions.setAdjustmentId (fromJust (id)))
}
},
})
const connectAttributes =
connect<AttributesStateProps, AttributesDispatchProps, AttributesOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const AttributesContainer = connectAttributes (Attributes)
@@ -1,54 +1,54 @@
import { connect } from 'react-redux';
import { Action, Dispatch } from 'redux';
import * as CombatTechniquesActions from '../actions/CombatTechniquesActions';
import { AppState } from '../reducers/appReducer';
import { getAttributesForSheet } from '../selectors/attributeSelectors';
import { getFilteredCombatTechniques } from '../selectors/combatTechniquesSelectors';
import { getDerivedCharacteristicsMap } from '../selectors/derivedCharacteristicsSelectors';
import { getIsRemovingEnabled } from '../selectors/phaseSelectors';
import { getCombatTechniquesFilterText } from '../selectors/stateSelectors';
import { getCombatTechniquesSortOrder } from '../selectors/uisettingsSelectors';
import { CombatTechniques, CombatTechniquesDispatchProps, CombatTechniquesOwnProps, CombatTechniquesStateProps } from '../views/combatTechniques/CombatTechniques';
import { connect } from "react-redux";
import { ReduxDispatch } from "../Actions/Actions";
import * as CombatTechniquesActions from "../Actions/CombatTechniquesActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAttributesForSheet } from "../Selectors/attributeSelectors";
import { getFilteredCombatTechniques } from "../Selectors/combatTechniquesSelectors";
import { getDerivedCharacteristicsMap } from "../Selectors/derivedCharacteristicsSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getCombatTechniquesFilterText } from "../Selectors/stateSelectors";
import { getCombatTechniquesSortOrder } from "../Selectors/uisettingsSelectors";
import { CombatTechniques, CombatTechniquesDispatchProps, CombatTechniquesOwnProps, CombatTechniquesStateProps } from "../Views/CombatTechniques/CombatTechniques";
const mapStateToProps = (
state: AppState,
state: AppStateRecord,
ownProps: CombatTechniquesOwnProps
): CombatTechniquesStateProps => ({
attributes: getAttributesForSheet (state),
attributes: getAttributesForSheet (state, ownProps),
derivedCharacteristics: getDerivedCharacteristicsMap (state, ownProps),
isRemovingEnabled: getIsRemovingEnabled (state),
list: getFilteredCombatTechniques (state, ownProps),
sortOrder: getCombatTechniquesSortOrder (state),
filterText: getCombatTechniquesFilterText (state),
});
})
const mapDispatchToProps = (
dispatch: Dispatch<Action, AppState>,
{ locale }: CombatTechniquesOwnProps
dispatch: ReduxDispatch,
{ l10n }: CombatTechniquesOwnProps
) => ({
addPoint (id: string) {
dispatch (CombatTechniquesActions.addCombatTechniquePoint (locale) (id));
dispatch (CombatTechniquesActions.addCombatTechniquePoint (l10n) (id))
},
removePoint (id: string) {
dispatch (CombatTechniquesActions.removeCombatTechniquePoint (id));
dispatch (CombatTechniquesActions.removeCombatTechniquePoint (id))
},
setSortOrder (sortOrder: string) {
dispatch (CombatTechniquesActions.setCombatTechniquesSortOrder (sortOrder));
dispatch (CombatTechniquesActions.setCombatTechniquesSortOrder (sortOrder))
},
setFilterText (filterText: string) {
dispatch (CombatTechniquesActions.setCombatTechniquesFilterText (filterText));
dispatch (CombatTechniquesActions.setCombatTechniquesFilterText (filterText))
},
});
})
export const connectCombatTechniques =
const connectCombatTechniques =
connect<
CombatTechniquesStateProps,
CombatTechniquesDispatchProps,
CombatTechniquesOwnProps,
AppState
AppStateRecord
> (
mapStateToProps,
mapDispatchToProps
);
)
export const CombatTechniquesContainer = connectCombatTechniques (CombatTechniques);
export const CombatTechniquesContainer = connectCombatTechniques (CombatTechniques)
+48
View File
@@ -0,0 +1,48 @@
import { connect } from "react-redux";
import { ReduxDispatch } from "../Actions/Actions";
import * as CultureActions from "../Actions/CultureActions";
import { setTab } from "../Actions/LocationActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getFilteredCultures } from "../Selectors/rcpSelectors";
import { getCulturesFilterText, getCurrentCultureId } from "../Selectors/stateSelectors";
import { getCulturesSortOrder, getCulturesVisibilityFilter } from "../Selectors/uisettingsSelectors";
import { TabId } from "../Utilities/LocationUtils";
import { Cultures, CulturesDispatchProps, CulturesOwnProps, CulturesStateProps } from "../Views/Cultures/Cultures";
const mapStateToProps =
(state: AppStateRecord, ownProps: CulturesOwnProps): CulturesStateProps => ({
cultures: getFilteredCultures (state, ownProps),
currentId: getCurrentCultureId (state),
sortOrder: getCulturesSortOrder (state),
visibilityFilter: getCulturesVisibilityFilter (state),
filterText: getCulturesFilterText (state),
})
const mapDispatchToProps = (dispatch: ReduxDispatch): CulturesDispatchProps => ({
selectCulture (id: string) {
dispatch (CultureActions.selectCulture (id))
},
setSortOrder (sortOrder: string) {
dispatch (CultureActions.setSortOrder (sortOrder))
},
setVisibilityFilter (sortOrder: string) {
dispatch (CultureActions.setVisibilityFilter (sortOrder))
},
switchValueVisibilityFilter () {
dispatch (CultureActions.switchValueVisibilityFilter ())
},
setFilterText (filterText: string) {
dispatch (CultureActions.setFilterText (filterText))
},
switchToProfessions () {
dispatch (setTab (TabId.Professions))
},
})
const connectCultures =
connect<CulturesStateProps, CulturesDispatchProps, CulturesOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const CulturesContainer = connectCultures (Cultures)
@@ -0,0 +1,75 @@
import { connect } from "react-redux";
import { join } from "../../Data/Maybe";
import { Record } from "../../Data/Record";
import { ReduxDispatch } from "../Actions/Actions";
import * as ConfigActions from "../Actions/ConfigActions";
import * as DisAdvActions from "../Actions/DisAdvActions";
import { ActivatableActivationOptions } from "../Models/Actions/ActivatableActivationOptions";
import { ActivatableDeactivationOptions } from "../Models/Actions/ActivatableDeactivationOptions";
import { HeroModel } from "../Models/Hero/HeroModel";
import { AppStateRecord } from "../Reducers/appReducer";
import { getDisadvantagesRating, getFilteredActiveDisadvantages } from "../Selectors/activatableSelectors";
import { getAPObjectMap, getMagicalAdvantagesDisadvantagesAdventurePointsMaximum } from "../Selectors/adventurePointsSelectors";
import { getFilteredInactiveDisadvantages } from "../Selectors/combinedActivatablesSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getDisadvantages, getDisadvantagesFilterText, getInactiveDisadvantagesFilterText, getWikiDisadvantages } from "../Selectors/stateSelectors";
import { getAdvantagesDisadvantagesCultureRatingVisibility, getEnableActiveItemHints } from "../Selectors/uisettingsSelectors";
import { Disadvantages, DisadvantagesDispatchProps, DisadvantagesOwnProps, DisadvantagesStateProps } from "../Views/DisAdvantages/Disadvantages";
const mapStateToProps =
(state: AppStateRecord, ownProps: DisadvantagesOwnProps): DisadvantagesStateProps => ({
activeList: getFilteredActiveDisadvantages (state, ownProps),
ap: join (getAPObjectMap (HeroModel.A.id (ownProps.hero)) (state, ownProps)),
deactiveList:
join (getFilteredInactiveDisadvantages (HeroModel.A.id (ownProps.hero))
(state, ownProps)),
enableActiveItemHints: getEnableActiveItemHints (state),
isRemovingEnabled: getIsRemovingEnabled (state),
stateEntries: getDisadvantages (state),
wikiEntries: getWikiDisadvantages (state),
magicalMax: getMagicalAdvantagesDisadvantagesAdventurePointsMaximum (state),
rating: getDisadvantagesRating (state),
showRating: getAdvantagesDisadvantagesCultureRatingVisibility (state),
filterText: getDisadvantagesFilterText (state),
inactiveFilterText: getInactiveDisadvantagesFilterText (state),
})
const mapDispatchToProps = (
dispatch: ReduxDispatch,
{ l10n }: DisadvantagesOwnProps
): DisadvantagesDispatchProps => ({
switchRatingVisibility () {
dispatch (DisAdvActions.switchRatingVisibility ())
},
switchActiveItemHints () {
dispatch (ConfigActions.switchEnableActiveItemHints ())
},
addToList (args: Record<ActivatableActivationOptions>) {
dispatch (DisAdvActions.addDisAdvantage (l10n) (args))
},
removeFromList (args: Record<ActivatableDeactivationOptions>) {
dispatch (DisAdvActions.removeDisAdvantage (l10n) (args))
},
setLevel (id: string, index: number, level: number) {
dispatch (DisAdvActions.setDisAdvantageLevel (l10n) (id) (index) (level))
},
setFilterText (filterText: string) {
dispatch (DisAdvActions.setActiveDisadvantagesFilterText (filterText))
},
setInactiveFilterText (filterText: string) {
dispatch (DisAdvActions.setInactiveDisadvantagesFilterText (filterText))
},
})
const connectDisadvantages =
connect<
DisadvantagesStateProps,
DisadvantagesDispatchProps,
DisadvantagesOwnProps,
AppStateRecord
> (
mapStateToProps,
mapDispatchToProps
)
export const DisadvantagesContainer = connectDisadvantages (Disadvantages)
+15
View File
@@ -0,0 +1,15 @@
import { connect } from "react-redux";
import { AppStateRecord } from "../Reducers/appReducer";
import { getUpdateDownloadProgress } from "../Selectors/stateSelectors";
import { Downloader, DownloaderDispatchProps, DownloaderOwnProps, DownloaderStateProps } from "../Views/Downloader/Downloader";
const mapStateToProps = (state: AppStateRecord): DownloaderStateProps => ({
progress: getUpdateDownloadProgress (state),
})
const connectDownloader =
connect<DownloaderStateProps, DownloaderDispatchProps, DownloaderOwnProps, AppStateRecord> (
mapStateToProps
)
export const DownloaderContainer = connectDownloader (Downloader)
+82
View File
@@ -0,0 +1,82 @@
import { connect } from "react-redux";
import { Maybe } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as EquipmentActions from "../Actions/EquipmentActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getInitialStartingWealth } from "../Selectors/activatableSelectors";
import { getHasCurrentNoAddedAP } from "../Selectors/adventurePointsSelectors";
import { getCarryingCapacity } from "../Selectors/attributeSelectors";
import { getFilteredCombatTechniques } from "../Selectors/combatTechniquesSelectors";
import { getAvailableSortedEquipmentGroups, getFilteredItems, getFilteredItemTemplates, getTotalPrice, getTotalWeight } from "../Selectors/equipmentSelectors";
import { getEquipmentFilterText, getItemTemplatesFilterText, getPurse } from "../Selectors/stateSelectors";
import { getEquipmentSortOrder, getMeleeItemTemplateCombatTechniqueFilter, getRangedItemTemplateCombatTechniqueFilter } from "../Selectors/uisettingsSelectors";
import { Equipment, EquipmentDispatchProps, EquipmentOwnProps, EquipmentStateProps } from "../Views/Equipment/Equipment";
const mapStateToProps =
(state: AppStateRecord, ownProps: EquipmentOwnProps): EquipmentStateProps => ({
combatTechniques: getFilteredCombatTechniques (state, ownProps),
carryingCapacity: getCarryingCapacity (state, ownProps),
initialStartingWealth: getInitialStartingWealth (state),
items: getFilteredItems (state, ownProps),
hasNoAddedAP: getHasCurrentNoAddedAP (state),
purse: getPurse (state),
sortOrder: getEquipmentSortOrder (state),
templates: getFilteredItemTemplates (state, ownProps),
totalPrice: getTotalPrice (state, ownProps),
totalWeight: getTotalWeight (state, ownProps),
meleeItemTemplateCombatTechniqueFilter: getMeleeItemTemplateCombatTechniqueFilter (state),
rangedItemTemplateCombatTechniqueFilter: getRangedItemTemplateCombatTechniqueFilter (state),
filterText: getEquipmentFilterText (state),
templatesFilterText: getItemTemplatesFilterText (state),
filteredEquipmentGroups: getAvailableSortedEquipmentGroups (state, ownProps),
})
const mapDispatchToProps = (dispatch: ReduxDispatch): EquipmentDispatchProps => ({
addTemplateToList (id: string): void {
dispatch (EquipmentActions.addTemplateToList (id))
},
createItem (): void {
dispatch (EquipmentActions.createItem ())
},
editItem (id: string): void {
dispatch (EquipmentActions.editItem (id))
},
deleteItem (id: string) {
dispatch (EquipmentActions.removeItem (id))
},
setSortOrder (option: string) {
dispatch (EquipmentActions.setItemsSortOrder (option))
},
setDucates (value: string) {
dispatch (EquipmentActions.setDucates (value))
},
setSilverthalers (value: string) {
dispatch (EquipmentActions.setSilverthalers (value))
},
setHellers (value: string) {
dispatch (EquipmentActions.setHellers (value))
},
setKreutzers (value: string) {
dispatch (EquipmentActions.setKreutzers (value))
},
setMeleeItemTemplatesCombatTechniqueFilter (filterOption: Maybe<string>) {
dispatch (EquipmentActions.setMeleeItemTemplatesCombatTechniqueFilter (filterOption))
},
setRangedItemTemplatesCombatTechniqueFilter (filterOption: Maybe<string>) {
dispatch (EquipmentActions.setRangedItemTemplatesCombatTechniqueFilter (filterOption))
},
setFilterText (filterText: string) {
dispatch (EquipmentActions.setEquipmentFilterText (filterText))
},
setTemplatesFilterText (filterText: string) {
dispatch (EquipmentActions.setItemTemplatesFilterText (filterText))
},
})
export const connectEquipment =
connect<EquipmentStateProps, EquipmentDispatchProps, EquipmentOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const EquipmentContainer = connectEquipment (Equipment)
+14
View File
@@ -0,0 +1,14 @@
import { connect } from "react-redux";
import { AppStateRecord } from "../Reducers/appReducer";
import { Help, HelpDispatchProps, HelpOwnProps, HelpStateProps } from "../Views/Help/Help";
const mapStateToProps = () => ({})
const mapDispatchToProps = () => ({})
const connectHelp = connect<HelpStateProps, HelpDispatchProps, HelpOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const HelpContainer = connectHelp (Help)
+97
View File
@@ -0,0 +1,97 @@
import { connect } from "react-redux";
import { Action } from "redux";
import { fromJust, isJust, Just, Maybe } from "../../Data/Maybe";
import { OrderedSet } from "../../Data/OrderedSet";
import { ReduxDispatch } from "../Actions/Actions";
import * as HerolistActions from "../Actions/HerolistActions";
import * as IOActions from "../Actions/IOActions";
import * as LocationActions from "../Actions/LocationActions";
import * as SubwindowsActions from "../Actions/SubwindowsActions";
import { InputTextEvent } from "../Models/Hero/heroTypeHelpers";
import { AppStateRecord } from "../Reducers/appReducer";
import { getSortedBooks } from "../Selectors/bookSelectors";
import { getSortedHerolist, getUnsavedHeroesById } from "../Selectors/herolistSelectors";
import { getCurrentHeroPresent, getHerolistFilterText, getIsCharacterCreatorOpen, getUsers, getWiki, getWikiExperienceLevels } from "../Selectors/stateSelectors";
import { getHerolistSortOrder, getHerolistVisibilityFilter } from "../Selectors/uisettingsSelectors";
import { TabId } from "../Utilities/LocationUtils";
import { Herolist, HerolistDispatchProps, HerolistOwnProps, HerolistStateProps } from "../Views/Heroes/Herolist";
const mapStateToProps = (state: AppStateRecord, props: HerolistOwnProps) => ({
currentHero: getCurrentHeroPresent (state),
experienceLevels: getWikiExperienceLevels (state),
filterText: getHerolistFilterText (state),
list: getSortedHerolist (state, props),
unsavedHeroesById: getUnsavedHeroesById (state),
users: getUsers (state),
sortOrder: getHerolistSortOrder (state),
visibilityFilter: getHerolistVisibilityFilter (state),
isCharacterCreatorOpen: getIsCharacterCreatorOpen (state),
sortedBooks: getSortedBooks (state, props),
wiki: getWiki (state),
})
const mapDispatchToProps = (
dispatch: ReduxDispatch<Action>,
{ l10n }: HerolistOwnProps
) => ({
loadHero (id: string) {
dispatch (HerolistActions.loadHero (id))
},
showHero () {
dispatch (LocationActions.setTab (TabId.Profile))
},
saveHero (id: string) {
dispatch (HerolistActions.saveHero (l10n) (Just (id)))
},
saveHeroAsJSON (id: string) {
dispatch (HerolistActions.exportHeroValidate (l10n) (id))
},
deleteHero (id: string) {
dispatch (HerolistActions.deleteHeroValidate (l10n) (id))
},
duplicateHero (id: string) {
dispatch (HerolistActions.duplicateHero (id))
},
createHero (
name: string,
sex: "m" | "f",
el: string,
enableAllRuleBooks: boolean,
enabledRuleBooks: OrderedSet<string>
) {
dispatch (HerolistActions.createHero (l10n)
(name)
(sex)
(el)
(enableAllRuleBooks)
(enabledRuleBooks))
},
importHero () {
dispatch (IOActions.requestHeroImport (l10n))
},
setSortOrder (id: string) {
dispatch (HerolistActions.setHerolistSortOrder (id))
},
setFilterText (event: InputTextEvent) {
dispatch (HerolistActions.setHerolistFilterText (event.target.value))
},
setVisibilityFilter (id: Maybe<string>) {
if (isJust (id)) {
dispatch (HerolistActions.setHerolistVisibilityFilter (fromJust (id)))
}
},
openCharacterCreator () {
dispatch (SubwindowsActions.openCharacterCreator ())
},
closeCharacterCreator () {
dispatch (SubwindowsActions.closeCharacterCreator ())
},
})
const connectHerolist =
connect<HerolistStateProps, HerolistDispatchProps, HerolistOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const HerolistContainer = connectHerolist (Herolist)
@@ -0,0 +1,52 @@
import { connect } from "react-redux";
import { Action } from "redux";
import { join, Just } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as HerolistActions from "../Actions/HerolistActions";
import * as LocationActions from "../Actions/LocationActions";
import { HeroModel } from "../Models/Hero/HeroModel";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAPObjectMap } from "../Selectors/adventurePointsSelectors";
import { getUnsavedHeroesById } from "../Selectors/herolistSelectors";
import { getUsers, getWiki } from "../Selectors/stateSelectors";
import { TabId } from "../Utilities/LocationUtils";
import { HerolistItem, HerolistItemDispatchProps, HerolistItemOwnProps, HerolistItemStateProps } from "../Views/Heroes/HerolistItem";
const mapStateToProps = (state: AppStateRecord, props: HerolistItemOwnProps) => ({
ap: join (getAPObjectMap (HeroModel.A.id (props .hero)) (state, props)),
unsavedHeroesById: getUnsavedHeroesById (state),
users: getUsers (state),
wiki: getWiki (state),
})
const mapDispatchToProps = (
dispatch: ReduxDispatch<Action>,
{ l10n }: HerolistItemOwnProps
) => ({
loadHero (id: string) {
dispatch (HerolistActions.loadHero (id))
},
showHero () {
dispatch (LocationActions.setTab (TabId.Profile))
},
saveHero (id: string) {
dispatch (HerolistActions.saveHero (l10n) (Just (id)))
},
saveHeroAsJSON (id: string) {
dispatch (HerolistActions.exportHeroValidate (l10n) (id))
},
deleteHero (id: string) {
dispatch (HerolistActions.deleteHeroValidate (l10n) (id))
},
duplicateHero (id: string) {
dispatch (HerolistActions.duplicateHero (id))
},
})
const connectHerolistItem =
connect<HerolistItemStateProps, HerolistItemDispatchProps, HerolistItemOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const HerolistItemContainer = connectHerolistItem (HerolistItem)
@@ -0,0 +1,114 @@
import { connect } from "react-redux";
import { Maybe } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as EquipmentActions from "../Actions/EquipmentActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getInitialStartingWealth } from "../Selectors/activatableSelectors";
import { getHasCurrentNoAddedAP } from "../Selectors/adventurePointsSelectors";
import { getCarryingCapacity } from "../Selectors/attributeSelectors";
import { getFilteredHitZoneArmors, getItems, getTemplates, getTotalPrice, getTotalWeight } from "../Selectors/equipmentSelectors";
import { getArmorZonesEditorInstance, getIsInHitZoneArmorCreation, getPurse, getZoneArmorFilterText } from "../Selectors/stateSelectors";
import { HitZoneArmors, HitZoneArmorsDispatchProps, HitZoneArmorsOwnProps, HitZoneArmorsStateProps } from "../Views/HitZoneArmors/HitZoneArmors";
const mapStateToProps = (
state: AppStateRecord,
ownProps: HitZoneArmorsOwnProps
): HitZoneArmorsStateProps => ({
armorZones: getFilteredHitZoneArmors (state, ownProps),
carryingCapacity: getCarryingCapacity (state, ownProps),
initialStartingWealth: getInitialStartingWealth (state),
items: getItems (state),
isInHitZoneArmorCreation: getIsInHitZoneArmorCreation (state),
armorZonesEditor: getArmorZonesEditorInstance (state),
hasNoAddedAP: getHasCurrentNoAddedAP (state),
purse: getPurse (state),
templates: getTemplates (state),
totalPrice: getTotalPrice (state, ownProps),
totalWeight: getTotalWeight (state, ownProps),
filterText: getZoneArmorFilterText (state),
})
const mapDispatchToProps = (dispatch: ReduxDispatch): HitZoneArmorsDispatchProps => ({
addToList () {
dispatch (EquipmentActions.addArmorZonesToList ())
},
createItem (): void {
dispatch (EquipmentActions.createArmorZones ())
},
editItem (id: string): void {
dispatch (EquipmentActions.editArmorZones (id))
},
deleteItem (id: string) {
dispatch (EquipmentActions.removeArmorZonesFromList (id))
},
closeEditor (): void {
dispatch (EquipmentActions.closeArmorZonesEditor ())
},
saveItem (): void {
dispatch (EquipmentActions.saveArmorZones ())
},
setDucates (value: string) {
dispatch (EquipmentActions.setDucates (value))
},
setSilverthalers (value: string) {
dispatch (EquipmentActions.setSilverthalers (value))
},
setHellers (value: string) {
dispatch (EquipmentActions.setHellers (value))
},
setKreutzers (value: string) {
dispatch (EquipmentActions.setKreutzers (value))
},
setName (value: string): void {
dispatch (EquipmentActions.setArmorZonesName (value))
},
setHead (id: Maybe<string>): void {
dispatch (EquipmentActions.setArmorZonesHead (id))
},
setHeadLoss (id: Maybe<number>): void {
dispatch (EquipmentActions.setArmorZonesHeadLoss (id))
},
setLeftArm (id: Maybe<string>): void {
dispatch (EquipmentActions.setArmorZonesLeftArm (id))
},
setLeftArmLoss (id: Maybe<number>): void {
dispatch (EquipmentActions.setArmorZonesLeftArmLoss (id))
},
setLeftLeg (id: Maybe<string>): void {
dispatch (EquipmentActions.setArmorZonesLeftLeg (id))
},
setLeftLegLoss (id: Maybe<number>): void {
dispatch (EquipmentActions.setArmorZonesLeftLegLoss (id))
},
setTorso (id: Maybe<string>): void {
dispatch (EquipmentActions.setArmorZonesTorso (id))
},
setTorsoLoss (id: Maybe<number>): void {
dispatch (EquipmentActions.setArmorZonesTorsoLoss (id))
},
setRightArm (id: Maybe<string>): void {
dispatch (EquipmentActions.setArmorZonesRightArm (id))
},
setRightArmLoss (id: Maybe<number>): void {
dispatch (EquipmentActions.setArmorZonesRightArmLoss (id))
},
setRightLeg (id: Maybe<string>): void {
dispatch (EquipmentActions.setArmorZonesRightLeg (id))
},
setRightLegLoss (id: Maybe<number>): void {
dispatch (EquipmentActions.setArmorZonesRightLegLoss (id))
},
setFilterText (filterText: string) {
dispatch (EquipmentActions.setZoneArmorFilterText (filterText))
},
})
export const connectHitZoneArmors =
connect<
HitZoneArmorsStateProps, HitZoneArmorsDispatchProps, HitZoneArmorsOwnProps, AppStateRecord
> (
mapStateToProps,
mapDispatchToProps
)
export const HitZoneArmorsContainer = connectHitZoneArmors (HitZoneArmors)
@@ -1,12 +1,12 @@
import { connect } from 'react-redux';
import { ActivatableAddListItem, ActivatableAddListItemDispatchProps, ActivatableAddListItemOwnProps, ActivatableAddListItemStateProps } from '../components/ActivatableAddListItem';
import { AppState } from '../reducers/appReducer';
import { getSkills, getWiki } from '../selectors/stateSelectors';
import { connect } from "react-redux";
import { AppStateRecord } from "../Reducers/appReducer";
import { getSkills, getWiki } from "../Selectors/stateSelectors";
import { ActivatableAddListItem, ActivatableAddListItemDispatchProps, ActivatableAddListItemOwnProps, ActivatableAddListItemStateProps } from "../Views/Activatable/ActivatableAddListItem";
const mapStateToProps = (state: AppState): ActivatableAddListItemStateProps => ({
const mapStateToProps = (state: AppStateRecord): ActivatableAddListItemStateProps => ({
skills: getSkills (state),
wiki: getWiki (state),
});
})
export const connectActivatableAddListItem =
@@ -14,9 +14,9 @@ export const connectActivatableAddListItem =
ActivatableAddListItemStateProps,
ActivatableAddListItemDispatchProps,
ActivatableAddListItemOwnProps,
AppState
AppStateRecord
>
(mapStateToProps);
(mapStateToProps)
export const ActivatableAddListItemContainer =
connectActivatableAddListItem (ActivatableAddListItem);
connectActivatableAddListItem (ActivatableAddListItem)
+157
View File
@@ -0,0 +1,157 @@
import { connect } from "react-redux";
import { Maybe } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as EquipmentActions from "../Actions/EquipmentActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getSortedTemplates } from "../Selectors/equipmentSelectors";
import { getIsItemCreation, getItemEditorInstance, getWikiAttributes, getWikiCombatTechniques } from "../Selectors/stateSelectors";
import { ItemEditor, ItemEditorDispatchProps, ItemEditorOwnProps, ItemEditorStateProps } from "../Views/Equipment/ItemEditor";
const mapStateToProps =
(state: AppStateRecord, ownProps: ItemEditorOwnProps): ItemEditorStateProps => ({
attributes: getWikiAttributes (state),
combatTechniques: getWikiCombatTechniques (state),
isInCreation: getIsItemCreation (state),
item: getItemEditorInstance (state),
templates: getSortedTemplates (state, ownProps),
})
const mapDispatchToProps = (dispatch: ReduxDispatch): ItemEditorDispatchProps => ({
addToList (): void {
dispatch (EquipmentActions.addItem)
},
closeEditor (): void {
dispatch (EquipmentActions.closeItemEditor ())
},
saveItem (): void {
dispatch (EquipmentActions.saveItem ())
},
setName (value: string): void {
dispatch (EquipmentActions.setName (value))
},
setPrice (value: string): void {
dispatch (EquipmentActions.setPrice (value))
},
setWeight (value: string): void {
dispatch (EquipmentActions.setWeight (value))
},
setAmount (value: string): void {
dispatch (EquipmentActions.setAmount (value))
},
setWhere (value: string): void {
dispatch (EquipmentActions.setWhere (value))
},
setGroup (gr: number): void {
dispatch (EquipmentActions.setGroup (gr))
},
setTemplate (template: string): void {
dispatch (EquipmentActions.setTemplate (template))
},
setCombatTechnique (id: string): void {
dispatch (EquipmentActions.setCombatTechnique (id))
},
setDamageDiceNumber (value: string): void {
dispatch (EquipmentActions.setDamageDiceNumber (value))
},
setDamageDiceSides (value: number): void {
dispatch (EquipmentActions.setDamageDiceSides (value))
},
setDamageFlat (value: string): void {
dispatch (EquipmentActions.setDamageFlat (value))
},
setPrimaryAttribute (primary: Maybe<string>): void {
dispatch (EquipmentActions.setPrimaryAttribute (primary))
},
setDamageThreshold (value: string): void {
dispatch (EquipmentActions.setDamageThreshold (value))
},
setFirstDamageThreshold (value: string): void {
dispatch (EquipmentActions.setFirstDamageThreshold (value))
},
setSecondDamageThreshold (value: string): void {
dispatch (EquipmentActions.setSecondDamageThreshold (value))
},
switchIsDamageThresholdSeparated (): void {
dispatch (EquipmentActions.switchIsDamageThresholdSeparated ())
},
setAttack (value: string): void {
dispatch (EquipmentActions.setAttack (value))
},
setParry (value: string): void {
dispatch (EquipmentActions.setParry (value))
},
setReach (id: number): void {
dispatch (EquipmentActions.setReach (id))
},
setLength (value: string): void {
dispatch (EquipmentActions.setLength (value))
},
setStructurePoints (value: string): void {
dispatch (EquipmentActions.setStructurePoints (value))
},
setRange (index: 1 | 2 | 3): (value: string) => void {
return value => dispatch (EquipmentActions.setRange (value, index))
},
setReloadTime (value: string): void {
dispatch (EquipmentActions.setReloadTime (value))
},
setAmmunition (id: string): void {
dispatch (EquipmentActions.setAmmunition (id))
},
setProtection (value: string): void {
dispatch (EquipmentActions.setProtection (value))
},
setEncumbrance (value: string): void {
dispatch (EquipmentActions.setEncumbrance (value))
},
setMovementModifier (value: string): void {
dispatch (EquipmentActions.setMovementModifier (value))
},
setInitiativeModifier (value: string): void {
dispatch (EquipmentActions.setInitiativeModifier (value))
},
setStabilityModifier (value: string): void {
dispatch (EquipmentActions.setStabilityModifier (value))
},
switchIsParryingWeapon (): void {
dispatch (EquipmentActions.switchIsParryingWeapon ())
},
switchIsTwoHandedWeapon (): void {
dispatch (EquipmentActions.switchIsTwoHandedWeapon ())
},
switchIsImprovisedWeapon (): void {
dispatch (EquipmentActions.switchIsImprovisedWeapon ())
},
setImprovisedWeaponGroup (gr: number): void {
dispatch (EquipmentActions.setImprovisedWeaponGroup (gr))
},
setLoss (id: Maybe<number>): void {
dispatch (EquipmentActions.setLoss (id))
},
switchIsForArmorZonesOnly (): void {
dispatch (EquipmentActions.switchIsForArmorZonesOnly ())
},
setHasAdditionalPenalties (): void {
dispatch (EquipmentActions.setHasAdditionalPenalties ())
},
setArmorType (id: number): void {
dispatch (EquipmentActions.setArmorType (id))
},
applyTemplate (): void {
dispatch (EquipmentActions.applyItemTemplate)
},
lockTemplate (): void {
dispatch (EquipmentActions.lockItemTemplate)
},
unlockTemplate (): void {
dispatch (EquipmentActions.unlockItemTemplate ())
},
})
export const connectItemEditor =
connect<ItemEditorStateProps, ItemEditorDispatchProps, ItemEditorOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const ItemEditorContainer = connectItemEditor (ItemEditor)
@@ -0,0 +1,76 @@
import { connect } from "react-redux";
import { ReduxDispatch } from "../Actions/Actions";
import * as ConfigActions from "../Actions/ConfigActions";
import * as LiturgicalChantActions from "../Actions/LiturgicalChantActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAttributesForSheet } from "../Selectors/attributeSelectors";
import { getDerivedCharacteristicsMap } from "../Selectors/derivedCharacteristicsSelectors";
import { getBlessedTraditionNumericId, getFilteredActiveLiturgicalChantsAndBlessings, getFilteredInactiveLiturgicalChantsAndBlessings, isActivationDisabled } from "../Selectors/liturgicalChantsSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getInactiveLiturgicalChantsFilterText, getLiturgicalChantsFilterText } from "../Selectors/stateSelectors";
import { getEnableActiveItemHints, getLiturgiesSortOrder } from "../Selectors/uisettingsSelectors";
import { LiturgicalChants, LiturgicalChantsDispatchProps, LiturgicalChantsOwnProps, LiturgicalChantsStateProps } from "../Views/LiturgicalChants/LiturgicalChants";
const mapStateToProps = (
state: AppStateRecord,
ownProps: LiturgicalChantsOwnProps
): LiturgicalChantsStateProps => ({
attributes: getAttributesForSheet (state, ownProps),
addChantsDisabled: isActivationDisabled (state, ownProps),
derivedCharacteristics: getDerivedCharacteristicsMap (state, ownProps),
enableActiveItemHints: getEnableActiveItemHints (state),
isRemovingEnabled: getIsRemovingEnabled (state),
activeList: getFilteredActiveLiturgicalChantsAndBlessings (state, ownProps),
inactiveList: getFilteredInactiveLiturgicalChantsAndBlessings (state, ownProps),
sortOrder: getLiturgiesSortOrder (state),
traditionId: getBlessedTraditionNumericId (state, ownProps),
filterText: getLiturgicalChantsFilterText (state),
inactiveFilterText: getInactiveLiturgicalChantsFilterText (state),
})
const mapDispatchToProps =
(dispatch: ReduxDispatch, { l10n }: LiturgicalChantsOwnProps): LiturgicalChantsDispatchProps => ({
addPoint (id: string) {
dispatch (LiturgicalChantActions.addLiturgicalChantPoint (l10n) (id))
},
addToList (id: string) {
dispatch (LiturgicalChantActions.addLiturgicalChant (l10n) (id))
},
addBlessingToList (id: string) {
dispatch (LiturgicalChantActions.addBlessing (l10n) (id))
},
removePoint (id: string) {
dispatch (LiturgicalChantActions.removeLiturgicalChantPoint (id))
},
removeFromList (id: string) {
dispatch (LiturgicalChantActions.removeLiturgicalChant (id))
},
removeBlessingFromList (id: string) {
dispatch (LiturgicalChantActions.removeBlessing (id))
},
setSortOrder (sortOrder: string) {
dispatch (LiturgicalChantActions.setLiturgicalChantsSortOrder (sortOrder))
},
switchActiveItemHints () {
dispatch (ConfigActions.switchEnableActiveItemHints ())
},
setFilterText (filterText: string) {
dispatch (LiturgicalChantActions.setActiveLiturgicalChantsFilterText (filterText))
},
setInactiveFilterText (filterText: string) {
dispatch (LiturgicalChantActions.setInactiveLiturgicalChantsFilterText (filterText))
},
})
export const connectLiturgicalChants =
connect<
LiturgicalChantsStateProps,
LiturgicalChantsDispatchProps,
LiturgicalChantsOwnProps,
AppStateRecord
> (
mapStateToProps,
mapDispatchToProps
)
export const LiturgicalChantsContainer = connectLiturgicalChants (LiturgicalChants)
@@ -0,0 +1,75 @@
import { connect } from "react-redux";
import { bind, join, Nothing } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as HerolistActions from "../Actions/HerolistActions";
import * as HistoryActions from "../Actions/HistoryActions";
import * as InGameActions from "../Actions/InGameActions";
import * as LocationActions from "../Actions/LocationActions";
import * as SubwindowsActions from "../Actions/SubwindowsActions";
import { HeroModel } from "../Models/Hero/HeroModel";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAPObjectMap, getMagicalAdvantagesDisadvantagesAdventurePointsMaximum } from "../Selectors/adventurePointsSelectors";
import { getRedoAvailability, getUndoAvailability } from "../Selectors/currentHeroSelectors";
import { getIsLiturgicalChantsTabAvailable } from "../Selectors/liturgicalChantsSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getIsSpellsTabAvailable } from "../Selectors/spellsSelectors";
import { getAvatar, getCurrentTab, getIsSettingsOpen } from "../Selectors/stateSelectors";
import { getIsHeroSection, getSubtabs, getTabs } from "../Selectors/uilocationSelectors";
import { TabId } from "../Utilities/LocationUtils";
import { NavigationBar, NavigationBarDispatchProps, NavigationBarOwnProps, NavigationBarStateProps } from "../Views/NavBar/NavigationBar";
const mapStateToProps =
(state: AppStateRecord, ownProps: NavigationBarOwnProps): NavigationBarStateProps => ({
currentTab: getCurrentTab (state),
avatar: getAvatar (state),
isRedoAvailable: getRedoAvailability (state),
isUndoAvailable: getUndoAvailability (state),
isRemovingEnabled: getIsRemovingEnabled (state),
isSettingsOpen: getIsSettingsOpen (state),
isHeroSection: getIsHeroSection (state),
tabs: getTabs (state, ownProps),
subtabs: getSubtabs (state, ownProps),
adventurePoints: join (bind (ownProps.mhero)
(hero => getAPObjectMap (HeroModel.A.id (hero)) (state, ownProps))),
maximumForMagicalAdvantagesDisadvantages:
getMagicalAdvantagesDisadvantagesAdventurePointsMaximum (state),
isSpellcaster: getIsSpellsTabAvailable (state, ownProps),
isBlessedOne: getIsLiturgicalChantsTabAvailable (state, ownProps),
})
const mapDispatchToProps = (dispatch: ReduxDispatch, ownProps: NavigationBarOwnProps) => ({
setTab (id: TabId) {
dispatch (LocationActions.setTab (id))
},
undo () {
dispatch (HistoryActions.undo ())
},
redo () {
dispatch (HistoryActions.redo ())
},
saveHero () {
dispatch (HerolistActions.saveHero (ownProps.l10n) (Nothing))
},
openSettings () {
dispatch (SubwindowsActions.openSettings ())
},
closeSettings () {
dispatch (SubwindowsActions.closeSettings ())
},
saveGroup () {
dispatch (InGameActions._save ())
},
})
const connectNavigationBarContainer =
connect<
NavigationBarStateProps,
NavigationBarDispatchProps,
NavigationBarOwnProps,
AppStateRecord
> (
mapStateToProps,
mapDispatchToProps
)
export const NavigationBarContainer = connectNavigationBarContainer (NavigationBar)
+47
View File
@@ -0,0 +1,47 @@
import { connect } from "react-redux";
import { Maybe } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as PactActions from "../Actions/PactActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getIsPactValid, isPactEditable } from "../Selectors/pactSelectors";
import { getPact } from "../Selectors/stateSelectors";
import { PactSettings, PactSettingsDispatchProps, PactSettingsOwnProps, PactSettingsStateProps } from "../Views/Pact/Pact";
const mapStateToProps =
(state: AppStateRecord, ownProps: PactSettingsOwnProps): PactSettingsStateProps => ({
pact: getPact (state),
isPactValid: getIsPactValid (state),
isPactEditable: isPactEditable (state, ownProps),
})
const mapDispatchToProps = (dispatch: ReduxDispatch): PactSettingsDispatchProps => ({
setPactCategory (category: Maybe<number>) {
dispatch (PactActions.setPactCategory (category))
},
setPactLevel (level: Maybe<number>) {
if (Maybe.isJust (level)) {
dispatch (PactActions.setPactLevel (Maybe.fromJust (level)))
}
},
setTargetType (type: Maybe<number>) {
if (Maybe.isJust (type)) {
dispatch (PactActions.setPactTargetType (Maybe.fromJust (type)))
}
},
setTargetDomain (domain: Maybe<number | string>) {
if (Maybe.isJust (domain)) {
dispatch (PactActions.setPactTargetDomain (Maybe.fromJust (domain)))
}
},
setTargetName (name: string) {
dispatch (PactActions.setPactTargetName (name))
},
})
const connectPact =
connect<PactSettingsStateProps, PactSettingsDispatchProps, PactSettingsOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const PactContainer = connectPact (PactSettings)
+137
View File
@@ -0,0 +1,137 @@
import { connect } from "react-redux";
import { fmapF } from "../../Data/Functor";
import { join, Maybe, Nothing } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as ProfileActions from "../Actions/ProfileActions";
import * as SubwindowsActions from "../Actions/SubwindowsActions";
import { HeroModel } from "../Models/Hero/HeroModel";
import { InputTextEvent } from "../Models/Hero/heroTypeHelpers";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAdvantagesForSheet, getDisadvantagesForSheet, isAlbino } from "../Selectors/activatableSelectors";
import { getAvailableAPMap } from "../Selectors/adventurePointsSelectors";
import { getStartEl } from "../Selectors/elSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getCurrentCulture, getCurrentFullProfessionName, getCurrentProfession, getCurrentProfessionVariant, getCurrentRace, getCurrentRaceVariant, getRandomSizeCalcStr, getRandomWeightCalcStr } from "../Selectors/rcpSelectors";
import { getAvatar, getCurrentHeroName, getCustomProfessionName, getIsAddAdventurePointsOpen, getIsEditCharacterAvatarOpen, getPhase, getProfile, getSex, getTotalAdventurePoints } from "../Selectors/stateSelectors";
import { getIsEditingHeroAfterCreationPhaseEnabled } from "../Selectors/uisettingsSelectors";
import { PersonalDataDispatchProps, PersonalDataOwnProps, PersonalDataStateProps, PersonalDataView } from "../Views/Profile/PersonalData";
const mapStateToProps =
(state: AppStateRecord, ownProps: PersonalDataOwnProps): PersonalDataStateProps => ({
advantages: getAdvantagesForSheet (state, ownProps),
apLeft: join (getAvailableAPMap (HeroModel.A.id (ownProps.hero)) (state, ownProps)),
apTotal: getTotalAdventurePoints (state),
avatar: getAvatar (state),
culture: getCurrentCulture (state),
currentEl: getStartEl (state),
disadvantages: getDisadvantagesForSheet (state, ownProps),
isRemovingEnabled: getIsRemovingEnabled (state),
isEditingHeroAfterCreationPhaseEnabled: getIsEditingHeroAfterCreationPhaseEnabled (state),
name: getCurrentHeroName (state),
phase: getPhase (state),
profession: getCurrentProfession (state),
professionName: getCustomProfessionName (state),
fullProfessionName: getCurrentFullProfessionName (state, ownProps),
professionVariant: getCurrentProfessionVariant (state),
profile: getProfile (state),
race: getCurrentRace (state),
raceVariant: getCurrentRaceVariant (state),
sex: getSex (state),
isAddAdventurePointsOpen: getIsAddAdventurePointsOpen (state),
isEditCharacterAvatarOpen: getIsEditCharacterAvatarOpen (state),
isAlbino: isAlbino (state),
sizeCalcStr: getRandomSizeCalcStr (state, ownProps),
weightCalcStr: getRandomWeightCalcStr (state, ownProps),
})
const mapDispatchToProps = (dispatch: ReduxDispatch): PersonalDataDispatchProps => ({
setAvatar (path: string) {
dispatch (ProfileActions.setHeroAvatar (path))
},
deleteAvatar () {
dispatch (ProfileActions.deleteHeroAvatar ())
},
setHeroName (name: string) {
dispatch (ProfileActions.setHeroName (name))
},
setCustomProfessionName (name: string) {
dispatch (ProfileActions.setCustomProfessionName (name))
},
endCharacterCreation () {
dispatch (ProfileActions.endHeroCreation ())
},
addAdventurePoints (ap: number) {
dispatch (ProfileActions.addAdventurePoints (ap))
},
openAddAdventurePoints () {
dispatch (SubwindowsActions.openAddAdventurePoints ())
},
closeAddAdventurePoints () {
dispatch (SubwindowsActions.closeAddAdventurePoints ())
},
openEditCharacterAvatar () {
dispatch (SubwindowsActions.openEditCharacterAvatar ())
},
closeEditCharacterAvatar () {
dispatch (SubwindowsActions.closeEditCharacterAvatar ())
},
changeFamily (e: InputTextEvent) {
dispatch (ProfileActions.setFamily (e.target.value as string))
},
changePlaceOfBirth (e: InputTextEvent) {
dispatch (ProfileActions.setPlaceOfBirth (e.target.value as string))
},
changeDateOfBirth (e: InputTextEvent) {
dispatch (ProfileActions.setDateOfBirth (e.target.value as string))
},
changeAge (e: InputTextEvent) {
dispatch (ProfileActions.setAge (e.target.value as string))
},
changeHaircolor (mresult: Maybe<number>) {
fmapF (mresult) (res => dispatch (ProfileActions.setHairColor (res)))
},
changeEyecolor (mresult: Maybe<number>) {
fmapF (mresult) (res => dispatch (ProfileActions.setEyeColor (res)))
},
changeSize (e: InputTextEvent) {
dispatch (ProfileActions.setSize (e.target.value as string) (Nothing))
},
changeWeight (e: InputTextEvent) {
dispatch (ProfileActions.setWeight (e.target.value as string) (Nothing))
},
changeTitle (e: InputTextEvent) {
dispatch (ProfileActions.setTitle (e.target.value as string))
},
changeSocialStatus (mresult: Maybe<number>) {
fmapF (mresult) (res => dispatch (ProfileActions.setSocialStatus (res)))
},
changeCharacteristics (e: InputTextEvent) {
dispatch (ProfileActions.setCharacteristics (e.target.value as string))
},
changeOtherInfo (e: InputTextEvent) {
dispatch (ProfileActions.setOtherInfo (e.target.value as string))
},
changeCultureAreaKnowledge (e: InputTextEvent) {
dispatch (ProfileActions.setCultureAreaKnowledge (e.target.value as string))
},
rerollHair () {
dispatch (ProfileActions.rerollHairColor)
},
rerollEyes () {
dispatch (ProfileActions.rerollEyeColor)
},
rerollSize () {
dispatch (ProfileActions.rerollSize)
},
rerollWeight () {
dispatch (ProfileActions.rerollWeight)
},
})
export const connectPersonalData =
connect<PersonalDataStateProps, PersonalDataDispatchProps, PersonalDataOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const PersonalDataContainer = connectPersonalData (PersonalDataView)
@@ -1,36 +1,37 @@
import { connect } from 'react-redux';
import { Action, Dispatch } from 'redux';
import * as PetActions from '../actions/PetActions';
import * as SubwindowsActions from '../actions/SubwindowsActions';
import { AppState } from '../reducers/appReducer';
import { getIsEditPetAvatarOpen, getIsInPetCreation, getPetEditorInstance, getPets } from '../selectors/stateSelectors';
import { Pets, PetsDispatchProps, PetsOwnProps, PetsStateProps } from '../views/pets/Pets';
import { connect } from "react-redux";
import { ReduxDispatch } from "../Actions/Actions";
import * as PetActions from "../Actions/PetActions";
import * as SubwindowsActions from "../Actions/SubwindowsActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getIsEditPetAvatarOpen, getIsInPetCreation, getPetEditorInstance, getPets, getWikiAttributes } from "../Selectors/stateSelectors";
import { Pets, PetsDispatchProps, PetsOwnProps, PetsStateProps } from "../Views/Pets/Pets";
const mapStateToProps = (state: AppState): PetsStateProps => ({
const mapStateToProps = (state: AppStateRecord): PetsStateProps => ({
attributes: getWikiAttributes (state),
pets: getPets (state),
isEditPetAvatarOpen: getIsEditPetAvatarOpen (state),
petInEditor: getPetEditorInstance (state),
isInCreation: getIsInPetCreation (state),
});
})
const mapDispatchToProps = (dispatch: Dispatch<Action, AppState>): PetsDispatchProps => ({
const mapDispatchToProps = (dispatch: ReduxDispatch): PetsDispatchProps => ({
addPet (): void {
dispatch (PetActions.addPet);
dispatch (PetActions.addPet)
},
createPet (): void {
dispatch (PetActions.createPet ());
dispatch (PetActions.createPet ())
},
editPet (id: string): void {
dispatch (PetActions.editPet (id));
dispatch (PetActions.editPet (id))
},
closePetEditor () {
dispatch (PetActions.closePetEditor ());
dispatch (PetActions.closePetEditor ())
},
deletePet (id: string) {
dispatch (PetActions.removePet (id));
dispatch (PetActions.removePet (id))
},
savePet () {
dispatch (PetActions.savePet ());
dispatch (PetActions.savePet ())
},
setAvatar (path: string) {
dispatch (PetActions.setPetAvatar (path))
@@ -123,16 +124,17 @@ const mapDispatchToProps = (dispatch: Dispatch<Action, AppState>): PetsDispatchP
dispatch (PetActions.setPetNotes (notes))
},
openEditPetAvatar () {
dispatch (SubwindowsActions.openEditPetAvatar ());
dispatch (SubwindowsActions.openEditPetAvatar ())
},
closeEditPetAvatar () {
dispatch (SubwindowsActions.closeEditPetAvatar ());
dispatch (SubwindowsActions.closeEditPetAvatar ())
},
});
})
export const connectPets = connect<PetsStateProps, PetsDispatchProps, PetsOwnProps, AppState> (
mapStateToProps,
mapDispatchToProps
);
export const connectPets =
connect<PetsStateProps, PetsDispatchProps, PetsOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const PetsContainer = connectPets (Pets);
export const PetsContainer = connectPets (Pets)
@@ -0,0 +1,55 @@
import { connect } from "react-redux";
import { Maybe } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as ProfessionActions from "../Actions/ProfessionActions";
import * as ProfessionVariantActions from "../Actions/ProfessionVariantActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getFilteredProfessions } from "../Selectors/rcpSelectors";
import { getCurrentProfessionId, getCurrentProfessionVariantId, getProfessionsFilterText, getSex, getWiki } from "../Selectors/stateSelectors";
import { getProfessionsGroupVisibilityFilter, getProfessionsSortOrder, getProfessionsVisibilityFilter } from "../Selectors/uisettingsSelectors";
import { Professions, ProfessionsDispatchProps, ProfessionsOwnProps, ProfessionsStateProps } from "../Views/Professions/Professions";
const mapStateToProps =
(state: AppStateRecord, ownProps: ProfessionsOwnProps): ProfessionsStateProps => ({
currentProfessionId: getCurrentProfessionId (state),
currentProfessionVariantId: getCurrentProfessionVariantId (state),
groupVisibilityFilter: getProfessionsGroupVisibilityFilter (state),
professions: getFilteredProfessions (state, ownProps),
sex: getSex (state),
sortOrder: getProfessionsSortOrder (state),
visibilityFilter: getProfessionsVisibilityFilter (state),
filterText: getProfessionsFilterText (state),
wiki: getWiki (state),
})
const mapDispatchToProps = (dispatch: ReduxDispatch): ProfessionsDispatchProps => ({
selectProfession (id: string) {
dispatch (ProfessionActions.selectProfession (id))
},
selectProfessionVariant (id: Maybe<string>) {
dispatch (ProfessionVariantActions.selectProfessionVariant (id))
},
setSortOrder (sortOrder: string) {
dispatch (ProfessionActions.setProfessionsSortOrder (sortOrder))
},
setVisibilityFilter (filter: string) {
dispatch (ProfessionActions.setProfessionsVisibilityFilter (filter))
},
setGroupVisibilityFilter (filter: number) {
dispatch (ProfessionActions.setProfessionsGroupVisibilityFilter (filter))
},
switchExpansionVisibilityFilter () {
dispatch (ProfessionActions.switchProfessionsExpansionVisibilityFilter ())
},
setFilterText (filterText: string) {
dispatch (ProfessionActions.setProfessionsFilterText (filterText))
},
})
export const connectProfessions =
connect<ProfessionsStateProps, ProfessionsDispatchProps, ProfessionsOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const ProfessionsContainer = connectProfessions (Professions)
@@ -0,0 +1,33 @@
import { connect } from "react-redux";
import { ReduxDispatch } from "../Actions/Actions";
import * as ProfessionActions from "../Actions/ProfessionActions";
import { Selections as SelectionsInterface } from "../Models/Hero/heroTypeHelpers";
import { AppStateRecord } from "../Reducers/appReducer";
import { getCurrentCulture, getCurrentProfession, getCurrentProfessionVariant, getCurrentRace } from "../Selectors/rcpSelectors";
import { getAllSpellsForManualGuildMageSelect } from "../Selectors/spellsSelectors";
import { getWiki } from "../Selectors/stateSelectors";
import { RCPOptionSelections, SelectionsDispatchProps, SelectionsOwnProps, SelectionsStateProps } from "../Views/RCPOptionSelections/Selections";
const mapStateToProps =
(state: AppStateRecord, ownProps: SelectionsOwnProps): SelectionsStateProps => ({
currentRace: getCurrentRace (state),
currentCulture: getCurrentCulture (state),
currentProfession: getCurrentProfession (state),
currentProfessionVariant: getCurrentProfessionVariant (state),
wiki: getWiki (state),
munfamiliar_spells: getAllSpellsForManualGuildMageSelect (state, ownProps),
})
const mapDispatchToProps = (dispatch: ReduxDispatch): SelectionsDispatchProps => ({
setSelections (selections: SelectionsInterface) {
dispatch (ProfessionActions.setSelections (selections))
},
})
export const connectSelections =
connect<SelectionsStateProps, SelectionsDispatchProps, SelectionsOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const SelectionsContainer = connectSelections (RCPOptionSelections)
+50
View File
@@ -0,0 +1,50 @@
import { connect } from "react-redux";
import { Maybe } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import { setTab } from "../Actions/LocationActions";
import * as RaceActions from "../Actions/RaceActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getFilteredRaces } from "../Selectors/rcpSelectors";
import { getCurrentRaceId, getCurrentRaceVariantId, getRacesFilterText } from "../Selectors/stateSelectors";
import { getRacesSortOrder } from "../Selectors/uisettingsSelectors";
import { TabId } from "../Utilities/LocationUtils";
import { Races, RacesDispatchProps, RacesOwnProps, RacesStateProps } from "../Views/Races/Races";
const mapStateToProps = (state: AppStateRecord, ownProps: RacesOwnProps): RacesStateProps => {
return {
currentId: getCurrentRaceId (state),
currentVariantId: getCurrentRaceVariantId (state),
races: getFilteredRaces (state, ownProps),
sortOrder: getRacesSortOrder (state),
filterText: getRacesFilterText (state),
}
}
const mapDispatchToProps = (dispatch: ReduxDispatch): RacesDispatchProps => ({
selectRace (id: string): ((variantId: Maybe<string>) => void) {
return variantId => dispatch (RaceActions.selectRace (id) (variantId))
},
selectRaceVariant (id: string) {
dispatch (RaceActions.setRaceVariant (id))
},
setSortOrder (sortOrder: string) {
dispatch (RaceActions.setRacesSortOrder (sortOrder))
},
switchValueVisibilityFilter () {
dispatch (RaceActions.switchRaceValueVisibilityFilter ())
},
setFilterText (filterText: string) {
dispatch (RaceActions.setFilterText (filterText))
},
switchToCultures () {
dispatch (setTab (TabId.Cultures))
},
})
export const connectRaces =
connect<RacesStateProps, RacesDispatchProps, RacesOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const RacesContainer = connectRaces (Races)
+57
View File
@@ -0,0 +1,57 @@
import { connect } from "react-redux";
import { Maybe } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import { setHeroLocale } from "../Actions/ProfileActions";
import * as RulesActions from "../Actions/RulesActions";
import { setGuildMageUnfamiliarSpellId } from "../Actions/SpecialAbilitiesActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getGuildMageUnfamiliarSpellId } from "../Selectors/activatableSelectors";
import { getSortedBooks } from "../Selectors/bookSelectors";
import { isEnableLanguageSpecializationsDeactivatable } from "../Selectors/rulesSelectors";
import { getAllSpellsForManualGuildMageSelect } from "../Selectors/spellsSelectors";
import { getHeroLocale } from "../Selectors/stateSelectors";
import { RulesDispatchProps, RulesOwnProps, RulesStateProps, RulesView } from "../Views/Rules/Rules";
const mapStateToProps =
(state: AppStateRecord, ownProps: RulesOwnProps): RulesStateProps => ({
sortedBooks: getSortedBooks (state, ownProps),
isEnableLanguageSpecializationsDeactivatable:
isEnableLanguageSpecializationsDeactivatable (state, ownProps),
hero_locale: getHeroLocale (state, ownProps),
mcurrent_guild_mage_spell: getGuildMageUnfamiliarSpellId (state, ownProps),
all_spells_select_options: getAllSpellsForManualGuildMageSelect (state, ownProps),
})
const mapDispatchToProps = (dispatch: ReduxDispatch) => ({
changeHigherParadeValues (id: Maybe<number>) {
if (Maybe.isJust (id)) {
dispatch (RulesActions.setHigherParadeValues (Maybe.fromJust (id)))
}
},
changeAttributeValueLimit () {
dispatch (RulesActions.switchAttributeValueLimit ())
},
switchEnableAllRuleBooks () {
dispatch (RulesActions.switchEnableAllRuleBooks ())
},
switchEnableRuleBook (id: string) {
dispatch (RulesActions.switchEnableRuleBook (id))
},
switchEnableLanguageSpecializations () {
dispatch (RulesActions.switchEnableLanguageSpecializations ())
},
setGuildMageSpell (spellId: string) {
dispatch (setGuildMageUnfamiliarSpellId (spellId))
},
setHeroLocale (locale: string) {
dispatch (setHeroLocale (locale))
},
})
export const connectRules =
connect<RulesStateProps, RulesDispatchProps, RulesOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const RulesContainer = connectRules (RulesView)
+48
View File
@@ -0,0 +1,48 @@
import { connect } from "react-redux";
import { fromJust, isJust, Maybe } from "../../Data/Maybe";
import { runIO } from "../../System/IO";
import { ReduxDispatch } from "../Actions/Actions";
import * as ConfigActions from "../Actions/ConfigActions";
import * as IOActions from "../Actions/IOActions";
import * as LocaleActions from "../Actions/LocaleActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getLocaleId, getLocaleType } from "../Selectors/stateSelectors";
import { areAnimationsEnabled, getIsEditingHeroAfterCreationPhaseEnabled, getTheme } from "../Selectors/uisettingsSelectors";
import { Settings, SettingsDispatchProps, SettingsOwnProps, SettingsStateProps } from "../Views/Settings/Settings";
const mapStateToProps = (state: AppStateRecord): SettingsStateProps => ({
localeString: getLocaleId (state),
localeType: getLocaleType (state),
isEditingHeroAfterCreationPhaseEnabled: getIsEditingHeroAfterCreationPhaseEnabled (state),
areAnimationsEnabled: areAnimationsEnabled (state),
theme: getTheme (state),
})
const mapDispatchToProps =
(dispatch: ReduxDispatch, ownProps: SettingsOwnProps): SettingsDispatchProps => ({
setTheme (theme: Maybe<string>) {
if (isJust (theme)) {
dispatch (ConfigActions.setTheme (fromJust (theme)))
}
},
switchEnableEditingHeroAfterCreationPhase () {
dispatch (ConfigActions.switchEnableEditingHeroAfterCreationPhase ())
},
saveConfig () {
runIO (dispatch (IOActions.requestConfigSave (ownProps.l10n)))
},
setLocale (id: Maybe<string>) {
dispatch (LocaleActions.setLocale (id))
},
switchEnableAnimations () {
dispatch (ConfigActions.switchEnableAnimations ())
},
})
const connectSettings =
connect<SettingsStateProps, SettingsDispatchProps, SettingsOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const SettingsContainer = connectSettings (Settings)
+106
View File
@@ -0,0 +1,106 @@
import { connect } from "react-redux";
import { join, Just } from "../../Data/Maybe";
import { ReduxDispatch } from "../Actions/Actions";
import * as IOActions from "../Actions/IOActions";
import * as SheetActions from "../Actions/SheetActions";
import { HeroModel } from "../Models/Hero/HeroModel";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAdvantagesForSheet, getAspectKnowledgesForSheet, getBlessedSpecialAbilitiesForSheet, getBlessedTraditionForSheet, getCombatSpecialAbilitiesForSheet, getDisadvantagesForSheet, getFatePointsModifier, getGeneralSpecialAbilitiesForSheet, getMagicalSpecialAbilitiesForSheet, getMagicalTraditionForSheet, getPropertyKnowledgesForSheet } from "../Selectors/activatableSelectors";
import { getAPObjectMap } from "../Selectors/adventurePointsSelectors";
import { getAttributesForSheet, getPrimaryBlessedAttributeForSheet, getPrimaryMagicalAttributeForSheet } from "../Selectors/attributeSelectors";
import { getCombatTechniquesForSheet } from "../Selectors/combatTechniquesSelectors";
import { getDerivedCharacteristics } from "../Selectors/derivedCharacteristicsSelectors";
import { getStartEl } from "../Selectors/elSelectors";
import { getAllItems, getArmors, getArmorZones, getMeleeWeapons, getRangedWeapons, getShieldsAndParryingWeapons, getTotalPrice, getTotalWeight } from "../Selectors/equipmentSelectors";
import { getBlessingsForSheet, getLiturgicalChantsForSheet } from "../Selectors/liturgicalChantsSelectors";
import { getPet } from "../Selectors/petsSelectors";
import { getCurrentCulture, getCurrentFullProfessionName, getCurrentRace } from "../Selectors/rcpSelectors";
import { getConditions, getSkillPages, getSkillsByGroup, getStates } from "../Selectors/sheetSelectors";
import { getAllSkills } from "../Selectors/skillsSelectors";
import { getCantripsForSheet, getSpellsForSheet } from "../Selectors/spellsSelectors";
import { getAvatar, getCurrentHeroName, getProfile, getPurse, getSex, getSpecialAbilities, getWikiBooks, getWikiSpecialAbilities } from "../Selectors/stateSelectors";
import { getSheetCheckAttributeValueVisibility } from "../Selectors/uisettingsSelectors";
import { prefixSA } from "../Utilities/IDUtils";
import { pipe } from "../Utilities/pipe";
import { mapGetToMaybeSlice, mapGetToSlice } from "../Utilities/SelectorsUtils";
import { Sheets, SheetsDispatchProps, SheetsOwnProps, SheetsStateProps } from "../Views/Sheets/Sheets";
const mapStateToProps = (state: AppStateRecord, ownProps: SheetsOwnProps): SheetsStateProps => ({
advantagesActive: getAdvantagesForSheet (state, ownProps),
ap: join (getAPObjectMap (HeroModel.A.id (ownProps.hero)) (state, ownProps)),
armors: getArmors (state),
armorZones: getArmorZones (state),
attributes: getAttributesForSheet (state, ownProps),
avatar: getAvatar (state),
checkAttributeValueVisibility: getSheetCheckAttributeValueVisibility (state),
combatSpecialAbilities: getCombatSpecialAbilitiesForSheet (state, ownProps),
combatTechniques: getCombatTechniquesForSheet (state, ownProps),
culture: getCurrentCulture (state),
derivedCharacteristics: getDerivedCharacteristics (state, ownProps),
disadvantagesActive: getDisadvantagesForSheet (state, ownProps),
el: getStartEl (state),
fatePointsModifier: getFatePointsModifier (state),
generalsaActive: getGeneralSpecialAbilitiesForSheet (state, ownProps),
meleeWeapons: getMeleeWeapons (state),
name: getCurrentHeroName (state),
professionName: getCurrentFullProfessionName (state, ownProps),
// profession: getCurrentProfession (state),
// professionVariant: getCurrentProfessionVariant (state),
profile: getProfile (state),
race: getCurrentRace (state),
rangedWeapons: getRangedWeapons (state),
sex: getSex (state),
shieldsAndParryingWeapons: getShieldsAndParryingWeapons (state),
skills: getAllSkills (state),
items: getAllItems (state, ownProps),
pet: getPet (state),
purse: getPurse (state),
totalPrice: getTotalPrice (state, ownProps),
totalWeight: getTotalWeight (state, ownProps),
languagesWikiEntry: mapGetToMaybeSlice (pipe (getWikiSpecialAbilities, Just))
(prefixSA (29))
(state),
languagesStateEntry: mapGetToSlice (getSpecialAbilities)
(prefixSA (29))
(state, ownProps),
scriptsWikiEntry: mapGetToMaybeSlice (pipe (getWikiSpecialAbilities, Just))
(prefixSA (27))
(state),
scriptsStateEntry: mapGetToSlice (getSpecialAbilities)
(prefixSA (27))
(state, ownProps),
cantrips: getCantripsForSheet (state, ownProps),
magicalPrimary: getPrimaryMagicalAttributeForSheet (state, ownProps),
magicalSpecialAbilities: getMagicalSpecialAbilitiesForSheet (state, ownProps),
magicalTradition: getMagicalTraditionForSheet (state, ownProps),
properties: getPropertyKnowledgesForSheet (state, ownProps),
spells: getSpellsForSheet (state, ownProps),
aspects: getAspectKnowledgesForSheet (state, ownProps),
blessedPrimary: getPrimaryBlessedAttributeForSheet (state, ownProps),
blessedSpecialAbilities: getBlessedSpecialAbilitiesForSheet (state, ownProps),
blessedTradition: getBlessedTraditionForSheet (state, ownProps),
blessings: getBlessingsForSheet (state, ownProps),
liturgicalChants: getLiturgicalChantsForSheet (state, ownProps),
conditions: getConditions (state, ownProps),
states: getStates (state, ownProps),
books: getWikiBooks (state),
skillGroupPages: getSkillPages (state),
skillsByGroup: getSkillsByGroup (state),
})
const mapDispatchToProps = (dispatch: ReduxDispatch, { l10n }: SheetsOwnProps) => ({
switchAttributeValueVisibility () {
dispatch (SheetActions.switchAttributeValueVisibility ())
},
printToPDF () {
dispatch (IOActions.requestPrintHeroToPDF (l10n))
},
})
export const connectSheets =
connect<SheetsStateProps, SheetsDispatchProps, SheetsOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const SheetsContainer = connectSheets (Sheets)
+49
View File
@@ -0,0 +1,49 @@
import { connect } from "react-redux";
import { ReduxDispatch } from "../Actions/Actions";
import * as SkillActions from "../Actions/SkillActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAttributesForSheet } from "../Selectors/attributeSelectors";
import { getDerivedCharacteristicsMap } from "../Selectors/derivedCharacteristicsSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getFilteredSkills, getSkillRating } from "../Selectors/skillsSelectors";
import { getSkillsFilterText } from "../Selectors/stateSelectors";
import { getSkillsCultureRatingVisibility, getSkillsSortOrder } from "../Selectors/uisettingsSelectors";
import { Skills, SkillsDispatchProps, SkillsOwnProps, SkillsStateProps } from "../Views/Skills/Skills";
const mapStateToProps = (state: AppStateRecord, ownProps: SkillsOwnProps): SkillsStateProps => ({
attributes: getAttributesForSheet (state, ownProps),
derivedCharacteristics: getDerivedCharacteristicsMap (state, ownProps),
isRemovingEnabled: getIsRemovingEnabled (state),
list: getFilteredSkills (state, ownProps),
sortOrder: getSkillsSortOrder (state),
filterText: getSkillsFilterText (state),
ratingVisibility: getSkillsCultureRatingVisibility (state),
skillRating: getSkillRating (state),
})
const mapDispatchToProps =
(dispatch: ReduxDispatch, { l10n }: SkillsOwnProps): SkillsDispatchProps => ({
addPoint (id: string) {
dispatch (SkillActions.addSkillPoint (l10n) (id))
},
removePoint (id: string) {
dispatch (SkillActions.removeSkillPoint (id))
},
setSortOrder (sortOrder: string) {
dispatch (SkillActions.setSkillsSortOrder (sortOrder))
},
switchRatingVisibility () {
dispatch (SkillActions.switchSkillRatingVisibility ())
},
setFilterText (filterText: string) {
dispatch (SkillActions.setSkillsFilterText (filterText))
},
})
export const connectSkills =
connect<SkillsStateProps, SkillsDispatchProps, SkillsOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const SkillsContainer = connectSkills (Skills)
@@ -0,0 +1,71 @@
import { connect } from "react-redux";
import { join } from "../../Data/Maybe";
import { Record } from "../../Data/Record";
import { ReduxDispatch } from "../Actions/Actions";
import * as ConfigActions from "../Actions/ConfigActions";
import * as SpecialAbilitiesActions from "../Actions/SpecialAbilitiesActions";
import { ActivatableActivationOptions } from "../Models/Actions/ActivatableActivationOptions";
import { ActivatableDeactivationOptions } from "../Models/Actions/ActivatableDeactivationOptions";
import { HeroModel } from "../Models/Hero/HeroModel";
import { AppStateRecord } from "../Reducers/appReducer";
import { getFilteredActiveSpecialAbilities } from "../Selectors/activatableSelectors";
import { getFilteredInactiveSpecialAbilities } from "../Selectors/combinedActivatablesSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getInactiveSpecialAbilitiesFilterText, getSpecialAbilitiesFilterText, getWikiSpecialAbilities } from "../Selectors/stateSelectors";
import { getEnableActiveItemHints, getSpecialAbilitiesSortOrder } from "../Selectors/uisettingsSelectors";
import { SpecialAbilities, SpecialAbilitiesDispatchProps, SpecialAbilitiesOwnProps, SpecialAbilitiesStateProps } from "../Views/SpecialAbilities/SpecialAbilities";
const mapStateToProps = (
state: AppStateRecord,
ownProps: SpecialAbilitiesOwnProps
): SpecialAbilitiesStateProps => ({
activeList: getFilteredActiveSpecialAbilities (state, ownProps),
deactiveList: join (getFilteredInactiveSpecialAbilities (HeroModel.A.id (ownProps.hero))
(state, ownProps)),
enableActiveItemHints: getEnableActiveItemHints (state),
isRemovingEnabled: getIsRemovingEnabled (state),
wikiEntries: getWikiSpecialAbilities (state),
sortOrder: getSpecialAbilitiesSortOrder (state),
filterText: getSpecialAbilitiesFilterText (state),
inactiveFilterText: getInactiveSpecialAbilitiesFilterText (state),
})
const mapDispatchToProps = (
dispatch: ReduxDispatch,
{ l10n }: SpecialAbilitiesOwnProps
): SpecialAbilitiesDispatchProps => ({
setSortOrder (sortOrder: string) {
dispatch (SpecialAbilitiesActions.setSpecialAbilitiesSortOrder (sortOrder))
},
switchActiveItemHints () {
dispatch (ConfigActions.switchEnableActiveItemHints ())
},
addToList (args: Record<ActivatableActivationOptions>) {
dispatch (SpecialAbilitiesActions.addSpecialAbility (l10n) (args))
},
removeFromList (args: Record<ActivatableDeactivationOptions>) {
dispatch (SpecialAbilitiesActions.removeSpecialAbility (args))
},
setLevel (id: string, index: number, level: number) {
dispatch (SpecialAbilitiesActions.setSpecialAbilityLevel (l10n) (id) (index) (level))
},
setFilterText (filterText: string) {
dispatch (SpecialAbilitiesActions.setActiveSpecialAbilitiesFilterText (filterText))
},
setInactiveFilterText (filterText: string) {
dispatch (SpecialAbilitiesActions.setInactiveSpecialAbilitiesFilterText (filterText))
},
})
export const connectSpecialAbilities =
connect<
SpecialAbilitiesStateProps,
SpecialAbilitiesDispatchProps,
SpecialAbilitiesOwnProps,
AppStateRecord
> (
mapStateToProps,
mapDispatchToProps
)
export const SpecialAbilitiesContainer = connectSpecialAbilities (SpecialAbilities)
+67
View File
@@ -0,0 +1,67 @@
import { connect } from "react-redux";
import { ReduxDispatch } from "../Actions/Actions";
import * as ConfigActions from "../Actions/ConfigActions";
import * as SpellsActions from "../Actions/SpellsActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAttributesForSheet } from "../Selectors/attributeSelectors";
import { getDerivedCharacteristicsMap } from "../Selectors/derivedCharacteristicsSelectors";
import { getIsRemovingEnabled } from "../Selectors/phaseSelectors";
import { getFilteredActiveSpellsAndCantrips, getFilteredInactiveSpellsAndCantrips, isActivationDisabled } from "../Selectors/spellsSelectors";
import { getInactiveSpellsFilterText, getSpellsFilterText } from "../Selectors/stateSelectors";
import { getEnableActiveItemHints, getSpellsSortOrder } from "../Selectors/uisettingsSelectors";
import { Spells, SpellsDispatchProps, SpellsOwnProps, SpellsStateProps } from "../Views/Spells/Spells";
const mapStateToProps = (state: AppStateRecord, ownProps: SpellsOwnProps): SpellsStateProps => ({
activeList: getFilteredActiveSpellsAndCantrips (state, ownProps),
inactiveList: getFilteredInactiveSpellsAndCantrips (state, ownProps),
attributes: getAttributesForSheet (state, ownProps),
derivedCharacteristics: getDerivedCharacteristicsMap (state, ownProps),
addSpellsDisabled: isActivationDisabled (state, ownProps),
enableActiveItemHints: getEnableActiveItemHints (state),
isRemovingEnabled: getIsRemovingEnabled (state),
sortOrder: getSpellsSortOrder (state),
filterText: getSpellsFilterText (state),
inactiveFilterText: getInactiveSpellsFilterText (state),
})
const mapDispatchToProps =
(dispatch: ReduxDispatch, { l10n }: SpellsOwnProps): SpellsDispatchProps => ({
addPoint (id: string) {
dispatch (SpellsActions.addSpellPoint (l10n) (id))
},
addToList (id: string) {
dispatch (SpellsActions.addSpell (l10n) (id))
},
addCantripToList (id: string) {
dispatch (SpellsActions.addCantrip (l10n) (id))
},
removePoint (id: string) {
dispatch (SpellsActions.removeSpellPoint (id))
},
removeFromList (id: string) {
dispatch (SpellsActions.removeSpell (id))
},
removeCantripFromList (id: string) {
dispatch (SpellsActions.removeCantrip (id))
},
setSortOrder (sortOrder: string) {
dispatch (SpellsActions.setSpellsSortOrder (sortOrder))
},
switchActiveItemHints () {
dispatch (ConfigActions.switchEnableActiveItemHints ())
},
setFilterText (filterText: string) {
dispatch (SpellsActions.setActiveSpellsFilterText (filterText))
},
setInactiveFilterText (filterText: string) {
dispatch (SpellsActions.setInactiveSpellsFilterText (filterText))
},
})
export const connectSpells =
connect<SpellsStateProps, SpellsDispatchProps, SpellsOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
)
export const SpellsContainer = connectSpells (Spells)
@@ -1,17 +1,15 @@
import { connect } from 'react-redux';
import { Action, Dispatch } from 'redux';
import { setWikiCategory1, setWikiCategory2, setWikiCombatTechniquesGroup, setWikiFilter, setWikiFilterAll, setWikiItemTemplatesGroup, setWikiLiturgicalChantsGroup, setWikiProfessionsGroup, setWikiSkillsGroup, setWikiSpecialAbilitiesGroup, setWikiSpellsGroup } from '../actions/WikiActions';
import { AppState } from '../reducers/appReducer';
import { getSex, getWikiCombatTechniquesGroup, getWikiFilterAll, getWikiFilterText, getWikiItemTemplatesGroup, getWikiLiturgicalChantsGroup, getWikiMainCategory, getWikiProfessionsGroup, getWikiSkillsGroup, getWikiSpecialAbilitiesGroup, getWikiSpellsGroup } from '../selectors/stateSelectors';
import { getPreparedAdvantages, getPreparedBlessings, getPreparedCantrips, getPreparedCombatTechniques, getPreparedCultures, getPreparedDisadvantages, getPreparedItemTemplates, getPreparedLiturgicalChants, getPreparedProfessions, getPreparedRaces, getPreparedSkills, getPreparedSpecialAbilities, getPreparedSpells, getSpecialAbilityGroups } from '../selectors/wikiSelectors';
import { Maybe } from '../utils/dataUtils';
import { Wiki, WikiDispatchProps, WikiOwnProps, WikiStateProps } from '../views/wiki/Wiki';
import { connect } from "react-redux";
import { Action, Dispatch } from "redux";
import { fromJust, isJust, Maybe } from "../../Data/Maybe";
import { setWikiCategory1, setWikiCategory2, setWikiCombatTechniquesGroup, setWikiFilter, setWikiFilterAll, setWikiItemTemplatesGroup, setWikiLiturgicalChantsGroup, setWikiProfessionsGroup, setWikiSkillsGroup, setWikiSpecialAbilitiesGroup, setWikiSpellsGroup } from "../Actions/WikiActions";
import { AppStateRecord } from "../Reducers/appReducer";
import { getWikiCombatTechniquesGroup, getWikiFilterText, getWikiItemTemplatesGroup, getWikiLiturgicalChantsGroup, getWikiMainCategory, getWikiProfessionsGroup, getWikiSkillsGroup, getWikiSpecialAbilitiesGroup, getWikiSpellsGroup } from "../Selectors/stateSelectors";
import { getPreparedAdvantages, getPreparedBlessings, getPreparedCantrips, getPreparedCombatTechniques, getPreparedCultures, getPreparedDisadvantages, getPreparedItemTemplates, getPreparedLiturgicalChants, getPreparedProfessions, getPreparedRaces, getPreparedSkills, getPreparedSpecialAbilities, getPreparedSpells, getSpecialAbilityGroups } from "../Selectors/wikiSelectors";
import { Wiki, WikiDispatchProps, WikiOwnProps, WikiStateProps } from "../Views/Wiki/Wiki";
const mapStateToProps = (state: AppState, props: WikiOwnProps) => ({
const mapStateToProps = (state: AppStateRecord, props: WikiOwnProps): WikiStateProps => ({
filterText: getWikiFilterText (state),
filterAllText: getWikiFilterAll (state),
category: getWikiMainCategory (state),
sex: getSex (state),
races: getPreparedRaces (state, props),
cultures: getPreparedCultures (state, props),
professions: getPreparedProfessions (state, props),
@@ -33,51 +31,51 @@ const mapStateToProps = (state: AppState, props: WikiOwnProps) => ({
liturgicalChantsGroup: getWikiLiturgicalChantsGroup (state),
itemTemplatesGroup: getWikiItemTemplatesGroup (state),
specialAbilityGroups: getSpecialAbilityGroups (state, props),
});
})
const mapDispatchToProps = (dispatch: Dispatch<Action>) => ({
setCategory1 (category: Maybe<string>) {
if (Maybe.isJust (category)) {
dispatch (setWikiCategory1 (Maybe.fromJust (category)));
if (isJust (category)) {
dispatch (setWikiCategory1 (fromJust (category)))
}
},
setCategory2 (category: Maybe<string>) {
if (Maybe.isJust (category)) {
dispatch (setWikiCategory2 (Maybe.fromJust (category)));
if (isJust (category)) {
dispatch (setWikiCategory2 (fromJust (category)))
}
},
setFilter (filterText: string) {
dispatch (setWikiFilter (filterText));
dispatch (setWikiFilter (filterText))
},
setFilterAll (filterText: string) {
dispatch (setWikiFilterAll (filterText));
dispatch (setWikiFilterAll (filterText))
},
setProfessionsGroup (group: Maybe<number>) {
dispatch (setWikiProfessionsGroup (group));
dispatch (setWikiProfessionsGroup (group))
},
setSkillsGroup (group: Maybe<number>) {
dispatch (setWikiSkillsGroup (group));
dispatch (setWikiSkillsGroup (group))
},
setCombatTechniquesGroup (group: Maybe<number>) {
dispatch (setWikiCombatTechniquesGroup (group));
dispatch (setWikiCombatTechniquesGroup (group))
},
setSpecialAbilitiesGroup (group: Maybe<number>) {
dispatch (setWikiSpecialAbilitiesGroup (group));
dispatch (setWikiSpecialAbilitiesGroup (group))
},
setSpellsGroup (group: Maybe<number>) {
dispatch (setWikiSpellsGroup (group));
dispatch (setWikiSpellsGroup (group))
},
setLiturgicalChantsGroup (group: Maybe<number>) {
dispatch (setWikiLiturgicalChantsGroup (group));
dispatch (setWikiLiturgicalChantsGroup (group))
},
setItemTemplatesGroup (group: Maybe<number>) {
dispatch (setWikiItemTemplatesGroup (group));
dispatch (setWikiItemTemplatesGroup (group))
},
});
})
const connectWiki = connect<WikiStateProps, WikiDispatchProps, WikiOwnProps, AppState> (
const connectWiki = connect<WikiStateProps, WikiDispatchProps, WikiOwnProps, AppStateRecord> (
mapStateToProps,
mapDispatchToProps
);
)
export const WikiContainer = connectWiki (Wiki);
export const WikiContainer = connectWiki (Wiki)
@@ -1,14 +1,13 @@
import { connect } from 'react-redux';
import { mapGetToSlice } from '../App/Utils/SelectorsUtils';
import { AppState } from '../reducers/appReducer';
import { getDerivedCharacteristicsMap } from '../selectors/derivedCharacteristicsSelectors';
import * as stateSelectors from '../selectors/stateSelectors';
import { getAllWikiEntries } from '../selectors/wikiSelectors';
import { WikiInfo, WikiInfoDispatchProps, WikiInfoOwnProps } from '../views/wiki/WikiInfo';
import { WikiInfoContentStateProps } from '../views/wiki/WikiInfoContent';
import { connect } from "react-redux";
import { AppStateRecord } from "../Reducers/appReducer";
import { getAllCultures, getAllProfessions, getAllRaces } from "../Selectors/rcpSelectors";
import * as stateSelectors from "../Selectors/stateSelectors";
import { mapGetToSlice } from "../Utilities/SelectorsUtils";
import { WikiInfo, WikiInfoDispatchProps, WikiInfoOwnProps } from "../Views/InlineWiki/WikiInfo";
import { WikiInfoContentStateProps } from "../Views/InlineWiki/WikiInfoContent";
const mapStateToProps =
(state: AppState, ownProps: WikiInfoOwnProps): WikiInfoContentStateProps => ({
(state: AppStateRecord, ownProps: WikiInfoOwnProps): WikiInfoContentStateProps => ({
attributes: stateSelectors.getWikiAttributes (state),
advantages: stateSelectors.getWikiAdvantages (state),
blessings: stateSelectors.getWikiBlessings (state),
@@ -16,28 +15,30 @@ const mapStateToProps =
cantrips: stateSelectors.getWikiCantrips (state),
combatTechniques: stateSelectors.getWikiCombatTechniques (state),
cultures: stateSelectors.getWikiCultures (state),
derivedCharacteristics: getDerivedCharacteristicsMap (state, ownProps),
languages: mapGetToSlice (stateSelectors.getWikiSpecialAbilities) (state) ('SA_29'),
list: getAllWikiEntries (state),
combinedCultures: getAllCultures (state),
combinedRaces: getAllRaces (state),
combinedProfessions: getAllProfessions (state, ownProps),
disadvantages: stateSelectors.getWikiDisadvantages (state),
languages: mapGetToSlice (stateSelectors.getWikiSpecialAbilities) ("SA_29") (state),
items: stateSelectors.getItemsState (state),
itemTemplates: stateSelectors.getWikiItemTemplates (state),
professionVariants: stateSelectors.getWikiProfessionVariants (state),
raceVariants: stateSelectors.getWikiRaceVariants (state),
races: stateSelectors.getWikiRaces (state),
liturgicalChantExtensions:
mapGetToSlice (stateSelectors.getWikiSpecialAbilities) (state) ('SA_663'),
mapGetToSlice (stateSelectors.getWikiSpecialAbilities) ("SA_663") (state),
liturgicalChants: stateSelectors.getWikiLiturgicalChants (state),
scripts: mapGetToSlice (stateSelectors.getWikiSpecialAbilities) (state) ('SA_27'),
scripts: mapGetToSlice (stateSelectors.getWikiSpecialAbilities) ("SA_27") (state),
sex: stateSelectors.getSex (state),
skills: stateSelectors.getWikiSkills (state),
spellExtensions: mapGetToSlice (stateSelectors.getWikiSpecialAbilities) (state) ('SA_414'),
spellExtensions: mapGetToSlice (stateSelectors.getWikiSpecialAbilities) ("SA_414") (state),
spells: stateSelectors.getWikiSpells (state),
specialAbilities: stateSelectors.getWikiSpecialAbilities (state),
templates: stateSelectors.getWikiItemTemplates (state),
wiki: stateSelectors.getWiki (state),
});
})
export const connectWikiInfo =
connect<WikiInfoContentStateProps, WikiInfoDispatchProps, WikiInfoOwnProps, AppState> (
connect<WikiInfoContentStateProps, WikiInfoDispatchProps, WikiInfoOwnProps, AppStateRecord> (
mapStateToProps
);
)
export const WikiInfoContainer = connectWikiInfo (WikiInfo);
export const WikiInfoContainer = connectWikiInfo (WikiInfo)
@@ -0,0 +1,26 @@
import { Maybe, Nothing } from "../../../Data/Maybe";
import { fromDefault, Record } from "../../../Data/Record";
import { ActivatableDependent } from "../ActiveEntries/ActivatableDependent";
import { Advantage } from "../Wiki/Advantage";
import { Disadvantage } from "../Wiki/Disadvantage";
export interface ActivatableActivationEntryType {
isBlessed: boolean
isMagical: boolean
isDisadvantage: boolean
hairColor: Maybe<number>
eyeColor: Maybe<number>
heroEntry: Maybe<Record<ActivatableDependent>>
wikiEntry: Record<Advantage> | Record<Disadvantage>
}
export const ActivatableActivationEntryType =
fromDefault<ActivatableActivationEntryType> ({
isBlessed: false,
isMagical: false,
isDisadvantage: false,
hairColor: Nothing,
eyeColor: Nothing,
heroEntry: Nothing,
wikiEntry: Advantage.default,
})
@@ -0,0 +1,30 @@
import { Maybe, Nothing } from "../../../Data/Maybe";
import { fromDefault, makeLenses } from "../../../Data/Record";
export interface ActivatableActivationOptions {
id: string
selectOptionId1: Maybe<string | number>
selectOptionId2: Maybe<string | number>
input: Maybe<string>
level: Maybe<number>
cost: number
customCost: Maybe<number>
}
// export interface ActivatableActivatePayload extends ActivatableActivateOptions {
// wiki: Activatable
// instance?: Record<ActivatableDependent>
// }
export const ActivatableActivationOptions =
fromDefault<ActivatableActivationOptions> ({
id: "",
selectOptionId1: Nothing,
selectOptionId2: Nothing,
input: Nothing,
level: Nothing,
cost: 0,
customCost: Nothing,
})
export const ActivatableActivationOptionsL = makeLenses (ActivatableActivationOptions)
@@ -0,0 +1,26 @@
import { Maybe, Nothing } from "../../../Data/Maybe";
import { fromDefault, Record } from "../../../Data/Record";
import { ActivatableDependent } from "../ActiveEntries/ActivatableDependent";
import { Advantage } from "../Wiki/Advantage";
import { Disadvantage } from "../Wiki/Disadvantage";
export interface ActivatableDeactivationEntryType {
isBlessed: boolean
isMagical: boolean
isDisadvantage: boolean
hairColor: Maybe<number>
eyeColor: Maybe<number>
heroEntry: Record<ActivatableDependent>
wikiEntry: Record<Advantage> | Record<Disadvantage>
}
export const ActivatableDeactivationEntryType =
fromDefault<ActivatableDeactivationEntryType> ({
isBlessed: false,
isMagical: false,
isDisadvantage: false,
hairColor: Nothing,
eyeColor: Nothing,
heroEntry: ActivatableDependent.default,
wikiEntry: Advantage.default,
})
@@ -0,0 +1,16 @@
import { fromDefault, makeLenses } from "../../../Data/Record";
export interface ActivatableDeactivationOptions {
id: string
index: number
cost: number
}
export const ActivatableDeactivationOptions =
fromDefault<ActivatableDeactivationOptions> ({
id: "",
index: -1,
cost: 0,
})
export const ActivatableDeactivationOptionsL = makeLenses (ActivatableDeactivationOptions)
@@ -1,8 +1,8 @@
import { fnull } from "../../../Data/Foldable";
import { List } from "../../../Data/List";
import { fnull, List } from "../../../Data/List";
import { fromJust, isJust, Just, Maybe } from "../../../Data/Maybe";
import { fromDefault, makeLenses, member, notMember, Omit, Record } from "../../../Data/Record";
import { ActivatableDependency, Dependent } from "../Hero/heroTypeHelpers";
import { ActivatableSkillDependent } from "./ActivatableSkillDependent";
import { ActiveObject } from "./ActiveObject";
export interface ActivatableDependent {
@@ -47,9 +47,13 @@ export const isActivatableDependent =
member ("active") (entry)
&& notMember ("value") (entry)
const { active, dependencies } = ActivatableDependent.A
const { active, dependencies } = ActivatableDependent.AL
export const isActivatableDependentUnused =
(entry: Record<ActivatableDependent>): boolean =>
fnull (active (entry))
&& fnull (dependencies (entry))
export const isExtendedActivatableDependent =
(x: Dependent): x is Record<ActivatableDependent> | Record<ActivatableSkillDependent> =>
ActivatableDependent.is (x) || ActivatableSkillDependent.is (x)
@@ -1,5 +1,4 @@
import { fnull } from "../../../Data/Foldable";
import { List } from "../../../Data/List";
import { fnull, List } from "../../../Data/List";
import { fromJust, isJust, Just, Maybe } from "../../../Data/Maybe";
import { fromDefault, makeLenses, member, Omit, Record } from "../../../Data/Record";
import { Dependent, ExtendedSkillDependency } from "../Hero/heroTypeHelpers";
@@ -51,7 +50,7 @@ export const isActivatableSkillDependent =
member ("value") (entry)
&& member ("active") (entry)
const { active, value, dependencies } = ActivatableSkillDependent.A
const { active, value, dependencies } = ActivatableSkillDependent.AL
export const isActivatableSkillDependentUnused =
(entry: Record<ActivatableSkillDependent>): boolean =>
@@ -1,5 +1,5 @@
import { Nothing } from "../../../Data/Maybe";
import { fromDefault, makeLenses } from "../../../Data/Record";
import { fromDefault, makeLenses, Record } from "../../../Data/Record";
import { ActiveObject } from "./ActiveObject";
export interface ActiveObjectWithId extends ActiveObject {
@@ -18,3 +18,25 @@ export const ActiveObjectWithId =
})
export const ActiveObjectWithIdL = makeLenses (ActiveObjectWithId)
export const toActiveObjectWithId =
(index: number) =>
(id: string) =>
(active: Record<ActiveObject>) =>
ActiveObjectWithId ({
id,
index,
cost: ActiveObject.A.cost (active),
sid: ActiveObject.A.sid (active),
sid2: ActiveObject.A.sid2 (active),
tier: ActiveObject.A.tier (active),
})
export const fromActiveObjectWithId =
(active: Record<ActiveObjectWithId>) =>
ActiveObject ({
cost: ActiveObject.A.cost (active),
sid: ActiveObject.A.sid (active),
sid2: ActiveObject.A.sid2 (active),
tier: ActiveObject.A.tier (active),
})
@@ -1,5 +1,4 @@
import { fnull } from "../../../Data/Foldable";
import { List } from "../../../Data/List";
import { fnull, List } from "../../../Data/List";
import { fromJust, isJust, Just, Maybe } from "../../../Data/Maybe";
import { fromDefault, makeLenses, member, notMember, Omit, Record } from "../../../Data/Record";
import { Dependent, SkillDependency } from "../Hero/heroTypeHelpers";
@@ -50,7 +49,7 @@ export const isAttributeDependent =
&& member ("mod") (entry)
&& notMember ("active") (entry)
const { mod, value, dependencies } = AttributeDependent.A
const { mod, value, dependencies } = AttributeDependent.AL
export const isAttributeDependentUnused =
(entry: Record<AttributeDependent>): boolean =>
+11 -6
View File
@@ -1,9 +1,10 @@
import { add, pipe } from "ramda";
import { fnull } from "../../../Data/Foldable";
import { List } from "../../../Data/List";
import { fnull, List } from "../../../Data/List";
import { fromJust, isJust, Just, Maybe } from "../../../Data/Maybe";
import { fromDefault, makeLenses, member, notMember, Omit, Record } from "../../../Data/Record";
import { add } from "../../Utilities/mathUtils";
import { pipe } from "../../Utilities/pipe";
import { Dependent, ExtendedSkillDependent, SkillDependency } from "../Hero/heroTypeHelpers";
import { ActivatableSkillDependent } from "./ActivatableSkillDependent";
export interface SkillDependent {
id: string;
@@ -53,12 +54,16 @@ export const isSkillDependent =
export const isExtendedSkillDependent =
(entry: Dependent): entry is ExtendedSkillDependent =>
member ("value") (entry)
&& notMember ("mod") (entry)
SkillDependent.is (entry) || ActivatableSkillDependent.is (entry)
const { value, dependencies } = SkillDependent.A
const { value, dependencies } = SkillDependent.AL
export const isSkillDependentUnused =
(entry: Record<SkillDependent>): boolean =>
value (entry) === 0
&& fnull (dependencies (entry))
export const isCombatTechniqueSkillDependentUnused =
(entry: Record<SkillDependent>): boolean =>
value (entry) === 6
&& fnull (dependencies (entry))
+7 -7
View File
@@ -1,8 +1,8 @@
import { Maybe, Nothing } from "../../../Data/Maybe";
import { OrderedMap } from "../../../Data/OrderedMap";
import { fromDefault, makeLenses, Record } from "../../../Data/Record";
import { EditHitZoneArmor } from "./EditHitZoneArmor";
import { EditItem } from "./EditItem";
import { ArmorZonesEditorInstance } from "./heroTypeHelpers";
import { HitZoneArmor } from "./HitZoneArmor";
import { Item } from "./Item";
import { Purse } from "./Purse";
@@ -11,9 +11,9 @@ export interface Belongings {
items: OrderedMap<string, Record<Item>>
itemInEditor: Maybe<Record<EditItem>>
isInItemCreation: boolean
armorZones: OrderedMap<string, Record<HitZoneArmor>>
zoneArmorInEditor: Maybe<Record<ArmorZonesEditorInstance>>
isInZoneArmorCreation: boolean
hitZoneArmors: OrderedMap<string, Record<HitZoneArmor>>
hitZoneArmorInEditor: Maybe<Record<EditHitZoneArmor>>
isInHitZoneArmorCreation: boolean
purse: Record<Purse>
}
@@ -25,9 +25,9 @@ export const Belongings =
items: OrderedMap.empty,
itemInEditor: Nothing,
isInItemCreation: false,
armorZones: OrderedMap.empty,
zoneArmorInEditor: Nothing,
isInZoneArmorCreation: false,
hitZoneArmors: OrderedMap.empty,
hitZoneArmorInEditor: Nothing,
isInHitZoneArmorCreation: false,
purse: Purse .default,
})
+35
View File
@@ -0,0 +1,35 @@
import { isJust, Just, Maybe, Nothing } from "../../../Data/Maybe";
import { fromDefault, makeLenses, Record } from "../../../Data/Record";
import { HitZoneArmorBase } from "./HitZoneArmor";
export interface EditHitZoneArmor extends HitZoneArmorBase {
id: Maybe<string>
}
export interface EditHitZoneArmorSafe extends EditHitZoneArmor {
id: Just<string>
}
export const EditHitZoneArmor =
fromDefault<EditHitZoneArmor> ({
id: Nothing,
name: "",
head: Nothing,
headLoss: Nothing,
leftArm: Nothing,
leftArmLoss: Nothing,
rightArm: Nothing,
rightArmLoss: Nothing,
torso: Nothing,
torsoLoss: Nothing,
leftLeg: Nothing,
leftLegLoss: Nothing,
rightLeg: Nothing,
rightLegLoss: Nothing,
})
export const EditHitZoneArmorL = makeLenses (EditHitZoneArmor)
export const ensureHitZoneArmorId =
(x: Record<EditHitZoneArmor>): x is Record<EditHitZoneArmorSafe> =>
isJust (EditHitZoneArmor.AL.id (x))
+15 -6
View File
@@ -1,12 +1,16 @@
import { List } from "../../../Data/List";
import { Nothing } from "../../../Data/Maybe";
import { fromDefault } from "../../../Data/Record";
import { isJust, Just, Nothing } from "../../../Data/Maybe";
import { fromDefault, makeLenses, Record } from "../../../Data/Record";
import { EditPrimaryAttributeDamageThreshold } from "./EditPrimaryAttributeDamageThreshold";
import { ItemEditorSpecific } from "./heroTypeHelpers";
import { ItemBase } from "./Item";
export interface EditItem extends ItemBase, ItemEditorSpecific { }
export interface EditItemSafe extends EditItem {
id: Just<string>
}
export const EditItem =
fromDefault<EditItem> ({
id: Nothing,
@@ -15,16 +19,16 @@ export const EditItem =
combatTechnique: Nothing,
damageDiceSides: Nothing,
gr: 0,
isParryingWeapon: Nothing,
isParryingWeapon: false,
isTemplateLocked: false,
reach: Nothing,
template: Nothing,
where: Nothing,
isTwoHandedWeapon: Nothing,
isTwoHandedWeapon: false,
improvisedWeaponGroup: Nothing,
loss: Nothing,
forArmorZoneOnly: Nothing,
addPenalties: Nothing,
forArmorZoneOnly: false,
addPenalties: false,
armorType: Nothing,
at: "",
iniMod: "",
@@ -44,3 +48,8 @@ export const EditItem =
weight: "",
stabilityMod: "",
})
export const EditItemL = makeLenses (EditItem)
export const ensureEditId =
(x: Record<EditItem>): x is Record<EditItemSafe> => isJust (EditItem.AL.id (x))
+8 -2
View File
@@ -1,5 +1,5 @@
import { Maybe, Nothing } from "../../../Data/Maybe";
import { fromDefault } from "../../../Data/Record";
import { Just, Maybe, Nothing } from "../../../Data/Maybe";
import { fromDefault, makeLenses } from "../../../Data/Record";
import { PetBase } from "./Pet";
export interface EditPet extends PetBase {
@@ -34,6 +34,10 @@ export interface EditPet extends PetBase {
pa: string;
}
export interface EditPetSafe extends EditPet {
id: Just<string>
}
export const EditPet =
fromDefault<EditPet> ({
id: Nothing,
@@ -68,3 +72,5 @@ export const EditPet =
at: "",
pa: "",
})
export const EditPetL = makeLenses (EditPet)
@@ -1,14 +1,17 @@
import { List } from "../../../Data/List";
import { Maybe, Nothing } from "../../../Data/Maybe";
import { fromDefault } from "../../../Data/Record";
import { fromDefault, makeLenses } from "../../../Data/Record";
import { Pair } from "../../../Data/Tuple";
export interface EditPrimaryAttributeDamageThreshold {
primary: Maybe<string>
threshold: string | List<string>
threshold: string | Pair<string, string>
}
export const EditPrimaryAttributeDamageThreshold =
fromDefault<EditPrimaryAttributeDamageThreshold> ({
primary: Nothing,
threshold: List.empty,
threshold: "",
})
export const EditPrimaryAttributeDamageThresholdL =
makeLenses (EditPrimaryAttributeDamageThreshold)
+15 -6
View File
@@ -3,25 +3,28 @@ import { Maybe, Nothing } from "../../../Data/Maybe";
import { OrderedMap } from "../../../Data/OrderedMap";
import { OrderedSet } from "../../../Data/OrderedSet";
import { fromDefault, makeLenses, Record } from "../../../Data/Record";
import { currentVersion } from "../../Utils/Raw/compatibilityUtils";
import { current_version } from "../../Selectors/envSelectors";
import { ActivatableDependent } from "../ActiveEntries/ActivatableDependent";
import { ActivatableSkillDependent } from "../ActiveEntries/ActivatableSkillDependent";
import { AttributeDependent } from "../ActiveEntries/AttributeDependent";
import { SkillDependent } from "../ActiveEntries/SkillDependent";
import { L10n, L10nRecord } from "../Wiki/L10n";
import { Belongings } from "./Belongings";
import { EditPet } from "./EditPet";
import { Energies } from "./Energies";
import { Sex, StyleDependency } from "./heroTypeHelpers";
import { Sex } from "./heroTypeHelpers";
import { Pact } from "./Pact";
import { PersonalData } from "./PersonalData";
import { Pet } from "./Pet";
import { Rules } from "./Rules";
import { StyleDependency } from "./StyleDependency";
export type HeroModelRecord = Record<HeroModel>
export interface HeroModel {
id: string
clientVersion: string
locale: string
player: Maybe<string>
dateCreated: Date
dateModified: Date
@@ -59,6 +62,7 @@ export interface HeroModel {
combatStyleDependencies: List<Record<StyleDependency>>
magicalStyleDependencies: List<Record<StyleDependency>>
blessedStyleDependencies: List<Record<StyleDependency>>
skillStyleDependencies: List<Record<StyleDependency>>
}
/**
@@ -68,7 +72,8 @@ export interface HeroModel {
export const HeroModel =
fromDefault<HeroModel> ({
id: "",
clientVersion: currentVersion,
clientVersion: current_version,
locale: "",
player: Nothing,
dateCreated: new Date (),
dateModified: new Date (),
@@ -103,9 +108,10 @@ export const HeroModel =
petInEditor: Nothing,
isInPetCreation: false,
pact: Nothing,
combatStyleDependencies: List.empty,
magicalStyleDependencies: List.empty,
blessedStyleDependencies: List.empty,
combatStyleDependencies: List (),
magicalStyleDependencies: List (),
blessedStyleDependencies: List (),
skillStyleDependencies: List (),
})
export const HeroModelL = makeLenses (HeroModel)
@@ -115,6 +121,7 @@ export const HeroModelL = makeLenses (HeroModel)
* a new hero.
*/
export const getInitialHeroObject =
(l10n: L10nRecord) =>
(id: string) =>
(name: string) =>
(sex: "m" | "f") =>
@@ -125,6 +132,7 @@ export const getInitialHeroObject =
HeroModel ({
id,
clientVersion: Nothing,
locale: L10n.A.id (l10n),
dateCreated: new Date (),
dateModified: new Date (),
phase: Nothing,
@@ -158,4 +166,5 @@ export const getInitialHeroObject =
combatStyleDependencies: Nothing,
magicalStyleDependencies: Nothing,
blessedStyleDependencies: Nothing,
skillStyleDependencies: Nothing,
})
+3 -1
View File
@@ -1,5 +1,5 @@
import { Maybe, Nothing } from "../../../Data/Maybe";
import { fromDefault } from "../../../Data/Record";
import { fromDefault, makeLenses } from "../../../Data/Record";
export interface HitZoneArmorBase {
name: string
@@ -38,3 +38,5 @@ export const HitZoneArmor =
rightLeg: Nothing,
rightLegLoss: Nothing,
})
export const HitZoneArmorL = makeLenses (HitZoneArmor)

Some files were not shown because too many files have changed in this diff Show More