diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-08 23:57:27 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-09 00:00:50 +0100 |
commit | 4d665cde4571c4621c6a0779e8b83f9bd10abb05 (patch) | |
tree | 0d4cb9ff498249b17dd8bb7c7c4eef3df0b4632b /rules.js | |
parent | f15dd0c0842cb3944ebc006da5b135cea6eed7b2 (diff) | |
download | maria-4d665cde4571c4621c6a0779e8b83f9bd10abb05.tar.gz |
log deals
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 46 |
1 files changed, 26 insertions, 20 deletions
@@ -1139,24 +1139,20 @@ function tc_per_turn_modifier() { return n } -function tc_per_turn() { - return tc_per_turn_base() + tc_per_turn_modifier() -} - function count_subsidies(pow) { let n = 0 - if (game.contracts[game.power]) + if (game.contracts[pow]) for (let other of all_powers) - if (map_get(game.contracts[game.power], other, 0) > 0) + if (map_get(game.contracts[pow], other, 0) > 0) ++n return n } function list_subsidies(pow) { let result = [] - if (game.contracts[game.power]) + if (game.contracts[pow]) for (let other of all_powers) - if (map_get(game.contracts[game.power], other, 0) > 0) + if (map_get(game.contracts[pow], other, 0) > 0) result.push(power_name[other]) return result } @@ -1361,7 +1357,7 @@ function goto_start_turn() { } // remove expired deals - game.deals = game.deals.filter(deal => deal[DI_TURN] < game.turn) + game.deals = game.deals.filter(deal => deal[DI_TURN] >= game.turn) } function goto_end_turn() { @@ -1742,7 +1738,7 @@ function log_draw_tc(k, pow) { } } -function draw_tc(draw, n, pow) { +function draw_tc(draw, n) { let k = 0 while (n > 0) { if (game.deck.length === 0) { @@ -1768,8 +1764,8 @@ function give_subsidy(other) { log(">1 Saxony subsidy lost\nS" + DRESDEN + " is enemy controlled") return } - draw_tc(game.hand2[other], 1, other) log(">1 " + power_name[other] + " subsidy") + draw_tc(game.hand2[other], 1) } function goto_tactical_cards() { @@ -1857,7 +1853,7 @@ function draw_tactical_cards() { else log(`>${n} ${power_name[game.power]}`) - draw_tc(game.draw, base + mod - sub, game.power) + draw_tc(game.draw, base + mod - sub) if (game.contracts[game.power]) { for (let other of all_powers) { @@ -4510,7 +4506,7 @@ function goto_politics() { } else { for (;;) { let list = [] - draw_tc(list, 1, -1) + draw_tc(list, 1) log("Trump " + format_card(list[0]) + ".") if (!is_reserve(list[0])) { game.trump = to_suit(list[0]) @@ -4679,7 +4675,7 @@ states.must_save_tc = { view.actions.save = 1 }, save() { - log(power_name[game.power] + " saved her TC.") + log(power_name[game.power] + " saved TC.") goto_select_political_card() }, } @@ -4712,7 +4708,7 @@ states.select_political_card = { game.state = "political_card_discard_or_execute" }, save() { - log(power_name[game.power] + " saved her TC.") + log(power_name[game.power] + " saved TC.") goto_select_political_card() }, } @@ -4727,7 +4723,7 @@ states.political_card_discard_or_execute = { }, execute() { push_undo() - log(power_name[game.power] + " executes card.") + log(power_name[game.power] + " executed card.") next_execute_political_card() }, discard() { @@ -4906,6 +4902,7 @@ states.political_troop_power = { set_active_to_power(pow) if (info.tcs > 0) { clear_undo() // reveal random cards + log(power_name[pow] + " TC.") draw_tc(game.draw = [], info.tcs, game.power) game.state = "political_troops_draw" } else { @@ -6274,6 +6271,15 @@ function goto_propose_deal(deal) { game.state = "accept_deal_from" } +function log_deal(deal, prefix, postfix = "") { + log(prefix + + "Deal until " + turn_name[deal[DI_TURN]] + ".\n" + + power_name[deal[DI_A_POWER]] + ": " + deal[DI_A_PROMISE] + "\n" + + power_name[deal[DI_B_POWER]] + ": " + deal[DI_B_PROMISE] + "\n" + + postfix + ) +} + states.accept_deal_from = { inactive: "accept deal", prompt() { @@ -6313,14 +6319,14 @@ states.accept_deal_to = { } function end_accept_deal(okay) { - let from = game.proposal.deal[DI_A_POWER] - let to = game.proposal.deal[DI_B_POWER] if (okay) { - log(`Accepted ${power_name[from]} - ${power_name[to]} deal.`) + log_deal(game.proposal.deal, "{") game.deals.push(game.proposal.deal) } else { - log(`Rejected ${power_name[from]} - ${power_name[to]} deal.`) + log_deal(game.proposal.deal, "}", "Rejected by " + power_name[game.power] + ".") } + log_br() + set_active_to_power(game.proposal.save_power) game.state = game.proposal.save_state delete game.proposal |