summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js28
-rw-r--r--rules.js87
2 files changed, 72 insertions, 43 deletions
diff --git a/play.js b/play.js
index 27dade3..d7e3b8e 100644
--- a/play.js
+++ b/play.js
@@ -969,9 +969,22 @@ function on_update() {
ui.legacy[pi].classList.toggle("legacy_40", false)
}
- let y = 30
+ let n = 0
+ for (let k = 0; k < player_count; ++k) {
+ let k_legacy = view.legacy[k]
+ if (k_legacy > 80)
+ k_legacy -= 40
+ if (k_legacy > 40)
+ k_legacy -= 40
+ if (legacy === k_legacy)
+ ++n
+ }
+
+ let y = (n === 1) ? 50 : (n === 2) ? 40 : 30
for (let k = 0; k < pi; ++k) {
let k_legacy = view.legacy[k]
+ if (k_legacy > 80)
+ k_legacy -= 40
if (k_legacy > 40)
k_legacy -= 40
if (legacy === k_legacy)
@@ -982,12 +995,15 @@ function on_update() {
ui.legacy[pi].style.left = Math.round(43 + legacy * 60.2) + "px"
ui.legacy[pi].style.top = 2 + y + "px"
- y = 30
- for (let k = 0; k < pi; ++k) {
- let k_turns = view.emperor_turns[k]
- if (turns === k_turns)
+ n = 0
+ for (let k = 0; k < player_count; ++k)
+ if (turns === view.emperor_turns[k])
+ ++n
+
+ y = (n === 1) ? 50 : (n === 2) ? 40 : 30
+ for (let k = 0; k < pi; ++k)
+ if (turns === view.emperor_turns[k])
y += 20
- }
show(ui.emperor_turns[pi])
ui.emperor_turns[pi].style.left = Math.round(41 + turns * 60.2) + "px"
diff --git a/rules.js b/rules.js
index ae2aa02..f389277 100644
--- a/rules.js
+++ b/rules.js
@@ -2267,6 +2267,7 @@ function roll_to_place_governor(pg) {
if (game.where === ITALIA)
game.count += count_own_basilicas()
+ log_br()
if (pg)
log("Praetorian Guard in %" + game.where)
else
@@ -2280,25 +2281,29 @@ function roll_to_place_governor(pg) {
have = roll_dice(game.count, 2)
if (have >= need) {
- logi("Success!")
+ log("Success!")
+ log_br()
if (game.where === ITALIA) {
// Remember for Damnatio Memoriae
let old_emperor = get_province_player(ITALIA)
- if (old_emperor >= 0)
- game.count = (old_emperor << 3) | get_support(ITALIA)
- else
- game.count = 0
- }
+ let old_support = get_support(ITALIA)
- place_governor(game.where, game.selected_governor)
+ place_governor(game.where, game.selected_governor)
- if (game.where === ITALIA && (has_card_event(CARD_S4) || has_card_event(CARD_S4B)))
- game.state = "damnatio_memoriae"
- else
+ if (old_emperor >= 0 && (has_card_event(CARD_S4) || has_card_event(CARD_S4B))) {
+ game.count = (old_emperor << 3) | old_support
+ game.state = "damnatio_memoriae"
+ } else {
+ game.state = "take_actions"
+ }
+ } else {
+ place_governor(game.where, game.selected_governor)
game.state = "take_actions"
+ }
} else {
- logi("Failed!")
+ log("Failed!")
+ log_br()
game.state = "take_actions"
}
}
@@ -2313,7 +2318,7 @@ states.damnatio_memoriae = {
},
card(c) {
push_undo()
- log(card_name(c))
+ log("Damnatio Memoriae.")
set_add(game.used, c)
play_card_event(c)
},
@@ -2738,7 +2743,7 @@ states.mob = {
gen_action_region(where)
},
region(where) {
- log("Mob in %" + where)
+ log("Mob in %" + where + ".")
set_mobs(where, get_mobs(where) + 1)
game.state = "take_actions"
},
@@ -2827,23 +2832,23 @@ function play_flanking_maneuver() {
}
function goto_battle_vs_general(where, attacker, target) {
- log("Initiate Battle against " + GENERAL_NAME[target] + " in %" + where)
+ log_h3("Battle " + PLAYER_NAME[target/6|0] + " in %" + where)
goto_battle("general", where, attacker, target)
}
function goto_battle_vs_barbarian(where, attacker, target) {
let tribe = get_barbarian_tribe(target)
- log("Initiate Battle against " + BARBARIAN_NAME[tribe] + " in %" + where)
+ log_h3("Battle " + BARBARIAN_NAME[tribe] + " in %" + where)
goto_battle("barbarians", where, attacker, tribe)
}
function goto_battle_vs_rival_emperor(where, attacker, target) {
- log("Initiate Battle against " + RIVAL_EMPEROR_NAME[target] + " in %" + where)
+ log_h3("Battle " + RIVAL_EMPEROR_NAME[target] + " in %" + where)
goto_battle("rival_emperor", where, attacker, target)
}
function goto_battle_vs_militia(where, attacker) {
- log("Initiated Battle against militia in %" + where)
+ log_h3("Battle militia in %" + where)
goto_battle("militia", where, attacker, -1)
}
@@ -2910,7 +2915,7 @@ states.battle = {
},
card(c) {
push_undo()
- log(card_event_name(c))
+ log(card_event_name(c) + ".")
set_add(game.used, c)
play_card_event(c)
},
@@ -2932,13 +2937,8 @@ states.flanking_maneuver = {
prompt() {
prompt("Flanking Maneuver: " + format_hits() + ".")
view.actions.continue = 1
- view.actions.pass = 1 // XXX
view.actions.reroll = 1
},
- // XXX
- pass() {
- goto_assign_hits()
- },
continue() {
goto_assign_hits()
},
@@ -2952,16 +2952,19 @@ function roll_combat_dice() {
game.battle.dtaken = 0
game.battle.ataken = 0
- game.battle.dhits = roll_attacker_dice()
- log("Total " + game.battle.dhits + " hits!")
-
+ log_h4("DEFENDER")
game.battle.ahits = roll_defender_dice()
log("Total " + game.battle.ahits + " hits!")
log_br()
+
+ log_h4("ATTACKER")
+ game.battle.dhits = roll_attacker_dice()
+ log("Total " + game.battle.dhits + " hits!")
+ log_br()
}
function roll_flanking_maneuver_dice() {
- log("Flanking Maneuver Reroll")
+ log_h4("FLANKING MANEUVER")
game.battle.dhits = roll_defender_dice()
log("Total " + game.battle.dhits + " hits!")
log_br()
@@ -3033,14 +3036,11 @@ function roll_barbarian_dice(tribe) {
}
function roll_attacker_dice() {
- log_h3("ATTACKER")
-
let n = get_plague_hits()
if (game.battle.attacker < 0)
n += roll_militia_dice()
else
n += roll_general_dice(game.battle.attacker)
-
if (game.battle.type === "militia" && has_militia_castra(game.where)) {
log("Castra reduces 1 hit")
n -= 1
@@ -3049,18 +3049,14 @@ function roll_attacker_dice() {
log("Castra reduces 1 hit")
n -= 1
}
-
if (game.battle.type === "barbarians" && get_barbarian_location(SHAPUR) === game.where) {
log("Shapur I reduced 1 hit")
n -= 1
}
-
return Math.max(0, n)
}
function roll_defender_dice() {
- log_h3("DEFENDER")
-
let n = get_plague_hits()
switch (game.battle.type) {
case "militia":
@@ -3221,16 +3217,19 @@ states.assign_hits_on_attacker = {
gen_hits_general(game.battle.attacker)
},
militia(where) {
+ push_undo()
game.battle.ataken += 1
eliminate_militia(where)
goto_assign_hits_on_attacker()
},
legion(id) {
+ push_undo()
game.battle.ataken += 1
assign_hit_to_legion(id)
goto_assign_hits_on_attacker()
},
barbarian(id) {
+ push_undo()
game.battle.ataken += 1
eliminate_barbarian(id)
goto_assign_hits_on_attacker()
@@ -3256,21 +3255,25 @@ states.assign_hits_on_defender = {
}
},
militia(where) {
+ push_undo()
game.battle.dtaken += 1
eliminate_militia(where)
goto_assign_hits_on_defender()
},
legion(id) {
+ push_undo()
game.battle.dtaken += 1
assign_hit_to_legion(id)
goto_assign_hits_on_defender()
},
barbarian(id) {
+ push_undo()
game.battle.dtaken += 1
eliminate_barbarian(id)
goto_assign_hits_on_defender()
},
rival_emperor(id) {
+ push_undo()
game.battle.dtaken += 1
eliminate_rival_emperor(id)
goto_assign_hits_on_defender()
@@ -3305,7 +3308,7 @@ function goto_combat_victory() {
let de = is_defender_eliminated()
let ae = is_attacker_eliminated()
if (de && ae)
- end_battle()
+ goto_combat_no_victory()
else if (de || game.battle.dtaken > game.battle.ataken)
goto_combat_victory_attacker()
else
@@ -3314,12 +3317,17 @@ function goto_combat_victory() {
function award_legacy(p, reason, n) {
if (n > 0)
- log(PLAYER_NAMES[p] + " gained " + n + " Legacy for " + reason + ".")
+ log(PLAYER_NAMES[p] + " +" + n + " Legacy for " + reason + ".")
if (n < 0)
- log(PLAYER_NAMES[p] + " lost " + (-n) + " Legacy for " + reason + ".")
+ log(PLAYER_NAMES[p] + " " + n + " Legacy for " + reason + ".")
game.legacy[p] += n
}
+function goto_combat_no_victory() {
+ game.battle.killed = 0
+ end_battle()
+}
+
function goto_combat_victory_defender() {
game.battle.killed = 0
if (game.battle.type === "general")
@@ -4164,6 +4172,11 @@ function log_h3(msg) {
log(".h3 " + msg)
}
+function log_h4(msg) {
+ log_br()
+ log(msg)
+}
+
function logi(msg) {
game.log.push(">" + msg)
}