summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-05-16 15:21:35 +0200
committerTor Andersson <tor@ccxvii.net>2023-02-18 12:42:59 +0100
commiteeae39b84a5644527e595b7460d44a22c378fa15 (patch)
tree923508e5b1fa006b8d2bf46505ff5d603130f80e /rules.js
parent84fba8fbdfd5fa70cd05706ac5f3fae57eb4bcc1 (diff)
download300-earth-and-water-eeae39b84a5644527e595b7460d44a22c378fa15.tar.gz
300: immortals event starts a new battle
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js52
1 files changed, 40 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index 35538f5..a792382 100644
--- a/rules.js
+++ b/rules.js
@@ -1732,6 +1732,7 @@ function persian_land_battle_round() {
}
if (can_play_the_immortals()) {
+ end_battle_event();
game.active = PERSIA;
game.state = 'persian_land_battle_immortals';
} else {
@@ -1754,6 +1755,7 @@ function greek_land_battle_round() {
}
if (can_play_the_immortals()) {
+ end_battle_event();
game.active = PERSIA;
game.state = 'greek_land_battle_immortals';
} else {
@@ -1772,9 +1774,12 @@ states.persian_land_battle_immortals = {
},
card_event: function (card) {
play_the_immortals();
- resume_persian_land_battle();
+ restart_persian_land_battle();
+ game.immortals = 0;
},
- next: resume_persian_land_battle,
+ next: function () {
+ end_battle(true);
+ }
}
states.greek_land_battle_immortals = {
@@ -1788,9 +1793,12 @@ states.greek_land_battle_immortals = {
},
card_event: function (card) {
play_the_immortals();
- resume_greek_land_battle();
+ restart_greek_land_battle();
+ game.immortals = 0;
},
- next: resume_greek_land_battle,
+ next: function () {
+ end_battle(true);
+ }
}
function resume_persian_land_battle(_, current) {
@@ -1809,6 +1817,16 @@ function resume_greek_land_battle(_, current) {
end_battle();
}
+function restart_persian_land_battle(_, current) {
+ game.active = PERSIA;
+ goto_persian_land_battle();
+}
+
+function restart_greek_land_battle(_, current) {
+ game.active = GREECE;
+ goto_greek_land_battle();
+}
+
function gen_land_retreat_attacker(view, is_friendly_control) {
// RULES: if land movement started in neighboring city, do they have to
// retreat to origin city if it is neighboring, or could they have gone
@@ -1973,20 +1991,17 @@ states.greek_land_retreat_defender = {
},
}
-function end_battle() {
- game.naval_battle = 0;
- game.from = null;
-
+function end_battle_event() {
log("Battle in " + game.where + " ends.");
if (game.greek.event == EVANGELION) {
game.greek.event = 0;
if (count_persian_armies(game.where) == 0) {
- log("Greece scores 1 point.");
+ log("Evangelion: Greece scores 1 point.");
add_greek_vp();
}
if (!is_greek_control(game.where)) {
- log("Greece loses 1 point.");
+ log("Evangelion: Greece loses 1 point.");
add_persian_vp();
}
}
@@ -1994,15 +2009,25 @@ function end_battle() {
if (game.persian.event == THE_GREAT_KING) {
game.persian.event = 0;
if (count_greek_armies(game.where) == 0) {
- log("Persia scores 1 point.");
+ log("The Great King: Persia scores 1 point.");
add_persian_vp();
}
if (!is_persian_control(game.where)) {
- log("Persia loses 1 point.");
+ log("The Great King: Persia loses 1 point.");
add_greek_vp();
}
}
+ game.greek.battle_event = 0;
+}
+
+function end_battle(already_ended=0) {
+ if (!already_ended)
+ end_battle_event();
+
+ game.naval_battle = 0;
+ game.from = null;
+
if (game.active == PERSIA) {
end_persian_movement();
} else {
@@ -2847,10 +2872,13 @@ function can_play_the_immortals() {
return false;
if (game.trigger.xerxes)
return false;
+ if (game.immortals == 0)
+ return false;
return count_persian_armies(game.where) == 0;
}
function play_the_immortals() {
+ log("");
play_persian_event_card(THE_IMMORTALS);
log("The Immortals recover " + game.immortals + " armies!");
move_persian_army(RESERVE, game.where, game.immortals);