@rpg-engine/long-bow 0.3.33 → 0.3.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/components/Spellbook/QuickSpells.d.ts +9 -0
  2. package/dist/components/Spellbook/Spell.d.ts +11 -0
  3. package/dist/components/Spellbook/Spellbook.d.ts +15 -0
  4. package/dist/components/Spellbook/SpellbookShortcuts.d.ts +10 -0
  5. package/dist/components/Spellbook/constants.d.ts +3 -0
  6. package/dist/components/Spellbook/mockSpells.d.ts +2 -0
  7. package/dist/index.d.ts +2 -0
  8. package/dist/long-bow.cjs.development.js +243 -7
  9. package/dist/long-bow.cjs.development.js.map +1 -1
  10. package/dist/long-bow.cjs.production.min.js +1 -1
  11. package/dist/long-bow.cjs.production.min.js.map +1 -1
  12. package/dist/long-bow.esm.js +243 -9
  13. package/dist/long-bow.esm.js.map +1 -1
  14. package/dist/stories/QuickSpells.stories.d.ts +5 -0
  15. package/dist/stories/Spellbook.stories.d.ts +5 -0
  16. package/package.json +2 -2
  17. package/src/components/Chat/Chat.tsx +1 -0
  18. package/src/components/CraftBook/CraftBook.tsx +1 -2
  19. package/src/components/Spellbook/QuickSpells.tsx +116 -0
  20. package/src/components/Spellbook/Spell.tsx +201 -0
  21. package/src/components/Spellbook/Spellbook.tsx +144 -0
  22. package/src/components/Spellbook/SpellbookShortcuts.tsx +77 -0
  23. package/src/components/Spellbook/constants.ts +12 -0
  24. package/src/components/Spellbook/mockSpells.ts +60 -0
  25. package/src/index.tsx +2 -0
  26. package/src/stories/QuickSpells.stories.tsx +38 -0
  27. package/src/stories/Spellbook.stories.tsx +107 -0
  28. package/src/.DS_Store +0 -0
  29. package/src/components/NPCDialog/.DS_Store +0 -0
  30. package/src/components/NPCDialog/img/.DS_Store +0 -0
  31. package/src/mocks/.DS_Store +0 -0
  32. package/src/mocks/atlas/.DS_Store +0 -0
@@ -0,0 +1,38 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import { RPGUIRoot } from '../components/RPGUIRoot';
4
+ import { SPELL_SHORTCUTS_STORAGE_KEY } from '../components/Spellbook/constants';
5
+ import {
6
+ QuickSpells,
7
+ QuickSpellsProps,
8
+ } from '../components/Spellbook/QuickSpells';
9
+
10
+ const meta: Meta = {
11
+ title: 'QuickSpells',
12
+ component: QuickSpells,
13
+ };
14
+
15
+ export default meta;
16
+
17
+ const Template: Story<QuickSpellsProps> = args => {
18
+ return (
19
+ <RPGUIRoot>
20
+ <div
21
+ style={{
22
+ width: '100%',
23
+ }}
24
+ >
25
+ <QuickSpells {...args} />
26
+ </div>
27
+ </RPGUIRoot>
28
+ );
29
+ };
30
+
31
+ export const Default = Template.bind({});
32
+ Default.args = {
33
+ onSpellCast: spellKey => console.log(spellKey),
34
+ quickSpells: JSON.parse(
35
+ localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY) as string
36
+ ),
37
+ mana: 100,
38
+ };
@@ -0,0 +1,107 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React, { useEffect, useState } from 'react';
3
+ import { RPGUIRoot } from '../components/RPGUIRoot';
4
+ import {
5
+ defaultSpellShortcut,
6
+ SPELL_SHORTCUTS_STORAGE_KEY,
7
+ } from '../components/Spellbook/constants';
8
+ import { mockSpells } from '../components/Spellbook/mockSpells';
9
+ import { ISpellbookProps, Spellbook } from '../components/Spellbook/Spellbook';
10
+
11
+ const meta: Meta = {
12
+ title: 'Spellbook',
13
+ component: Spellbook,
14
+ };
15
+
16
+ export default meta;
17
+
18
+ const Template: Story<ISpellbookProps> = args => {
19
+ const [spellShortcuts, setSpellShortcuts] = useState([]);
20
+
21
+ useEffect(() => {
22
+ const shortcuts = localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY);
23
+ if (shortcuts) {
24
+ setSpellShortcuts(JSON.parse(shortcuts));
25
+ }
26
+ }, []);
27
+
28
+ const setSpellShortcut = (key: string, index: number) => {
29
+ const spellShortcuts = JSON.parse(
30
+ localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY) as string
31
+ );
32
+
33
+ const spell = mockSpells.find(s => s.key === key);
34
+ if (!spell) {
35
+ return;
36
+ }
37
+
38
+ if (!spellShortcuts) {
39
+ const newSpellShortcuts = [
40
+ defaultSpellShortcut,
41
+ defaultSpellShortcut,
42
+ defaultSpellShortcut,
43
+ defaultSpellShortcut,
44
+ ];
45
+
46
+ newSpellShortcuts[index] = spell;
47
+
48
+ localStorage.setItem(
49
+ SPELL_SHORTCUTS_STORAGE_KEY,
50
+ JSON.stringify(newSpellShortcuts)
51
+ );
52
+ } else {
53
+ spellShortcuts[index] = spell;
54
+
55
+ localStorage.setItem(
56
+ SPELL_SHORTCUTS_STORAGE_KEY,
57
+ JSON.stringify(spellShortcuts)
58
+ );
59
+ }
60
+
61
+ setSpellShortcuts(spellShortcuts);
62
+ };
63
+
64
+ const removeSpellShortcut = (index: number) => {
65
+ const spellShortcuts = JSON.parse(
66
+ localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY) as string
67
+ );
68
+
69
+ if (!spellShortcuts) return;
70
+
71
+ spellShortcuts[index] = defaultSpellShortcut;
72
+
73
+ localStorage.setItem(
74
+ SPELL_SHORTCUTS_STORAGE_KEY,
75
+ JSON.stringify(spellShortcuts)
76
+ );
77
+
78
+ setSpellShortcuts(spellShortcuts);
79
+ };
80
+
81
+ return (
82
+ <RPGUIRoot>
83
+ <div
84
+ style={{
85
+ width: '50%',
86
+ height: '75%',
87
+ }}
88
+ >
89
+ <Spellbook
90
+ {...args}
91
+ setSpellShortcut={setSpellShortcut}
92
+ removeSpellShortcut={removeSpellShortcut}
93
+ spellShortcuts={spellShortcuts}
94
+ />
95
+ </div>
96
+ </RPGUIRoot>
97
+ );
98
+ };
99
+
100
+ export const Default = Template.bind({});
101
+ Default.args = {
102
+ onClose: () => console.log('close'),
103
+ onSpellClick: spellKey => console.log(spellKey),
104
+ spells: mockSpells,
105
+ magicLevel: 3,
106
+ mana: 5,
107
+ };
package/src/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file