diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 61 |
1 files changed, 38 insertions, 23 deletions
@@ -1299,7 +1299,7 @@ function next_attack_cavalry_step() { log_br() log(`${faction_name[game.cmd.attacker]} scores ${game.cmd.a_hit} hits.`) log(`${faction_name[game.cmd.target]} scores ${game.cmd.d_hit} hits.`) - goto_attack_casualties("target") + goto_attack_casualties() } } @@ -1367,27 +1367,31 @@ function get_attack_victor() { return -1 } -function goto_attack_casualties(step) { - if (step === "target") { - game.current = game.cmd.target +function goto_attack_casualties() { + let curr + if (game.cmd.step === 2) { + curr = game.cmd.target game.cmd.count = game.cmd.a_hit - } else if (step === "attacker") { - game.current = game.cmd.attacker + } else if (game.cmd.step === 3) { + curr = game.cmd.attacker game.cmd.count = game.cmd.d_hit } // Auto-remove MI casualties - if (game.current === MI) { + if (curr === MI) { remove_mi_casualties(game.cmd.where) end_attack_casualties() - } else if (game.cmd.count > 0) { - game.state = "attack_casualties" - } else - end_attack_casualties() + } else { + game.current = curr + if (game.cmd.count > 0) { + game.state = "attack_casualties" + } else + end_attack_casualties() + } } function remove_mi_casualties(s) { - while (game.cmd.count > 0 && count_pieces(s, MI, TROOPS) > 0) { + while ((game.cmd.count > 0) && (count_pieces(s, MI, TROOPS) > 0)) { let p = find_piece(s, MI, TROOPS) remove_piece(p) game.cmd.count -= 1 @@ -1422,8 +1426,10 @@ states.attack_casualties = { } function end_attack_casualties() { - if (game.current === game.cmd.target) - goto_attack_casualties("attacker") + if (game.cmd.step === 2) { + game.cmd.step += 1 + goto_attack_casualties() + } else goto_attack_resolution() } @@ -1432,8 +1438,7 @@ function goto_attack_resolution() { game.dice = [0, 0, 0, 0, 0, 0] if (is_rebel_faction(game.cmd.target) && is_rebel_faction(game.cmd.attacker)) attack_influence_shift() - - if (game.cmd.attacker === MI && !is_timurid()) { + else if (game.cmd.attacker === MI && !is_timurid()) { game.current = game.cmd.sa_faction game.state = "plunder" } else if (game.vm) { @@ -1454,7 +1459,10 @@ function attack_influence_shift() { } if (up) { - game.inf_shift = { "next": "attack" } + if (game.vm) + game.inf_shift = { "next": vm_next } + else + game.inf_shift = { "next": "attack" } add_influence(up) remove_influence(down) } else { @@ -2246,6 +2254,7 @@ states.compel_space = { }, piece(p) { + set_add(game.cmd.pieces, p) if (piece_space(p) === AVAILABLE) log_summary_place(p) else @@ -2254,6 +2263,7 @@ states.compel_space = { game.decree.count -= 1 }, next() { + pop_summary() game.state = "compel_space_influencial" }, end_compel: end_decree @@ -2268,9 +2278,15 @@ states.compel_space_influencial = { gen_piece_in_space(game.decree.where, BK, ELITE) }, piece(p) { - logi("Removed " + piece_name(p)) + logi("Removed " + piece_name(p) + " from S" + piece_space(p)) + let f = piece_faction(p) remove_piece(p) - goto_cavalry(1) + + if (f === DS) + for (let r of game.cmd.pieces) + to_rebel(r) + + goto_cavalry(1, end_decree) } } @@ -2347,9 +2363,11 @@ function goto_conspire_space(s) { function conspire_piece(p) { logi("1 " + piece_name(p)) log_br() + let rebel = is_rebel(p) remove_piece(p) let amir = find_piece(AVAILABLE, BK, ELITE) - place_piece(amir, game.decree.where) + let pp = place_piece(amir, game.decree.where) + if (rebel) to_rebel(pp) game.decree.count -= 1 game.state = "conspire" } @@ -4810,9 +4828,6 @@ function vm_end_game() { logi(faction_name[i] + " " + game.vp[i] + " VP") } - game.vp = [0,12,12] - game.resources = [0, 12, 12] - let result = get_result() goto_game_over(result) } |