@wwawing/engine 3.9.3 → 3.10.0-alpha.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,
@@ -260,8 +255,11 @@ export declare enum MacroType {
260
255
  END_IF = 59,
261
256
  SET = 60,
262
257
  GAMEPAD_BUTTON = 100,
263
- OLDMOVE = 101
258
+ OLDMOVE = 101,
259
+ LEGACY_IF = 10050
264
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;
265
263
  export declare var macrotable: {
266
264
  "": number;
267
265
  $imgplayer: number;
@@ -567,4 +565,12 @@ export declare enum IDTable {
567
565
  }
568
566
  export declare type StatusSolutionKind = "all" | "bare" | "equipment";
569
567
  export declare type UserVarNameListRequestErrorKind = JsonResponseErrorKind | "notObject" | "noFileSpecified";
570
- 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,11 +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;
164
+ private _execChoiceWindowObjectSellEvent;
157
165
  private _execChoiceWindowRunningEvent;
158
- setMessageQueue(message: string, showChoice: boolean, isSystemMessage: boolean, partsID?: number, partsType?: PartsType, partsPosition?: Coord, messageDisplayed?: boolean): boolean;
159
- getMessageQueueByRawMessage(message: string, partsID: number, partsType: PartsType, partsPosition: Coord, isSystemMessage?: boolean): ParsedMessage[];
160
- 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;
161
175
  appearPartsByDirection(distance: number, targetPartsID: number, targetPartsType: PartsType): void;
162
176
  appearPartsEval(triggerPartsPos: Coord, xstr: string, ystr: string, targetPartsID: number, targetPartsType: PartsType): void;
163
177
  private _replaceRandomObject;
@@ -196,7 +210,7 @@ export declare class WWA {
196
210
  hidePasswordWindow(isCancel?: boolean): void;
197
211
  private _displayUserVars;
198
212
  private _displayHelp;
199
- _setNextMessage(displayCenter?: boolean): void;
213
+ _setNextPage(): void;
200
214
  private _hideMessageWindow;
201
215
  loadMapPartsObjectID(id: number): number;
202
216
  loadMapPartsID(id: number): number;
@@ -215,7 +229,9 @@ export declare class WWA {
215
229
  setObjectNotCollapseOnPartsOnPlayer(flag: boolean): boolean;
216
230
  setGameOverPosition(pos: Coord): Coord;
217
231
  private toValidStatusValue;
218
- setPlayerStatus(type: MacroStatusIndex, value: number, isCalledByMacro: boolean): void;
232
+ setPlayerStatus(type: MacroStatusIndex, value: number, isCalledByMacro: boolean): {
233
+ isGameOver?: true;
234
+ };
219
235
  setDelPlayer(flag: boolean): boolean;
220
236
  setPlayerGetItem(pos: number, id: number): void;
221
237
  setStatusIconCoord(type: MacroImgFrameIndex, coord: Coord): Coord;
@@ -255,7 +271,9 @@ export declare class WWA {
255
271
  setUserVarAT(num: number, kind: StatusSolutionKind): void;
256
272
  setUserVarDF(num: number, kind: StatusSolutionKind): void;
257
273
  setUserVarMONEY(num: number): void;
258
- setHPUserVar(index: number, isCalledByMacro: boolean): void;
274
+ setHPUserVar(index: number, isCalledByMacro: boolean): {
275
+ isGameOver?: true;
276
+ };
259
277
  setHPMAXUserVar(index: number): void;
260
278
  setATUserVar(index: number): void;
261
279
  setDFUserVar(index: number): void;
@@ -271,10 +289,10 @@ export declare class WWA {
271
289
  setUserValRandNum(x: number, num: number, bias: number): void;
272
290
  private _generateUserValString;
273
291
  speedChangeJudge(speedChangeFlag: boolean): void;
274
- switchConditionalExecutionStatus(descriminant?: string): void;
275
- execSetMacro(macroStr?: string): void;
292
+ execSetMacro(macroStr?: string): {
293
+ isGameOver?: true;
294
+ };
276
295
  private _generateTokenValues;
277
- resetConditionalMacroExecStaus(): void;
278
296
  userVarUserIf(_triggerPartsPosition: Coord, args: string[]): void;
279
297
  private compareUserVar;
280
298
  setPlayerSpeedIndex(speedIndex: number): void;
@@ -296,3 +314,4 @@ export declare class WWA {
296
314
  isCalledByMacro: boolean;
297
315
  }): boolean;
298
316
  }
317
+ export {};
@@ -1,19 +1,62 @@
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
+ next?: Node;
23
+ }
24
+ export declare class Junction extends Node {
25
+ branches: Branch[];
26
+ constructor(branches?: Branch[]);
27
+ appendBranch(branch: Branch): void;
28
+ getLastUnconnectedBranch(): Branch | undefined;
29
+ evaluateAndGetNextNode(tokenValues: TokenValues): Node | undefined;
30
+ }
31
+ export declare class ParsedMessage extends Node {
11
32
  macro?: Macro[];
33
+ next?: Node;
12
34
  private messageArray;
13
- constructor(textOrMessageSegments: string | MessageSegments, isSystemMessage: boolean, isEndOfPartsEvent?: boolean, macro?: Macro[]);
35
+ constructor(textOrMessageSegments: string | MessageSegments, macro?: Macro[], next?: Node);
14
36
  isEmpty(): boolean;
15
37
  generatePrintableMessage(): string;
38
+ appendMessage(message: string | MessageSegments, withNewLine?: boolean): void;
39
+ private parseMessage;
16
40
  }
41
+ export declare function isEmptyMessageTree(node: Node | undefined): boolean;
42
+ export declare function getLastMessage(node: undefined): undefined;
43
+ export declare function getLastMessage(node: Node): Node;
44
+ export declare function concatMessage(node1: Node | undefined, node2: Node | undefined): Node | undefined;
45
+ export declare type MessageLineType = PreprocessMacroType | "text" | "normalMacro";
46
+ export declare const messagLineIsText: (lineType: MessageLineType) => boolean;
47
+ export declare type MessageLine = ({
48
+ type: PreprocessMacroType;
49
+ text: string;
50
+ macro: Macro;
51
+ } | {
52
+ type: "normalMacro";
53
+ text: string;
54
+ macro: Macro;
55
+ } | {
56
+ type: "text";
57
+ text: string;
58
+ macro?: undefined;
59
+ });
17
60
  export declare class Macro {
18
61
  private _wwa;
19
62
  private _triggerPartsID;
@@ -23,7 +66,9 @@ export declare class Macro {
23
66
  macroArgs: string[];
24
67
  constructor(_wwa: WWA, _triggerPartsID: number, _triggerPartsType: number, _triggerPartsPosition: Coord, macroType: MacroType, macroArgs: string[]);
25
68
  isJunction(): boolean;
26
- execute(): void;
69
+ execute(): {
70
+ isGameOver?: true;
71
+ };
27
72
  private _concatEmptyArgs;
28
73
  private _parseInt;
29
74
  private _executeJumpGateMacro;
@@ -51,10 +96,7 @@ export declare class Macro {
51
96
  private _executeVarModMacro;
52
97
  private _executeVarSetRandMacro;
53
98
  private _executeGameSpeedMacro;
54
- private _executeIfMacro;
55
- private _executeIfElseMacro;
56
- private _executeElseMacro;
57
- private _executeEndIfMacro;
99
+ private _executeLegacyIfMacro;
58
100
  private _executeSetSpeedMacro;
59
101
  private _executeCopyTimeToMacro;
60
102
  private _executeHideStatusMacro;
@@ -154,7 +196,7 @@ export declare class MessageWindow {
154
196
  setPosition(x: number, y: number, width: number, height: number): void;
155
197
  setPositionByPlayerPosition(existsFaces: boolean, existsScoreWindow: boolean, displayCenter: boolean, playerPos: Position, cameraPos: Position): void;
156
198
  setPositionEasy(pos: Positioning): void;
157
- setParsedMessage(message: ParsedMessage): void;
199
+ setMessage(message: string): void;
158
200
  clear(): void;
159
201
  setYesNoChoice(isYesNo: boolean): boolean;
160
202
  isYesNoChoice(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wwawing/engine",
3
- "version": "3.9.3",
3
+ "version": "3.10.0-alpha.0",
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.3",
49
- "@wwawing/common-interface": "^3.9.3",
50
- "@wwawing/debug-server": "^3.9.3",
51
- "@wwawing/event-emitter": "^3.9.3",
52
- "@wwawing/loader": "^3.9.3",
53
- "@wwawing/page-generator": "^3.9.3",
54
- "@wwawing/styles": "^3.9.3",
48
+ "@wwawing/assets": "^3.10.0-alpha.0",
49
+ "@wwawing/common-interface": "^3.10.0-alpha.0",
50
+ "@wwawing/debug-server": "^3.10.0-alpha.0",
51
+ "@wwawing/event-emitter": "^3.10.0-alpha.0",
52
+ "@wwawing/loader": "^3.10.0-alpha.0",
53
+ "@wwawing/page-generator": "^3.10.0-alpha.0",
54
+ "@wwawing/styles": "^3.10.0-alpha.0",
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": "b75927812988f50079efc97d479578b51297e318"
74
+ "gitHead": "437235dca891a22c4a3fa9714d3adcb25def6fbf"
75
75
  }