@malib/gear 1.0.0-next.6 → 1.0.0-next.8
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.
- package/README.md +191 -0
- package/dist/_tsup-dts-rollup.d.cts +1223 -1181
- package/dist/_tsup-dts-rollup.d.ts +1223 -1181
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# @malib/gear
|
|
2
|
+
|
|
3
|
+
메이플스토리 장비 강화 및 관리 기능을 제공합니다.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
# Npm
|
|
9
|
+
npm install @malib/gear
|
|
10
|
+
# Yarn
|
|
11
|
+
yarn add @malib/gear
|
|
12
|
+
# Pnpm
|
|
13
|
+
pnpm add @malib/gear
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
### GearData
|
|
19
|
+
|
|
20
|
+
장비 정보는 `GearData` 타입의 순수한 JS 객체로 저장됩니다. `JSON.stringify` 및 `JSON.parse` 후에도 동일한 상태를 유지합니다.
|
|
21
|
+
|
|
22
|
+
### ReadonlyGear
|
|
23
|
+
|
|
24
|
+
`ReadonlyGear` 클래스는 `GearData` 객체에 대한 가벼운 래퍼입니다. `GearData`의 모든 속성을 읽기 전용으로 제공하며, 어떠한 작업도 `GearData`의 상태를 변경하지 않습니다.
|
|
25
|
+
|
|
26
|
+
`GearData`가 외부에서 변경될 경우, `ReadonlyGear` 인스턴스에도 투명하게 노출됩니다. 따라서 하나의 `GearData`로부터 여러 `ReadonlyGear`를 생성하는 것도 가능합니다.
|
|
27
|
+
|
|
28
|
+
`ReadonlyGear`의 참조형 속성(`baseOption` 등)은 호출 간 같은 값을 가지는 다른 객체를 반환할 수 있습니다. 다시 말해, 깊은 동등은 보장되지만 참조 동등은 보장되지 않습니다.
|
|
29
|
+
|
|
30
|
+
### Gear
|
|
31
|
+
|
|
32
|
+
`Gear` 클래스는 `ReadonlyGear` 클래스를 상속합니다.
|
|
33
|
+
|
|
34
|
+
`GearData`를 변경할 수 있는 속성과 메서드를 추가로 제공합니다. 모든 작업은 내부의 `GearData` 객체를 직접 수정하는 방식으로 작동합니다. 따라서 불변성이 필요한 경우 `Immer` 등을 사용하여 직접 구현해야 합니다.
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
### Creating GearData
|
|
39
|
+
|
|
40
|
+
`GearData` 객체를 생성하는 별도의 기능은 없으며 직접 생성해야 합니다.
|
|
41
|
+
|
|
42
|
+
라이브러리 업데이트로 인해 `GearData`의 형태가 변경될 경우 `meta.version` 속성에 반영되며, 기존의 장비를 새로운 버전으로 변환하는 함수가 제공됩니다.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { type GearData, type GearType } from '@malib/gear';
|
|
46
|
+
|
|
47
|
+
const data: GearData = {
|
|
48
|
+
meta: {
|
|
49
|
+
id: 1009876,
|
|
50
|
+
version: 1,
|
|
51
|
+
},
|
|
52
|
+
name: 'Example cap',
|
|
53
|
+
icon: '1000000',
|
|
54
|
+
type: GearType.cap,
|
|
55
|
+
req: { level: 100 },
|
|
56
|
+
attributes: {},
|
|
57
|
+
baseOption: { str: 1 },
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Creating ReadonlyGear
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { ReadonlyGear } from '@malib/gear';
|
|
65
|
+
|
|
66
|
+
const gear = new ReadonlyGear(data);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Creating Gear
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { Gear } from '@malib/gear';
|
|
73
|
+
|
|
74
|
+
const gear = new Gear(data);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Reading Property
|
|
78
|
+
|
|
79
|
+
`GearData`의 값을 그대로 반환하며, 존재하지 않는 속성에 접근하면 기본값을 반환합니다.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
console.log(gear.name); // 'Example cap'
|
|
83
|
+
|
|
84
|
+
console.log(gear.req.level); // 100
|
|
85
|
+
|
|
86
|
+
console.log(gear.req.job); // 0
|
|
87
|
+
|
|
88
|
+
console.log(gear.starforceOption.dex); // 0
|
|
89
|
+
|
|
90
|
+
console.log(gear.soul); // undefined
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Modifying State
|
|
94
|
+
|
|
95
|
+
`Gear` 클래스는 `GearData` 상태를 변경하는 여러 메서드를 제공합니다. 인게임에서 수행할 수 없는 작업은 `Gear`에서 제공되지 않으므로 `GearData`를 직접 수정해야 합니다.
|
|
96
|
+
|
|
97
|
+
#### 착용 제한 레벨 변경
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
gear.req.level = 120; // Impossible!
|
|
101
|
+
|
|
102
|
+
gear.data.req.level = 120; // OK
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### 추가 옵션 적용
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
gear.applyAddOption(AddOptionType.str, /* grade */ 7);
|
|
109
|
+
|
|
110
|
+
console.log(gear.addOption.str); // 42
|
|
111
|
+
|
|
112
|
+
gear.applyAddOption(AddOptionType.str_dex, /* grade */ 7);
|
|
113
|
+
|
|
114
|
+
console.log(gear.addOption.str); // 63
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### 주문서 강화 적용
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
const premiumAttackScroll = {
|
|
121
|
+
name: 'Premium Attack Scroll',
|
|
122
|
+
option: { attackPower: 5 },
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Example, modify data with caution.
|
|
126
|
+
gear.data.scrollUpgradeableCount = 1;
|
|
127
|
+
|
|
128
|
+
if (gear.supportsUpgrade) {
|
|
129
|
+
if (gear.canApplyScroll) {
|
|
130
|
+
gear.applyScroll(premiumAttackScroll);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (gear.canApplyScroll) {
|
|
134
|
+
gear.applySpellTrace(SpellTraceType.dex /* rate */ 30);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### 스타포스 강화 적용
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
if (gear.canApplyStarforce) {
|
|
143
|
+
gear.applyStarforce();
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### 놀라운 장비 강화 주문서 적용
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
gear.resetStarforce();
|
|
151
|
+
|
|
152
|
+
if (gear.canApplyStarScroll) {
|
|
153
|
+
gear.applyStarScroll();
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### 소울 장착
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
const godSoul = {
|
|
161
|
+
name: 'God Soul',
|
|
162
|
+
skill: 'Jung Sang Hwa',
|
|
163
|
+
option: { attackPowerRate: 3 },
|
|
164
|
+
chargeFactor: 2,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Example, modify data with caution.
|
|
168
|
+
gear.data.type = GearType.bow;
|
|
169
|
+
|
|
170
|
+
if (gear.canApplySoulEnchant) {
|
|
171
|
+
gear.applySoulEnchant();
|
|
172
|
+
gear.setSoul(godSoul);
|
|
173
|
+
gear.setSoulCharge(1000);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### 익셉셔널 강화
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
const exceptionalHammer = {
|
|
181
|
+
name: 'Exceptional Hammer (Bow)',
|
|
182
|
+
option: { str: 15, dex: 15, luk: 15, attackPower: 10 },
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// Example, modify data with caution.
|
|
186
|
+
gear.data.exceptionalUpgradeableCount = 1;
|
|
187
|
+
|
|
188
|
+
if (gear.canApplyExceptional) {
|
|
189
|
+
gear.applyExceptional(exceptionalHammer);
|
|
190
|
+
}
|
|
191
|
+
```
|