@wwawing/engine 3.12.3 → 3.13.0-acorn-statement-v2.based-on.3.12.3

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.
@@ -0,0 +1,80 @@
1
+ import { parse, type Node } from "acorn";
2
+ export { parse, Node };
3
+ export interface Program extends Node {
4
+ type: "Program";
5
+ body: Node[];
6
+ }
7
+ export interface ExpressionStatement extends Node {
8
+ type: "ExpressionStatement";
9
+ expression: Node;
10
+ }
11
+ export interface AssignmentExpression extends Node {
12
+ type: "AssignmentExpression";
13
+ operator: string;
14
+ left: Node;
15
+ right: Node;
16
+ }
17
+ export interface MemberExpression extends Node {
18
+ type: "MemberExpression";
19
+ object: Node;
20
+ property: Node;
21
+ }
22
+ export interface UnaryExpression extends Node {
23
+ type: "UnaryExpression";
24
+ operator: string;
25
+ argument: Node;
26
+ }
27
+ export interface BinaryExpression extends Node {
28
+ type: "BinaryExpression";
29
+ operator: string;
30
+ left: Node;
31
+ right: Node;
32
+ }
33
+ export interface Identifier extends Node {
34
+ type: "Identifier";
35
+ name: string;
36
+ }
37
+ export interface Literal extends Node {
38
+ type: "Literal";
39
+ value: number;
40
+ }
41
+ export interface CallExpression extends Node {
42
+ type: "CallExpression";
43
+ arguments: Literal[];
44
+ callee: Identifier;
45
+ }
46
+ export interface IfStatement extends Node {
47
+ type: "IfStatement";
48
+ consequent: Node;
49
+ test: Node;
50
+ alternate?: IfStatement;
51
+ }
52
+ export interface BlockStatement extends Node {
53
+ type: "BlockStatement";
54
+ body: Node[];
55
+ }
56
+ export interface FunctionDeclaration extends Node {
57
+ type: "FunctionDeclaration";
58
+ body: BlockStatement;
59
+ id: Identifier;
60
+ }
61
+ export interface ForStatement extends Node {
62
+ type: "ForStatement";
63
+ body: BlockStatement;
64
+ init: Node;
65
+ test: Node;
66
+ update: Node;
67
+ }
68
+ export interface UpdateExpression extends Node {
69
+ type: "UpdateExpression";
70
+ operator: string;
71
+ argument: Node;
72
+ }
73
+ export interface BreakStatement extends Node {
74
+ label: string;
75
+ type: "BreakExpression";
76
+ }
77
+ export interface ContinueStatement extends Node {
78
+ label: string;
79
+ type: "ContinueExpression";
80
+ }
@@ -0,0 +1,4 @@
1
+ import * as Acorn from "./acorn";
2
+ import * as Wwa from "./wwa";
3
+ export declare function convertNodeAcornToWwaArray(node: Acorn.Node): Wwa.WWANode[];
4
+ export declare function convertNodeAcornToWwa(node: Acorn.Node): Wwa.WWANode;
@@ -0,0 +1,38 @@
1
+ import { WWA } from "../wwa_main";
2
+ import * as Wwa from "./wwa";
3
+ export declare class EvalCalcWwaNode {
4
+ wwa: WWA;
5
+ for_id: {
6
+ i: number;
7
+ j: number;
8
+ k: number;
9
+ loopCount: number;
10
+ };
11
+ break_flag: boolean;
12
+ continue_flag: boolean;
13
+ loop_limit: number;
14
+ constructor(wwa: WWA);
15
+ evalWwaNodes(nodes: Wwa.WWANode[]): any[];
16
+ evalWwaNode(node: Wwa.WWANode): any;
17
+ callDefinedFunction(node: Wwa.CallDefinedFunction): void;
18
+ updateExpression(node: Wwa.UpdateExpression): void;
19
+ contunueStatment(node: Wwa.Continue): void;
20
+ breakStatement(node: Wwa.Break): void;
21
+ forStateMent(node: Wwa.ForStatement): void;
22
+ evalAnyFunction(node: Wwa.AnyFunction): void;
23
+ partsAssignment(node: Wwa.PartsAssignment): void;
24
+ blockStatement(node: Wwa.BlockStatement): void;
25
+ ifStatement(node: Wwa.IfStatement): number;
26
+ itemAssignment(node: Wwa.ItemAssignment): number;
27
+ evalMessage(node: Wwa.Msg): number;
28
+ evalJumpgate(node: Wwa.Jumpgate): void;
29
+ evalRandom(node: Wwa.Random): any;
30
+ evalSetSpecialParameter(node: Wwa.SpecialParameterAssignment): number;
31
+ evalSetUserVariable(node: Wwa.UserVariableAssignment): number;
32
+ evalUnaryOperation(node: Wwa.UnaryOperation): any;
33
+ evalBinaryOperation(node: Wwa.BinaryOperation): any;
34
+ evalSymbol(node: Wwa.Symbol): number;
35
+ evalArray1D(node: Wwa.Array1D): number;
36
+ evalArray2D(node: Wwa.Array2D): number;
37
+ evalNumber(node: Wwa.Number): number;
38
+ }
@@ -0,0 +1,4 @@
1
+ import * as Acorn from "./acorn";
2
+ export * from "./converter";
3
+ export * from "./eval";
4
+ export declare function parse(rawMessage: string): Acorn.Node;
@@ -0,0 +1,113 @@
1
+ export declare type Calcurable = Array1D | Array2D | Number | Symbol | UnaryOperation | BinaryOperation;
2
+ export declare function isCalcurable(node: WWANode): node is Calcurable;
3
+ export interface PartsAssignment {
4
+ type: "PartsAssignment";
5
+ partsKind: "map" | "object";
6
+ operator?: "+" | "-" | "*" | "/" | "%";
7
+ destinationX: Calcurable;
8
+ destinationY: Calcurable;
9
+ value: Calcurable;
10
+ }
11
+ export interface ItemAssignment {
12
+ type: "ItemAssignment";
13
+ itemBoxPosition1to12: Calcurable;
14
+ value: Calcurable;
15
+ }
16
+ export interface UserVariableAssignment {
17
+ type: "UserVariableAssignment";
18
+ index: Calcurable;
19
+ value: Calcurable;
20
+ }
21
+ export interface SpecialParameterAssignment {
22
+ type: "SpecialParameterAssignment";
23
+ kind: "X" | "Y" | "PX" | "PY" | "HP" | "HPMAX" | "AT" | "DF" | "GD" | "STEP" | "TIME" | "PRID" | "i" | "j" | "k" | "LOOPLIMIT";
24
+ value: Calcurable;
25
+ }
26
+ export interface UnaryOperation {
27
+ type: "UnaryOperation";
28
+ operator: "+" | "-";
29
+ argument: Calcurable;
30
+ }
31
+ export interface BinaryOperation {
32
+ type: "BinaryOperation";
33
+ operator: "+" | "-" | "*" | "/" | "%" | ">" | "<" | ">=" | "<=" | "==" | "!=";
34
+ left: Calcurable;
35
+ right: Calcurable;
36
+ }
37
+ export interface Symbol {
38
+ type: "Symbol";
39
+ name: "ITEM" | "m" | "o" | "v" | "X" | "Y" | "PX" | "PY" | "HP" | "HPMAX" | "AT" | "DF" | "GD" | "STEP" | "TIME" | "PRID" | "i" | "j" | "k" | "LOOPLIMIT";
40
+ }
41
+ export interface Array1D {
42
+ type: "Array1D";
43
+ name: "ITEM" | "m" | "o" | "v";
44
+ index0: Calcurable;
45
+ }
46
+ export interface Array2D {
47
+ type: "Array2D";
48
+ name: "m" | "o";
49
+ index0: Calcurable;
50
+ index1: Calcurable;
51
+ }
52
+ export interface Number {
53
+ type: "Number";
54
+ value: number;
55
+ }
56
+ export interface Random {
57
+ type: "Random";
58
+ value: WWANode;
59
+ }
60
+ export interface Jumpgate {
61
+ type: "Jumpgate";
62
+ x: WWANode;
63
+ y: WWANode;
64
+ }
65
+ export interface Msg {
66
+ type: "Msg";
67
+ value: WWANode;
68
+ }
69
+ export interface IfStatement {
70
+ type: "IfStatement";
71
+ consequent: WWANode;
72
+ test: WWANode;
73
+ alternate?: WWANode;
74
+ }
75
+ export interface BlockStatement {
76
+ type: "BlockStatement";
77
+ value: WWANode[];
78
+ }
79
+ export interface ForStatement {
80
+ type: "ForStatement";
81
+ body: WWANode[];
82
+ init: WWANode;
83
+ test: WWANode;
84
+ update: WWANode;
85
+ }
86
+ export interface AnyFunction {
87
+ type: "AnyFunction";
88
+ functionName: string;
89
+ value: WWANode[];
90
+ }
91
+ export interface DefinedFunction {
92
+ type: "DefinedFunction";
93
+ functionName: string;
94
+ body: WWANode;
95
+ }
96
+ export interface CallDefinedFunction {
97
+ type: "CallDefinedFunction";
98
+ functionName: string;
99
+ }
100
+ export interface Break {
101
+ type: "Break";
102
+ label: string;
103
+ }
104
+ export interface Continue {
105
+ type: "Continue";
106
+ label: string;
107
+ }
108
+ export interface UpdateExpression {
109
+ type: "UpdateExpression";
110
+ operator: string;
111
+ argument: WWANode;
112
+ }
113
+ export declare type WWANode = PartsAssignment | ItemAssignment | UserVariableAssignment | SpecialParameterAssignment | UnaryOperation | BinaryOperation | Array1D | Array2D | Number | Symbol | Random | Jumpgate | Msg | IfStatement | BlockStatement | AnyFunction | DefinedFunction | CallDefinedFunction | ForStatement | AnyFunction | Break | Continue | UpdateExpression;
package/lib/wwa_main.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { Coord, Position, LoaderProgress, LoadStage, YesNoState, Face, SidebarButton, SpeedChange, PartsType, AppearanceTriggerType, EquipmentStatus, ChangeStyleType, MacroStatusIndex, UserDevice, MacroImgFrameIndex, StatusKind, StatusSolutionKind, ScoreOptions, TriggerParts } from "./wwa_data";
1
+ import { Coord, Position, LoaderProgress, LoadStage, YesNoState, Status, Face, Direction, SidebarButton, SpeedChange, PartsType, AppearanceTriggerType, EquipmentStatus, ChangeStyleType, MacroStatusIndex, UserDevice, MacroImgFrameIndex, StatusKind, StatusSolutionKind, ScoreOptions, TriggerParts } from "./wwa_data";
2
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
  import * as ExpressionParser from "./wwa_expression";
7
+ import { WWANode } from "./wwa_expression2/wwa";
7
8
  export declare function getProgress(current: number, total: number, stage: LoadStage): LoaderProgress;
8
9
  interface PartsAppearance {
9
10
  pos: Coord;
@@ -97,7 +98,15 @@ export declare class WWA {
97
98
  private soundLoadedCheckTimer;
98
99
  private _startTime;
99
100
  private _dumpElement;
101
+ private evalCalcWwaNode;
102
+ private userDefinedFunctions;
100
103
  constructor(mapFileName: string, urlgateEnabled: boolean, titleImgName: string, classicModeEnabled: boolean, itemEffectEnabled: boolean, useGoToWWA: boolean, audioDirectory: string, disallowLoadOldSave: boolean, dumpElm: HTMLElement, userVarNamesFile: string | null, canDisplayUserVars: boolean, enableVirtualPad?: boolean, virtualpadControllerElm?: HTMLElement);
104
+ callJumpGateUserDefineFunction(): void;
105
+ callMoveUserDefineFunction(): void;
106
+ getUserScript(functionName: string): WWANode | null;
107
+ private setUsertScript;
108
+ private convertWwaNodes;
109
+ private setUserVarStatus;
101
110
  private convertUserVariableNameListToArray;
102
111
  private _setProgressBar;
103
112
  private _setLoadingMessage;
@@ -180,6 +189,7 @@ export declare class WWA {
180
189
  reserveJumpInNextFrame(position: Position): void;
181
190
  appearPartsByDirection(distance: number, targetPartsID: number, targetPartsType: PartsType): void;
182
191
  appearPartsEval(triggerPartsPos: Coord, xstr: string, ystr: string, targetPartsID: number, targetPartsType: PartsType): void;
192
+ getPartsID(triggerPartsPos: Coord, targetPartsType: PartsType): number;
183
193
  private _replaceRandomObject;
184
194
  private _replaceRandomObjectsInScreen;
185
195
  private _replaceAllRandomObjects;
@@ -218,6 +228,7 @@ export declare class WWA {
218
228
  private _displayHelp;
219
229
  _setNextPage(): void;
220
230
  private _hideMessageWindow;
231
+ getPlayerPositon(): Position;
221
232
  loadMapPartsObjectID(id: number): number;
222
233
  loadMapPartsID(id: number): number;
223
234
  replaceParts(srcID: number, destID: number, partsType?: PartsType, onlyThisSight?: boolean): void;
@@ -271,6 +282,8 @@ export declare class WWA {
271
282
  getUserVar(no: number): number;
272
283
  recUserPosition(x: number, y: number): void;
273
284
  jumpRecUserPosition(x: number, y: number): void;
285
+ jumpSpecifiedXPos(x: number): void;
286
+ jumpSpecifiedYPos(y: number): void;
274
287
  outputUserVar(num: number): void;
275
288
  setUserVarHP(num: number): void;
276
289
  setUserVarHPMAX(num: number): void;
@@ -305,7 +318,7 @@ export declare class WWA {
305
318
  private compareUserVar;
306
319
  setPlayerSpeedIndex(speedIndex: number): void;
307
320
  setUserVarPlayTime(num: number): void;
308
- private setNowPlayTime;
321
+ setNowPlayTime(): void;
309
322
  hideStatus(no: number, isHide: boolean): void;
310
323
  varMap(triggerPartsPos: Coord, xstr: string, ystr: string, partsID: number, targetPartsType: PartsType): void;
311
324
  setItemboxBackgroundPosition(pos: {
@@ -324,5 +337,18 @@ export declare class WWA {
324
337
  shouldApplyGameOver({ isCalledByMacro }: {
325
338
  isCalledByMacro: boolean;
326
339
  }): boolean;
340
+ getGameStatus(): {
341
+ totalStatus: Status;
342
+ bareStatus: Status;
343
+ itemStatus: EquipmentStatus;
344
+ energyMax: number;
345
+ moveCount: number;
346
+ playTime: number;
347
+ userVars: number[];
348
+ playerCoord: Coord;
349
+ playerDirection: Direction;
350
+ itemBox: number[];
351
+ };
352
+ private _debugEvalString;
327
353
  }
328
354
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wwawing/engine",
3
- "version": "3.12.3",
3
+ "version": "3.13.0-acorn-statement-v2.based-on.3.12.3",
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.12.3",
49
- "@wwawing/common-interface": "^3.12.3",
50
- "@wwawing/debug-server": "^3.12.3",
51
- "@wwawing/event-emitter": "^3.12.3",
52
- "@wwawing/loader": "^3.12.3",
53
- "@wwawing/page-generator": "^3.12.3",
54
- "@wwawing/styles": "^3.12.3",
55
- "@wwawing/virtual-pad": "^3.12.3",
48
+ "@wwawing/assets": "^3.13.0-acorn-statement-v2.based-on.3.12.3",
49
+ "@wwawing/common-interface": "^3.13.0-acorn-statement-v2.based-on.3.12.3",
50
+ "@wwawing/debug-server": "^3.13.0-acorn-statement-v2.based-on.3.12.3",
51
+ "@wwawing/event-emitter": "^3.13.0-acorn-statement-v2.based-on.3.12.3",
52
+ "@wwawing/loader": "^3.13.0-acorn-statement-v2.based-on.3.12.3",
53
+ "@wwawing/page-generator": "^3.13.0-acorn-statement-v2.based-on.3.12.3",
54
+ "@wwawing/styles": "^3.13.0-acorn-statement-v2.based-on.3.12.3",
55
+ "@wwawing/virtual-pad": "^3.13.0-acorn-statement-v2.based-on.3.12.3",
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": ">=18",
73
73
  "npm": ">=8"
74
74
  },
75
- "gitHead": "1a6c602077ce8ca2e6ad1427e588fde140e8197a"
75
+ "gitHead": "4318683f88a03e665af4db286a7f17328b8c7283"
76
76
  }