diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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" |