From afa7dba661d39abdaa2f5712b8ee42ce972e276f Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 6 May 2024 15:23:14 +0200 Subject: common favour change logging for events --- rules.js | 25 +++++++++++++++---------- rules.ts | 26 ++++++++++++++++---------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/rules.js b/rules.js index f2c257f..11b97f5 100644 --- a/rules.js +++ b/rules.js @@ -1476,6 +1476,14 @@ function is_lancaster_dominating_wales() { return n >= all_wales_locales.length; } // === 1.4 INFLUENCE === +function log_favour(loc) { + if (has_york_favour(loc)) + log(`S${loc} to Yorkist.`); + else if (has_lancaster_favour(loc)) + log(`S${loc} to Lancastrian.`); + else + log(`S${loc} to Neutral.`); +} function log_ip(n) { if (n < 0) log(".ip " + n); @@ -2764,8 +2772,8 @@ states.levy_lord_at_seat = { muster_lord(game.who, loc); levy_burgundians(game.who); if (game.active === YORK) { - add_york_favour(loc); remove_lancaster_favour(loc); + add_york_favour(loc); } else { if (loc === LOC_LONDON && has_york_favour(LONDON_FOR_YORK)) { @@ -9945,7 +9953,7 @@ states.warwicks_propaganda_yorkist_choice = { remove() { remove_york_favour(game.where); remove_propaganda_target(game.where); - logi(`Removed York Favour at S${game.where}.`); + log_favour(game.where); game.where = NOWHERE; }, pay() { @@ -10085,7 +10093,7 @@ states.welsh_rebellion_remove_favour = { locale(loc) { push_undo(); remove_york_favour(loc); - log(`Removed York Favour at S${loc}.`); + log_favour(loc); game.count++; }, done() { @@ -10226,8 +10234,8 @@ states.wilful_disobedience = { locale(loc) { push_undo(); remove_york_favour(loc); + log_favour(loc); game.count++; - logi(`Yorkist Favour removed at S${loc}`); }, done() { end_immediate_event(); @@ -10306,7 +10314,7 @@ states.robins_rebellion = { locale(loc) { push_undo(); shift_favour_toward(loc); - log(`Placed/Removed Favour at S${loc}.`); + log_favour(loc); game.count++; }, done() { @@ -10351,7 +10359,7 @@ states.tudor_banners = { locale(loc) { remove_york_favour(loc); add_lancaster_favour(loc); - log(`Placed Lancastrian Favour at S${loc}`); + log_favour(loc); }, done() { game.who = NOBODY; @@ -10544,10 +10552,7 @@ states.richard_leigh = { }, locale(loc) { shift_favour_toward(loc); - if (has_york_favour(loc)) - log(`L${loc} to Yorkist Favour.`); - else - log(`L${loc} to neutral.`); + log_favour(loc); end_immediate_event(); } }; diff --git a/rules.ts b/rules.ts index 7614d0d..c580ca4 100644 --- a/rules.ts +++ b/rules.ts @@ -1949,6 +1949,15 @@ function is_lancaster_dominating_wales() { // === 1.4 INFLUENCE === +function log_favour(loc) { + if (has_york_favour(loc)) + log(`S${loc} to Yorkist.`) + else if (has_lancaster_favour(loc)) + log(`S${loc} to Lancastrian.`) + else + log(`S${loc} to Neutral.`) +} + function log_ip(n) { if (n < 0) log(".ip " + n) @@ -3401,8 +3410,8 @@ states.levy_lord_at_seat = { levy_burgundians(game.who) if (game.active === YORK) { - add_york_favour(loc) remove_lancaster_favour(loc) + add_york_favour(loc) } else { if (loc === LOC_LONDON && has_york_favour(LONDON_FOR_YORK)) { logevent(EVENT_YORK_LONDON_FOR_YORK) @@ -11501,7 +11510,7 @@ states.warwicks_propaganda_yorkist_choice = { remove() { remove_york_favour(game.where) remove_propaganda_target(game.where) - logi(`Removed York Favour at S${game.where}.`) + log_favour(game.where) game.where = NOWHERE }, pay() { @@ -11650,7 +11659,7 @@ states.welsh_rebellion_remove_favour = { locale(loc) { push_undo() remove_york_favour(loc) - log(`Removed York Favour at S${loc}.`) + log_favour(loc) game.count++ }, done() { @@ -11803,8 +11812,8 @@ states.wilful_disobedience = { locale(loc) { push_undo() remove_york_favour(loc) + log_favour(loc) game.count++ - logi(`Yorkist Favour removed at S${loc}`) }, done() { end_immediate_event() @@ -11888,7 +11897,7 @@ states.robins_rebellion = { locale(loc) { push_undo() shift_favour_toward(loc) - log(`Placed/Removed Favour at S${loc}.`) + log_favour(loc) game.count++ }, done() { @@ -11936,7 +11945,7 @@ states.tudor_banners = { locale(loc) { remove_york_favour(loc) add_lancaster_favour(loc) - log(`Placed Lancastrian Favour at S${loc}`) + log_favour(loc) }, done() { game.who = NOBODY @@ -12142,10 +12151,7 @@ states.richard_leigh = { }, locale(loc) { shift_favour_toward(loc) - if (has_york_favour(loc)) - log(`L${loc} to Yorkist Favour.`) - else - log(`L${loc} to neutral.`) + log_favour(loc) end_immediate_event() } } -- cgit v1.2.3