summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-01-19 14:57:07 +0100
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:19:39 +0100
commitf2d9c93f40313db7a0d8987dc550263492c0c21a (patch)
tree451fa0041deea2a791ffc111676d6707c7aea37e
parent4861c41e8c8cfad2779f8773947856b58fe0c876 (diff)
downloadcrusader-rex-f2d9c93f40313db7a0d8987dc550263492c0c21a.tar.gz
Log combat hits taken.
-rw-r--r--rules.js43
1 files changed, 32 insertions, 11 deletions
diff --git a/rules.js b/rules.js
index d39cdff..890120d 100644
--- a/rules.js
+++ b/rules.js
@@ -2961,13 +2961,21 @@ states.field_battle_hits = {
block: apply_field_battle_hit,
}
-function apply_field_battle_hit(who) {
+function apply_field_battle_hit_to(who, flash) {
+ let msg;
if (block_plural(who))
- game.flash = block_name(who) + " take a hit.";
+ msg = block_name(who) + " take a hit.";
else
- game.flash = block_name(who) + " takes a hit.";
- reduce_block(who, 'combat');
+ msg = block_name(who) + " takes a hit.";
+ log(game.active[0] + ": " + msg);
+ if (flash)
+ game.flash = msg;
+ reduce_block(who);
game.hits--;
+}
+
+function apply_field_battle_hit(who) {
+ apply_field_battle_hit_to(who, true);
if (game.hits === 0)
resume_field_battle();
else {
@@ -3019,22 +3027,35 @@ states.siege_battle_hits = {
block: apply_siege_battle_hit,
}
-function apply_siege_battle_hit(who) {
+function apply_siege_battle_hit_to(who, flash) {
+ let msg;
if (block_plural(who))
- game.flash = block_name(who) + " take a hit.";
+ msg = block_name(who) + " take a ";
else
- game.flash = block_name(who) + " takes a hit.";
+ msg = block_name(who) + " takes a ";
if (game.halfhit === who) {
- reduce_block(who, 'combat');
+ msg += "hit.";
+ log(game.active[0] + ": " + msg);
+ reduce_block(who);
game.halfhit = null;
} else {
- if (is_block_in_castle(who))
+ if (is_block_in_castle(who)) {
+ msg += "half-hit.";
+ log(game.active[0] + ": " + msg);
game.halfhit = who;
- else
- reduce_block(who, 'combat');
+ } else {
+ msg += "hit.";
+ log(game.active[0] + ": " + msg);
+ reduce_block(who);
+ }
}
+ if (flash)
+ game.flash = msg;
game.hits--;
+}
+function apply_siege_battle_hit(who) {
+ apply_siege_battle_hit_to(who, true);
if (game.hits === 0) {
resume_siege_battle();
} else {