@rpg-engine/long-bow 0.3.34 → 0.3.36

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.
@@ -39,7 +39,7 @@ export const items: IItem[] = [
39
39
  isStackable: false,
40
40
  createdAt: '2022-06-04T03:18:09.335Z',
41
41
  updatedAt: '2022-06-04T18:16:49.056Z',
42
- rarity: ItemRarities.Common
42
+ rarity: ItemRarities.Legendary
43
43
  },
44
44
  {
45
45
  _id: '629acef1c7c8e8002ff73564',
@@ -72,7 +72,7 @@ export const items: IItem[] = [
72
72
  isStackable: false,
73
73
  createdAt: '2022-06-04T03:18:09.335Z',
74
74
  updatedAt: '2022-06-04T18:16:49.056Z',
75
- rarity: ItemRarities.Common
75
+ rarity: ItemRarities.Epic
76
76
  },
77
77
  {
78
78
  _id: '629acef1c7c8e8002ff60723',
@@ -106,7 +106,7 @@ export const items: IItem[] = [
106
106
  fullDescription: 'Recover your life',
107
107
  createdAt: '2022-06-04T03:18:09.335Z',
108
108
  updatedAt: '2022-06-04T18:16:49.056Z',
109
- rarity: ItemRarities.Common
109
+ rarity: ItemRarities.Uncommon
110
110
  },
111
111
  {
112
112
  _id: '629acek4j7c8e8002ff60034',
@@ -140,7 +140,7 @@ export const items: IItem[] = [
140
140
  fullDescription: 'Recover your mana',
141
141
  createdAt: '2022-06-04T03:18:09.335Z',
142
142
  updatedAt: '2022-06-04T18:16:49.056Z',
143
- rarity: ItemRarities.Common
143
+ rarity: ItemRarities.Rare
144
144
  },
145
145
  {
146
146
  _id: '629acek4j7c8e8002fg60034',
@@ -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
+ };