From 440a6dd7874f8cf46af167c4b70dbc17bb7d996e Mon Sep 17 00:00:00 2001 From: iainp5 Date: Wed, 25 Sep 2024 17:54:57 +0100 Subject: Fix +1 bonus in Stasi --- play.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'play.js') diff --git a/play.js b/play.js index 5aedbdf..647be0f 100644 --- a/play.js +++ b/play.js @@ -202,6 +202,29 @@ function is_action(action) { function on_log(text) { // eslint-disable-line no-unused-vars let p = document.createElement("div") +//Check if adding influence the the same place as the previous influence + + //let last_log_entry = document.getElementById("log").lastElementChild + console.log('view.log', view.log) + let last_log_entry = document.querySelector(`#log div:nth-child(${view.log.length-1})`) + let last_log_entry_text + console.log('last_log_entry', last_log_entry) + if (last_log_entry) { + last_log_entry_text = last_log_entry.innerHTML + console.log('last_log_entry_text', last_log_entry_text) + } + + +/* + let last_text = last_log_entry ? last_log_entry.split(' ') : [] + console.log('last text', last_text, 'text', text.split(' ')[3]) + if (last_text[0] === 'Added' && last_text[4] === text.split(' ')[4]) { + let new_influence = parseInt(last_text[1]) + 1 + new_text = `Added ${new_influence} influence in ${last_text[4]}` + console.log('new_influence', new_influence, 'new_text', new_text) + } */ + + if (text.match(/^>/)) { text = text.substring(1) p.className = 'i' @@ -235,6 +258,13 @@ function on_log(text) { // eslint-disable-line no-unused-vars p.className = 'h3' } + //console.log('view.log', view.log) + console.log('new text', text) + if (last_log_entry_text) { + console.log('log = text', last_log_entry_text === text) + } + + p.innerHTML = text return p } @@ -595,7 +625,7 @@ if (view.persistent_events['the_tyrant_is_gone'] > 0) { action_button("done", "Done") action_button("undo", "Undo") - console.log('view.log', view.log) + //console.log('view.log', view.log) } -- cgit v1.2.3