summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-12-10 19:38:18 +0100
committerTor Andersson <tor@ccxvii.net>2024-12-10 19:38:18 +0100
commitc70c909671e9a629bccb785d2777954131480dd7 (patch)
tree09357c1be56cae46462e85ae1cc3f82387f9b831 /play.js
parent35c925531b670275801c7d7057fb3b5c46985c92 (diff)
downloadmaria-c70c909671e9a629bccb785d2777954131480dd7.tar.gz
Annul deals.
Diffstat (limited to 'play.js')
-rw-r--r--play.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/play.js b/play.js
index c14d442..9be37f9 100644
--- a/play.js
+++ b/play.js
@@ -1844,13 +1844,17 @@ function update_subsidy_list(subs, elt, title) {
}
}
-function update_deal_item(deal) {
+function update_deal_item(deal, ix) {
let [ a_power, b_power, a_turn, b_turn, a_phase, b_phase, a_promise, b_promise ] = deal
let str = "<tr class='a'>"
str += "<td width=24>" + power_image[a_power]
str += "<td>" + html_escape(a_promise)
str += "<td width=80><i>" + phase_list(a_phase) + "</i>"
str += "<td width=60>" + turn_name[a_turn]
+ if (is_action("cancel_deal"))
+ str += `<td width=15 class="action" style="color:brown" onclick="cancel_deal(${ix})">\u274c</a>`
+ else
+ str += "<td width=15>"
str += "<tr class='b'>"
str += "<td>" + power_image[b_power]
str += "<td>" + html_escape(b_promise)
@@ -1859,11 +1863,19 @@ function update_deal_item(deal) {
return str
}
+function cancel_deal(ix) {
+ let deal = view.deals[ix]
+ if (window.confirm(
+ `ANNUL deal between between ${power_name[deal[DI_A_POWER]]} and ${power_name[deal[DI_B_POWER]]}?`
+ ))
+ send_message("action", [ "cancel_deal", ix, game_cookie ])
+}
+
function update_deal_list(deals, elt, title) {
if (deals && deals.length > 0) {
//let str = "<table><tr><th><th>" + title + "<th>phase<th>until"
- let str = "<table><tr><th colspan=4>" + title
- str += deals.map(update_deal_item).join("<tr class='sep'><td colspan=4>")
+ let str = "<table><tr><th colspan=5>" + title
+ str += deals.map(update_deal_item).join("<tr class='sep'><td colspan=5>")
str += "</table>"
elt.innerHTML = str
elt.style.display = "block"