summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorteisuru <31881306+teisuru@users.noreply.github.com>2023-08-28 15:54:52 +0200
committerTor Andersson <tor@ccxvii.net>2023-12-10 18:16:55 +0100
commitd5d422bf7b89e2fc189375275a5592c6a29a3159 (patch)
tree64ead1bc52d1dd57b6f5e4cf5114c6976a85cf09
parentd45ad852b81c44fc769a5cfee8d9deb4fc142a1d (diff)
downloadplantagenet-d5d422bf7b89e2fc189375275a5592c6a29a3159.tar.gz
early sail action
-rw-r--r--rules.js38
1 files changed, 28 insertions, 10 deletions
diff --git a/rules.js b/rules.js
index 8a2be03..8707cf0 100644
--- a/rules.js
+++ b/rules.js
@@ -764,6 +764,12 @@ function count_group_forces(type) {
n += get_lord_forces(lord, type)
return n
}
+function count_group_provender(type) {
+ let n = 0
+ for (let lord of game.group)
+ n += get_lord_provender(lord)
+ return n
+}
function count_group_transport(type) {
let n = 0
@@ -772,6 +778,8 @@ function count_group_transport(type) {
return n
}
+
+
function max_plan_length() {
switch (current_season()) {
case SUMMER:
@@ -1141,6 +1149,12 @@ function count_lord_transport(lord, type) {
return n
}
+function get_lord_provender(lord) {
+ let n = 0
+ n += get_lord_assets(lord, PROV)
+ return n
+}
+
function list_ways(from, to) {
for (let ways of data.locales[from].ways)
if (ways[0] === to)
@@ -3555,9 +3569,8 @@ function drop_prov(lord) {
function has_enough_available_ships_for_army() {
let ships = count_group_ships()
- let army = count_group_forces()
-
- let needed_ships = army/6
+ let army = count_lord_all_forces()
+ let needed_ships= army/6
return needed_ships <= ships
}
@@ -3597,18 +3610,23 @@ states.sail = {
let here = get_lord_locale(game.command)
let ships = count_group_ships()
- // let horses = count_group_horses()
+ // CAPABILITY SHIPS x2
+ // CAPABILITY MOVE EVERYWHERE WITH SHIPS
let prov = count_group_assets(PROV)
-
- let overflow = 0
- overflow = (count_lord_all_forces(game.group) + prov) - ships
-
- if (overflow > 0) {
+ let cart = count_group_assets(CART)
+ console.log (ships + " " + cart + " " + prov)
+ let needed_ships_cart = cart/2
+ let needed_ships_prov = prov/2
+ console.log (ships + " " + needed_ships_cart + " " + needed_ships_prov)
+
+ let overflow_prov = 0
+ overflow_prov = (prov/2 - ships)*2
+ if (overflow_prov > 0) {
view.prompt = `Sailing with ${ships} Ships.`
// TODO: stricter greed!
if (prov > 0) {
for (let lord of game.group) {
- if (get_lord_assets(lord, PROV) > 0)
+ if (get_lord_assets(lord, prov) > 0)
gen_action_prov(lord)
}
}