@civ-clone/base-unit-lifecycle 0.0.0-stage → 0.1.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/.gitattributes +4 -0
- package/.github/workflows/build-on-push.yml +39 -0
- package/.prettierrc +4 -0
- package/LICENSE +21 -0
- package/README.md +35 -2
- package/lib/activate.d.ts +15 -0
- package/lib/activate.js +27 -0
- package/lib/activate.js.map +1 -0
- package/lib/activate.ts +47 -0
- package/lib/canStow.d.ts +8 -0
- package/lib/canStow.js +17 -0
- package/lib/canStow.js.map +1 -0
- package/lib/canStow.ts +25 -0
- package/lib/created.d.ts +9 -0
- package/lib/created.js +19 -0
- package/lib/created.js.map +1 -0
- package/lib/created.ts +24 -0
- package/lib/defeated.d.ts +25 -0
- package/lib/defeated.js +33 -0
- package/lib/defeated.js.map +1 -0
- package/lib/defeated.ts +55 -0
- package/lib/destroyed.d.ts +37 -0
- package/lib/destroyed.js +74 -0
- package/lib/destroyed.js.map +1 -0
- package/lib/destroyed.ts +106 -0
- package/lib/halted.d.ts +6 -0
- package/lib/halted.js +10 -0
- package/lib/halted.js.map +1 -0
- package/lib/halted.ts +11 -0
- package/lib/impassable.d.ts +8 -0
- package/lib/impassable.js +15 -0
- package/lib/impassable.js.map +1 -0
- package/lib/impassable.ts +19 -0
- package/lib/lostAtSea.d.ts +12 -0
- package/lib/lostAtSea.js +26 -0
- package/lib/lostAtSea.js.map +1 -0
- package/lib/lostAtSea.ts +37 -0
- package/lib/playerAction.d.ts +22 -0
- package/lib/playerAction.js +28 -0
- package/lib/playerAction.js.map +1 -0
- package/lib/playerAction.ts +64 -0
- package/lib/stowed.d.ts +2 -0
- package/lib/stowed.js +8 -0
- package/lib/stowed.js.map +1 -0
- package/lib/stowed.ts +6 -0
- package/lib/unsupported.d.ts +6 -0
- package/lib/unsupported.js +9 -0
- package/lib/unsupported.js.map +1 -0
- package/lib/unsupported.ts +10 -0
- package/lib/validateMove.d.ts +11 -0
- package/lib/validateMove.js +26 -0
- package/lib/validateMove.js.map +1 -0
- package/lib/validateMove.ts +36 -0
- package/package.json +43 -4
- package/tests/lifecycle.test.ts +657 -0
- package/tsconfig.json +16 -0
package/.gitattributes
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Build and test application on push to remote
|
|
2
|
+
|
|
3
|
+
on: [push]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v4
|
|
10
|
+
- uses: pnpm/action-setup@v4
|
|
11
|
+
with:
|
|
12
|
+
version: 11
|
|
13
|
+
- uses: actions/setup-node@v4
|
|
14
|
+
with:
|
|
15
|
+
node-version: 22
|
|
16
|
+
# No lock file, so this tests what a consumer resolves. The settings match
|
|
17
|
+
# web-renderer's pnpm-workspace.yaml: several @civ-clone packages depend on
|
|
18
|
+
# each other as `github:` URLs, this project's own releases are often only
|
|
19
|
+
# minutes old, and nothing here needs a dependency's build script.
|
|
20
|
+
- run: >-
|
|
21
|
+
pnpm install --no-frozen-lockfile
|
|
22
|
+
--config.block-exotic-subdeps=false
|
|
23
|
+
--config.minimum-release-age=0
|
|
24
|
+
--config.strict-dep-builds=false
|
|
25
|
+
- run: npm run --if-present prettier:check
|
|
26
|
+
# The tests load the committed `.js`, so compile to prove the source
|
|
27
|
+
# type-checks, and fail if the committed output is stale. `--force`
|
|
28
|
+
# because a fresh checkout's timestamps can make `tsc --build` treat the
|
|
29
|
+
# committed output as up to date and skip the compile entirely.
|
|
30
|
+
- run: npm run --if-present ts:compile -- --force
|
|
31
|
+
- run: npm run --if-present prettier:format
|
|
32
|
+
# Stale *or never committed* output fails: `git diff` alone misses a new
|
|
33
|
+
# module whose `.js` was never added, which the published package would
|
|
34
|
+
# then omit. Only the compiled extensions, so the lock file the install
|
|
35
|
+
# writes cannot fail it; `node_modules` is ignored, so it stays out.
|
|
36
|
+
- run: |
|
|
37
|
+
git status --short --untracked-files=all -- '*.js' '*.d.ts' '*.js.map'
|
|
38
|
+
test -z "$(git status --porcelain --untracked-files=all -- '*.js' '*.d.ts' '*.js.map')"
|
|
39
|
+
- run: npm run --if-present test
|
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Dom Hastings
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# base-unit-lifecycle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Building blocks for a ruleset's unit lifecycle rules. The ruleset keeps its own rules (`Created`, `Destroyed` and the
|
|
4
|
+
rest), with its own ids, order and numbers, and builds their criteria and effects from these functions. Each one is a
|
|
5
|
+
rule's criterion or effect as it is: pass it straight to `new Criterion(...)` or `new Effect(...)`. Those that need a
|
|
6
|
+
registry, the engine or a number take it first and return the function.
|
|
7
|
+
|
|
8
|
+
- `lib/created`: `registerUnit(unitRegistry)`, `applyVisibility`, `setMoves` (full moves) and `emitCreated(engine)`
|
|
9
|
+
(`unit:created`).
|
|
10
|
+
- `lib/activate`: `hasMoves`, `setActive`, `isBusy`, `clearBusy`, and `hasImprovement(unitImprovementRegistry, Type)` /
|
|
11
|
+
`removeImprovement(unitImprovementRegistry, Type)` for each improvement waking a unit removes.
|
|
12
|
+
- `lib/validateMove`: `hasMovesFor` / `spendMoves` for a step the unit has the moves for, and `shortOfMovesFor` /
|
|
13
|
+
`spendShort(shortfallFactor, randomNumberGenerator)` for one it hasn't: it spends what's left and gets there by
|
|
14
|
+
base-unit-action-rules' `succeedsShort`.
|
|
15
|
+
- `lib/impassable`: `fromLand`, `toPartnersLand(partnerOf)` and `impassable`, so routes go round a treaty partner's
|
|
16
|
+
land; `partnerOf` is the ruleset's territory model.
|
|
17
|
+
- `lib/canStow`: `carriesDomain(Domain)` and `carriesUnit(Domain)`, one `CanStow` rule per domain a transport may be
|
|
18
|
+
declared to carry, from its `Carries` traits.
|
|
19
|
+
- `lib/stowed`: `sleepAboard`, a unit that boards sleeps.
|
|
20
|
+
- `lib/halted`: `emitHalted(engine)` (`unit:halted`), a GoTo stopped next to its destination.
|
|
21
|
+
- `lib/unsupported`: `emitUnsupported(engine)` (`unit:unsupported`).
|
|
22
|
+
- `lib/defeated`: `emitAndDestroy(engine, ruleRegistry)` (`unit:defeated`, then `Destroyed`), and for a defeated
|
|
23
|
+
defender's stack, `defended`, `notInCity(cityRegistry)`, `hasStack(unitRegistry)` and
|
|
24
|
+
`destroyStack(unitRegistry, ruleRegistry)`.
|
|
25
|
+
- `lib/destroyed`: `emitDestroyed(engine)` (`unit:destroyed`); `destroyedByAnother`, `notYetDestroyed` and
|
|
26
|
+
`countLoss(unitLossRegistry)` for a loss report; `deactivate`; `removeImprovements(unitImprovementRegistry)`;
|
|
27
|
+
`carriesCargo(transportRegistry)` / `loseCargo(transportRegistry)`, cargo lost with its transport at sea; and
|
|
28
|
+
`isAboard(transportRegistry)` / `leaveOwnTransport(transportRegistry)`, cargo destroyed on its own. Both take units
|
|
29
|
+
off with `leaveTransport(transportRegistry)`, which also clears `Stowed`.
|
|
30
|
+
- `lib/lostAtSea`: `emitLostAtSea(engine)` (`unit:lost-at-sea`), `countLosses(unitLossRegistry, transportRegistry)`
|
|
31
|
+
(the transport and its cargo; before `sink`) and `sink`.
|
|
32
|
+
- `lib/playerAction`: `hasActiveUnits(unitRegistry)` / `activeUnits(unitRegistry, ActiveUnit)` and
|
|
33
|
+
`hasInactiveUnits(unitRegistry)` / `inactiveUnits(unitRegistry, InactiveUnit)`, waiting units last.
|
|
34
|
+
|
|
35
|
+
A library: no `main`, so it registers nothing on its own. Import what you need, for example
|
|
36
|
+
`@civ-clone/base-unit-lifecycle/lib/destroyed`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
2
|
+
import UnitImprovement from '@civ-clone/core-unit-improvement/UnitImprovement';
|
|
3
|
+
import UnitImprovementRegistry from '@civ-clone/core-unit-improvement/UnitImprovementRegistry';
|
|
4
|
+
export declare const hasMoves: (unit: Unit) => boolean;
|
|
5
|
+
export declare const setActive: (unit: Unit) => void;
|
|
6
|
+
export declare const isBusy: (unit: Unit) => boolean;
|
|
7
|
+
export declare const clearBusy: (unit: Unit) => void;
|
|
8
|
+
export declare const hasImprovement: (
|
|
9
|
+
unitImprovementRegistry: UnitImprovementRegistry,
|
|
10
|
+
UnitImprovementType: typeof UnitImprovement
|
|
11
|
+
) => (unit: Unit) => boolean;
|
|
12
|
+
export declare const removeImprovement: (
|
|
13
|
+
unitImprovementRegistry: UnitImprovementRegistry,
|
|
14
|
+
UnitImprovementType: typeof UnitImprovement
|
|
15
|
+
) => (unit: Unit) => void;
|
package/lib/activate.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeImprovement = exports.hasImprovement = exports.clearBusy = exports.isBusy = exports.setActive = exports.hasMoves = void 0;
|
|
4
|
+
// What a ruleset's `Activate` rules ask and do when a unit is woken to take orders.
|
|
5
|
+
// The unit has moves left.
|
|
6
|
+
const hasMoves = (unit) => unit.moves().value() > 0;
|
|
7
|
+
exports.hasMoves = hasMoves;
|
|
8
|
+
// Makes the unit active.
|
|
9
|
+
const setActive = (unit) => unit.setActive();
|
|
10
|
+
exports.setActive = setActive;
|
|
11
|
+
// The unit is busy (sleeping, fortifying, working...).
|
|
12
|
+
const isBusy = (unit) => unit.busy() !== null;
|
|
13
|
+
exports.isBusy = isBusy;
|
|
14
|
+
// Clears what the unit was busy with.
|
|
15
|
+
const clearBusy = (unit) => unit.setBusy();
|
|
16
|
+
exports.clearBusy = clearBusy;
|
|
17
|
+
// The unit has an improvement of `UnitImprovementType` (one that waking it should remove, such as being fortified).
|
|
18
|
+
const hasImprovement = (unitImprovementRegistry, UnitImprovementType) => (unit) => unitImprovementRegistry
|
|
19
|
+
.getByUnit(unit)
|
|
20
|
+
.some((unitImprovement) => unitImprovement instanceof UnitImprovementType);
|
|
21
|
+
exports.hasImprovement = hasImprovement;
|
|
22
|
+
// Removes the unit's improvements of `UnitImprovementType`.
|
|
23
|
+
const removeImprovement = (unitImprovementRegistry, UnitImprovementType) => (unit) => unitImprovementRegistry.unregister(...unitImprovementRegistry
|
|
24
|
+
.getByUnit(unit)
|
|
25
|
+
.filter((unitImprovement) => unitImprovement instanceof UnitImprovementType));
|
|
26
|
+
exports.removeImprovement = removeImprovement;
|
|
27
|
+
//# sourceMappingURL=activate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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 +1,47 @@
|
|
|
1
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
2
|
+
import UnitImprovement from '@civ-clone/core-unit-improvement/UnitImprovement';
|
|
3
|
+
import UnitImprovementRegistry from '@civ-clone/core-unit-improvement/UnitImprovementRegistry';
|
|
4
|
+
|
|
5
|
+
// What a ruleset's `Activate` rules ask and do when a unit is woken to take orders.
|
|
6
|
+
|
|
7
|
+
// The unit has moves left.
|
|
8
|
+
export const hasMoves = (unit: Unit): boolean => unit.moves().value() > 0;
|
|
9
|
+
|
|
10
|
+
// Makes the unit active.
|
|
11
|
+
export const setActive = (unit: Unit): void => unit.setActive();
|
|
12
|
+
|
|
13
|
+
// The unit is busy (sleeping, fortifying, working...).
|
|
14
|
+
export const isBusy = (unit: Unit): boolean => unit.busy() !== null;
|
|
15
|
+
|
|
16
|
+
// Clears what the unit was busy with.
|
|
17
|
+
export const clearBusy = (unit: Unit): void => unit.setBusy();
|
|
18
|
+
|
|
19
|
+
// The unit has an improvement of `UnitImprovementType` (one that waking it should remove, such as being fortified).
|
|
20
|
+
export const hasImprovement =
|
|
21
|
+
(
|
|
22
|
+
unitImprovementRegistry: UnitImprovementRegistry,
|
|
23
|
+
UnitImprovementType: typeof UnitImprovement
|
|
24
|
+
) =>
|
|
25
|
+
(unit: Unit): boolean =>
|
|
26
|
+
unitImprovementRegistry
|
|
27
|
+
.getByUnit(unit)
|
|
28
|
+
.some(
|
|
29
|
+
(unitImprovement: UnitImprovement): boolean =>
|
|
30
|
+
unitImprovement instanceof UnitImprovementType
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// Removes the unit's improvements of `UnitImprovementType`.
|
|
34
|
+
export const removeImprovement =
|
|
35
|
+
(
|
|
36
|
+
unitImprovementRegistry: UnitImprovementRegistry,
|
|
37
|
+
UnitImprovementType: typeof UnitImprovement
|
|
38
|
+
) =>
|
|
39
|
+
(unit: Unit): void =>
|
|
40
|
+
unitImprovementRegistry.unregister(
|
|
41
|
+
...unitImprovementRegistry
|
|
42
|
+
.getByUnit(unit)
|
|
43
|
+
.filter(
|
|
44
|
+
(unitImprovement: UnitImprovement): boolean =>
|
|
45
|
+
unitImprovement instanceof UnitImprovementType
|
|
46
|
+
)
|
|
47
|
+
);
|
package/lib/canStow.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ITransport } from '@civ-clone/core-unit-transport/Transport';
|
|
2
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
3
|
+
export declare const carriesDomain: (
|
|
4
|
+
Domain: typeof Unit
|
|
5
|
+
) => (transport: ITransport) => boolean;
|
|
6
|
+
export declare const carriesUnit: (
|
|
7
|
+
Domain: typeof Unit
|
|
8
|
+
) => (transport: ITransport, unit: Unit) => boolean;
|
package/lib/canStow.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.carriesUnit = exports.carriesDomain = void 0;
|
|
4
|
+
const Carries_1 = require("@civ-clone/base-unit-trait-carries/Carries");
|
|
5
|
+
// What a ruleset's `CanStow` rules ask, one rule for each domain (`Land`, `Air`...) a transport may be declared to
|
|
6
|
+
// carry: what a transport carries is its `Carries` traits.
|
|
7
|
+
// The transport is declared to carry units of `Domain`.
|
|
8
|
+
const carriesDomain = (Domain) => (transport) => transport
|
|
9
|
+
.traits(Carries_1.default)
|
|
10
|
+
.some((carries) => carries.what === Domain);
|
|
11
|
+
exports.carriesDomain = carriesDomain;
|
|
12
|
+
// The transport carries `unit` as one of `Domain`: a `Carries` trait for `Domain` that accepts it.
|
|
13
|
+
const carriesUnit = (Domain) => (transport, unit) => transport
|
|
14
|
+
.traits(Carries_1.default)
|
|
15
|
+
.some((carries) => carries.what === Domain && carries.carries(unit));
|
|
16
|
+
exports.carriesUnit = carriesUnit;
|
|
17
|
+
//# sourceMappingURL=canStow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canStow.js","sourceRoot":"","sources":["canStow.ts"],"names":[],"mappings":";;;AAAA,wEAAiE;AAIjE,mHAAmH;AACnH,4DAA4D;AAE5D,wDAAwD;AACjD,MAAM,aAAa,GACxB,CAAC,MAAmB,EAAE,EAAE,CACxB,CAAC,SAAqB,EAAW,EAAE,CAChC,SAA6B;KAC3B,MAAM,CAAC,iBAAO,CAAC;KACf,IAAI,CAAC,CAAC,OAAgB,EAAW,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AALvD,QAAA,aAAa,iBAK0C;AAEpE,mGAAmG;AAC5F,MAAM,WAAW,GACtB,CAAC,MAAmB,EAAE,EAAE,CACxB,CAAC,SAAqB,EAAE,IAAU,EAAW,EAAE,CAC5C,SAA6B;KAC3B,MAAM,CAAC,iBAAO,CAAC;KACf,IAAI,CACH,CAAC,OAAgB,EAAW,EAAE,CAC5B,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CACnD,CAAC;AARK,QAAA,WAAW,eAQhB"}
|
package/lib/canStow.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Carries from '@civ-clone/base-unit-trait-carries/Carries';
|
|
2
|
+
import { ITransport } from '@civ-clone/core-unit-transport/Transport';
|
|
3
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
4
|
+
|
|
5
|
+
// What a ruleset's `CanStow` rules ask, one rule for each domain (`Land`, `Air`...) a transport may be declared to
|
|
6
|
+
// carry: what a transport carries is its `Carries` traits.
|
|
7
|
+
|
|
8
|
+
// The transport is declared to carry units of `Domain`.
|
|
9
|
+
export const carriesDomain =
|
|
10
|
+
(Domain: typeof Unit) =>
|
|
11
|
+
(transport: ITransport): boolean =>
|
|
12
|
+
(transport as unknown as Unit)
|
|
13
|
+
.traits(Carries)
|
|
14
|
+
.some((carries: Carries): boolean => carries.what === Domain);
|
|
15
|
+
|
|
16
|
+
// The transport carries `unit` as one of `Domain`: a `Carries` trait for `Domain` that accepts it.
|
|
17
|
+
export const carriesUnit =
|
|
18
|
+
(Domain: typeof Unit) =>
|
|
19
|
+
(transport: ITransport, unit: Unit): boolean =>
|
|
20
|
+
(transport as unknown as Unit)
|
|
21
|
+
.traits(Carries)
|
|
22
|
+
.some(
|
|
23
|
+
(carries: Carries): boolean =>
|
|
24
|
+
carries.what === Domain && carries.carries(unit)
|
|
25
|
+
);
|
package/lib/created.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Engine from '@civ-clone/core-engine/Engine';
|
|
2
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
3
|
+
import UnitRegistry from '@civ-clone/core-unit/UnitRegistry';
|
|
4
|
+
export declare const registerUnit: (
|
|
5
|
+
unitRegistry: UnitRegistry
|
|
6
|
+
) => (unit: Unit) => void;
|
|
7
|
+
export declare const applyVisibility: (unit: Unit) => void;
|
|
8
|
+
export declare const setMoves: (unit: Unit) => void;
|
|
9
|
+
export declare const emitCreated: (engine: Engine) => (unit: Unit) => void;
|
package/lib/created.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitCreated = exports.setMoves = exports.applyVisibility = exports.registerUnit = void 0;
|
|
4
|
+
// What a ruleset's `Created` rules do with a new unit, one function for each rule's effect.
|
|
5
|
+
// Adds the unit to `unitRegistry`.
|
|
6
|
+
const registerUnit = (unitRegistry) => (unit) => unitRegistry.register(unit);
|
|
7
|
+
exports.registerUnit = registerUnit;
|
|
8
|
+
// Reveals what the unit can see to its player.
|
|
9
|
+
const applyVisibility = (unit) => unit.applyVisibility();
|
|
10
|
+
exports.applyVisibility = applyVisibility;
|
|
11
|
+
// Gives the unit its full moves.
|
|
12
|
+
const setMoves = (unit) => unit.moves().set(unit.movement());
|
|
13
|
+
exports.setMoves = setMoves;
|
|
14
|
+
// Emits `unit:created` with the unit.
|
|
15
|
+
const emitCreated = (engine) => (unit) => {
|
|
16
|
+
engine.emit('unit:created', unit);
|
|
17
|
+
};
|
|
18
|
+
exports.emitCreated = emitCreated;
|
|
19
|
+
//# sourceMappingURL=created.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"created.js","sourceRoot":"","sources":["created.ts"],"names":[],"mappings":";;;AAIA,4FAA4F;AAE5F,mCAAmC;AAC5B,MAAM,YAAY,GACvB,CAAC,YAA0B,EAAE,EAAE,CAC/B,CAAC,IAAU,EAAQ,EAAE,CACnB,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAHnB,QAAA,YAAY,gBAGO;AAEhC,+CAA+C;AACxC,MAAM,eAAe,GAAG,CAAC,IAAU,EAAQ,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;AAA/D,QAAA,eAAe,mBAAgD;AAE5E,iCAAiC;AAC1B,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAQ,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;AAAnE,QAAA,QAAQ,YAA2D;AAEhF,sCAAsC;AAC/B,MAAM,WAAW,GACtB,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,IAAU,EAAQ,EAAE;IACnB,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC;AAJS,QAAA,WAAW,eAIpB"}
|
package/lib/created.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Engine from '@civ-clone/core-engine/Engine';
|
|
2
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
3
|
+
import UnitRegistry from '@civ-clone/core-unit/UnitRegistry';
|
|
4
|
+
|
|
5
|
+
// What a ruleset's `Created` rules do with a new unit, one function for each rule's effect.
|
|
6
|
+
|
|
7
|
+
// Adds the unit to `unitRegistry`.
|
|
8
|
+
export const registerUnit =
|
|
9
|
+
(unitRegistry: UnitRegistry) =>
|
|
10
|
+
(unit: Unit): void =>
|
|
11
|
+
unitRegistry.register(unit);
|
|
12
|
+
|
|
13
|
+
// Reveals what the unit can see to its player.
|
|
14
|
+
export const applyVisibility = (unit: Unit): void => unit.applyVisibility();
|
|
15
|
+
|
|
16
|
+
// Gives the unit its full moves.
|
|
17
|
+
export const setMoves = (unit: Unit): void => unit.moves().set(unit.movement());
|
|
18
|
+
|
|
19
|
+
// Emits `unit:created` with the unit.
|
|
20
|
+
export const emitCreated =
|
|
21
|
+
(engine: Engine) =>
|
|
22
|
+
(unit: Unit): void => {
|
|
23
|
+
engine.emit('unit:created', unit);
|
|
24
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Action from '@civ-clone/core-unit/Action';
|
|
2
|
+
import CityRegistry from '@civ-clone/core-city/CityRegistry';
|
|
3
|
+
import Engine from '@civ-clone/core-engine/Engine';
|
|
4
|
+
import RuleRegistry from '@civ-clone/core-rule/RuleRegistry';
|
|
5
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
6
|
+
import UnitRegistry from '@civ-clone/core-unit/UnitRegistry';
|
|
7
|
+
export declare const emitAndDestroy: (
|
|
8
|
+
engine: Engine,
|
|
9
|
+
ruleRegistry: RuleRegistry
|
|
10
|
+
) => (unit: Unit, by: Unit, action?: Action) => void;
|
|
11
|
+
export declare const defended: (
|
|
12
|
+
unit: Unit,
|
|
13
|
+
by: Unit,
|
|
14
|
+
action?: Action
|
|
15
|
+
) => boolean;
|
|
16
|
+
export declare const notInCity: (
|
|
17
|
+
cityRegistry: CityRegistry
|
|
18
|
+
) => (unit: Unit) => boolean;
|
|
19
|
+
export declare const hasStack: (
|
|
20
|
+
unitRegistry: UnitRegistry
|
|
21
|
+
) => (unit: Unit) => boolean;
|
|
22
|
+
export declare const destroyStack: (
|
|
23
|
+
unitRegistry: UnitRegistry,
|
|
24
|
+
ruleRegistry: RuleRegistry
|
|
25
|
+
) => (unit: Unit, by: Unit) => void;
|
package/lib/defeated.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.destroyStack = exports.hasStack = exports.notInCity = exports.defended = exports.emitAndDestroy = void 0;
|
|
4
|
+
const Destroyed_1 = require("@civ-clone/core-unit/Rules/Destroyed");
|
|
5
|
+
// What a ruleset's `Defeated` rules ask and do when `unit` loses a fight to `by`. `action`, when given, is the attack:
|
|
6
|
+
// `action.unit()` attacked.
|
|
7
|
+
// Emits `unit:defeated` with the unit, the winner and the attack, then destroys the unit (`Destroyed`), credited to
|
|
8
|
+
// the winner's player.
|
|
9
|
+
const emitAndDestroy = (engine, ruleRegistry) => (unit, by, action) => {
|
|
10
|
+
engine.emit('unit:defeated', unit, by, action);
|
|
11
|
+
ruleRegistry.process(Destroyed_1.default, unit, by.player());
|
|
12
|
+
};
|
|
13
|
+
exports.emitAndDestroy = emitAndDestroy;
|
|
14
|
+
// The defeated unit defended: `Attack` processes `Defeated` for a losing attacker too.
|
|
15
|
+
const defended = (unit, by, action) => !action || action.unit() !== unit;
|
|
16
|
+
exports.defended = defended;
|
|
17
|
+
// The defeated unit is not in a city.
|
|
18
|
+
const notInCity = (cityRegistry) => (unit) => cityRegistry.getByTile(unit.tile()) === null;
|
|
19
|
+
exports.notInCity = notInCity;
|
|
20
|
+
// Other units of the defeated unit's player share its tile.
|
|
21
|
+
const hasStack = (unitRegistry) => (unit) => unitRegistry
|
|
22
|
+
.getByTile(unit.tile())
|
|
23
|
+
.filter((tileUnit) => tileUnit !== unit && tileUnit.player() === unit.player()).length > 0;
|
|
24
|
+
exports.hasStack = hasStack;
|
|
25
|
+
// Destroys (`Destroyed`) every other unit of the defeated unit's player on its tile, credited to the winner's player.
|
|
26
|
+
const destroyStack = (unitRegistry, ruleRegistry) => (unit, by) => unitRegistry
|
|
27
|
+
.getByTile(unit.tile())
|
|
28
|
+
.filter((tileUnit) => tileUnit !== unit && tileUnit.player() === unit.player())
|
|
29
|
+
.forEach((tileUnit) => {
|
|
30
|
+
ruleRegistry.process(Destroyed_1.default, tileUnit, by.player());
|
|
31
|
+
});
|
|
32
|
+
exports.destroyStack = destroyStack;
|
|
33
|
+
//# sourceMappingURL=defeated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defeated.js","sourceRoot":"","sources":["defeated.ts"],"names":[],"mappings":";;;AAEA,oEAA6D;AAM7D,uHAAuH;AACvH,6BAA6B;AAE7B,oHAAoH;AACpH,wBAAwB;AACjB,MAAM,cAAc,GACzB,CAAC,MAAc,EAAE,YAA0B,EAAE,EAAE,CAC/C,CAAC,IAAU,EAAE,EAAQ,EAAE,MAAe,EAAQ,EAAE;IAC9C,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IAE/C,YAAY,CAAC,OAAO,CAAC,mBAAS,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AANS,QAAA,cAAc,kBAMvB;AAEJ,uFAAuF;AAChF,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAE,EAAQ,EAAE,MAAe,EAAW,EAAE,CACzE,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC;AADvB,QAAA,QAAQ,YACe;AAEpC,sCAAsC;AAC/B,MAAM,SAAS,GACpB,CAAC,YAA0B,EAAE,EAAE,CAC/B,CAAC,IAAU,EAAW,EAAE,CACtB,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;AAHpC,QAAA,SAAS,aAG2B;AAEjD,4DAA4D;AACrD,MAAM,QAAQ,GACnB,CAAC,YAA0B,EAAE,EAAE,CAC/B,CAAC,IAAU,EAAW,EAAE,CACtB,YAAY;KACT,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;KACtB,MAAM,CACL,CAAC,QAAc,EAAE,EAAE,CACjB,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,MAAM,EAAE,CAC3D,CAAC,MAAM,GAAG,CAAC,CAAC;AARN,QAAA,QAAQ,YAQF;AAEnB,sHAAsH;AAC/G,MAAM,YAAY,GACvB,CAAC,YAA0B,EAAE,YAA0B,EAAE,EAAE,CAC3D,CAAC,IAAU,EAAE,EAAQ,EAAQ,EAAE,CAC7B,YAAY;KACT,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;KACtB,MAAM,CACL,CAAC,QAAc,EAAW,EAAE,CAC1B,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,MAAM,EAAE,CAC3D;KACA,OAAO,CAAC,CAAC,QAAc,EAAQ,EAAE;IAChC,YAAY,CAAC,OAAO,CAAC,mBAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC,CAAC;AAXI,QAAA,YAAY,gBAWhB"}
|
package/lib/defeated.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Action from '@civ-clone/core-unit/Action';
|
|
2
|
+
import CityRegistry from '@civ-clone/core-city/CityRegistry';
|
|
3
|
+
import Destroyed from '@civ-clone/core-unit/Rules/Destroyed';
|
|
4
|
+
import Engine from '@civ-clone/core-engine/Engine';
|
|
5
|
+
import RuleRegistry from '@civ-clone/core-rule/RuleRegistry';
|
|
6
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
7
|
+
import UnitRegistry from '@civ-clone/core-unit/UnitRegistry';
|
|
8
|
+
|
|
9
|
+
// What a ruleset's `Defeated` rules ask and do when `unit` loses a fight to `by`. `action`, when given, is the attack:
|
|
10
|
+
// `action.unit()` attacked.
|
|
11
|
+
|
|
12
|
+
// Emits `unit:defeated` with the unit, the winner and the attack, then destroys the unit (`Destroyed`), credited to
|
|
13
|
+
// the winner's player.
|
|
14
|
+
export const emitAndDestroy =
|
|
15
|
+
(engine: Engine, ruleRegistry: RuleRegistry) =>
|
|
16
|
+
(unit: Unit, by: Unit, action?: Action): void => {
|
|
17
|
+
engine.emit('unit:defeated', unit, by, action);
|
|
18
|
+
|
|
19
|
+
ruleRegistry.process(Destroyed, unit, by.player());
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// The defeated unit defended: `Attack` processes `Defeated` for a losing attacker too.
|
|
23
|
+
export const defended = (unit: Unit, by: Unit, action?: Action): boolean =>
|
|
24
|
+
!action || action.unit() !== unit;
|
|
25
|
+
|
|
26
|
+
// The defeated unit is not in a city.
|
|
27
|
+
export const notInCity =
|
|
28
|
+
(cityRegistry: CityRegistry) =>
|
|
29
|
+
(unit: Unit): boolean =>
|
|
30
|
+
cityRegistry.getByTile(unit.tile()) === null;
|
|
31
|
+
|
|
32
|
+
// Other units of the defeated unit's player share its tile.
|
|
33
|
+
export const hasStack =
|
|
34
|
+
(unitRegistry: UnitRegistry) =>
|
|
35
|
+
(unit: Unit): boolean =>
|
|
36
|
+
unitRegistry
|
|
37
|
+
.getByTile(unit.tile())
|
|
38
|
+
.filter(
|
|
39
|
+
(tileUnit: Unit) =>
|
|
40
|
+
tileUnit !== unit && tileUnit.player() === unit.player()
|
|
41
|
+
).length > 0;
|
|
42
|
+
|
|
43
|
+
// Destroys (`Destroyed`) every other unit of the defeated unit's player on its tile, credited to the winner's player.
|
|
44
|
+
export const destroyStack =
|
|
45
|
+
(unitRegistry: UnitRegistry, ruleRegistry: RuleRegistry) =>
|
|
46
|
+
(unit: Unit, by: Unit): void =>
|
|
47
|
+
unitRegistry
|
|
48
|
+
.getByTile(unit.tile())
|
|
49
|
+
.filter(
|
|
50
|
+
(tileUnit: Unit): boolean =>
|
|
51
|
+
tileUnit !== unit && tileUnit.player() === unit.player()
|
|
52
|
+
)
|
|
53
|
+
.forEach((tileUnit: Unit): void => {
|
|
54
|
+
ruleRegistry.process(Destroyed, tileUnit, by.player());
|
|
55
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Engine from '@civ-clone/core-engine/Engine';
|
|
2
|
+
import Player from '@civ-clone/core-player/Player';
|
|
3
|
+
import TransportManifest from '@civ-clone/core-unit-transport/TransportManifest';
|
|
4
|
+
import TransportRegistry from '@civ-clone/core-unit-transport/TransportRegistry';
|
|
5
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
6
|
+
import UnitImprovementRegistry from '@civ-clone/core-unit-improvement/UnitImprovementRegistry';
|
|
7
|
+
import UnitLossRegistry from '@civ-clone/core-unit/UnitLossRegistry';
|
|
8
|
+
export declare const emitDestroyed: (
|
|
9
|
+
engine: Engine
|
|
10
|
+
) => (unit: Unit, player: Player | null) => void;
|
|
11
|
+
export declare const destroyedByAnother: (
|
|
12
|
+
unit: Unit,
|
|
13
|
+
player: Player | null
|
|
14
|
+
) => boolean;
|
|
15
|
+
export declare const notYetDestroyed: (unit: Unit) => boolean;
|
|
16
|
+
export declare const countLoss: (
|
|
17
|
+
unitLossRegistry: UnitLossRegistry
|
|
18
|
+
) => (unit: Unit) => void;
|
|
19
|
+
export declare const deactivate: (unit: Unit) => void;
|
|
20
|
+
export declare const removeImprovements: (
|
|
21
|
+
unitImprovementRegistry: UnitImprovementRegistry
|
|
22
|
+
) => (unit: Unit) => void;
|
|
23
|
+
export declare const leaveTransport: (
|
|
24
|
+
transportRegistry: TransportRegistry
|
|
25
|
+
) => (manifest: TransportManifest) => void;
|
|
26
|
+
export declare const carriesCargo: (
|
|
27
|
+
transportRegistry: TransportRegistry
|
|
28
|
+
) => (unit: Unit) => boolean;
|
|
29
|
+
export declare const loseCargo: (
|
|
30
|
+
transportRegistry: TransportRegistry
|
|
31
|
+
) => (unit: Unit, player: Player | null) => void;
|
|
32
|
+
export declare const isAboard: (
|
|
33
|
+
transportRegistry: TransportRegistry
|
|
34
|
+
) => (unit: Unit) => boolean;
|
|
35
|
+
export declare const leaveOwnTransport: (
|
|
36
|
+
transportRegistry: TransportRegistry
|
|
37
|
+
) => (unit: Unit) => void;
|
package/lib/destroyed.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.leaveOwnTransport = exports.isAboard = exports.loseCargo = exports.carriesCargo = exports.leaveTransport = exports.removeImprovements = exports.deactivate = exports.countLoss = exports.notYetDestroyed = exports.destroyedByAnother = exports.emitDestroyed = void 0;
|
|
4
|
+
const Stowed_1 = require("@civ-clone/base-unit-action-embark/Busy/Stowed");
|
|
5
|
+
const Types_1 = require("@civ-clone/core-terrain/Types");
|
|
6
|
+
// What a ruleset's `Destroyed` rules ask and do when `unit` is destroyed. `player` destroyed it, or is `null` when no
|
|
7
|
+
// one did (disbanding, founding or joining a city, a spent unit...).
|
|
8
|
+
// Emits `unit:destroyed` with the unit and the player who destroyed it.
|
|
9
|
+
const emitDestroyed = (engine) => (unit, player) => {
|
|
10
|
+
engine.emit('unit:destroyed', unit, player);
|
|
11
|
+
};
|
|
12
|
+
exports.emitDestroyed = emitDestroyed;
|
|
13
|
+
// Another player destroyed the unit.
|
|
14
|
+
const destroyedByAnother = (unit, player) => player !== null && player !== unit.player();
|
|
15
|
+
exports.destroyedByAnother = destroyedByAnother;
|
|
16
|
+
// The unit isn't marked destroyed yet: a rule that should act once per unit asks it before `deactivate` runs.
|
|
17
|
+
const notYetDestroyed = (unit) => !unit.destroyed();
|
|
18
|
+
exports.notYetDestroyed = notYetDestroyed;
|
|
19
|
+
// Records the unit's type as a loss of its player's in `unitLossRegistry`.
|
|
20
|
+
const countLoss = (unitLossRegistry) => (unit) => {
|
|
21
|
+
unitLossRegistry.record(unit.player(), unit.sourceClass());
|
|
22
|
+
};
|
|
23
|
+
exports.countLoss = countLoss;
|
|
24
|
+
// Makes the unit inactive and marks it destroyed.
|
|
25
|
+
const deactivate = (unit) => {
|
|
26
|
+
unit.setActive(false);
|
|
27
|
+
unit.setDestroyed();
|
|
28
|
+
};
|
|
29
|
+
exports.deactivate = deactivate;
|
|
30
|
+
// Removes the unit's improvements (veteran status, fortification...).
|
|
31
|
+
const removeImprovements = (unitImprovementRegistry) => (unit) => unitImprovementRegistry
|
|
32
|
+
.getByUnit(unit)
|
|
33
|
+
.forEach((unitImprovement) => unitImprovementRegistry.unregister(unitImprovement));
|
|
34
|
+
exports.removeImprovements = removeImprovements;
|
|
35
|
+
// Takes a unit off its transport. Nothing clears `Stowed` on its own (its criterion is `() => false`), so a unit taken
|
|
36
|
+
// off a transport, destroyed or not, would otherwise stay stowed aboard nothing.
|
|
37
|
+
const leaveTransport = (transportRegistry) => (manifest) => {
|
|
38
|
+
const cargo = manifest.unit();
|
|
39
|
+
transportRegistry.unregister(manifest);
|
|
40
|
+
if (cargo.busy() instanceof Stowed_1.default) {
|
|
41
|
+
cargo.setBusy();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.leaveTransport = leaveTransport;
|
|
45
|
+
// The unit is a transport with something aboard.
|
|
46
|
+
const carriesCargo = (transportRegistry) => (unit) => transportRegistry.getByTransport(unit).length > 0;
|
|
47
|
+
exports.carriesCargo = carriesCargo;
|
|
48
|
+
// Takes everything off the transport (`leaveTransport`). At sea (on `Water`) the cargo goes down with it, destroyed by
|
|
49
|
+
// `player`; in a city it stays in the city.
|
|
50
|
+
const loseCargo = (transportRegistry) => {
|
|
51
|
+
const leave = (0, exports.leaveTransport)(transportRegistry);
|
|
52
|
+
return (unit, player) => transportRegistry
|
|
53
|
+
.getByTransport(unit)
|
|
54
|
+
// A copy: unregistering changes the list.
|
|
55
|
+
.slice()
|
|
56
|
+
.forEach((manifest) => {
|
|
57
|
+
const cargo = manifest.unit();
|
|
58
|
+
leave(manifest);
|
|
59
|
+
if (unit.tile().terrain() instanceof Types_1.Water && !cargo.destroyed()) {
|
|
60
|
+
cargo.destroy(player);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
exports.loseCargo = loseCargo;
|
|
65
|
+
// The unit is aboard a transport.
|
|
66
|
+
const isAboard = (transportRegistry) => (unit) => transportRegistry.hasUnit(unit);
|
|
67
|
+
exports.isAboard = isAboard;
|
|
68
|
+
// Takes the unit off the transport it's aboard (`leaveTransport`).
|
|
69
|
+
const leaveOwnTransport = (transportRegistry) => {
|
|
70
|
+
const leave = (0, exports.leaveTransport)(transportRegistry);
|
|
71
|
+
return (unit) => leave(transportRegistry.getByUnit(unit));
|
|
72
|
+
};
|
|
73
|
+
exports.leaveOwnTransport = leaveOwnTransport;
|
|
74
|
+
//# sourceMappingURL=destroyed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroyed.js","sourceRoot":"","sources":["destroyed.ts"],"names":[],"mappings":";;;AAGA,2EAAoE;AAMpE,yDAAsD;AAEtD,sHAAsH;AACtH,sEAAsE;AAEtE,wEAAwE;AACjE,MAAM,aAAa,GACxB,CAAC,MAAc,EAAE,EAAE,CACnB,CAAC,IAAU,EAAE,MAAqB,EAAQ,EAAE;IAC1C,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC,CAAC;AAJS,QAAA,aAAa,iBAItB;AAEJ,qCAAqC;AAC9B,MAAM,kBAAkB,GAAG,CAChC,IAAU,EACV,MAAqB,EACZ,EAAE,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;AAH7C,QAAA,kBAAkB,sBAG2B;AAE1D,8GAA8G;AACvG,MAAM,eAAe,GAAG,CAAC,IAAU,EAAW,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;AAA7D,QAAA,eAAe,mBAA8C;AAE1E,2EAA2E;AACpE,MAAM,SAAS,GACpB,CAAC,gBAAkC,EAAE,EAAE,CACvC,CAAC,IAAU,EAAQ,EAAE;IACnB,gBA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