From c70c909671e9a629bccb785d2777954131480dd7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 10 Dec 2024 19:38:18 +0100 Subject: Annul deals. --- play.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'play.js') 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 = "" str += "" + power_image[a_power] str += "" + html_escape(a_promise) str += "" + phase_list(a_phase) + "" str += "" + turn_name[a_turn] + if (is_action("cancel_deal")) + str += `\u274c` + else + str += "" str += "" str += "" + power_image[b_power] str += "" + 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 = "
" + title + "phaseuntil" - let str = "
" + title - str += deals.map(update_deal_item).join("
") + let str = "
" + title + str += deals.map(update_deal_item).join("
") str += "
" elt.innerHTML = str elt.style.display = "block" -- cgit v1.2.3