@civ-clone/base-unit-action-industrial-sabotage 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 +2 -0
- package/.github/workflows/build-on-push.yml +39 -0
- package/.prettierrc +4 -0
- package/IndustrialSabotage.d.ts +19 -0
- package/IndustrialSabotage.js +28 -0
- package/IndustrialSabotage.js.map +1 -0
- package/IndustrialSabotage.ts +50 -0
- package/LICENSE +21 -0
- package/README.md +2 -2
- package/Rules/CitySabotaged.d.ts +6 -0
- package/Rules/CitySabotaged.js +10 -0
- package/Rules/CitySabotaged.js.map +1 -0
- package/Rules/CitySabotaged.ts +8 -0
- package/package.json +28 -4
- 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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RuleRegistry } from '@civ-clone/core-rule/RuleRegistry';
|
|
2
|
+
import Action from '@civ-clone/core-unit/Action';
|
|
3
|
+
import City from '@civ-clone/core-city/City';
|
|
4
|
+
import Tile from '@civ-clone/core-world/Tile';
|
|
5
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
6
|
+
/** A Diplomat sabotages `city()`. What it destroys is up to the `CitySabotaged` rules. The Diplomat is used up. */
|
|
7
|
+
export declare class IndustrialSabotage extends Action {
|
|
8
|
+
protected _city: City;
|
|
9
|
+
constructor(
|
|
10
|
+
from: Tile,
|
|
11
|
+
to: Tile,
|
|
12
|
+
unit: Unit,
|
|
13
|
+
city: City,
|
|
14
|
+
ruleRegistry?: RuleRegistry
|
|
15
|
+
);
|
|
16
|
+
forUnit(unit: Unit): Action;
|
|
17
|
+
perform(): void;
|
|
18
|
+
}
|
|
19
|
+
export default IndustrialSabotage;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndustrialSabotage = void 0;
|
|
4
|
+
const RuleRegistry_1 = require("@civ-clone/core-rule/RuleRegistry");
|
|
5
|
+
const Action_1 = require("@civ-clone/core-unit/Action");
|
|
6
|
+
const Moved_1 = require("@civ-clone/core-unit/Rules/Moved");
|
|
7
|
+
const CitySabotaged_1 = require("./Rules/CitySabotaged");
|
|
8
|
+
/** A Diplomat sabotages `city()`. What it destroys is up to the `CitySabotaged` rules. The Diplomat is used up. */
|
|
9
|
+
class IndustrialSabotage extends Action_1.default {
|
|
10
|
+
constructor(from, to, unit, city, ruleRegistry = RuleRegistry_1.instance) {
|
|
11
|
+
super(from, to, unit, ruleRegistry);
|
|
12
|
+
this._city = city;
|
|
13
|
+
}
|
|
14
|
+
// `Action.forUnit` rebuilds an action from `(from, to, unit, ruleRegistry)`, which would put the `RuleRegistry` where
|
|
15
|
+
// the `City` goes.
|
|
16
|
+
// Typed as `Action`: a subclass with a member of its own isn't assignable to it (civ-clone/web-renderer#21).
|
|
17
|
+
forUnit(unit) {
|
|
18
|
+
return new IndustrialSabotage(this.from(), this.to(), unit, this._city, this.ruleRegistry());
|
|
19
|
+
}
|
|
20
|
+
perform() {
|
|
21
|
+
this.ruleRegistry().process(CitySabotaged_1.default, this.unit(), this._city);
|
|
22
|
+
this.ruleRegistry().process(Moved_1.default, this.unit(), this);
|
|
23
|
+
this.unit().destroy();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.IndustrialSabotage = IndustrialSabotage;
|
|
27
|
+
exports.default = IndustrialSabotage;
|
|
28
|
+
//# sourceMappingURL=IndustrialSabotage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndustrialSabotage.js","sourceRoot":"","sources":["IndustrialSabotage.ts"],"names":[],"mappings":";;;AAAA,oEAG2C;AAC3C,wDAAiD;AAEjD,4DAAqD;AACrD,yDAAkD;AAIlD,mHAAmH;AACnH,MAAa,kBAAmB,SAAQ,gBAAM;IAG5C,YACE,IAAU,EACV,EAAQ,EACR,IAAU,EACV,IAAU,EACV,eAA6B,uBAAoB;QAEjD,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QAEpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,sHAAsH;IACtH,mBAAmB;IACnB,6GAA6G;IAC7G,OAAO,CAAC,IAAU;QAChB,OAAO,IAAI,kBAAkB,CAC3B,IAAI,CAAC,IAAI,EAAE,EACX,IAAI,CAAC,EAAE,EAAE,EACT,IAAI,EACJ,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,YAAY,EAAE,CACC,CAAC;IACzB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,uBAAa,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAEpE,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,eAAK,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,IAAyB,CAAC,CAAC;QAE3E,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;CACF;AAnCD,gDAmCC;AAED,kBAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RuleRegistry,
|
|
3
|
+
instance as ruleRegistryInstance,
|
|
4
|
+
} from '@civ-clone/core-rule/RuleRegistry';
|
|
5
|
+
import Action from '@civ-clone/core-unit/Action';
|
|
6
|
+
import City from '@civ-clone/core-city/City';
|
|
7
|
+
import Moved from '@civ-clone/core-unit/Rules/Moved';
|
|
8
|
+
import CitySabotaged from './Rules/CitySabotaged';
|
|
9
|
+
import Tile from '@civ-clone/core-world/Tile';
|
|
10
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
11
|
+
|
|
12
|
+
/** A Diplomat sabotages `city()`. What it destroys is up to the `CitySabotaged` rules. The Diplomat is used up. */
|
|
13
|
+
export class IndustrialSabotage extends Action {
|
|
14
|
+
protected _city: City;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
from: Tile,
|
|
18
|
+
to: Tile,
|
|
19
|
+
unit: Unit,
|
|
20
|
+
city: City,
|
|
21
|
+
ruleRegistry: RuleRegistry = ruleRegistryInstance
|
|
22
|
+
) {
|
|
23
|
+
super(from, to, unit, ruleRegistry);
|
|
24
|
+
|
|
25
|
+
this._city = city;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// `Action.forUnit` rebuilds an action from `(from, to, unit, ruleRegistry)`, which would put the `RuleRegistry` where
|
|
29
|
+
// the `City` goes.
|
|
30
|
+
// Typed as `Action`: a subclass with a member of its own isn't assignable to it (civ-clone/web-renderer#21).
|
|
31
|
+
forUnit(unit: Unit): Action {
|
|
32
|
+
return new IndustrialSabotage(
|
|
33
|
+
this.from(),
|
|
34
|
+
this.to(),
|
|
35
|
+
unit,
|
|
36
|
+
this._city,
|
|
37
|
+
this.ruleRegistry()
|
|
38
|
+
) as unknown as Action;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
perform(): void {
|
|
42
|
+
this.ruleRegistry().process(CitySabotaged, this.unit(), this._city);
|
|
43
|
+
|
|
44
|
+
this.ruleRegistry().process(Moved, this.unit(), this as unknown as Action);
|
|
45
|
+
|
|
46
|
+
this.unit().destroy();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default IndustrialSabotage;
|
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,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# base-unit-action-industrial-sabotage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `IndustrialSabotage` unit action. See civ-clone/web-renderer#58.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import City from '@civ-clone/core-city/City';
|
|
2
|
+
import Rule from '@civ-clone/core-rule/Rule';
|
|
3
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
4
|
+
/** Processed when a Diplomat (`Unit`) sabotages `City`, before it's used up. */
|
|
5
|
+
export declare class CitySabotaged extends Rule<[Unit, City], void> {}
|
|
6
|
+
export default CitySabotaged;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CitySabotaged = void 0;
|
|
4
|
+
const Rule_1 = require("@civ-clone/core-rule/Rule");
|
|
5
|
+
/** Processed when a Diplomat (`Unit`) sabotages `City`, before it's used up. */
|
|
6
|
+
class CitySabotaged extends Rule_1.default {
|
|
7
|
+
}
|
|
8
|
+
exports.CitySabotaged = CitySabotaged;
|
|
9
|
+
exports.default = CitySabotaged;
|
|
10
|
+
//# sourceMappingURL=CitySabotaged.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CitySabotaged.js","sourceRoot":"","sources":["CitySabotaged.ts"],"names":[],"mappings":";;;AACA,oDAA6C;AAG7C,gFAAgF;AAChF,MAAa,aAAc,SAAQ,cAAwB;CAAG;AAA9D,sCAA8D;AAE9D,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import City from '@civ-clone/core-city/City';
|
|
2
|
+
import Rule from '@civ-clone/core-rule/Rule';
|
|
3
|
+
import Unit from '@civ-clone/core-unit/Unit';
|
|
4
|
+
|
|
5
|
+
/** Processed when a Diplomat (`Unit`) sabotages `City`, before it's used up. */
|
|
6
|
+
export class CitySabotaged extends Rule<[Unit, City], void> {}
|
|
7
|
+
|
|
8
|
+
export default CitySabotaged;
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civ-clone/base-unit-action-industrial-sabotage",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "IndustrialSabotage.js",
|
|
5
|
+
"repository": "git@github.com:civ-clone/base-unit-action-industrial-sabotage.git",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"typescript",
|
|
8
|
+
"civilization"
|
|
9
|
+
],
|
|
10
|
+
"author": "dom111 <dom111@users.noreply.github.com>",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"private": false,
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "npm run ts:compile && npm run prettier:format",
|
|
15
|
+
"prettier:check": "prettier --config .prettierrc --check '**/*.ts'",
|
|
16
|
+
"prettier:format": "prettier --config .prettierrc '**/*.ts' --write",
|
|
17
|
+
"ts:compile": "tsc --build tsconfig.json"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^14.18.63",
|
|
21
|
+
"prettier": "^2.8.8",
|
|
22
|
+
"typescript": "^4.9.5"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@civ-clone/core-city": "^0.1.19",
|
|
26
|
+
"@civ-clone/core-rule": "^0.1.6",
|
|
27
|
+
"@civ-clone/core-unit": "^0.1.25",
|
|
28
|
+
"@civ-clone/core-world": "^0.1.14"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/tsconfig.json
ADDED