@wwawing/engine 3.10.1 → 3.11.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/lib/wwa_data.d.ts CHANGED
@@ -20,12 +20,7 @@ export declare class Status extends EquipmentStatus {
20
20
  plus(s: EquipmentStatus): Status;
21
21
  minus(s: EquipmentStatus): Status;
22
22
  equals(e: Status): boolean;
23
- calculateScore(weight: {
24
- energy: number;
25
- strength: number;
26
- defence: number;
27
- gold: number;
28
- }): number;
23
+ calculateScore(scoreOption: ScoreOptions): number;
29
24
  constructor(e: number, s: number, d: number, g: number);
30
25
  }
31
26
  export declare class Coord {
@@ -237,7 +232,7 @@ export declare enum MacroType {
237
232
  COPY_DF_TO = 34,
238
233
  SET_DF = 35,
239
234
  COPY_MONEY_TO = 36,
240
- SET_MOENEY = 37,
235
+ SET_MONEY = 37,
241
236
  COPY_STEP_COUNT_TO = 38,
242
237
  VAR_SET_VAL = 39,
243
238
  VAR_SET = 40,
@@ -263,6 +258,8 @@ export declare enum MacroType {
263
258
  OLDMOVE = 101,
264
259
  LEGACY_IF = 10050
265
260
  }
261
+ export declare type ConditionalExecuteMacroType = MacroType.IF | MacroType.ELSE_IF | MacroType.ELSE | MacroType.END_IF;
262
+ export declare type PreprocessMacroType = ConditionalExecuteMacroType | MacroType.SHOW_STR;
266
263
  export declare var macrotable: {
267
264
  "": number;
268
265
  $imgplayer: number;
@@ -568,4 +565,12 @@ export declare enum IDTable {
568
565
  }
569
566
  export declare type StatusSolutionKind = "all" | "bare" | "equipment";
570
567
  export declare type UserVarNameListRequestErrorKind = JsonResponseErrorKind | "notObject" | "noFileSpecified";
571
- export declare type ConditionalMacroExecStatus = "outside-ifelse" | "can-execute" | "cannot-execute" | "executed";
568
+ export interface ScoreOptions {
569
+ rates: ScoreRates;
570
+ }
571
+ export interface ScoreRates {
572
+ energy: number;
573
+ strength: number;
574
+ defence: number;
575
+ gold: number;
576
+ }
@@ -1,2 +1,5 @@
1
+ import type { Descriminant, TokenValues, Comparable } from "./typedef";
2
+ export declare function evaluateDescriminant(d: Descriminant, tokenValues: TokenValues): boolean;
3
+ export declare function evaluateValue(comparable: Comparable, tokenValues: TokenValues): number;
1
4
  export declare function calc(operator: string, leftValue: number, rightValue: number): number;
2
5
  export declare function compare(operator: string, leftValue: number, rightValue: number): boolean;
@@ -1,5 +1,9 @@
1
- import { parseValue, parseType, type TokenValues } from "./parsers";
1
+ import type { TokenValues, Descriminant } from "./typedef";
2
2
  import { type ValueAssignOperation } from "./value-assign-operation";
3
- export { TokenValues, ValueAssignOperation, parseType, parseValue };
3
+ export * from "./typedef";
4
+ export * from "./parsers";
5
+ export * from "./eval";
6
+ export * from "./regexp";
7
+ export declare function parseAndEvaluateValue(value: string, tokenValues: TokenValues): number;
4
8
  export declare function evaluateSetMacroExpression(expression: string, tokenValues: TokenValues): ValueAssignOperation;
5
- export declare function evaluateIfMacroExpression(expression: string, tokenValues: TokenValues): boolean;
9
+ export declare function parseDescriminant(expression: string): Descriminant | undefined;
@@ -1,16 +1,3 @@
1
- import { EquipmentStatus, Status, Coord } from "../wwa_data";
2
- export interface TokenValues {
3
- totalStatus: Status;
4
- bareStatus: EquipmentStatus;
5
- itemStatus: EquipmentStatus;
6
- energyMax: number;
7
- moveCount: number;
8
- playTime: number;
9
- userVars: number[];
10
- playerCoord: Coord;
11
- }
12
- export declare type SetMacroType = 'VARIABLE' | 'NUMBER' | 'HP' | 'HPMAX' | 'AT' | 'AT_TOTAL' | 'AT_ITEMS' | 'DF' | 'DF_TOTAL' | 'DF_ITEMS' | 'GD' | 'TIME' | 'STEP' | 'PX' | 'PY' | 'RAND';
13
- export declare function parseType(str: string): SetMacroType | null;
14
- export declare function parseValue(value: string, tokenValues: TokenValues): number;
15
- export declare function parseVariable(value: string, tokenValues: TokenValues): number;
16
- export declare function parseNumber(value: string): number;
1
+ import type { Comparable, CValue } from "./typedef";
2
+ export declare function isCValue(c: Comparable): c is CValue;
3
+ export declare function parseType(str: string): Comparable | null;
@@ -1,8 +1,6 @@
1
1
  export declare const regNumber: RegExp;
2
2
  export declare const regUserVar: RegExp;
3
- export declare const regUserVarCapture: RegExp;
4
3
  export declare const regRand: RegExp;
5
- export declare const regRandCapture: RegExp;
6
4
  export declare const regAdvance: RegExp;
7
5
  export declare const regNormal: RegExp;
8
6
  export declare const regIf: RegExp;
@@ -0,0 +1,39 @@
1
+ import type { EquipmentStatus, Status, Coord } from "../wwa_data";
2
+ export declare type SetMacroType = 'VARIABLE' | 'NUMBER' | 'HP' | 'HPMAX' | 'AT' | 'AT_TOTAL' | 'AT_ITEMS' | 'DF' | 'DF_TOTAL' | 'DF_ITEMS' | 'GD' | 'TIME' | 'STEP' | 'PX' | 'PY' | 'RAND';
3
+ export declare type CNumberKind = "NUMBER";
4
+ export declare type CVariableKind = "VARIABLE";
5
+ export declare type CEnvKind = "HP" | "HPMAX" | "AT" | "AT_TOTAL" | "AT_ITEMS" | "DF" | "DF_TOTAL" | "DF_ITEMS" | "GD" | "STEP" | "TIME" | "PX" | "PY";
6
+ export declare type CFunctionKind = "RAND";
7
+ export interface CNumber {
8
+ type: CNumberKind;
9
+ rawValue: number;
10
+ }
11
+ export interface CVariable {
12
+ type: CVariableKind;
13
+ index: number;
14
+ }
15
+ export interface CEnv {
16
+ type: CEnvKind;
17
+ }
18
+ export interface CFunction {
19
+ type: CFunctionKind;
20
+ argument: CValue;
21
+ }
22
+ export declare type CValue = CNumber | CVariable | CEnv;
23
+ export declare type Comparable = CValue | CFunction;
24
+ export declare type ComparisionOperatorKind = "<" | ">" | "<=" | ">=" | "==" | "!=";
25
+ export declare type Descriminant = boolean | {
26
+ left: Comparable;
27
+ right: Comparable;
28
+ operator: ComparisionOperatorKind;
29
+ };
30
+ export interface TokenValues {
31
+ totalStatus: Status;
32
+ bareStatus: EquipmentStatus;
33
+ itemStatus: EquipmentStatus;
34
+ energyMax: number;
35
+ moveCount: number;
36
+ playTime: number;
37
+ userVars: number[];
38
+ playerCoord: Coord;
39
+ }
package/lib/wwa_main.d.ts CHANGED
@@ -1,9 +1,14 @@
1
- import { Coord, Position, LoaderProgress, LoadStage, YesNoState, Face, SidebarButton, SpeedChange, PartsType, AppearanceTriggerType, EquipmentStatus, ChangeStyleType, MacroStatusIndex, UserDevice, MacroImgFrameIndex, StatusKind, StatusSolutionKind } from "./wwa_data";
2
- import { MessageWindow, ParsedMessage } from "./wwa_message";
1
+ import { Coord, Position, LoaderProgress, LoadStage, YesNoState, Face, SidebarButton, SpeedChange, PartsType, AppearanceTriggerType, EquipmentStatus, ChangeStyleType, MacroStatusIndex, UserDevice, MacroImgFrameIndex, StatusKind, StatusSolutionKind, ScoreOptions } from "./wwa_data";
2
+ import { MessageWindow, Page } from "./wwa_message";
3
3
  import { ItemMenu } from "./wwa_item_menu";
4
4
  import { WWACompress } from "./wwa_save";
5
5
  import { IEventEmitter } from "@wwawing/event-emitter";
6
6
  export declare function getProgress(current: number, total: number, stage: LoadStage): LoaderProgress;
7
+ interface PartsAppearance {
8
+ pos: Coord;
9
+ triggerType: AppearanceTriggerType;
10
+ triggerPartsId: number;
11
+ }
7
12
  export declare class WWA {
8
13
  private _cvs;
9
14
  private _cvsSub;
@@ -25,7 +30,7 @@ export declare class WWA {
25
30
  _messageWindow: MessageWindow;
26
31
  private _monsterWindow;
27
32
  private _scoreWindow;
28
- private _messageQueue;
33
+ private _pages;
29
34
  private _yesNoJudge;
30
35
  private _yesNoJudgeInNextFrame;
31
36
  private _yesNoChoicePartsCoord;
@@ -49,7 +54,8 @@ export declare class WWA {
49
54
  checkOriginalMapString: string;
50
55
  private _prevFrameEventExected;
51
56
  private _reservedMoveMacroTurn;
52
- private _lastMessage;
57
+ private _lastPage;
58
+ private _reservedPartsAppearances;
53
59
  private _frameCoord;
54
60
  private _battleEffectCoord;
55
61
  private sounds;
@@ -60,7 +66,7 @@ export declare class WWA {
60
66
  private _passwordLoadExecInNextFrame;
61
67
  private _passwordSaveExtractData;
62
68
  private _faces;
63
- private _execMacroListInNextFrame;
69
+ private _execPageInNextFrame?;
64
70
  private _clearFacesInNextFrame;
65
71
  private _paintSkipByDoorOpen;
66
72
  private _isClassicModeEnable;
@@ -78,8 +84,7 @@ export declare class WWA {
78
84
  private _mapIDTable;
79
85
  private _mapObjectIDTable;
80
86
  wwaCustomEventEmitter: IEventEmitter;
81
- private _scoreRates?;
82
- private _conditionalMacroExecStatus;
87
+ private _lastScoreOptions?;
83
88
  debug: boolean;
84
89
  private hoge;
85
90
  private _loadHandler;
@@ -113,6 +118,8 @@ export declare class WWA {
113
118
  onchangespeed(type: SpeedChange): void;
114
119
  isBattleSpeedIndexForQuickBattle(battleSpeedIndex: number): boolean;
115
120
  private _checkTurnKeyPressed;
121
+ private _executeNode;
122
+ private _executeNodes;
116
123
  private _main;
117
124
  vibration(isStrong: boolean): void;
118
125
  private _drawAll;
@@ -155,12 +162,18 @@ export declare class WWA {
155
162
  private _execObjectLocalGateEvent;
156
163
  private _execObjectUrlGateEvent;
157
164
  private _execObjectScoreEvent;
158
- updateScore(): void;
165
+ updateScore(scoreOption?: ScoreOptions): void;
159
166
  private _execChoiceWindowObjectSellEvent;
160
167
  private _execChoiceWindowRunningEvent;
161
- setMessageQueue(message: string, showChoice: boolean, isSystemMessage: boolean, partsID?: number, partsType?: PartsType, partsPosition?: Coord, messageDisplayed?: boolean): boolean;
162
- getMessageQueueByRawMessage(message: string, partsID: number, partsType: PartsType, partsPosition: Coord, isSystemMessage?: boolean): ParsedMessage[];
163
- appearParts(pos: Coord, triggerType: AppearanceTriggerType, triggerPartsID?: number): void;
168
+ generatePageAndReserveExecution(message: string, showChoice: boolean, isSystemMessage: boolean, partsID?: number, partsType?: PartsType, partsPosition?: Coord, scoreOption?: ScoreOptions | undefined): void;
169
+ generatePagesByRawMessage(message: string, partsId: number, partsType: PartsType, partsPosition: Coord, isSystemMessage: boolean, showChoice: boolean, scoreOption: ScoreOptions): Page[];
170
+ private parseMessageLines;
171
+ private createNewNode;
172
+ private processConditionalExecuteMacroLine;
173
+ private connectOrMergeToPreviousNode;
174
+ private connectToFinalNode;
175
+ appearParts({ pos, triggerType, triggerPartsId }: PartsAppearance): void;
176
+ reserveAppearPartsInNextFrame(pos: Coord, triggerType: AppearanceTriggerType, triggerPartsId?: number): void;
164
177
  appearPartsByDirection(distance: number, targetPartsID: number, targetPartsType: PartsType): void;
165
178
  appearPartsEval(triggerPartsPos: Coord, xstr: string, ystr: string, targetPartsID: number, targetPartsType: PartsType): void;
166
179
  private _replaceRandomObject;
@@ -199,7 +212,7 @@ export declare class WWA {
199
212
  hidePasswordWindow(isCancel?: boolean): void;
200
213
  private _displayUserVars;
201
214
  private _displayHelp;
202
- _setNextMessage(displayCenter?: boolean): void;
215
+ _setNextPage(): void;
203
216
  private _hideMessageWindow;
204
217
  loadMapPartsObjectID(id: number): number;
205
218
  loadMapPartsID(id: number): number;
@@ -218,7 +231,9 @@ export declare class WWA {
218
231
  setObjectNotCollapseOnPartsOnPlayer(flag: boolean): boolean;
219
232
  setGameOverPosition(pos: Coord): Coord;
220
233
  private toValidStatusValue;
221
- setPlayerStatus(type: MacroStatusIndex, value: number, isCalledByMacro: boolean): void;
234
+ setPlayerStatus(type: MacroStatusIndex, value: number, isCalledByMacro: boolean): {
235
+ isGameOver?: true;
236
+ };
222
237
  setDelPlayer(flag: boolean): boolean;
223
238
  setPlayerGetItem(pos: number, id: number): void;
224
239
  setStatusIconCoord(type: MacroImgFrameIndex, coord: Coord): Coord;
@@ -258,7 +273,9 @@ export declare class WWA {
258
273
  setUserVarAT(num: number, kind: StatusSolutionKind): void;
259
274
  setUserVarDF(num: number, kind: StatusSolutionKind): void;
260
275
  setUserVarMONEY(num: number): void;
261
- setHPUserVar(index: number, isCalledByMacro: boolean): void;
276
+ setHPUserVar(index: number, isCalledByMacro: boolean): {
277
+ isGameOver?: true;
278
+ };
262
279
  setHPMAXUserVar(index: number): void;
263
280
  setATUserVar(index: number): void;
264
281
  setDFUserVar(index: number): void;
@@ -274,10 +291,10 @@ export declare class WWA {
274
291
  setUserValRandNum(x: number, num: number, bias: number): void;
275
292
  private _generateShowStrString;
276
293
  speedChangeJudge(speedChangeFlag: boolean): void;
277
- switchConditionalExecutionStatus(descriminant?: string): void;
278
- execSetMacro(macroStr?: string): void;
294
+ execSetMacro(macroStr?: string): {
295
+ isGameOver?: true;
296
+ };
279
297
  private _generateTokenValues;
280
- resetConditionalMacroExecStaus(): void;
281
298
  userVarUserIf(_triggerPartsPosition: Coord, args: string[]): void;
282
299
  private compareUserVar;
283
300
  setPlayerSpeedIndex(speedIndex: number): void;
@@ -302,3 +319,4 @@ export declare class WWA {
302
319
  isCalledByMacro: boolean;
303
320
  }): boolean;
304
321
  }
322
+ export {};
@@ -1,19 +1,66 @@
1
1
  import { WWA } from "./wwa_main";
2
- import { Coord, PartsType, MacroType, Position, Direction } from "./wwa_data";
2
+ import { Coord, PartsType, MacroType, Position, Direction, PreprocessMacroType, ScoreOptions as ScoreOptions } from "./wwa_data";
3
3
  import { Monster } from "./wwa_monster";
4
4
  import { WWAData } from "./wwa_data";
5
5
  import { WWASave } from "./wwa_save";
6
+ import { type TokenValues, type Descriminant } from "./wwa_expression";
6
7
  export declare type LazyEvaluateValue = () => number;
7
8
  export declare type MessageSegments = (string | LazyEvaluateValue)[];
8
- export declare class ParsedMessage {
9
- isSystemMessage: boolean;
10
- isEndOfPartsEvent?: boolean;
9
+ export declare class Page {
10
+ firstNode?: Node;
11
+ isLastPage?: boolean;
12
+ showChoice?: boolean;
13
+ isSystemMessage?: boolean;
14
+ scoreOptions?: ScoreOptions;
15
+ constructor(firstNode?: Node, isLastPage?: boolean, showChoice?: boolean, isSystemMessage?: boolean, scoreOptions?: ScoreOptions);
16
+ }
17
+ export declare abstract class Node {
18
+ constructor();
19
+ }
20
+ export interface Branch {
21
+ descriminant?: Descriminant;
22
+ elseBranch?: {
23
+ type: "real" | "pesudo-else";
24
+ };
25
+ next?: Node;
26
+ }
27
+ export declare class Junction extends Node {
28
+ branches: Branch[];
29
+ constructor(branches?: Branch[]);
30
+ appendBranch(branch: Branch): void;
31
+ getLastUnconnectedBranch(): Branch | undefined;
32
+ evaluateAndGetNextNode(generateTokenValues: () => TokenValues): Node | undefined;
33
+ hasElseBranch(): boolean;
34
+ }
35
+ export declare class ParsedMessage extends Node {
11
36
  macro?: Macro[];
12
- private messageArray;
13
- constructor(textOrMessageSegments: string | MessageSegments, isSystemMessage: boolean, isEndOfPartsEvent?: boolean, macro?: Macro[]);
37
+ next?: Node;
38
+ private messageSegments;
39
+ constructor(textOrMessageSegments: string | MessageSegments, macro?: Macro[], next?: Node);
14
40
  isEmpty(): boolean;
15
41
  generatePrintableMessage(): string;
42
+ appendMessage(message: string | MessageSegments, withNewLine?: boolean): void;
43
+ private parseMessage;
16
44
  }
45
+ export declare function isEmptyMessageTree(node: Node | undefined): boolean;
46
+ export declare function getLastMessage(node: undefined): undefined;
47
+ export declare function getLastMessage(node: Node): Node;
48
+ export declare function concatMessage(node1: Node | undefined, node2: Node | undefined): Node | undefined;
49
+ export declare type MessageLineType = PreprocessMacroType | "text" | "normalMacro";
50
+ export declare const messagLineIsText: (lineType: MessageLineType) => boolean;
51
+ export declare type MessageLine = ({
52
+ type: PreprocessMacroType;
53
+ text: string;
54
+ macro: Macro;
55
+ } | {
56
+ type: "normalMacro";
57
+ text: string;
58
+ macro: Macro;
59
+ } | {
60
+ type: "text";
61
+ text: string;
62
+ macro?: undefined;
63
+ });
17
64
  export declare class Macro {
18
65
  private _wwa;
19
66
  private _triggerPartsID;
@@ -23,7 +70,9 @@ export declare class Macro {
23
70
  macroArgs: string[];
24
71
  constructor(_wwa: WWA, _triggerPartsID: number, _triggerPartsType: number, _triggerPartsPosition: Coord, macroType: MacroType, macroArgs: string[]);
25
72
  isJunction(): boolean;
26
- execute(): void;
73
+ execute(): {
74
+ isGameOver?: true;
75
+ };
27
76
  private _concatEmptyArgs;
28
77
  private _parseInt;
29
78
  private _executeJumpGateMacro;
@@ -51,11 +100,7 @@ export declare class Macro {
51
100
  private _executeVarModMacro;
52
101
  private _executeVarSetRandMacro;
53
102
  private _executeGameSpeedMacro;
54
- private _executeIfMacro;
55
103
  private _executeLegacyIfMacro;
56
- private _executeIfElseMacro;
57
- private _executeElseMacro;
58
- private _executeEndIfMacro;
59
104
  private _executeSetSpeedMacro;
60
105
  private _executeCopyTimeToMacro;
61
106
  private _executeHideStatusMacro;
@@ -155,7 +200,7 @@ export declare class MessageWindow {
155
200
  setPosition(x: number, y: number, width: number, height: number): void;
156
201
  setPositionByPlayerPosition(existsFaces: boolean, existsScoreWindow: boolean, displayCenter: boolean, playerPos: Position, cameraPos: Position): void;
157
202
  setPositionEasy(pos: Positioning): void;
158
- setParsedMessage(message: ParsedMessage): void;
203
+ setMessage(message: string): void;
159
204
  clear(): void;
160
205
  setYesNoChoice(isYesNo: boolean): boolean;
161
206
  isYesNoChoice(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wwawing/engine",
3
- "version": "3.10.1",
3
+ "version": "3.11.0",
4
4
  "description": "World Wide Adventure: an RPG Engine.",
5
5
  "main": "./lib/wwa.js",
6
6
  "files": [
@@ -45,14 +45,14 @@
45
45
  "@types/pug": "^2.0.6",
46
46
  "@types/terser-webpack-plugin": "^5.2.0",
47
47
  "@types/webpack": "^5.28.0",
48
- "@wwawing/assets": "^3.10.1",
49
- "@wwawing/common-interface": "^3.10.1",
50
- "@wwawing/debug-server": "^3.10.1",
51
- "@wwawing/event-emitter": "^3.10.1",
52
- "@wwawing/loader": "^3.10.1",
53
- "@wwawing/page-generator": "^3.10.1",
54
- "@wwawing/styles": "^3.10.1",
55
- "@wwawing/virtual-pad": "^3.10.1",
48
+ "@wwawing/assets": "^3.11.0",
49
+ "@wwawing/common-interface": "^3.11.0",
50
+ "@wwawing/debug-server": "^3.11.0",
51
+ "@wwawing/event-emitter": "^3.11.0",
52
+ "@wwawing/loader": "^3.11.0",
53
+ "@wwawing/page-generator": "^3.11.0",
54
+ "@wwawing/styles": "^3.11.0",
55
+ "@wwawing/virtual-pad": "^3.11.0",
56
56
  "crypto-js": "^4.1.1",
57
57
  "npm-run-all": "^4.1.5",
58
58
  "pug": "^3.0.2",
@@ -72,5 +72,5 @@
72
72
  "node": ">=16",
73
73
  "npm": ">=8"
74
74
  },
75
- "gitHead": "2c6cd7009d44316bb7739920dff9b5fd71a18a3d"
75
+ "gitHead": "6bd6f7f1b128d8b30aba03322c745667c1cc167c"
76
76
  }