summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-06-23 15:42:49 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:08:56 +0100
commitbba2352b38b5ad5d25bb07198eed2d426ce1831d (patch)
treec238d30bbe72ec7338bbcdab4c1ccb2c56d383cb /rules.js
parent7eebbf33f8e84cc6ca468cfe1aa23297100f0bfe (diff)
downloadjulius-caesar-bba2352b38b5ad5d25bb07198eed2d426ce1831d.tar.gz
caesar: Pick Mars and Neptune battles after movement.
This is like the Jihad card in Crusader Rex where the rules clarify that the surprise attack is declared before player two moves. We can then also mark the surprise attacking blocks on the map.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js96
1 files changed, 58 insertions, 38 deletions
diff --git a/rules.js b/rules.js
index 54e33a4..f82928a 100644
--- a/rules.js
+++ b/rules.js
@@ -809,6 +809,7 @@ function start_turn() {
game.active = "Both";
game.state = 'play_card';
game.show_cards = false;
+ game.surprise = 0;
log("");
log("Start Turn ", game.turn, " of Year ", game.year, ".");
}
@@ -1094,6 +1095,41 @@ states.vulcan = {
},
}
+function goto_mars_and_neptune() {
+ game.surprise_list = [];
+ for (let where in SPACES)
+ if (is_map_space(where) && is_contested_space(where))
+ game.surprise_list.push(where);
+ if (game.surprise_list.length == 0) {
+ delete game.surprise_list;
+ return end_player_turn();
+ }
+ if (game.surprise_list.length == 1) {
+ game.surprise = game.surprise_list[0];
+ log("Surprise attack in " + game.surprise + ".");
+ delete game.surprise_list;
+ return end_player_turn();
+ }
+ game.state = 'mars_and_neptune';
+}
+
+states.mars_and_neptune = {
+ prompt: function (view, current) {
+ let god = game.mars == game.active ? "Mars: " : "Neptune: ";
+ if (is_inactive_player(current))
+ return view.prompt = god + ": Waiting for " + game.active + ".";
+ view.prompt = god + "Select battle for surprise attack.";
+ for (let space of game.surprise_list)
+ gen_action(view, 'space', space);
+ },
+ space: function (where) {
+ game.surprise = where;
+ log("Surprise attack in " + game.surprise + ".");
+ delete game.surprise_list;
+ end_player_turn();
+ },
+}
+
function is_amphibious_move(who, from, to) {
if (BLOCKS[who].type == 'navis')
return false;
@@ -1386,10 +1422,10 @@ states.mercury_move_3 = {
function end_movement() {
print_turn_log("moves");
- if (game.pluto == game.active ||
- game.mars == game.active ||
- game.neptune == game.active ||
- game.mercury == game.active)
+ if (game.mars == game.active || game.neptune == game.active)
+ return goto_mars_and_neptune();
+
+ if (game.pluto == game.active || game.mercury == game.active)
return end_player_turn();
game.who = null;
@@ -1500,35 +1536,8 @@ states.pick_battle = {
},
space: function (where) {
game.where = where;
- if (game.mars == game.attacker[where]) {
- game.state = 'use_battle_event';
- } else if (game.neptune == game.attacker[where]) {
- game.state = 'use_battle_event';
- } else {
- start_battle(false);
- }
- },
-}
-
-states.use_battle_event = {
- prompt: function (view, current) {
- if (is_inactive_player(current))
- return view.prompt = "Waiting for " + game.active + " to pick a battle...";
- if (game.mars)
- view.prompt = "Do you want to use the surprise attack granted by Mars?";
- else
- view.prompt = "Do you want to use the surprise attack granted by Neptune?";
- gen_action(view, 'surprise');
- gen_action_pass(view, "No");
+ start_battle();
},
- surprise: function () {
- delete game.mars; /* Used up the event! */
- delete game.neptune; /* Used up the event! */
- start_battle(true);
- },
- pass: function () {
- start_battle(false);
- }
}
function is_attacker(b) {
@@ -1561,12 +1570,11 @@ function count_defenders() {
return count;
}
-function start_battle(surprise) {
- game.surprise = surprise;
+function start_battle() {
game.battle_round = 0;
game.flash = "";
log("");
- if (game.surprise)
+ if (game.surprise == game.where)
log("Surprise attack in ", game.where, ".");
else
log("Battle in ", game.where, ".");
@@ -1609,7 +1617,8 @@ function start_battle_round() {
game.moved = {};
if (game.battle_round == 2) {
- game.surprise = false;
+ if (game.surprise == game.where)
+ game.surprise = 0;
if (count_defenders() == 0) {
log("Defending main force was eliminated.");
log("Defending reserves are disrupted.");
@@ -1664,7 +1673,7 @@ function pump_battle_round() {
let attacker = game.attacker[game.where];
let defender = enemy(attacker);
- if (game.surprise) {
+ if (game.surprise == game.where) {
if (battle_step(attacker, 'A', is_attacker)) return;
if (battle_step(attacker, 'B', is_attacker)) return;
if (battle_step(attacker, 'C', is_attacker)) return;
@@ -1689,6 +1698,8 @@ function pump_battle_round() {
}
function end_battle() {
+ if (game.surprise == game.where)
+ game.surprise = 0;
game.flash = "";
game.battle_round = 0;
reset_road_limits();
@@ -2369,7 +2380,7 @@ function make_battle_view() {
};
bv.title = game.attacker[game.where];
- if (game.surprise && game.battle_round == 1)
+ if (game.surprise == game.where)
bv.title += " surprise attacks ";
else
bv.title += " attacks ";
@@ -2431,6 +2442,15 @@ exports.view = function(state, current) {
if (states[game.state].show_battle)
view.battle = make_battle_view();
+ if (game.mars && game.surprise) {
+ view.mars = game.p1;
+ view.surprise = game.surprise;
+ }
+ if (game.neptune && game.surprise) {
+ view.neptune = game.p1;
+ view.surprise = game.surprise;
+ }
+
for (let b in BLOCKS) {
if (game.state == 'game_over') {
if (game.location[b] != LEVY)