Skip to content

Commit

Permalink
resolve #69
Browse files Browse the repository at this point in the history
  • Loading branch information
egocarib committed Jan 19, 2024
1 parent a1e2e27 commit 135f3c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 51 deletions.
44 changes: 0 additions & 44 deletions hagadias/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,47 +552,3 @@
"WalltrapGas": {"IsEMPSensitive": True, "IsPowerLoadSensitive": False},
"WalltrapShock": {"IsEMPSensitive": True, "IsPowerLoadSensitive": False},
}
# The 'Butcherable' part can contain a population tables reference if it begins with an '@' symbol.
# One day, we could potentially replace this if we start loading data from PopulationTables.xml.
BUTCHERABLE_POPTABLES = {
"Eyeless Crab Corpse": {
"Eyeless Crab Legs": {"Number": 1, "Weight": 95},
"EyelessCrabShell": {"Number": 1, "Weight": 5},
},
"Knollworm Corpse": {
"Raw Worm Meat": {"Number": 1, "Weight": 98},
"Knollworm Skull": {"Number": 1, "Weight": 2},
},
"Albino ape corpse": {
"Albino Ape Heart": {"Number": 1, "Weight": 20},
"Ape Fur Cloak": {"Number": 1, "Weight": 13},
"Ape Fur Hat": {"Number": 1, "Weight": 13},
"Ape Fur Gloves": {"Number": 1, "Weight": 13},
"Albino Ape Pelt": {"Number": 1, "Weight": 40},
},
"Ogre ape corpse": {
"Ogre Ape Heart": {"Number": 1, "Weight": 20},
"Ogre Fur Cloak": {"Number": 1, "Weight": 13},
"Ogre Fur Hat": {"Number": 1, "Weight": 13},
"Ogre Fur Gloves": {"Number": 1, "Weight": 13},
"Ogre Ape Pelt": {"Number": 1, "Weight": 40},
},
"Salthopper Corpse": {
"Salthopper Chip": {"Number": 1, "Weight": 85},
"SalthopperMandible": {"Number": 1, "Weight": 15},
},
"Quartz Baboon Corpse": {
"Quartzfur Hat": {"Number": 1, "Weight": 20},
"Quartzfur Cloak": {"Number": 1, "Weight": 20},
"Quartzfur Gloves": {"Number": 1, "Weight": 20},
},
"Kaleidoslug Corpse": {
"Kaleidocera Cape": {"Number": 1, "Weight": 20},
"Kaleidocera Muffs": {"Number": 1, "Weight": 20},
"Kaleidocera Krakows": {"Number": 1, "Weight": 20},
},
"Enigma Snail Corpse": {
"Enigma Cone": {"Number": 1, "Weight": 20},
"Enigma Cap": {"Number": 1, "Weight": 20},
},
}
24 changes: 17 additions & 7 deletions hagadias/qudobject_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
CHARGE_USE_REASONS,
ACTIVE_PARTS,
STAT_DISPLAY_NAMES,
BUTCHERABLE_POPTABLES,
CHERUBIM_DESC,
MECHANICAL_CHERUBIM_DESC,
)
Expand Down Expand Up @@ -400,15 +399,26 @@ def butcheredinto(self) -> List[dict] | None:
"""What a corpse item can be butchered into."""
butcher_obj = self.part_Butcherable_OnSuccess
if butcher_obj:
if butcher_obj[:1] == "@":
if butcher_obj[1:] not in BUTCHERABLE_POPTABLES:
log.error("Butcherable poptable %s not recognized.", butcher_obj)
if butcher_obj[:1] != "@":
return [{"Object": butcher_obj, "Number": 1, "Weight": 100}]
pop_name = butcher_obj[1:]
pop: QudPopulation = self.gameroot.get_populations().get(pop_name)
if pop is not None and len(pop.get_effective_children()) > 0:
if (
pop.depth > 1
or pop.style == "pickeach"
or any(item.type != "object" for item in pop.get_effective_children())
):
# complex pop - requires additional logic (butcherables don't currently use)
log.error("Butcherable poptable %s requires complex processing", butcher_obj)
else:
outcomes = []
for butcherable, info in BUTCHERABLE_POPTABLES[butcher_obj[1:]].items():
outcomes.append({**{"Object": butcherable}, **info})
for pop_item in pop.get_effective_children():
num = pop_item.number
wgt = pop_item.weight
obj = pop_item.blueprint
outcomes.append({"Object": obj, "Number": num, "Weight": wgt})
return outcomes
return [{"Object": butcher_obj, "Number": 1, "Weight": 100}]

@cached_property
def canbuild(self) -> bool | None:
Expand Down

0 comments on commit 135f3c8

Please sign in to comment.