@malib/gear 0.7.0 → 0.9.0

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/internal.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  export * from "./lib/gear";
2
- export * from "./lib/gearicon";
3
2
  export * from "./lib/gearoption";
4
3
  export * from "./lib/gearproptype";
5
- export * from "./lib/gearreq";
6
4
  export * from "./lib/geartype";
7
5
  export * from "./lib/potential";
8
6
  export * from "./lib/potentialgrade";
@@ -12,3 +10,8 @@ export * from "./lib/logic/bonusstattype";
12
10
  export * from "./lib/logic/enhancement";
13
11
  export * from "./lib/logic/scroll";
14
12
  export * from "./lib/logic/upgrade";
13
+ export * from "./lib/serialize/fromplain";
14
+ export * from "./lib/serialize/interface";
15
+ export * from "./lib/serialize/toplain";
16
+ export * from "./lib/serialize/util";
17
+ export * from "./lib/serialize/validate";
package/lib/gear.d.ts CHANGED
@@ -1,11 +1,37 @@
1
- import { GearIcon } from "./gearicon";
2
1
  import { GearOption } from "./gearoption";
3
2
  import { GearPropType } from "./gearproptype";
4
- import { GearReq } from "./gearreq";
5
3
  import { GearType } from "./geartype";
6
4
  import { Potential } from "./potential";
7
5
  import { PotentialGrade } from "./potentialgrade";
8
6
  import { SoulWeapon } from "./soul";
7
+ /**
8
+ * 장비 아이콘
9
+ */
10
+ export interface GearIcon {
11
+ /** 아이콘 ID */
12
+ id: number;
13
+ /** 아이콘 오프셋 */
14
+ origin: [number, number];
15
+ }
16
+ /**
17
+ * 장비 착용 제한
18
+ */
19
+ export interface GearReq {
20
+ /** 착용 가능 레벨 */
21
+ level: number;
22
+ /** 착용 가능 STR */
23
+ str: number;
24
+ /** 착용 가능 LUK */
25
+ luk: number;
26
+ /** 착용 가능 DEX */
27
+ dex: number;
28
+ /** 착용 가능 INT */
29
+ int: number;
30
+ /** 착용 가능 직업 분류 */
31
+ job: number;
32
+ /** 착용 가능 직업 */
33
+ specJob: number;
34
+ }
9
35
  /**
10
36
  * 장비
11
37
  */
@@ -59,13 +85,14 @@ export declare class Gear {
59
85
  /** 잠재능력 등급 */
60
86
  grade: PotentialGrade;
61
87
  /** 잠재옵션 목록 */
62
- potentials: (Potential | undefined)[];
88
+ potentials: (Potential | null)[];
63
89
  /** 에디셔널 잠재능력 등급 */
64
90
  additionalGrade: PotentialGrade;
65
91
  /** 에디셔널 잠재옵션 목록 */
66
- additionalPotentials: (Potential | undefined)[];
92
+ additionalPotentials: (Potential | null)[];
67
93
  /** 소울 */
68
94
  soulWeapon: SoulWeapon;
95
+ constructor();
69
96
  /**
70
97
  * 업그레이드 가능 횟수
71
98
  */
@@ -102,8 +129,8 @@ export declare class Gear {
102
129
  getBooleanValue(type: GearPropType): boolean;
103
130
  /**
104
131
  * 장비에 신비의 모루 외형을 적용합니다.
105
- * @param icon 외형 아이콘
106
- * @param name 외형 장비명
132
+ * @param icon 외형 아이콘.
133
+ * @param name 외형 장비명.
107
134
  */
108
135
  setAnvil(icon: GearIcon, name: string): void;
109
136
  /**
@@ -11,19 +11,18 @@ export type SpellTraceStatType = GearPropType.incSTR | GearPropType.incDEX | Gea
11
11
  /**
12
12
  * 주문서
13
13
  */
14
- export declare class Scroll {
14
+ export interface Scroll {
15
15
  /** 주문서 이름 */
16
16
  name: string;
17
17
  /** 주문서 옵션 */
18
18
  stat: Map<GearPropType, number>;
19
- constructor(name?: string, stats?: Map<GearPropType, number>);
20
- /**
21
- * 주문의 흔적 주문서를 생성합니다.
22
- * @param gear 주문의 흔적을 적용할 장비.
23
- * @param type 주문의 흔적 스탯 종류. `GearPropType` 타입이고
24
- * `incSTR` / `incDEX` / `incINT` / `incLUK` / `incAllStat` / `incMHP` 중 하나입니다.
25
- * @param probability 주문의 흔적 성공 확률. `100` / `70` / `30` / `15` 중 하나입니다.
26
- * @returns 주문의 흔적 주문서. 지정된 장비, 스탯, 확률을 만족하는 주문서가 존재하지 않을 경우 `undefined`를 반환합니다.
27
- */
28
- static getSpellTraceScroll(gear: Gear, type: SpellTraceStatType, probability: SpellTraceProbability): Scroll | undefined;
29
19
  }
20
+ /**
21
+ * 주문의 흔적 주문서를 생성합니다.
22
+ * @param gear 주문의 흔적을 적용할 장비.
23
+ * @param type 주문의 흔적 스탯 종류. `GearPropType` 타입이고
24
+ * `incSTR` / `incDEX` / `incINT` / `incLUK` / `incAllStat` / `incMHP` 중 하나입니다.
25
+ * @param probability 주문의 흔적 성공 확률. `100` / `70` / `30` / `15` 중 하나입니다.
26
+ * @returns 주문의 흔적 주문서. 지정된 장비, 스탯, 확률을 만족하는 주문서가 존재하지 않을 경우 `undefined`를 반환합니다.
27
+ */
28
+ export declare function getSpellTraceScroll(gear: Gear, type: SpellTraceStatType, probability: SpellTraceProbability): Scroll | undefined;
@@ -0,0 +1,8 @@
1
+ import { Gear } from "../gear";
2
+ import { GearLike } from "./interface";
3
+ /**
4
+ * 순수 객체를 장비로 변환합니다.
5
+ * @param like 변환할 객체.
6
+ * @returns 변환된 장비.
7
+ */
8
+ export declare function plainToGear(like: GearLike): Gear;
@@ -0,0 +1,53 @@
1
+ import { GearIcon, GearReq } from "../gear";
2
+ import { GearPropType } from "../gearproptype";
3
+ import { GearType } from "../geartype";
4
+ import { PotentialGrade } from "../potentialgrade";
5
+ import { Soul } from "../soul";
6
+ /**
7
+ * `Gear`를 나타내는 순수 객체 형식
8
+ */
9
+ export interface GearLike {
10
+ id: number;
11
+ name: string;
12
+ desc?: string;
13
+ icon: GearIcon;
14
+ anvilIcon?: GearIcon;
15
+ anvilName?: string;
16
+ type: GearType;
17
+ req: GearReq;
18
+ props: [GearPropType, number][];
19
+ options: [GearPropType, OptionLike][];
20
+ tuc?: number;
21
+ up?: number;
22
+ fail?: number;
23
+ hammer?: number;
24
+ maxStar?: number;
25
+ star?: number;
26
+ amazing?: boolean;
27
+ karma?: number;
28
+ canPot?: boolean;
29
+ grade?: PotentialGrade;
30
+ pots?: (PotLike | null)[];
31
+ addGrade?: PotentialGrade;
32
+ addPots?: (PotLike | null)[];
33
+ soulWeapon: SoulWeaponLike;
34
+ }
35
+ export interface OptionLike {
36
+ base?: number;
37
+ bonus?: number;
38
+ upgrade?: number;
39
+ enchant?: number;
40
+ }
41
+ export interface PotLike {
42
+ code: number;
43
+ optionType: number;
44
+ reqLevel: number;
45
+ summary: string;
46
+ option: [GearPropType, number][];
47
+ }
48
+ export interface SoulWeaponLike {
49
+ enchanted?: boolean;
50
+ soul?: Soul;
51
+ charge?: number;
52
+ chargeOption?: [GearPropType, number][];
53
+ }
@@ -0,0 +1,8 @@
1
+ import { Gear } from "../gear";
2
+ import { GearLike } from "./interface";
3
+ /**
4
+ * 장비를 순수 객체로 변환합니다.
5
+ * @param like 변환할 장비.
6
+ * @returns 변환된 순수 객체.
7
+ */
8
+ export declare function gearToPlain(gear: Gear): GearLike;
@@ -0,0 +1,19 @@
1
+ import { Gear } from "../gear";
2
+ /**
3
+ * 장비를 문자열로 변환합니다. `JSON.stringify`를 사용합니다.
4
+ * @param gear 변환할 장비.
5
+ * @returns 장비를 나타내는 문자열.
6
+ */
7
+ export declare function stringifyGear(gear: Gear): string;
8
+ /**
9
+ * 문자열을 장비로 변환합니다. 입력을 검사하지 않고 `JSON.parse`를 사용합니다.
10
+ * @param gear 변환할 문자열.
11
+ * @returns 장비. 입력이 잘못되었을 경우 오류가 발생하거나 장비를 반환합니다.
12
+ */
13
+ export declare function parseGear(like: string): Gear;
14
+ /**
15
+ * 문자열을 장비로 변환합니다. 입력을 검사하고 `JSON.parse`를 사용합니다.
16
+ * @param gear 변환할 문자열.
17
+ * @returns 장비. 입력이 잘못되었을 경우 `null`을 반환합니다.
18
+ */
19
+ export declare function validateParseGear(maybe: string): Gear | null;
@@ -0,0 +1,7 @@
1
+ import { GearLike } from "./interface";
2
+ /**
3
+ * 객체가 `GearLike` 형식인지 여부를 확인합니다.
4
+ * @param input 확인할 객체.
5
+ * @returns 입력이 `GearLike` 형식일 경우 `true`; 아닐 경우 `false`.
6
+ */
7
+ export declare const isGearLike: (input: unknown) => input is GearLike;
package/lib/soul.d.ts CHANGED
@@ -1,5 +1,17 @@
1
1
  import { Gear } from "./gear";
2
2
  import { GearPropType } from "./gearproptype";
3
+ /**
4
+ * 소울
5
+ */
6
+ export interface Soul {
7
+ /** 소울 이름 */
8
+ name: string;
9
+ /** 스킬명 */
10
+ skill: string;
11
+ /** 소울 옵션 */
12
+ option: Map<GearPropType, number>;
13
+ multiplier: number;
14
+ }
3
15
  /**
4
16
  * 소울 웨폰
5
17
  */
@@ -52,15 +64,3 @@ export declare class SoulWeapon {
52
64
  setCharge(charge: number): boolean;
53
65
  private getChargeAD;
54
66
  }
55
- /**
56
- * 소울
57
- */
58
- export declare class Soul {
59
- /** 소울 이름 */
60
- name: string;
61
- /** 스킬명 */
62
- skill: string;
63
- /** 소울 옵션 */
64
- option: Map<GearPropType, number>;
65
- multiplier: number;
66
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malib/gear",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
package/lib/gearicon.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * 장비 아이콘
3
- */
4
- export declare class GearIcon {
5
- /** 아이콘 ID */
6
- id: number;
7
- /** 아이콘 오프셋 */
8
- origin: [number, number];
9
- }
package/lib/gearreq.d.ts DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * 장비 착용 제한
3
- */
4
- export declare class GearReq {
5
- /** 착용 가능 레벨 */
6
- level: number;
7
- /** 착용 가능 STR */
8
- str: number;
9
- /** 착용 가능 LUK */
10
- luk: number;
11
- /** 착용 가능 DEX */
12
- dex: number;
13
- /** 착용 가능 INT */
14
- int: number;
15
- /** 착용 가능 직업 분류 */
16
- job: number;
17
- /** 착용 가능 직업 */
18
- specJob: number;
19
- }