summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-06-23 01:57:22 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-07 18:39:37 +0200
commit038d51ab138f2a8bfc86cb11e7b968d1e4e12ad8 (patch)
treeab117a8822ae43cf747fade83de639db4140e314
parente05ce5bf91eefbe70d4ee7780a4c9980ed23c8e9 (diff)
downloadtime-of-crisis-038d51ab138f2a8bfc86cb11e7b968d1e4e12ad8.tar.gz
Flanking Maneuver.
-rw-r--r--play.js26
-rw-r--r--rules.js123
2 files changed, 104 insertions, 45 deletions
diff --git a/play.js b/play.js
index be4b192..ef65b2f 100644
--- a/play.js
+++ b/play.js
@@ -841,13 +841,14 @@ function layout_stack(id, list, region, in_capital, dx, dy) {
function layout_available(list, dx, x0, y0) {
let y = 1650 + 45 - y0
let x = 25 + x0
+ let z = 7
for (let item of list) {
- let xo = item.my_id % 6
- //if (list.length < 6) xo -= 1
- item.style.left = (x + xo * dx) + "px"
+ item.style.left = x + "px"
item.style.top = y + "px"
- item.style.zIndex = 7 - xo
+ item.style.zIndex = z
item.my_stack = 0
+ x += dx
+ z -= 1
}
}
@@ -1151,8 +1152,12 @@ function on_update() {
e.classList.toggle("unavailable", region === UNAVAILABLE)
e.classList.toggle("selected", view.selected_general === pi * 6 + ai)
}
- //layout_available(avail_stack, avail_stack.length > 5 ? 48 : 63, pi * 625 + 0, 30)
- layout_available(avail_stack, 48, pi * 625 + 0, 30)
+ if (avail_stack.length >= 6)
+ layout_available(avail_stack, 48, pi * 625 + 0, 30)
+ else if (avail_stack.length >= 5)
+ layout_available(avail_stack, 63, pi * 625 + 0, 30)
+ else
+ layout_available(avail_stack, 69, pi * 625 + 0, 30)
}
for (let pi = 0; pi < player_count; ++pi) {
@@ -1172,8 +1177,12 @@ function on_update() {
e.classList.toggle("unavailable", region === UNAVAILABLE)
e.classList.toggle("selected", view.selected_governor === pi * 6 + ai)
}
- //layout_available(avail_stack, avail_stack.length > 5 ? 43 : 58, pi * 625 + 325, 27)
- layout_available(avail_stack, 43, pi * 625 + 325, 27)
+ if (avail_stack.length >= 6)
+ layout_available(avail_stack, 43, pi * 625 + 325, 27)
+ else if (avail_stack.length >= 5)
+ layout_available(avail_stack, 58, pi * 625 + 325, 27)
+ else
+ layout_available(avail_stack, 64, pi * 625 + 325, 27)
}
ui.body.classList.toggle("military", view.color === 0)
@@ -1240,6 +1249,7 @@ function on_update() {
action_button("spend_military", "Spend Military")
action_button("spend_senate", "Spend Senate")
+ action_button("reroll", "Reroll")
action_button("roll", "Roll")
diff --git a/rules.js b/rules.js
index 15b79ab..a92d550 100644
--- a/rules.js
+++ b/rules.js
@@ -6,8 +6,6 @@
TODO
----
-game.battle -> game.battle / game.count + game.where
-
-- castra/quaestor - directly or extra select target step?
[x] crisis ira deorum
@@ -53,7 +51,7 @@ game.battle -> game.battle / game.count + game.where
[x] place
[ ] expand
[x] scoring effects
- [ ] occupation effects
+ [x] occupation effects
[x] game end
@@ -415,27 +413,27 @@ function card_event_name(c) {
const PLAY_CARD_EVENT = {
"Castra": play_castra,
- // "Flanking Maneuver": play_flanking_maneuver,
- "Praetorian Guard": play_praetorian_guard,
"Tribute": play_tribute,
+ "Quaestor": play_quaestor,
+ "Flanking Maneuver": play_flanking_maneuver,
"Foederati": play_foederati,
+ "Mob": play_mob,
+ "Praetorian Guard": play_praetorian_guard,
// "Damnatio Memoriae": play_damnatio_memoriae,
// "Damnatio Memoriae (exp)": play_damnatio_memoriae_exp,
- "Quaestor": play_quaestor,
- "Mob": play_mob,
"Pretender": play_pretender,
}
const CAN_PLAY_CARD_EVENT = {
"Castra": can_play_castra,
- // "Flanking Maneuver": can_play_flanking_maneuver,
- "Praetorian Guard": can_play_praetorian_guard,
"Tribute": can_play_tribute,
+ "Quaestor": can_play_quaestor,
+ // "Flanking Maneuver": can_play_flanking_maneuver,
"Foederati": can_play_foederati,
+ "Mob": can_play_mob,
+ "Praetorian Guard": can_play_praetorian_guard,
// "Damnatio Memoriae": can_play_damnatio_memoriae,
// "Damnatio Memoriae (exp)": can_play_damnatio_memoriae_exp,
- "Quaestor": can_play_quaestor,
- "Mob": can_play_mob,
"Pretender": can_play_pretender,
}
@@ -1070,6 +1068,9 @@ function is_expand_pretender_province(from) {
states.setup_province = {
prompt() {
view.prompt = "Select a starting Province."
+ view.selected_governor = game.current * 6
+ view.selected_general = game.current * 6
+ view.color = SENATE
for (let where = 2; where <= 12; ++where)
if (is_neutral_province(where) && !is_no_place_governor(where))
gen_action("capital", where)
@@ -1555,6 +1556,7 @@ states.take_actions = {
game.selected_governor = -1
game.selected_general = id
} else {
+ push_undo()
goto_battle_vs_general(get_general_location(game.selected_general), game.selected_general, id)
}
},
@@ -2210,12 +2212,14 @@ function can_foederati_from_region_and_adjacent(from) {
function can_play_foederati() {
let where = get_selected_region()
- if (game.selected_general >= 0)
- if (can_foederati_from_region_and_adjacent(where))
- return true
- if (game.selected_governor >= 0)
- if (has_lone_militia(where) && can_foederati_from_region_and_adjacent(where))
- return true
+ if (is_region(where)) {
+ if (game.selected_general >= 0)
+ if (can_foederati_from_region_and_adjacent(where))
+ return true
+ if (game.selected_governor >= 0)
+ if (has_lone_militia(where) && can_foederati_from_region_and_adjacent(where))
+ return true
+ }
return false
}
@@ -2351,6 +2355,10 @@ states.pretender_breakaway = {
// === COMBAT ===
+function play_flanking_maneuver() {
+ game.battle.flanking = 1
+}
+
function goto_battle_vs_general(where, attacker, target) {
log("Initiate Battle vs " + GENERAL_NAME[target] + " in S" + where)
goto_battle("general", where, attacker, target)
@@ -2375,7 +2383,7 @@ function goto_battle_vs_militia(where, attacker) {
function goto_battle(type, where, attacker, target) {
spend_ip(MILITARY, 1)
game.where = where
- game.battle = { type, attacker, target }
+ game.battle = { type, attacker, target, flanking: 0 }
game.state = "battle"
if (attacker >= 0) {
if (is_general_inside_capital(attacker))
@@ -2412,34 +2420,75 @@ function gen_initiate_battle(where) {
}
}
+function gen_card_event(event) {
+ for (let c of event)
+ if (set_has(game.played, c) && !set_has(game.used, c))
+ gen_action_card(c)
+}
+
states.battle = {
prompt() {
prompt("Battle!")
- // TODO: play "Flanking Maneuver"
+ if (!game.battle.flanking)
+ gen_card_event(CARD_M3)
view.actions.roll = 1
},
+ card(c) {
+ set_add(game.used, c)
+ play_card_event(c)
+ },
roll() {
// clear_undo()
+ roll_combat_dice()
+ if (game.battle.flanking)
+ game.state = "flanking_maneuver"
+ else
+ goto_assign_hits()
+ },
+}
- game.battle.dhits = roll_attacker_dice()
- game.battle.dtaken = 0
-
- if (game.battle.type === "militia" && has_militia_castra(game.where)) {
- log("Castra reduces 1 hit")
- if (game.battle.dhits > 0)
- game.battle.dhits -= 1
- }
- if (game.battle.type === "general" && has_general_castra(game.battle.target)) {
- log("Castra reduces 1 hit")
- if (game.battle.dhits > 0)
- game.battle.dhits -= 1
- }
-
- game.battle.ahits = roll_defender_dice()
- game.battle.ataken = 0
+function format_hits() {
+ return `${game.battle.ahits} attacking hits vs ${game.battle.dhits} defending hits`
+}
+states.flanking_maneuver = {
+ prompt() {
+ prompt("Flanking Maneuver: " + format_hits() + ".")
+ view.actions.reroll = 1
+ view.actions.pass = 1
+ },
+ pass() {
goto_assign_hits()
},
+ reroll() {
+ roll_flanking_maneuver_dice()
+ goto_assign_hits()
+ },
+}
+
+function roll_combat_dice() {
+ game.battle.dhits = roll_attacker_dice()
+ game.battle.dtaken = 0
+
+ if (game.battle.type === "militia" && has_militia_castra(game.where)) {
+ log("Castra reduces 1 hit")
+ if (game.battle.dhits > 0)
+ game.battle.dhits -= 1
+ }
+ if (game.battle.type === "general" && has_general_castra(game.battle.target)) {
+ log("Castra reduces 1 hit")
+ if (game.battle.dhits > 0)
+ game.battle.dhits -= 1
+ }
+
+ game.battle.ahits = roll_defender_dice()
+ game.battle.ataken = 0
+}
+
+function roll_flanking_maneuver_dice() {
+ log("Flanking Maneuver Reroll")
+ game.battle.ahits = roll_defender_dice()
+ game.battle.ataken = 0
}
function roll_general_dice(general) {
@@ -2659,7 +2708,7 @@ function goto_assign_hits_on_defender() {
states.assign_hits_on_attacker = {
prompt() {
- prompt("Assign " + (game.battle.ahits - game.battle.ataken) + " hits to attacker!")
+ prompt("Combat: " + format_hits() + " \u2013 assign " + (game.battle.ahits - game.battle.ataken) + " hits to attacker!")
if (game.battle.attacker < 0)
gen_hits_militia()
else
@@ -2684,7 +2733,7 @@ states.assign_hits_on_attacker = {
states.assign_hits_on_defender = {
prompt() {
- prompt("Assign " + (game.battle.dhits - game.battle.dtaken) + " hits to defender!")
+ prompt("Combat: " + format_hits() + " \u2013 assign " + (game.battle.dhits - game.battle.dtaken) + " hits to defender!")
switch (game.battle.type) {
case "militia":
gen_hits_militia()