From 04d373b6b46f821b8d44c52105d183f4de75ce1d Mon Sep 17 00:00:00 2001 From: Mari Date: Thu, 4 May 2023 21:52:37 -0400 Subject: [PATCH] hell ya bby look at that life bar --- .idea/vcs.xml | 6 + README.md | 48 +------ package-lock.json | 290 ++++++++++++++++++++++++++++++++++++++++ package.json | 4 + src/App.tsx | 115 +++++++++++++--- src/CharacterStatus.css | 181 +++++++++++++++++++++++++ src/CharacterStatus.tsx | 232 ++++++++++++++++++++++++++++++++ src/SpringyValueHook.ts | 131 ++++++++++++++++++ src/fabula-points.svg | 20 +++ src/logo.svg | 1 - src/resource_bar.tsx | 81 +++++++++++ src/type_check.ts | 3 + src/ultima-points.svg | 20 +++ 13 files changed, 1068 insertions(+), 64 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 src/CharacterStatus.css create mode 100644 src/CharacterStatus.tsx create mode 100644 src/SpringyValueHook.ts create mode 100644 src/fabula-points.svg delete mode 100644 src/logo.svg create mode 100644 src/resource_bar.tsx create mode 100644 src/type_check.ts create mode 100644 src/ultima-points.svg diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index b87cb00..48dc46f 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,4 @@ -# Getting Started with Create React App +# Image Sources -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.\ -You will also see any lint errors in the console. - -### `npm test` - -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). +* src/fabula-points.svg: https://game-icons.net/1x1/lorc/star-swirl.html +* src/ultima-points.svg: https://game-icons.net/1x1/lorc/evil-moon.html \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bbec164..c71b161 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "fabula-ultima-react", "version": "0.1.0", "dependencies": { + "@react-spring/web": "^9.7.2", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", @@ -15,7 +16,10 @@ "@types/node": "^16.18.23", "@types/react": "^18.0.33", "@types/react-dom": "^18.0.11", + "bootstrap": "^5.2.3", + "csstype": "^3.1.2", "react": "^18.2.0", + "react-bootstrap": "^2.7.2", "react-dom": "^18.2.0", "react-scripts": "5.0.1", "typescript": "^4.9.5", @@ -3081,6 +3085,135 @@ } } }, + "node_modules/@popperjs/core": { + "version": "2.11.7", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.7.tgz", + "integrity": "sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, + "node_modules/@react-aria/ssr": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.6.0.tgz", + "integrity": "sha512-OFiYQdv+Yk7AO7IsQu/fAEPijbeTwrrEYvdNoJ3sblBBedD5j5fBTNWrUPNVlwC4XWWnWTCMaRIVsJujsFiWXg==", + "dependencies": { + "@swc/helpers": "^0.4.14" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0" + } + }, + "node_modules/@react-spring/animated": { + "version": "9.7.2", + "resolved": "https://registry.npmjs.org/@react-spring/animated/-/animated-9.7.2.tgz", + "integrity": "sha512-ipvleJ99ipqlnHkz5qhSsgf/ny5aW0ZG8Q+/2Oj9cI7LCc7COdnrSO6V/v8MAX3JOoQNzfz6dye2s5Pt5jGaIA==", + "dependencies": { + "@react-spring/shared": "~9.7.2", + "@react-spring/types": "~9.7.2" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@react-spring/core": { + "version": "9.7.2", + "resolved": "https://registry.npmjs.org/@react-spring/core/-/core-9.7.2.tgz", + "integrity": "sha512-fF512edZT/gKVCA90ZRxfw1DmELeVwiL4OC2J6bMUlNr707C0h4QRoec6DjzG27uLX2MvS1CEatf9KRjwZR9/w==", + "dependencies": { + "@react-spring/animated": "~9.7.2", + "@react-spring/rafz": "~9.7.2", + "@react-spring/shared": "~9.7.2", + "@react-spring/types": "~9.7.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/react-spring/donate" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@react-spring/rafz": { + "version": "9.7.2", + "resolved": "https://registry.npmjs.org/@react-spring/rafz/-/rafz-9.7.2.tgz", + "integrity": "sha512-kDWMYDQto3+flkrX3vy6DU/l9pxQ4TVW91DglQEc11iDc7shF4+WVDRJvOVLX+xoMP7zyag1dMvlIgvQ+dvA/A==" + }, + "node_modules/@react-spring/shared": { + "version": "9.7.2", + "resolved": "https://registry.npmjs.org/@react-spring/shared/-/shared-9.7.2.tgz", + "integrity": "sha512-6U9qkno+9DxlH5nSltnPs+kU6tYKf0bPLURX2te13aGel8YqgcpFYp5Av8DcN2x3sukinAsmzHUS/FRsdZMMBA==", + "dependencies": { + "@react-spring/rafz": "~9.7.2", + "@react-spring/types": "~9.7.2" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@react-spring/types": { + "version": "9.7.2", + "resolved": "https://registry.npmjs.org/@react-spring/types/-/types-9.7.2.tgz", + "integrity": "sha512-GEflx2Ex/TKVMHq5g5MxQDNNPNhqg+4Db9m7+vGTm8ttZiyga7YQUF24shgRNebKIjahqCuei16SZga8h1pe4g==" + }, + "node_modules/@react-spring/web": { + "version": "9.7.2", + "resolved": "https://registry.npmjs.org/@react-spring/web/-/web-9.7.2.tgz", + "integrity": "sha512-7qNc7/5KShu2D05x7o2Ols2nUE7mCKfKLaY2Ix70xPMfTle1sZisoQMBFgV9w/fSLZlHZHV9P0uWJqEXQnbV4Q==", + "dependencies": { + "@react-spring/animated": "~9.7.2", + "@react-spring/core": "~9.7.2", + "@react-spring/shared": "~9.7.2", + "@react-spring/types": "~9.7.2" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@restart/hooks": { + "version": "0.4.9", + "resolved": "https://registry.npmjs.org/@restart/hooks/-/hooks-0.4.9.tgz", + "integrity": "sha512-3BekqcwB6Umeya+16XPooARn4qEPW6vNvwYnlofIYe6h9qG1/VeD7UvShCWx11eFz5ELYmwIEshz+MkPX3wjcQ==", + "dependencies": { + "dequal": "^2.0.2" + }, + "peerDependencies": { + "react": ">=16.8.0" + } + }, + "node_modules/@restart/ui": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@restart/ui/-/ui-1.6.2.tgz", + "integrity": "sha512-hcYs8PwpmHEtwjihLVn2Jr89yrYajfhxN5HtTq3HA9U3+feg1SC3swBM8/qibMTCFsXWToEEtzJMV+LWE+Qjpg==", + "dependencies": { + "@babel/runtime": "^7.21.0", + "@popperjs/core": "^2.11.6", + "@react-aria/ssr": "^3.5.0", + "@restart/hooks": "^0.4.9", + "@types/warning": "^3.0.0", + "dequal": "^2.0.3", + "dom-helpers": "^5.2.0", + "uncontrollable": "^8.0.0", + "warning": "^4.0.3" + }, + "peerDependencies": { + "react": ">=16.14.0", + "react-dom": ">=16.14.0" + } + }, + "node_modules/@restart/ui/node_modules/uncontrollable": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-8.0.0.tgz", + "integrity": "sha512-a954G/0JyXoZdpt0YIzTfoQyWtRS1VvygOBsHttCtZL8jDTKd6vQlUo811y46XnWoXIqQ36QKi3cSEdPuFADkA==", + "dependencies": { + "@types/react": ">=18.0.28" + }, + "peerDependencies": { + "react": ">=17.0.0" + } + }, "node_modules/@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -3399,6 +3532,14 @@ "url": "https://github.com/sponsors/gregberge" } }, + "node_modules/@swc/helpers": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.14.tgz", + "integrity": "sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@testing-library/dom": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.2.0.tgz", @@ -3939,6 +4080,14 @@ "@types/react": "*" } }, + "node_modules/@types/react-transition-group": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.5.tgz", + "integrity": "sha512-juKD/eiSM3/xZYzjuzH6ZwpP+/lejltmiS3QEzV/vmb/Q8+HfDmxu+Baga8UEMGBqV88Nbg4l2hY/K2DkyaLLA==", + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -4005,6 +4154,11 @@ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.3.tgz", "integrity": "sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==" }, + "node_modules/@types/warning": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz", + "integrity": "sha512-t/Tvs5qR47OLOr+4E9ckN8AmP2Tf16gWq+/qA4iUGS/OOyHVO8wv2vjJuX8SNOUTJyWb+2t7wJm6cXILFnOROA==" + }, "node_modules/@types/ws": { "version": "8.5.4", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.4.tgz", @@ -5219,6 +5373,24 @@ "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" }, + "node_modules/bootstrap": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.3.tgz", + "integrity": "sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], + "peerDependencies": { + "@popperjs/core": "^2.11.6" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -5479,6 +5651,11 @@ "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz", "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==" }, + "node_modules/classnames": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz", + "integrity": "sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==" + }, "node_modules/clean-css": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.2.tgz", @@ -6292,6 +6469,14 @@ "node": ">= 0.8" } }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "engines": { + "node": ">=6" + } + }, "node_modules/destroy": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", @@ -6412,6 +6597,15 @@ "utila": "~0.4" } }, + "node_modules/dom-helpers": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", + "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==", + "dependencies": { + "@babel/runtime": "^7.8.7", + "csstype": "^3.0.2" + } + }, "node_modules/dom-serializer": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", @@ -8787,6 +8981,14 @@ "node": ">= 0.4" } }, + "node_modules/invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "dependencies": { + "loose-envify": "^1.0.0" + } + }, "node_modules/ipaddr.js": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.1.tgz", @@ -13755,6 +13957,23 @@ "react-is": "^16.13.1" } }, + "node_modules/prop-types-extra": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/prop-types-extra/-/prop-types-extra-1.1.1.tgz", + "integrity": "sha512-59+AHNnHYCdiC+vMwY52WmvP5dM3QLeoumYuEyceQDi9aEhtwN9zIQ2ZNo25sMyXnbh32h+P1ezDsUpUH3JAew==", + "dependencies": { + "react-is": "^16.3.2", + "warning": "^4.0.0" + }, + "peerDependencies": { + "react": ">=0.14.0" + } + }, + "node_modules/prop-types-extra/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + }, "node_modules/prop-types/node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -13935,6 +14154,35 @@ "node": ">=14" } }, + "node_modules/react-bootstrap": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-2.7.2.tgz", + "integrity": "sha512-WDSln+mG4RLLFO01stkj2bEx/3MF4YihK9D/dWnHaSxOiQZLbhhlf95D2Jb20X3t2m7vMxRe888FVrfLJoGmmA==", + "dependencies": { + "@babel/runtime": "^7.17.2", + "@restart/hooks": "^0.4.6", + "@restart/ui": "^1.4.1", + "@types/react-transition-group": "^4.4.4", + "classnames": "^2.3.1", + "dom-helpers": "^5.2.1", + "invariant": "^2.2.4", + "prop-types": "^15.8.1", + "prop-types-extra": "^1.1.0", + "react-transition-group": "^4.4.2", + "uncontrollable": "^7.2.1", + "warning": "^4.0.3" + }, + "peerDependencies": { + "@types/react": ">=16.14.8", + "react": ">=16.14.0", + "react-dom": ">=16.14.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/react-dev-utils": { "version": "12.0.1", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz", @@ -14074,6 +14322,11 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" }, + "node_modules/react-lifecycles-compat": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", + "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" + }, "node_modules/react-refresh": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", @@ -14154,6 +14407,21 @@ } } }, + "node_modules/react-transition-group": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", + "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==", + "dependencies": { + "@babel/runtime": "^7.5.5", + "dom-helpers": "^5.0.1", + "loose-envify": "^1.4.0", + "prop-types": "^15.6.2" + }, + "peerDependencies": { + "react": ">=16.6.0", + "react-dom": ">=16.6.0" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -15892,6 +16160,20 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/uncontrollable": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-7.2.1.tgz", + "integrity": "sha512-svtcfoTADIB0nT9nltgjujTi7BzVmwjZClOmskKu/E8FW9BXzg9os8OLr4f8Dlnk0rYWJIWr4wv9eKUXiQvQwQ==", + "dependencies": { + "@babel/runtime": "^7.6.3", + "@types/react": ">=16.9.11", + "invariant": "^2.2.4", + "react-lifecycles-compat": "^3.0.4" + }, + "peerDependencies": { + "react": ">=15.0.0" + } + }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", @@ -16100,6 +16382,14 @@ "makeerror": "1.0.12" } }, + "node_modules/warning": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz", + "integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==", + "dependencies": { + "loose-envify": "^1.0.0" + } + }, "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", diff --git a/package.json b/package.json index 3c3c139..1a02dde 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "@react-spring/web": "^9.7.2", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", @@ -10,7 +11,10 @@ "@types/node": "^16.18.23", "@types/react": "^18.0.33", "@types/react-dom": "^18.0.11", + "bootstrap": "^5.2.3", + "csstype": "^3.1.2", "react": "^18.2.0", + "react-bootstrap": "^2.7.2", "react-dom": "^18.2.0", "react-scripts": "5.0.1", "typescript": "^4.9.5", diff --git a/src/App.tsx b/src/App.tsx index a53698a..2edd3b3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,25 +1,104 @@ -import React from 'react'; -import logo from './logo.svg'; +import React, {ChangeEvent, useCallback, useMemo, useState} from 'react'; import './App.css'; +import {Col, Container, Form, InputGroup, Row,} from "react-bootstrap"; +import {Character, CharacterStatus, SPType} from "./CharacterStatus"; function App() { + const [maxHp, _setMaxHp] = useState(1) + const [hp, _setHp] = useState(1) + const setHp = useCallback(function (v: number) { + v = Math.floor(v) + if (Number.isNaN(v) || v < 0 || v > maxHp || v === hp) { + return + } + _setHp(v) + }, [hp, maxHp]) + const setHpMax = useCallback(function (v: number) { + v = Math.floor(v) + if (Number.isNaN(v) || v < 0 || v > 9999 || v === maxHp) { + return + } + if (v < hp) { + setHp(v) + } + _setMaxHp(v) + }, [hp, maxHp, setHp]) + const onHpChange = useCallback( + (e: ChangeEvent) => setHp(parseInt(e.target.value)), [setHp]) + const onMaxHpChange = useCallback( + (e: ChangeEvent) => setHpMax(parseInt(e.target.value)), [setHpMax]) + const [maxMp, _setMaxMp] = useState(6) + const [mp, _setMp] = useState(6) + const setMp = useCallback(function (v: number) { + v = Math.floor(v) + if (Number.isNaN(v) || v < 0 || v > maxMp || v === mp) { + return + } + _setMp(v) + }, [mp, maxMp]) + const setMpMax = useCallback(function (v: number) { + v = Math.floor(v) + if (Number.isNaN(v) || v < 0 || v > 9999 || v === maxMp) { + return + } + if (v < mp) { + setMp(v) + } + _setMaxMp(v) + }, [mp, maxMp, setMp]) + const onMpChange = useCallback( + (e: ChangeEvent) => setMp(parseInt(e.target.value)), [setMp]) + const onMaxMpChange = useCallback( + (e: ChangeEvent) => setMpMax(parseInt(e.target.value)), [setMpMax]) + + const character = useMemo(() => ({ + name: "Test", + level: 50, + hp: 40, + maxHp: 50, + mp: 40, + maxMp: 50, + ip: mp, + maxIp: maxMp, + sp: 1, + spType: SPType.UltimaPoints, + turnsLeft: hp, + turnsTotal: maxHp, + }), [hp, maxHp, mp, maxMp]) return ( -
-
- logo -

- Edit src/App.tsx and save to reload. -

- - Learn React - -
-
+ + + + + Max HP + + + + + + Current HP + + + + + + + + Max MP + + + + + + Current MP + + + + + + + + ); } diff --git a/src/CharacterStatus.css b/src/CharacterStatus.css new file mode 100644 index 0000000..b8993df --- /dev/null +++ b/src/CharacterStatus.css @@ -0,0 +1,181 @@ +.characterStatus { + height: 150px; + width: 500px; + position: relative; + background-color: #454; +} + +.characterHeader { + position: absolute; + left: 160px; + bottom: 60px; + z-index: 4; +} + +.characterLevel { + display: inline; + color: white; + -webkit-text-stroke: 1px rgba(0, 0, 0, 0.2); + text-shadow: 0 0 2px black; + margin-right: 0.25em; +} + +.characterLevelLabel { + font-size: smaller; + font-variant: small-caps; +} + +.characterName { + display: inline; + color: white; + font-family: sans-serif; + font-weight: bold; + font-size: 30px; + text-align: left; + -webkit-text-stroke: 1px rgba(0, 0, 0, 0.5); + text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); +} + +.characterHpBar, .characterMpBar, .characterIpBar { + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5); + border: 2px solid black; + transform: skewX(-30deg) translateX(15px); + border-radius: 5px; + position: absolute; + width: calc(100% - 30px); + margin: 2px 2px 8px 5px; + bottom: 0; +} + +.characterHpValue, .characterMpValue, .characterIpValue { + color: white; + font-family: sans-serif; + font-weight: bold; + font-style: italic; + font-size: 60px; + text-align: right; + -webkit-text-stroke: 1px black; + text-shadow: 2px 2px rgba(0, 0, 0, 0.5); + position: absolute; + bottom: 5px; +} + +.characterHp { + position: absolute; + height: 60px; + left: 112px; + right: 0; + bottom: 28px; + overflow: visible; + z-index: 1; +} + +.characterHpBar { + height: 25px; +} + +.characterHpValue { + font-size: 60px; + right: 5px; +} + +.characterMp, .characterIp { + position: absolute; + bottom: 0; + height: 40px; +} + +.characterMp { + left: 95px; + right: 155px; + z-index: 3; +} + +.characterIp { + width: 150px; + right: 20px; + z-index: 2; +} + +.characterMpBar, .characterIpBar { + height: 20px; +} + +.characterMpValue, .characterIpValue { + font-size: 40px; + right: 10px; +} + +.characterMpBar { + height: 20px; +} + +.characterMpValue { + font-size: 40px; +} + +.characterPortrait { + position: absolute; + top: 10px; + bottom: 15px; + left: 50px; + width: 125px; + background: no-repeat center / cover; + z-index: 0; +} + +.characterTurns { + position: absolute; + top: 5px; + left: 5px; + width: 40px; + height: 40px; + font-size: 40px; + font-weight: bold; + -webkit-text-stroke: 2px black; + text-shadow: 2px 2px 2px black ; + line-height: 40px; + text-align: center; + box-sizing: border-box; + border: 2px solid black; + border-radius: 9px 0; + color: white; + background-color: deepskyblue; +} + +.characterTurnsDone { + background-color: darkblue; +} + +.characterSp { + position: absolute; + color: white; + line-height: 40px; + -webkit-text-stroke: 2px black; + text-shadow: 2px 2px 2px black ; + font-size: 30px; + letter-spacing: -3px; + text-align: center; + font-weight: bold; + bottom: 5px; + left: 5px; + width: 40px; + height: 40px; +} + +.characterSpFabula { + background: url("fabula-points.svg"); +} + +.characterSpUltima { + background: url("ultima-points.svg"); +} + +.characterSp { + opacity: 50%; + transition: opacity 0.3s ease-out; +} + +.characterSp:hover { + opacity: 100%; +} \ No newline at end of file diff --git a/src/CharacterStatus.tsx b/src/CharacterStatus.tsx new file mode 100644 index 0000000..f323979 --- /dev/null +++ b/src/CharacterStatus.tsx @@ -0,0 +1,232 @@ +import { animated } from "@react-spring/web"; +import {ReactElement, useMemo} from "react"; +import { + evaluateResourceBarStyles, + ResourceBarColors, + ResourceBarStyles +} from "./resource_bar"; +import {isDefined} from "./type_check"; +import { + SpringyValueInterpolatables, + useSpringyValue +} from "./SpringyValueHook"; +import "./CharacterStatus.css"; + +export enum CharacterHealth { + Full = "Full", + Healthy = "Healthy", + Wounded = "Wounded", + Crisis = "Crisis", + Peril = "Peril", + KO = "KO", +} + +export enum CharacterTurnState { + None = "None", + Ready = "Ready", + HighTurns = "HighTurns", + Done = "Done", + CantAct = "CantAct", + KO = "KO", +} + +export enum SPType { + UltimaPoints = "Ultima", + FabulaPoints = "Fabula", +} + +export interface StatusEffect { + name: string + iconUrl: string +} + +export interface Character { + portraitUrl?: string + name?: string + level?: number + hp?: number + maxHp?: number + health?: CharacterHealth + mp?: number + maxMp?: number + ip?: number + maxIp?: number + sp?: number + spType?: SPType + turnsLeft?: number + turnsTotal?: number + canAct?: boolean + statuses?: StatusEffect[] +} + +const hpBarStyle: SpringyValueInterpolatables = { + foreground: 'linear-gradient(to bottom, rgb(255, 255, 255, 0.1) 0%, rgb(0, 0, 0, 0) 30% 50%, rgb(0, 0, 0, 0.1) 80%, rgb(0, 0, 0, 0.2) 95%, rgb(0, 0, 0, 0.3) 100%)', + barDirection: "to right", + barColors: ({flashValue}: {flashValue: number}): ResourceBarColors => { + return { + emptiedColor: `rgb(${Math.min(1, Math.max(flashValue, 0)) * 55 + 55}, 55, 55)`, + toEmptyColor: 'rgb(200, 0, 0)', + toFillColor: 'rgb(150, 250, 250)', + filledColor: 'rgb(0, 200, 0)', + } + }, +} + +const mpBarStyle: SpringyValueInterpolatables = { + foreground: 'linear-gradient(to bottom, rgb(255, 255, 255, 0.1) 0%, rgb(0, 0, 0, 0) 30% 50%, rgb(0, 0, 0, 0.1) 80%, rgb(0, 0, 0, 0.2) 95%, rgb(0, 0, 0, 0.3) 100%)', + barColors: ({flashValue}: {flashValue: number}): ResourceBarColors => { + return { + emptiedColor: `rgb(${Math.min(1, Math.max(flashValue, 0)) * 55 + 55}, 55, 55)`, + toEmptyColor: 'rgb(250, 250, 60)', + toFillColor: 'rgb(150, 250, 250)', + filledColor: 'rgb(0, 150, 255)', + } + }, +} + +const ipBarStyle: SpringyValueInterpolatables = { + foreground: 'linear-gradient(to bottom, rgb(255, 255, 255, 0.1) 0%, rgb(0, 0, 0, 0) 30% 50%, rgb(0, 0, 0, 0.1) 80%, rgb(0, 0, 0, 0.2) 95%, rgb(0, 0, 0, 0.3) 100%)', + barColors: ({flashValue}: {flashValue: number}): ResourceBarColors => { + return { + emptiedColor: `rgb(${Math.min(1, Math.max(flashValue, 0)) * 55 + 55}, 55, 55)`, + toEmptyColor: 'rgb(160, 55, 195)', + toFillColor: 'rgb(250, 250, 60)', + filledColor: 'rgb(255, 150, 55)', + } + }, +} + +export function CharacterStatus({character}: {character: Character}): ReactElement { + const {name, level, health} = character + + const {hp, maxHp} = character + const {interpolate: hpInterpolate} = useSpringyValue({ + current: hp, + max: maxHp, + flash: isDefined(maxHp) && isDefined(hp) && hp * 2 < maxHp && hp > 0, + }) + const {hpText, hpBarStyleInterpolated} = useMemo(() => { + if (isDefined(hp) && isDefined(maxHp) && maxHp > 0) { + return { + hpText: hpInterpolate(({recentValue}) => `${Math.round(recentValue)}`), + hpBarStyleInterpolated: evaluateResourceBarStyles(hpBarStyle, hpInterpolate), + } + } else { + return {} + } + }, [hp, maxHp, hpInterpolate]) + + const {mp, maxMp} = character + const {interpolate: mpInterpolate} = useSpringyValue({ + current: mp, + max: maxMp, + flash: false, + }) + const {mpText, mpBarStyleInterpolated} = useMemo(() => { + if (isDefined(mp) && isDefined(maxMp) && maxMp > 0) { + return { + mpText: mpInterpolate(({recentValue}) => `${Math.round(recentValue)}`), + mpBarStyleInterpolated: evaluateResourceBarStyles(mpBarStyle, mpInterpolate), + } + } else { + return {} + } + }, [mp, maxMp, mpInterpolate]) + + const {ip, maxIp} = character + const {interpolate: ipInterpolate} = useSpringyValue({ + current: ip, + max: maxIp, + flash: false, + }) + const {ipText, ipBarStyleInterpolated} = useMemo(() => { + if (isDefined(ip) && isDefined(maxIp) && maxIp > 0) { + return { + ipText: ipInterpolate(({recentValue}) => `${Math.round(recentValue)}`), + ipBarStyleInterpolated: evaluateResourceBarStyles(ipBarStyle, ipInterpolate), + } + } else { + return {} + } + }, [ip, maxIp, ipInterpolate]) + + const {sp, spType} = character + const {interpolate: spInterpolate} = useSpringyValue({ + current: sp, + flash: isDefined(spType) && isDefined(sp) && sp > 0, + }) + const {spText} = useMemo(() => { + if (isDefined(sp) && isDefined(spType)) { + return { + spText: spInterpolate(({recentValue}) => recentValue.toFixed(0)) + } + } else { + return {} + } + }, [sp, spType, spInterpolate]) + + const {turnsLeft, turnsTotal, canAct} = character + const {turnsState, turnsText} = useMemo(() => { + if (isDefined(turnsTotal) && hp === 0 && isDefined(maxHp) && maxHp > 0) { + return { + turnsState: CharacterTurnState.KO, + } + } else if (isDefined(turnsTotal) && (canAct === false || turnsTotal === 0)) { + return { + turnsState: CharacterTurnState.CantAct, + } + } else if (isDefined(turnsTotal) && turnsLeft === 0) { + return { + turnsState: CharacterTurnState.Done, + } + } else if (turnsTotal === 1 && turnsLeft === 1) { + return { + turnsState: CharacterTurnState.Ready, + } + } else if (isDefined(turnsTotal) && turnsTotal > 1 && isDefined(turnsLeft)) { + return { + turnsState: CharacterTurnState.HighTurns, + turnsText: `${turnsLeft}` + } + } else { + return { + turnsState: CharacterTurnState.None + } + } + }, [hp, maxHp, canAct, turnsLeft, turnsTotal]) + + return
+
+ {isDefined(turnsState) && +
{turnsText}
} +
+ {isDefined(level) && +
+ Lv + {level} +
} + {isDefined(name) && +
{name}
} +
+ {isDefined(hpText) && +
+ + {hpText} +
} + {isDefined(mpText) && +
+ + {mpText} +
} + {isDefined(ipText) && +
+ + {ipText} +
} + {isDefined(spText) && + + + {spText} + } +
+} diff --git a/src/SpringyValueHook.ts b/src/SpringyValueHook.ts new file mode 100644 index 0000000..12b91f4 --- /dev/null +++ b/src/SpringyValueHook.ts @@ -0,0 +1,131 @@ +import {useCallback, useMemo, useState} from "react"; +import {Interpolation, SpringConfig, SpringValue, to, useSpring, useTrail} from "@react-spring/web"; + +export interface UseSpringyValueProps { + current?: number + max?: number + flash?: boolean + springDelays?: readonly [number, number, number] + springConfigs?: readonly [SpringConfig, SpringConfig, SpringConfig] + flashConfig?: SpringConfig +} + +export interface UseSpringyValueOutput { + springs: {v: SpringValue}[] + flashSpring: {v: SpringValue} + interpolate: SpringyValueInterpolate +} + +export interface SpringyValues { + currentValue?: number // The true current value of the resource, after the recent delta. + displayedValue: number // The displayed current value of the resource, after the recent delta. + newValue: number // The displayed value of the resource as of ~2 seconds ago. + recentValue: number // The end of the delta that's being applied. + maxValue?: number // The maximum value of the resource. + previousValue?: number // The original value before the most recent delta. + flashValue: number // The position in the oscillation of the flashing resource. + flashing?: boolean // Whether the resource is actively flashing. +} + +const literalSymbol: unique symbol = Symbol("SpringyValueLiteralSymbol") +export type SpringyValueLiteral = {[literalSymbol]: T} +export function markSpringyValueLiteral(value: T): SpringyValueLiteral { + return {[literalSymbol]: value} +} +export function isSpringyValueLiteral(value: SpringyValueInterpolatable): value is SpringyValueLiteral { + return typeof value === "object" && value !== null && Object.hasOwn(value, literalSymbol) +} +export type SpringyValueInterpolator = (v: SpringyValues) => T +export type SpringyValueInterpolatable = SpringyValueLiteral | Exclude | SpringyValueInterpolator +export type SpringyValueInterpolate = (v: SpringyValueInterpolatable) => SpringyValueInterpolated +export type SpringyValueInterpolated = T | Interpolation +export type SpringyValueInterpolatables = + {[Property in keyof TargetType]: SpringyValueInterpolatable} +export type SpringyValueInterpolateds = + {[Property in keyof TargetType]: SpringyValueInterpolated} + +export function evaluateSpringyValueInterpolator(f: SpringyValueInterpolatable, v: SpringyValues): T { + if (f instanceof Function) { + return f(v) + } else if (isSpringyValueLiteral(f)) { + return f[literalSymbol] + } else { + return f + } +} +export function interpolateSpringyValueInterpolatables(values: SpringyValueInterpolatables, interpolator: SpringyValueInterpolate): SpringyValueInterpolateds { + const result: {[key: string]: SpringyValueInterpolated} = {} + for (const [key, value] of Object.entries(values) as [string, SpringyValueInterpolatable][]) { + result[key] = interpolator(value) + } + return result as SpringyValueInterpolateds +} + +const DEFAULT_SPRING_DELAYS = [0, 500, 50] as const +const DEFAULT_SPRING_CONFIGS: readonly [SpringConfig, SpringConfig, SpringConfig] = [{tension: 1200, friction: 40, precision: 0.1, round: 0.001, clamp: true}, {tension: 200, friction: 20, precision: 0.1, round: 0.001}, {mass: 2, tension: 200, friction: 90, precision: 0.1, round: 0.001}] +const DEFAULT_FLASH_CONFIG: SpringConfig = { + tension: 170, + friction: 26, + clamp: true, +} + +export function useSpringyValue({current, max, flash, springConfigs=DEFAULT_SPRING_CONFIGS, springDelays=DEFAULT_SPRING_DELAYS, flashConfig=DEFAULT_FLASH_CONFIG}: UseSpringyValueProps): UseSpringyValueOutput { + const [lastCurrent, setLastCurrent] = useState(current) + const [wasFlashing, setWasFlashing] = useState(flash) + + const [springs, barApi] = useTrail(3, () => ({ + v: current ?? 0 + }), []) + const [flashSpring, flashApi] = useSpring({ + from: {v: 0}, + to: flash ? [{v: 1}, {v: 0}] : [{v: 0}], + loop: flash, + config: flashConfig, + }, []) + + const interpolate = useCallback(function (v: SpringyValueInterpolatable): SpringyValueInterpolated { + if (v instanceof Function) { + return to([...springs.map(s => s.v), flashSpring.v], + (displayedValue: number, newValue: number, recentValue: number, flashValue: number) => v({ + currentValue: current, + displayedValue, + newValue, + recentValue, + flashValue, + maxValue: max, + previousValue: lastCurrent, + flashing: flash ?? false + })) + } else if (isSpringyValueLiteral(v)) { + return v[literalSymbol] + } else { + return v + } + }, [current, lastCurrent, max, flash, springs, flashSpring.v]) + + if (flash !== wasFlashing) { + if (flash && !wasFlashing) { + flashApi.start({to: [{v: 1}, {v: 0}], loop: true}) + } else if (!flash && wasFlashing) { + flashApi.start({to: [{v: 0}], loop: false}) + } + setWasFlashing(flash) + } + + if (current !== lastCurrent) { + barApi.stop(true) + if ((lastCurrent ?? 0) < (current ?? 0)) { + barApi.set((idx, ctrl) => ({ v: Math.max(lastCurrent ?? 0, ctrl.get().v) })) + } else { + barApi.set((idx, ctrl) => ({ v: Math.min(lastCurrent ?? 0, ctrl.get().v) })) + } + barApi.start((i) => ({to: [{v: current ?? 0}], immediate: false, delay: springDelays[i], config: springConfigs[i]})) + setLastCurrent(current) + } + + return useMemo(() => ({ + springs, + flashSpring, + interpolate, + }), [springs, flashSpring, interpolate]) +} \ No newline at end of file diff --git a/src/fabula-points.svg b/src/fabula-points.svg new file mode 100644 index 0000000..196c123 --- /dev/null +++ b/src/fabula-points.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/logo.svg b/src/logo.svg deleted file mode 100644 index 9dfc1c0..0000000 --- a/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/resource_bar.tsx b/src/resource_bar.tsx new file mode 100644 index 0000000..e0887d3 --- /dev/null +++ b/src/resource_bar.tsx @@ -0,0 +1,81 @@ +import CSS from "csstype"; +import { + evaluateSpringyValueInterpolator, interpolateSpringyValueInterpolatables, + SpringyValueInterpolatables, + SpringyValueInterpolate, + SpringyValueInterpolateds, + SpringyValues +} from "./SpringyValueHook"; +import {isDefined} from "./type_check"; + +export interface ResourceBarColors { + filledColor: CSS.Property.Color + toFillColor: CSS.Property.Color + toEmptyColor: CSS.Property.Color + emptiedColor: CSS.Property.Color +} + +export function resourceGradient( + {filledColor, toFillColor, toEmptyColor, emptiedColor}: ResourceBarColors, + {displayedValue, recentValue, newValue, maxValue}: SpringyValues, + direction: string): string { + const effectiveMax = isDefined(maxValue) && maxValue !== 0 ? maxValue : Number.POSITIVE_INFINITY + const currentStop = Math.min(Math.max(100 * displayedValue / effectiveMax, 0), 100) + const currentSoftEdgeLeft = Math.min(Math.max(currentStop - 0.2, 0), 100) + const currentSoftEdgeRight = Math.min(Math.max(currentStop + 0.2, 0), 100) + + const endFillingStop = Math.min(Math.max(100 * recentValue / effectiveMax, 0), currentStop) + const midFillingStop = Math.min(Math.max(100 * newValue / effectiveMax, endFillingStop), currentStop) + + const endFadingStop = Math.min(Math.max(100 * recentValue / effectiveMax, currentStop), 100) + const midFadingStop = + Math.min(Math.max(100 * newValue / effectiveMax, currentStop), endFadingStop) + + const layers = [] + if (currentStop === 100) { + layers.unshift(filledColor) + } else { + layers.unshift(emptiedColor) + if (currentStop > 0) { + layers.unshift(`linear-gradient(${direction}, ${filledColor} 0% ${currentSoftEdgeLeft.toFixed(4)}%, transparent ${currentSoftEdgeRight.toFixed(4)}% 100%)`) + } + } + if (endFillingStop !== currentStop || midFillingStop !== currentStop) { + layers.unshift(`linear-gradient(${direction}, transparent 0% ${endFillingStop.toFixed(4)}%, ${toFillColor} ${midFillingStop.toFixed(4)}% ${currentSoftEdgeLeft.toFixed(4)}%, transparent ${currentSoftEdgeRight.toFixed(4)}% 100%)`) + } + if (endFadingStop !== currentStop || midFadingStop !== currentStop) { + layers.unshift(`linear-gradient(${direction}, transparent 0% ${currentSoftEdgeLeft.toFixed(4)}%, ${toEmptyColor} ${currentSoftEdgeRight.toFixed(4)}% ${midFadingStop.toFixed(4)}%, transparent ${endFadingStop.toFixed(4)}% 100%)`) + } + return layers.join(", ") +} + +export interface ResourceBarStyles extends CSS.Properties { + foreground?: CSS.Properties["background"] + barDirection?: string + barColors?: ResourceBarColors +} + +export const DEFAULT_BAR_COLORS: ResourceBarColors = { + emptiedColor: 'black', + filledColor: 'limegreen', + toEmptyColor: 'red', + toFillColor: 'cyan', +} as const + +export const DEFAULT_BAR_DIRECTION: string = "to right" + +export function evaluateResourceBarStyles(barStyle: SpringyValueInterpolatables, interpolate: SpringyValueInterpolate) { + const intermediate: SpringyValueInterpolatables = Object.assign({}, barStyle) + delete intermediate.background + delete intermediate.foreground + delete intermediate.barColors + delete intermediate.barDirection + intermediate.background = (v: SpringyValues) => [ + evaluateSpringyValueInterpolator(barStyle["foreground"], v) as string | undefined, + resourceGradient( + evaluateSpringyValueInterpolator(barStyle["barColors"], v) ?? DEFAULT_BAR_COLORS, v, + evaluateSpringyValueInterpolator(barStyle["barDirection"], v) ?? DEFAULT_BAR_DIRECTION), + evaluateSpringyValueInterpolator(barStyle["background"], v) as string | undefined + ].filter((s) => !!s).join(', ') + return interpolateSpringyValueInterpolatables(intermediate as SpringyValueInterpolateds, interpolate) +} \ No newline at end of file diff --git a/src/type_check.ts b/src/type_check.ts new file mode 100644 index 0000000..ae99339 --- /dev/null +++ b/src/type_check.ts @@ -0,0 +1,3 @@ +export function isDefined(i: T | undefined): i is T { + return typeof i !== "undefined" +} \ No newline at end of file diff --git a/src/ultima-points.svg b/src/ultima-points.svg new file mode 100644 index 0000000..e84cd74 --- /dev/null +++ b/src/ultima-points.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file