Skip to content
Snippets Groups Projects
Commit f7bfaa3c authored by dg's avatar dg
Browse files

Each reason of death is recorded in the online charsheet

git-svn-id: http://svn.net-core.org/repos/t-engine4@2264 51575b47-30f0-44d4-a5cc-537603b46e54
parent 776f1f68
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,7 @@ function _M:init(t, no_default)
mod.class.interface.PlayerLore.init(self, t)
self.descriptor = {}
self.died_times = {}
end
function _M:onBirth(birther)
......@@ -410,7 +411,7 @@ function _M:die(src)
game.paused = true
self.energy.value = game.energy_to_act
self.killedBy = src
self.died_times = (self.died_times or 0) + 1
self.died_times[#self.died_times+1] = {name=src.name, level=self.level, turn=game.turn}
self:registerDeath(self.killedBy)
game:registerDialog(DeathDialog.new(self))
else
......
......@@ -35,6 +35,14 @@ function _M:dumpToJSON(js)
-------------------------------------------------------------------
-- Character
-------------------------------------------------------------------
local deaths = "no deaths recorded"
if #self.died_times > 0 then
deaths = "<ul>"
for i, reason in ipairs(self.died_times) do
deaths = deaths..string.format("<li>Killed by %s at level %d on the %s</li>", reason.name or "unknown", reason.level, game.calendar:getTimeDate(reason.turn, "%s %s %s year of Ascendancy at %02d:%02d"))
end
deaths = deaths.."</ul>"
end
js:newSection("character", "char", "pairs", "add", {
{ game = string.format("%s (version %d.%d.%d)", game.__mod_info.long_name, game.__mod_info.version[1], game.__mod_info.version[2], game.__mod_info.version[3]) },
{ name = self.name },
......@@ -45,7 +53,7 @@ function _M:dumpToJSON(js)
{ level = self.level },
{ exp = string.format("%d%%", 100 * cur_exp / max_exp) },
{ gold = string.format("%d", self.money) },
{ died = string.format("%d times (now %s)", self.died_times or 0, self.dead and "dead" or "alive") },
{ died = { val=string.format("%d times (now %s)", #self.died_times or 0, self.dead and "dead" or "alive"), tooltip=deaths } },
})
-------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment