@rpgjs/action-battle 5.0.0-beta.10 → 5.0.0-beta.12
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/CHANGELOG.md +22 -0
- package/dist/client/ai.server.d.ts +45 -8
- package/dist/client/attack-input.d.ts +3 -0
- package/dist/client/core/action-use.d.ts +18 -0
- package/dist/client/core/ai-behavior-tree.d.ts +99 -0
- package/dist/client/core/attack-runtime.d.ts +2 -0
- package/dist/client/core/defaults.d.ts +2 -1
- package/dist/client/core/equipment.d.ts +1 -0
- package/dist/client/core/targets.d.ts +15 -0
- package/dist/client/enemies/factory.d.ts +2 -0
- package/dist/client/index.d.ts +12 -7
- package/dist/client/index.js +16 -11
- package/dist/client/index10.js +32 -56
- package/dist/client/index11.js +99 -52
- package/dist/client/index12.js +76 -103
- package/dist/client/index13.js +72 -135
- package/dist/client/index14.js +67 -23
- package/dist/client/index15.js +197 -63
- package/dist/client/index16.js +112 -1337
- package/dist/client/index17.js +193 -7
- package/dist/client/index18.js +32 -58
- package/dist/client/index19.js +70 -8
- package/dist/client/index20.js +57 -501
- package/dist/client/index21.js +69 -0
- package/dist/client/index22.js +225 -0
- package/dist/client/index23.js +16 -0
- package/dist/client/index24.js +25 -0
- package/dist/client/index25.js +107 -0
- package/dist/client/index26.js +1707 -0
- package/dist/client/index27.js +12 -0
- package/dist/client/index28.js +589 -0
- package/dist/client/index4.js +79 -38
- package/dist/client/index6.js +65 -306
- package/dist/client/index7.js +33 -33
- package/dist/client/index8.js +24 -100
- package/dist/client/index9.js +293 -61
- package/dist/client/locomotion.d.ts +16 -0
- package/dist/client/movement.d.ts +14 -0
- package/dist/client/server.d.ts +7 -3
- package/dist/client/ui.d.ts +22 -0
- package/dist/client/visual.d.ts +15 -0
- package/dist/server/ai.server.d.ts +45 -8
- package/dist/server/attack-input.d.ts +3 -0
- package/dist/server/core/action-use.d.ts +18 -0
- package/dist/server/core/ai-behavior-tree.d.ts +99 -0
- package/dist/server/core/attack-runtime.d.ts +2 -0
- package/dist/server/core/defaults.d.ts +2 -1
- package/dist/server/core/equipment.d.ts +1 -0
- package/dist/server/core/targets.d.ts +15 -0
- package/dist/server/enemies/factory.d.ts +2 -0
- package/dist/server/index.d.ts +12 -7
- package/dist/server/index.js +14 -9
- package/dist/server/index10.js +64 -1336
- package/dist/server/index11.js +33 -33
- package/dist/server/index13.js +66 -11
- package/dist/server/index14.js +206 -484
- package/dist/server/index15.js +15 -9
- package/dist/server/index16.js +26 -0
- package/dist/server/index17.js +25 -0
- package/dist/server/index18.js +107 -0
- package/dist/server/index19.js +1707 -0
- package/dist/server/index2.js +10 -2
- package/dist/server/index20.js +37 -0
- package/dist/server/index21.js +588 -0
- package/dist/server/index22.js +78 -0
- package/dist/server/index23.js +12 -0
- package/dist/server/index5.js +79 -38
- package/dist/server/index6.js +192 -129
- package/dist/server/index7.js +198 -24
- package/dist/server/index8.js +28 -66
- package/dist/server/index9.js +68 -51
- package/dist/server/locomotion.d.ts +16 -0
- package/dist/server/movement.d.ts +14 -0
- package/dist/server/server.d.ts +7 -3
- package/dist/server/ui.d.ts +22 -0
- package/dist/server/visual.d.ts +15 -0
- package/package.json +10 -10
- package/src/ai.server.spec.ts +233 -0
- package/src/ai.server.ts +627 -108
- package/src/animations.spec.ts +40 -0
- package/src/animations.ts +31 -9
- package/src/attack-input.spec.ts +51 -0
- package/src/attack-input.ts +59 -0
- package/src/client.ts +75 -62
- package/src/components/action-bar.ce +2 -2
- package/src/config.ts +84 -37
- package/src/core/action-use.spec.ts +317 -0
- package/src/core/action-use.ts +386 -0
- package/src/core/ai-behavior-tree.spec.ts +116 -0
- package/src/core/ai-behavior-tree.ts +272 -0
- package/src/core/attack-profile.spec.ts +46 -0
- package/src/core/attack-runtime.spec.ts +35 -0
- package/src/core/attack-runtime.ts +32 -0
- package/src/core/context.ts +9 -0
- package/src/core/contracts.ts +146 -1
- package/src/core/defaults.ts +56 -0
- package/src/core/equipment.ts +9 -5
- package/src/core/targets.spec.ts +112 -0
- package/src/core/targets.ts +147 -0
- package/src/enemies/factory.ts +8 -0
- package/src/index.ts +111 -2
- package/src/locomotion.spec.ts +51 -0
- package/src/locomotion.ts +48 -0
- package/src/movement.spec.ts +78 -0
- package/src/movement.ts +46 -0
- package/src/server.ts +242 -66
- package/src/types.ts +105 -35
- package/src/ui.ts +113 -0
- package/src/visual.spec.ts +166 -0
- package/src/visual.ts +285 -0
- package/README.md +0 -1242
package/dist/server/index11.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
//#region src/
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
//#region src/attack-input.ts
|
|
2
|
+
var ACTION_BATTLE_DIRECTIONS = new Set([
|
|
3
|
+
"up",
|
|
4
|
+
"down",
|
|
5
|
+
"left",
|
|
6
|
+
"right"
|
|
7
|
+
]);
|
|
8
|
+
var normalizeDirection = (value) => {
|
|
9
|
+
if (typeof value !== "string") return void 0;
|
|
10
|
+
return ACTION_BATTLE_DIRECTIONS.has(value) ? value : void 0;
|
|
6
11
|
};
|
|
7
|
-
var
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
var resolveActionBattleAttackDirection = (entity, input) => {
|
|
13
|
+
const payloadDirection = normalizeDirection(input?.data?.direction) ?? normalizeDirection(input?.data?.attackDirection) ?? normalizeDirection(input?.direction);
|
|
14
|
+
if (payloadDirection) return payloadDirection;
|
|
15
|
+
if (typeof entity?.getDirection === "function") {
|
|
16
|
+
const direction = normalizeDirection(entity.getDirection());
|
|
17
|
+
if (direction) return direction;
|
|
18
|
+
}
|
|
19
|
+
if (typeof entity?.direction === "function") {
|
|
20
|
+
const direction = normalizeDirection(entity.direction());
|
|
21
|
+
if (direction) return direction;
|
|
22
|
+
}
|
|
23
|
+
return normalizeDirection(entity?.direction) ?? "down";
|
|
24
|
+
};
|
|
25
|
+
var applyActionBattleAttackDirection = (entity, direction) => {
|
|
26
|
+
if (typeof entity?.changeDirection === "function") {
|
|
27
|
+
const previousDirectionFixed = entity.directionFixed;
|
|
28
|
+
if (previousDirectionFixed === true) entity.directionFixed = false;
|
|
29
|
+
try {
|
|
30
|
+
entity.changeDirection(direction);
|
|
31
|
+
} finally {
|
|
32
|
+
if (previousDirectionFixed === true) entity.directionFixed = previousDirectionFixed;
|
|
21
33
|
}
|
|
22
|
-
}
|
|
23
|
-
if (cells.length === 0) cells.push({
|
|
24
|
-
dx: 0,
|
|
25
|
-
dy: 0
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
width,
|
|
29
|
-
height,
|
|
30
|
-
centerX,
|
|
31
|
-
centerY,
|
|
32
|
-
cells
|
|
33
|
-
};
|
|
34
|
+
}
|
|
34
35
|
};
|
|
35
|
-
var manhattanDistance = (a, b) => Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
|
|
36
36
|
//#endregion
|
|
37
|
-
export {
|
|
37
|
+
export { applyActionBattleAttackDirection, resolveActionBattleAttackDirection };
|
package/dist/server/index13.js
CHANGED
|
@@ -1,13 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { RpgEvent, RpgPlayer } from "@rpgjs/server";
|
|
2
|
+
//#region src/core/targets.ts
|
|
3
|
+
var ACTION_BATTLE_PLAYER_FACTION = "players";
|
|
4
|
+
var ACTION_BATTLE_ENEMY_FACTION = "enemies";
|
|
5
|
+
var getBattleAi = (entity) => entity?.battleAi;
|
|
6
|
+
var getActionBattleEntityKind = (entity) => {
|
|
7
|
+
if (getBattleAi(entity)) return "event";
|
|
8
|
+
if (entity instanceof RpgEvent) return "event";
|
|
9
|
+
if (typeof entity?.attachShape === "function") return "event";
|
|
10
|
+
if (entity instanceof RpgPlayer) return "player";
|
|
11
|
+
return "player";
|
|
12
|
+
};
|
|
13
|
+
var isActionBattlePlayer = (entity) => getActionBattleEntityKind(entity) === "player";
|
|
14
|
+
var isActionBattleEvent = (entity) => getActionBattleEntityKind(entity) === "event";
|
|
15
|
+
var isActionBattleCombatEntity = (entity) => {
|
|
16
|
+
if (!entity) return false;
|
|
17
|
+
if (isActionBattlePlayer(entity)) return true;
|
|
18
|
+
return !!getBattleAi(entity);
|
|
19
|
+
};
|
|
20
|
+
var getActionBattleFaction = (entity, options = {}) => {
|
|
21
|
+
const configured = options.getFaction?.(entity);
|
|
22
|
+
if (configured !== void 0) return configured;
|
|
23
|
+
const battleAi = getBattleAi(entity);
|
|
24
|
+
if (battleAi && typeof battleAi.getFaction === "function") {
|
|
25
|
+
const faction = battleAi.getFaction();
|
|
26
|
+
if (faction !== void 0) return faction;
|
|
9
27
|
}
|
|
10
|
-
|
|
11
|
-
|
|
28
|
+
const entityFaction = entity.actionBattleFaction ?? entity.faction;
|
|
29
|
+
if (entityFaction !== void 0) return String(entityFaction);
|
|
30
|
+
if (isActionBattlePlayer(entity)) return ACTION_BATTLE_PLAYER_FACTION;
|
|
31
|
+
if (battleAi) return ACTION_BATTLE_ENEMY_FACTION;
|
|
32
|
+
};
|
|
33
|
+
var getActionBattleTargets = (entity, fallback) => {
|
|
34
|
+
const battleAi = getBattleAi(entity);
|
|
35
|
+
if (battleAi && typeof battleAi.getTargets === "function") return battleAi.getTargets();
|
|
36
|
+
return entity.actionBattleTargets ?? fallback;
|
|
37
|
+
};
|
|
38
|
+
var isActionBattleTargetDefeated = (target) => {
|
|
39
|
+
if (!target) return true;
|
|
40
|
+
const hp = target.hp;
|
|
41
|
+
return typeof hp === "number" && hp <= 0;
|
|
42
|
+
};
|
|
43
|
+
var matchesActionBattleTargetSelector = (selector, context) => {
|
|
44
|
+
if (!selector) return false;
|
|
45
|
+
if (typeof selector === "function") return selector(context);
|
|
46
|
+
if (selector === "all") return true;
|
|
47
|
+
if (selector === "players") return isActionBattlePlayer(context.target);
|
|
48
|
+
if (selector === "events") return isActionBattleEvent(context.target);
|
|
49
|
+
if (selector === "hostile") return !!context.attackerFaction && !!context.targetFaction && context.attackerFaction !== context.targetFaction;
|
|
50
|
+
if (Array.isArray(selector)) return !!context.targetFaction && selector.includes(context.targetFaction);
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
var canActionBattleTarget = (attacker, target, selector, options = {}) => {
|
|
54
|
+
if (attacker === target) return false;
|
|
55
|
+
if (!isActionBattleCombatEntity(target)) return false;
|
|
56
|
+
if (isActionBattleTargetDefeated(target)) return false;
|
|
57
|
+
const context = {
|
|
58
|
+
attacker,
|
|
59
|
+
target,
|
|
60
|
+
attackerFaction: getActionBattleFaction(attacker, options),
|
|
61
|
+
targetFaction: getActionBattleFaction(target, options)
|
|
62
|
+
};
|
|
63
|
+
const allowed = options.canTarget?.(context);
|
|
64
|
+
if (allowed !== void 0) return allowed;
|
|
65
|
+
return matchesActionBattleTargetSelector(selector, context);
|
|
66
|
+
};
|
|
12
67
|
//#endregion
|
|
13
|
-
export {
|
|
68
|
+
export { ACTION_BATTLE_ENEMY_FACTION, ACTION_BATTLE_PLAYER_FACTION, canActionBattleTarget, getActionBattleFaction, getActionBattleTargets, isActionBattleCombatEntity, isActionBattleEvent, isActionBattlePlayer, isActionBattleTargetDefeated, matchesActionBattleTargetSelector };
|