Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema: remove duplicate KO entry from Tier #20

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@ function common.proviant_vermoegen()
common.inner_rows(content, 4)
end

-- Truncating integer division
function common.div_trunc(numerator, denominator)
local quotient = numerator // denominator
if quotient < 0 and numerator % denominator ~= 0 then
quotient = quotient + 1
end
return quotient
end


common.schaden = {}

function common.schaden.parse(input)
Expand Down Expand Up @@ -501,16 +511,9 @@ function common.schaden.mod(tp, schwelle, schritt)
return nil
end
if schwelle ~= nil and schritt ~= nil and schritt > 0 then
while cur_kk < schwelle do
tp.num = tp.num - 1
cur_kk = cur_kk + schritt
end
while cur_kk >= schwelle + schritt do
tp.num = tp.num + 1
cur_kk = cur_kk - schritt
end
tp.num = tp.num + common.div_trunc(cur_kk - schwelle, schritt)
end
return tp
end

return common
return common
10 changes: 3 additions & 7 deletions src/kampfbogen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ local function atpa_mod(basis, talent, schwelle, schritt, wm, art, spez)
local val = basis
local cur_kk = data:cur("KK")
if cur_kk ~= "" and schwelle ~= nil and schritt ~= nil and schritt > 0 then
while cur_kk < schwelle do
val = val - 1
cur_kk = cur_kk + schritt
end
val = val + common.div_trunc(cur_kk - schwelle, schritt)
end
if art ~= nil and spez ~= nil then
for _, s in ipairs(spez) do
Expand Down Expand Up @@ -151,8 +148,7 @@ nahkampf_render[3]= {false, function(v, talent, ebe)
end
end}
nahkampf_render[5]= {true, function(v)
local tp = common.schaden.parse(v)
common.schaden.render(tp)
common.schaden.render(common.schaden.parse(v))
end}
for i=8,10 do
nahkampf_render[i] = {true, common.render_delta}
Expand Down Expand Up @@ -445,4 +441,4 @@ function kampfbogen.ini()
end
end

return kampfbogen
return kampfbogen
4 changes: 2 additions & 2 deletions src/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ function schema.Notizen.example(printer)
end

local Tier = d.Row:def({name = "Tier", description = "Werte eines Tiers."},
{"Name", String}, {"Art", String, ""}, {"INI", OptNum, {}}, {"AT", OptNum, {}}, {"PA", OptNum, {}}, {"TP", Schaden, ""}, {"LE", OptNum, {}}, {"RS", OptNum, {}}, {"KO", OptNum, {}}, {"KO", OptNum, {}}, {"GS", OptNum, {}}, {"AU", OptNum, {}}, {"MR", OptNum, {}}, {"LO", OptNum, {}}, {"TK", OptNum, {}}, {"ZK", OptNum, {}})
{"Name", String}, {"Art", String, ""}, {"INI", OptNum, {}}, {"AT", OptNum, {}}, {"PA", OptNum, {}}, {"TP", Schaden, ""}, {"LE", OptNum, {}}, {"RS", OptNum, {}}, {"KO", OptNum, {}}, {"GS", OptNum, {}}, {"AU", OptNum, {}}, {"MR", OptNum, {}}, {"LO", OptNum, {}}, {"TK", OptNum, {}}, {"ZK", OptNum, {}})
d:singleton(d.List, {name = "Tiere", description = "Liste von Tieren."}, {Tier})
function schema.Tiere.example(printer)

Expand Down Expand Up @@ -907,4 +907,4 @@ function schema.Ereignisse.example(printer)
}]])
end

return schema
return schema
Loading