Skip to content

Commit

Permalink
Merge pull request #1204 from myk002/myk_unit_syndromes
Browse files Browse the repository at this point in the history
[gui/unit-syndromes] canonicalize fields and make werecreature searchable
  • Loading branch information
myk002 authored Jun 24, 2024
2 parents e9dc66e + 751d68e commit 458ed20
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Template for new versions:
- `gui/control-panel`: highlight prefrences that have been changed from the defaults
- `gui/quickfort`: buildings can now be constructed in a "high priority" state, giving them first dibs on `buildingplan` materials and setting their construction jobs to the highest priority
- `prioritize`: add ``ButcherAnimal`` to the default prioritization list (``SlaughterAnimal`` was already there, but ``ButcherAnimal`` -- which is different -- was missing)
- `gui/unit-syndromes`: make werecreature syndromes easier to search for

## Removed
- `max-wave`: merged into `pop-control`
Expand Down
30 changes: 15 additions & 15 deletions gui/unit-syndromes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ end

local function getEffectCreatureName(effect)
if effect.race_str == "" then
return "UNKNOWN"
return "unknown"
end

local creature = df.global.world.raws.creatures.all[effect.race[0]]

if effect.caste_str == "DEFAULT" then
return ("%s%s"):format(string.upper(creature.name[0]), (", %s"):format(effect.caste_str))
return creature.name[0]
else
-- TODO: Caste seems to be entirely unused.
local caste = creature.caste[effect.caste[0]]

return ("%s%s"):format(string.upper(creature.name[0]), (", %s"):format(string.upper(caste.name[0])))
return ("%s%s"):format(creature.name[0], (", %s"):format(caste.name[0]))
end
end

Expand Down Expand Up @@ -178,11 +178,11 @@ local EffectFlagDescription = {
return ("ABILITY: %s"):format(getEffectInteraction(effect))
end,
[df.creature_interaction_effect_type.SKILL_ROLL_ADJUST] = function(effect)
return ("MODIFIER=%s, CHANGE=%s"):format(effect.multiplier, effect.chance)
return ("MODIFIER=%s, CHANCE=%s"):format(effect.multiplier, effect.prob)
end,
[df.creature_interaction_effect_type.BODY_TRANSFORMATION] = function(effect)
if effect.chance > 0 then
return ("%s, CHANCE=%s%%"):format(getEffectCreatureName(effect), effect.chance)
if effect.prob > 0 then
return ("%s, CHANCE=%s%%"):format(getEffectCreatureName(effect), effect.prob)
else
return getEffectCreatureName(effect)
end
Expand Down Expand Up @@ -235,20 +235,20 @@ local function getEffectDescription(effect)
end

local function getSyndromeName(syndrome_raw)
local is_transformation = false
local transform_creature_name

for _, effect in pairs(syndrome_raw.ce) do
for _, effect in ipairs(syndrome_raw.ce) do
if df.creature_interaction_effect_body_transformationst:is_instance(effect) then
is_transformation = true
transform_creature_name = getEffectCreatureName(effect)
elseif df.creature_interaction_effect_display_namest:is_instance(effect) then
return effect.name:gsub("^%l", string.upper)
end
end

if syndrome_raw.syn_name ~= "" then
return syndrome_raw.syn_name:gsub("^%l", string.upper)
elseif is_transformation then
return "Body transformation"
elseif transform_creature_name then
return ("Body transformation: %s"):format(transform_creature_name)
end

return "Mystery"
Expand All @@ -258,7 +258,7 @@ local function getSyndromeEffects(syndrome_type)
local syndrome_raw = df.global.world.raws.syndromes.all[syndrome_type]
local syndrome_effects = {}

for _, effect in pairs(syndrome_raw.ce) do
for _, effect in ipairs(syndrome_raw.ce) do
table.insert(syndrome_effects, effect)
end

Expand All @@ -270,7 +270,7 @@ local function getSyndromeDescription(syndrome_raw, syndrome)
local syndrome_min_duration = nil
local syndrome_max_duration = nil

for _, effect in pairs(syndrome_raw.ce) do
for _, effect in ipairs(syndrome_raw.ce) do
syndrome_min_duration = math.min(syndrome_min_duration or effect["end"], effect["end"])
syndrome_max_duration = math.max(syndrome_max_duration or effect["end"], effect["end"])
end
Expand Down Expand Up @@ -354,9 +354,9 @@ end
UnitSyndromes = defclass(UnitSyndromes, widgets.Window)
UnitSyndromes.ATTRS {
frame_title='Unit Syndromes',
frame={w=50, h=30},
frame={w=54, h=30},
resizable=true,
resize_min={h=20},
resize_min={w=30, h=20},
}

function UnitSyndromes:init()
Expand Down

0 comments on commit 458ed20

Please sign in to comment.