summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.html12
-rw-r--r--play.js79
-rw-r--r--rules.js53
3 files changed, 79 insertions, 65 deletions
diff --git a/play.html b/play.html
index 64c695b..10908e1 100644
--- a/play.html
+++ b/play.html
@@ -70,14 +70,10 @@
<div id="pieces">
<div id="turn" class="marker circle turn levy"></div>
<div id="end" class="marker circle end"></div>
- <div id="ip_y" class="marker square ip york"></div>
- <div id="ip_l" class="marker square ip lancaster"></div>
- <div id="towns_y" class="marker square towns york"></div>
- <div id="towns_l" class="marker square towns lancaster"></div>
- <div id="cities_y" class="marker square cities york"></div>
- <div id="cities_l" class="marker square cities lancaster"></div>
- <div id="fortresses_y" class="marker square fortresses york"></div>
- <div id="fortresses_l" class="marker square fortresses lancaster"></div>
+ <div id="ip" class="marker square ip"></div>
+ <div id="towns" class="marker square towns"></div>
+ <div id="cities" class="marker square cities"></div>
+ <div id="fortresses" class="marker square fortresses"></div>
<div id="victory_check" class="marker square victory_check"></div>
</div>
diff --git a/play.js b/play.js
index 0221763..5a86863 100644
--- a/play.js
+++ b/play.js
@@ -87,6 +87,9 @@ const first_lancaster_card = 37
const last_lancaster_card = 73
const last_aow_card = last_lancaster_card
+const first_locale = 0
+const last_locale = data.locales.length - 1
+
const Y1 = find_card("Y1")
const Y2 = find_card("Y2")
const Y3 = find_card("Y3")
@@ -167,8 +170,6 @@ const A1 = 0, A2 = 1, A3 = 2, D1 = 3, D2 = 4, D3 = 5
const RETINUE = 0
const VASSAL = 1
-
-
const MEN_AT_ARMS = 2
const LONGBOWMEN = 3
const MILITIA = 4
@@ -190,6 +191,9 @@ const VASSAL_MUSTERED = 2
const NOWHERE = -1
const CALENDAR = 100
+const TOWN = "town"
+const CITY = "city"
+const FORTRESS = "fortress"
const SUMMER = 0
const SPRING = 1
@@ -356,6 +360,21 @@ function count_lord_all_forces(lord) {
)
}
+function count_favour(type) {
+ let n = 0
+ for (let x = first_locale; x < last_locale; x++) {
+ if (data.locales[x].type !== type)
+ continue
+
+ if (view.pieces.favourl.includes(x))
+ n += 1
+ if (view.pieces.favoury.includes(x))
+ n -= 1
+ }
+
+ return n;
+}
+
function is_york_locale(loc) {
return loc >= first_york_locale && loc <= last_york_locale
}
@@ -553,14 +572,10 @@ const ui = {
turn: document.getElementById("turn"),
end: document.getElementById("end"),
victory_check: document.getElementById("victory_check"),
- fortressl: document.getElementById("fortresses_l"),
- fortressy: document.getElementById("fortresses_y"),
- townl: document.getElementById("towns_l"),
- towny: document.getElementById("towns_y"),
- citiesl: document.getElementById("cities_l"),
- citiesy: document.getElementById("cities_y"),
- influence_point_l: document.getElementById("ip_l"),
- influence_point_y: document.getElementById("ip_y"),
+ fortress: document.getElementById("fortresses"),
+ town: document.getElementById("towns"),
+ cities: document.getElementById("cities"),
+ influence: document.getElementById("ip"),
court1_header: document.getElementById("court1_header"),
@@ -1382,29 +1397,29 @@ function on_update() {
ui.victory_check.style.top = (track_xy[view.victory_check][1]) + "px"
ui.victory_check.style.left = (track_xy[view.victory_check][0]) + "px"
- ui.townl.style.top = (track_xy[view.townl][1]) + "px"
- ui.townl.style.left = (track_xy[view.townl][0]) + "px"
-
- ui.towny.style.top = (track_xy[view.towny][1]) + "px"
- ui.towny.style.left = (track_xy[view.towny][0]) + "px"
-
- ui.citiesl.style.top = (track_xy[view.citiesl][1]) + "px"
- ui.citiesl.style.left = (track_xy[view.citiesl][0]) + "px"
-
- ui.citiesy.style.top = (track_xy[view.citiesy][1]) + "px"
- ui.citiesy.style.left = (track_xy[view.citiesy][0]) + "px"
-
- ui.fortressl.style.top = (track_xy[view.fortressl][1]) + "px"
- ui.fortressl.style.left = (track_xy[view.fortressl][0]) + "px"
-
- ui.fortressy.style.top = (track_xy[view.fortressy][1]) + "px"
- ui.fortressy.style.left = (track_xy[view.fortressy][0]) + "px"
-
- ui.influence_point_l.style.top = (track_xy[view.influence_point_l][1]) + "px"
- ui.influence_point_l.style.left = (track_xy[view.influence_point_l][0]) + "px"
+ let town = count_favour(TOWN)
+ ui.town.style.top = (track_xy[Math.abs(town)][1]) + "px"
+ ui.town.style.left = (track_xy[Math.abs(town)][0]) + "px"
+ ui.town.classList.toggle("york", town < 0)
+ ui.town.classList.toggle("lancaster", town >= 0)
+
+ let cities = count_favour(CITY)
+ ui.cities.style.top = (track_xy[Math.abs(cities)][1]) + "px"
+ ui.cities.style.left = (track_xy[Math.abs(cities)][0]) + "px"
+ ui.cities.classList.toggle("york", cities < 0)
+ ui.cities.classList.toggle("lancaster", cities >= 0)
+
+ let fortress = count_favour(FORTRESS)
+ ui.fortress.style.top = (track_xy[Math.abs(fortress)][1]) + "px"
+ ui.fortress.style.left = (track_xy[Math.abs(fortress)][0]) + "px"
+ ui.fortress.classList.toggle("york", fortress < 0)
+ ui.fortress.classList.toggle("lancaster", fortress >= 0)
+
+ ui.influence.style.top = (track_xy[Math.abs(view.influence)][1]) + "px"
+ ui.influence.style.left = (track_xy[Math.abs(view.influence)][0]) + "px"
+ ui.influence.classList.toggle("york", view.influence < 0)
+ ui.influence.classList.toggle("lancaster", view.influences >= 0)
- ui.influence_point_y.style.top = (track_xy[view.influence_point_y][1]) + "px"
- ui.influence_point_y.style.left = (track_xy[view.influence_point_y][0]) + "px"
update_plan()
update_cards()
diff --git a/rules.js b/rules.js
index dc67462..3423f7d 100644
--- a/rules.js
+++ b/rules.js
@@ -1211,6 +1211,30 @@ function group_has_capability(c) {
return true
return false
}
+
+function reduce_influence(amt) {
+ if (game.active === YORK)
+ reduce_york_influence(amt)
+ else
+ reduce_lancaster_influence(amt)
+}
+
+function reduce_york_influence(amt) {
+ game.influence += amt
+}
+
+function increase_york_influence(amt) {
+ game.influence -= amt
+}
+
+function reduce_lancaster_influence(amt) {
+ game.influence -= amt
+}
+
+function increase_lancaster_influnce(amt) {
+ game.influence += amt
+}
+
/*
function count_unbesieged_friendly_lords(loc) {
let n = 0
@@ -1357,14 +1381,7 @@ exports.setup = function (seed, scenario, options) {
state: "setup_lords",
stack: [],
victory_check: 0,
- towny:0,
- fortressy:0,
- citiesy:0,
- townl:0,
- fortressl:0,
- citiesl:0,
- influence_point_l: 0,
- influence_point_y: 0,
+ influence: 0,
hand1: [],
hand2: [],
@@ -1444,14 +1461,7 @@ function setup_Ia(first_player, second_player) {
P2 = second_player
game.active = first_player
game.victory_check = 40
- game.towny = 0
- game.townl = 0
- game.citiesy = 0
- game.citiesl = 0
- game.fortressy = 0
- game.fortressl = 0
- game.influence_point_l = 0
- game.influence_point_y = 0
+ game.influence = 0
muster_lord(LORD_YORK, LOC_ELY)
muster_lord(LORD_MARCH, LOC_LUDLOW)
muster_lord(LORD_HENRY_VI, LOC_LONDON)
@@ -4666,7 +4676,7 @@ function goto_battle_influence() {
.map(l => data.lords[l].influence)
.reduce((p, c) => p+c,0)
-// reduce_influence(influence)
+ reduce_influence(influence)
goto_battle_spoils()
} else {
goto_death_or_disband()
@@ -5793,14 +5803,7 @@ exports.view = function (state, current) {
end: scenario_last_turn[game.scenario],
turn: game.turn,
victory_check: game.victory_check,
- townl: game.townl,
- towny: game.townl,
- fortressl: game.fortressl,
- fortressy: game.fortressy,
- citiesl: game.citiesl,
- citiesy: game.citiesy,
- influence_point_l: game.influence_point_l,
- influence_point_y: game.influence_point_y,
+ influence: game.influence,
events: game.events,