@wwawing/engine 3.9.5 → 3.10.0-alpha.2

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,8 @@
1
- import { type TokenValues } from "./parsers";
1
+ import type { TokenValues, Descriminant } from "./typedef";
2
2
  import { type ValueAssignOperation } from "./value-assign-operation";
3
- export { TokenValues, ValueAssignOperation };
3
+ export * from "./typedef";
4
+ export * from "./parsers";
5
+ export * from "./eval";
6
+ export * from "./regexp";
4
7
  export declare function evaluateSetMacroExpression(expression: string, tokenValues: TokenValues): ValueAssignOperation;
5
- export declare function evaluateIfMacroExpression(expression: string, tokenValues: TokenValues): boolean;
8
+ 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;
@@ -23,7 +28,7 @@ export declare class WWA {
23
28
  _messageWindow: MessageWindow;
24
29
  private _monsterWindow;
25
30
  private _scoreWindow;
26
- private _messageQueue;
31
+ private _pages;
27
32
  private _yesNoJudge;
28
33
  private _yesNoJudgeInNextFrame;
29
34
  private _yesNoChoicePartsCoord;
@@ -47,7 +52,8 @@ export declare class WWA {
47
52
  checkOriginalMapString: string;
48
53
  private _prevFrameEventExected;
49
54
  private _reservedMoveMacroTurn;
50
- private _lastMessage;
55
+ private _lastPage;
56
+ private _reservedPartsAppearance;
51
57
  private _frameCoord;
52
58
  private _battleEffectCoord;
53
59
  private sounds;
@@ -58,7 +64,7 @@ export declare class WWA {
58
64
  private _passwordLoadExecInNextFrame;
59
65
  private _passwordSaveExtractData;
60
66
  private _faces;
61
- private _execMacroListInNextFrame;
67
+ private _execPageInNextFrame?;
62
68
  private _clearFacesInNextFrame;
63
69
  private _paintSkipByDoorOpen;
64
70
  private _isClassicModeEnable;
@@ -76,8 +82,7 @@ export declare class WWA {
76
82
  private _mapIDTable;
77
83
  private _mapObjectIDTable;
78
84
  wwaCustomEventEmitter: IEventEmitter;
79
- private _scoreRates?;
80
- private _conditionalMacroExecStatus;
85
+ private _lastScoreOptions?;
81
86
  debug: boolean;
82
87
  private hoge;
83
88
  private _loadHandler;
@@ -111,6 +116,8 @@ export declare class WWA {
111
116
  onchangespeed(type: SpeedChange): void;
112
117
  isBattleSpeedIndexForQuickBattle(battleSpeedIndex: number): boolean;
113
118
  private _checkTurnKeyPressed;
119
+ private _executeNode;
120
+ private _executeNodes;
114
121
  private _main;
115
122
  vibration(isStrong: boolean): void;
116
123
  private _drawAll;
@@ -153,12 +160,18 @@ export declare class WWA {
153
160
  private _execObjectLocalGateEvent;
154
161
  private _execObjectUrlGateEvent;
155
162
  private _execObjectScoreEvent;
156
- updateScore(): void;
163
+ updateScore(scoreOption?: ScoreOptions): void;
157
164
  private _execChoiceWindowObjectSellEvent;
158
165
  private _execChoiceWindowRunningEvent;
159
- setMessageQueue(message: string, showChoice: boolean, isSystemMessage: boolean, partsID?: number, partsType?: PartsType, partsPosition?: Coord, messageDisplayed?: boolean): boolean;
160
- getMessageQueueByRawMessage(message: string, partsID: number, partsType: PartsType, partsPosition: Coord, isSystemMessage?: boolean): ParsedMessage[];
161
- appearParts(pos: Coord, triggerType: AppearanceTriggerType, triggerPartsID?: number): void;
166
+ generatePageAndReserveExecution(message: string, showChoice: boolean, isSystemMessage: boolean, partsID?: number, partsType?: PartsType, partsPosition?: Coord, scoreOption?: ScoreOptions | undefined): boolean;
167
+ generatePagesByRawMessage(message: string, partsId: number, partsType: PartsType, partsPosition: Coord, isSystemMessage: boolean, showChoice: boolean, scoreOption: ScoreOptions): Page[];
168
+ private parseMessageLines;
169
+ private createNewNode;
170
+ private processConditionalExecuteMacroLine;
171
+ private connectOrMergeToPreviousNode;
172
+ private connectToFinalNode;
173
+ appearParts({ pos, triggerType, triggerPartsId }: PartsAppearance): void;
174
+ reserveAppearPartsInNextFrame(pos: Coord, triggerType: AppearanceTriggerType, triggerPartsId?: number): void;
162
175
  appearPartsByDirection(distance: number, targetPartsID: number, targetPartsType: PartsType): void;
163
176
  appearPartsEval(triggerPartsPos: Coord, xstr: string, ystr: string, targetPartsID: number, targetPartsType: PartsType): void;
164
177
  private _replaceRandomObject;
@@ -197,7 +210,7 @@ export declare class WWA {
197
210
  hidePasswordWindow(isCancel?: boolean): void;
198
211
  private _displayUserVars;
199
212
  private _displayHelp;
200
- _setNextMessage(displayCenter?: boolean): void;
213
+ _setNextPage(): void;
201
214
  private _hideMessageWindow;
202
215
  loadMapPartsObjectID(id: number): number;
203
216
  loadMapPartsID(id: number): number;
@@ -216,7 +229,9 @@ export declare class WWA {
216
229
  setObjectNotCollapseOnPartsOnPlayer(flag: boolean): boolean;
217
230
  setGameOverPosition(pos: Coord): Coord;
218
231
  private toValidStatusValue;
219
- setPlayerStatus(type: MacroStatusIndex, value: number, isCalledByMacro: boolean): void;
232
+ setPlayerStatus(type: MacroStatusIndex, value: number, isCalledByMacro: boolean): {
233
+ isGameOver?: true;
234
+ };
220
235
  setDelPlayer(flag: boolean): boolean;
221
236
  setPlayerGetItem(pos: number, id: number): void;
222
237
  setStatusIconCoord(type: MacroImgFrameIndex, coord: Coord): Coord;
@@ -256,7 +271,9 @@ export declare class WWA {
256
271
  setUserVarAT(num: number, kind: StatusSolutionKind): void;
257
272
  setUserVarDF(num: number, kind: StatusSolutionKind): void;
258
273
  setUserVarMONEY(num: number): void;
259
- setHPUserVar(index: number, isCalledByMacro: boolean): void;
274
+ setHPUserVar(index: number, isCalledByMacro: boolean): {
275
+ isGameOver?: true;
276
+ };
260
277
  setHPMAXUserVar(index: number): void;
261
278
  setATUserVar(index: number): void;
262
279
  setDFUserVar(index: number): void;
@@ -272,10 +289,10 @@ export declare class WWA {
272
289
  setUserValRandNum(x: number, num: number, bias: number): void;
273
290
  private _generateUserValString;
274
291
  speedChangeJudge(speedChangeFlag: boolean): void;
275
- switchConditionalExecutionStatus(descriminant?: string): void;
276
- execSetMacro(macroStr?: string): void;
292
+ execSetMacro(macroStr?: string): {
293
+ isGameOver?: true;
294
+ };
277
295
  private _generateTokenValues;
278
- resetConditionalMacroExecStaus(): void;
279
296
  userVarUserIf(_triggerPartsPosition: Coord, args: string[]): void;
280
297
  private compareUserVar;
281
298
  setPlayerSpeedIndex(speedIndex: number): void;
@@ -297,3 +314,4 @@ export declare class WWA {
297
314
  isCalledByMacro: boolean;
298
315
  }): boolean;
299
316
  }
317
+ 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(tokenValues: TokenValues): Node | undefined;
33
+ hasElseBranch(): boolean;
34
+ }
35
+ export declare class ParsedMessage extends Node {
11
36
  macro?: Macro[];
37
+ next?: Node;
12
38
  private messageArray;
13
- constructor(textOrMessageSegments: string | MessageSegments, isSystemMessage: boolean, isEndOfPartsEvent?: boolean, macro?: Macro[]);
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.9.5",
3
+ "version": "3.10.0-alpha.2",
4
4
  "description": "World Wide Adventure: an RPG Engine.",
5
5
  "main": "./lib/wwa.js",
6
6
  "files": [
@@ -45,13 +45,13 @@
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.9.5",
49
- "@wwawing/common-interface": "^3.9.5",
50
- "@wwawing/debug-server": "^3.9.5",
51
- "@wwawing/event-emitter": "^3.9.5",
52
- "@wwawing/loader": "^3.9.5",
53
- "@wwawing/page-generator": "^3.9.5",
54
- "@wwawing/styles": "^3.9.5",
48
+ "@wwawing/assets": "^3.10.0-alpha.2",
49
+ "@wwawing/common-interface": "^3.10.0-alpha.2",
50
+ "@wwawing/debug-server": "^3.10.0-alpha.2",
51
+ "@wwawing/event-emitter": "^3.10.0-alpha.2",
52
+ "@wwawing/loader": "^3.10.0-alpha.2",
53
+ "@wwawing/page-generator": "^3.10.0-alpha.2",
54
+ "@wwawing/styles": "^3.10.0-alpha.2",
55
55
  "crypto-js": "^4.1.1",
56
56
  "npm-run-all": "^4.1.5",
57
57
  "pug": "^3.0.2",
@@ -71,5 +71,5 @@
71
71
  "node": ">=16",
72
72
  "npm": ">=8"
73
73
  },
74
- "gitHead": "bf5d11d3ef3dc1407545ddb15a0e5e5886b3ae0d"
74
+ "gitHead": "22e3f5e69fb88d05abdf477a9e80dd825b3f3ad7"
75
75
  }