summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.eslintrc.js12
-rw-r--r--rules.ts32
2 files changed, 27 insertions, 17 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index fc71e34..9e9990a 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,6 +1,12 @@
module.exports = {
parser: "@typescript-eslint/parser",
- extends: "eslint:recommended",
+ extends: [
+ "eslint:recommended",
+ "plugin:@typescript-eslint/recommended",
+ ],
+ plugins: [
+ "@typescript-eslint"
+ ],
env: {
browser: true,
commonjs: true,
@@ -10,7 +16,9 @@ module.exports = {
"no-constant-binary-expression": "error",
indent: [ "warn", "tab", { SwitchCase: 1 } ],
semi: [ "error", "never" ],
- "no-unused-vars": [ "error", { "vars": "all", "args": "all", "argsIgnorePattern": "^_" } ],
"prefer-const": 0,
+ "no-unused-vars": "off",
+ "@typescript-eslint/no-unused-vars": [ "error", { "vars": "all", "args": "all", "argsIgnorePattern": "^_" } ],
+ "@typescript-eslint/no-explicit-any": "off",
},
}
diff --git a/rules.ts b/rules.ts
index 6e39457..4eeb8db 100644
--- a/rules.ts
+++ b/rules.ts
@@ -310,14 +310,22 @@ interface View {
who?: Lord,
}
-// === CONSTANTS ===
-
-var game: Game
-var view: View
-var states: { [index: string]: State } = {}
+// === GLOBALS ===
const data = require("./data.js")
+let game: Game
+let view: View
+let states: { [index: string]: State } = {}
+
+let P1: Side
+let P2: Side
+
+const search_seen: number[] = new Array(data.locales.length)
+const search_dist: number[] = new Array(data.locales.length)
+
+// === CONSTANTS ===
+
function find_card(name): Card {
let ix = data.cards.findIndex(x => x.name === name)
if (ix < 0)
@@ -463,6 +471,9 @@ const last_york_lord = 13
const first_lancaster_lord = 14
const last_lancaster_lord = 27
+const all_york_lords = make_list(0, 13) as Lord[]
+const all_lancaster_lords = make_list(14, 27) as Lord[]
+
const YORK_LORD_MASK = 0x1fff
const LANCASTER_LORD_MASK = YORK_LORD_MASK << 14
@@ -941,12 +952,6 @@ const EVENT_YORK_PATRICK_DE_LA_MOTE = Y37
// === STATE: ACTIVE PLAYER ===
-var P1: Side = YORK
-var P2: Side = LANCASTER
-
-const all_york_lords = make_list(0, 13) as Lord[]
-const all_lancaster_lords = make_list(14, 27) as Lord[]
-
function all_friendly_lords() {
if (game.active === YORK)
return all_york_lords
@@ -4237,9 +4242,6 @@ function can_parley_at(loc: Locale) {
return !is_exile(loc) && !is_friendly_locale(loc) && !has_enemy_lord(loc) && !is_sea(loc)
}
-var search_seen = new Array(data.locales.length)
-var search_dist = new Array(data.locales.length)
-
function search_parley(result, start: Locale, lord: Lord) {
let ships = get_shared_assets(start, SHIP)
@@ -12121,7 +12123,7 @@ function map_delete(map, item) {
}
}
-function map_for_each<K,V>(map: MyMap<K,V>, f: (_:K,_:V)=>void) {
+function map_for_each<K,V>(map: MyMap<K,V>, f: (k:K,v:V)=>void) {
for (let i = 0; i < map.length; i += 2)
f(map[i] as K, map[i+1] as V)
}