summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-05-02 00:13:36 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 12:53:17 +0100
commit0363bf3ea52abc01481e9852631d9d1e9ace46e4 (patch)
treeacdc295e7bfb4215fce0624d17d271567e67299b
parent3968626c16517f16c98974de4b274a80c11342c1 (diff)
downloadhammer-of-the-scots-0363bf3ea52abc01481e9852631d9d1e9ace46e4.tar.gz
hammer: Fix Moray and Scottish King wintering.
Delay disband question until normal disband phase. Allow staying even if over castle limit since you may want to be able to disband another unit to keep Moray or the King). Skip question completely if already at home or home is occupied. Improve UI for Edward wintering -- can click England to disband, and added button for wintering.
-rw-r--r--play.html3
-rw-r--r--rules.js61
-rw-r--r--ui.js5
3 files changed, 48 insertions, 21 deletions
diff --git a/play.html b/play.html
index fa527c6..accc68a 100644
--- a/play.html
+++ b/play.html
@@ -309,6 +309,9 @@ div.card_3{background-image:url('cards/card_3.jpg')}
<button id="end_disbanding_button" onclick="on_button_end_disbanding()" class="hide">
End disbanding
</button>
+ <button id="winter_button" onclick="on_button_winter()" class="hide">
+ Winter
+ </button>
<button id="disband_button" onclick="on_button_disband()" class="hide">
Disband
</button>
diff --git a/rules.js b/rules.js
index 4809c82..bfec678 100644
--- a/rules.js
+++ b/rules.js
@@ -2217,7 +2217,7 @@ function goto_moray() {
delete game.bruce_home;
delete game.comyn_home;
- if (is_on_map(MORAY)) {
+ if (is_on_map(MORAY) && game.location[MORAY] != "Moray" && is_friendly_or_neutral_area("Moray")) {
game.state = 'moray';
game.active = SCOTLAND;
game.who = MORAY;
@@ -2230,12 +2230,9 @@ states.moray = {
prompt: function (view, current) {
if (is_inactive_player(current))
return view.prompt = "Waiting for Scotland to move Moray.";
- view.prompt = "Nobles go Home: Move Moray to his home area, remain where he is, or disband.";
- gen_action(view, 'disband');
- if (is_within_castle_limit(game.location[MORAY]))
- gen_action(view, 'area', game.location[MORAY]);
- if (is_friendly_or_neutral_area("Moray"))
- gen_action(view, 'area', "Moray");
+ view.prompt = "Nobles go Home: Move Moray to his home area or remain where he is.";
+ gen_action(view, 'area', game.location[MORAY]);
+ gen_action(view, 'area', "Moray");
},
disband: function () {
game.turn_log.push(["Moray", "Pool"]);
@@ -2253,10 +2250,18 @@ states.moray = {
},
}
+function king_can_go_home(current) {
+ for (let where in AREAS)
+ if (where != current && is_cathedral_area(where))
+ if (is_friendly_or_neutral_area(where))
+ return true;
+ return false;
+}
+
function goto_scottish_king() {
print_turn_log_no_count("Scottish nobles go home:");
- if (is_on_map(KING)) {
+ if (is_on_map(KING) && king_can_go_home(game.location[KING])) {
game.state = 'scottish_king';
game.active = SCOTLAND;
game.who = KING;
@@ -2269,10 +2274,8 @@ states.scottish_king = {
prompt: function (view, current) {
if (is_inactive_player(current))
return view.prompt = "Waiting for Scotland to move the King.";
- view.prompt = "Scottish King: Move the King to a cathedral, remain where he is, or disband.";
- gen_action(view, 'disband');
- if (is_within_castle_limit(game.location[KING]))
- gen_action(view, 'area', game.location[KING]);
+ view.prompt = "Scottish King: Move the King to a cathedral or remain where he is.";
+ gen_action(view, 'area', game.location[KING]);
for (let where in AREAS) {
if (is_cathedral_area(where))
if (is_friendly_or_neutral_area(where))
@@ -2321,26 +2324,42 @@ function goto_edward_wintering() {
goto_english_disbanding();
}
+function disband_edward() {
+ log("Edward disbands.");
+ disband(EDWARD);
+ game.who = null;
+ game.wintered_last_year = false;
+ goto_english_disbanding();
+}
+
+function winter_edward() {
+ log("Edward winters in " + game.location[EDWARD] + ".");
+ game.who = null;
+ game.wintered_last_year = true;
+ goto_english_disbanding();
+}
+
states.edward_wintering = {
prompt: function (view, current) {
if (is_inactive_player(current))
return view.prompt = "Waiting for England to winter in Scotland or disband.";
view.prompt = "Edward Wintering: Winter in Scotland or disband.";
+ gen_action(view, 'winter');
gen_action(view, 'disband');
gen_action(view, 'area', game.location[EDWARD]);
+ gen_action(view, 'area', ENGLAND);
+ },
+ winter: function (to) {
+ winter_edward();
},
disband: function () {
- log("Edward disbands.");
- disband(EDWARD);
- game.who = null;
- game.wintered_last_year = false;
- goto_english_disbanding();
+ disband_endward();
},
area: function (to) {
- log("Edward winters in " + to + ".");
- game.who = null;
- game.wintered_last_year = true;
- goto_english_disbanding();
+ if (to == ENGLAND)
+ disband_edward();
+ else
+ winter_edward();
},
}
diff --git a/ui.js b/ui.js
index 683f0af..d974e5f 100644
--- a/ui.js
+++ b/ui.js
@@ -202,6 +202,10 @@ function on_button_disband(evt) {
send_action('disband');
}
+function on_button_winter(evt) {
+ send_action('winter');
+}
+
function on_button_end_disbanding(evt) {
send_action('end_disbanding');
}
@@ -711,6 +715,7 @@ function on_update(state, player) {
show_action_button("#end_move_phase_button", "end_move_phase");
show_action_button("#end_regroup_button", "end_regroup");
show_action_button("#end_retreat_button", "end_retreat");
+ show_action_button("#winter_button", "winter");
show_action_button("#eliminate_button", "eliminate");
show_action_button("#disband_button", "disband");
show_action_button("#end_disbanding_button", "end_disbanding");