Magic number reduction: Job types

develop
Eric Wald 2014-05-04 15:02:12 -06:00
parent 2d5f7e4022
commit bdb22235af
1 changed files with 189 additions and 172 deletions

@ -19,6 +19,12 @@ triggers = {
{name = "Never"}, {name = "Never"},
} }
-- There must be a better way get the value of an enum.
job_types = {}
for key, value in ipairs(df.job_type) do
job_types[value] = key
end
entry_ints = { entry_ints = {
stockpile_id = 1, stockpile_id = 1,
order_number = 2, order_number = 2,
@ -197,11 +203,11 @@ end
function clothing_reactions(reactions, mat_info, filter) function clothing_reactions(reactions, mat_info, filter)
local resources = df.global.world.entities.all[df.global.ui.civ_id].resources local resources = df.global.world.entities.all[df.global.ui.civ_id].resources
local itemdefs = df.global.world.raws.itemdefs local itemdefs = df.global.world.raws.itemdefs
resource_reactions(reactions, 101, mat_info, resources.armor_type, itemdefs.armor, {permissible = filter}) resource_reactions(reactions, job_types.MakeArmor, mat_info, resources.armor_type, itemdefs.armor, {permissible = filter})
resource_reactions(reactions, 103, mat_info, resources.pants_type, itemdefs.pants, {permissible = filter}) resource_reactions(reactions, job_types.MakePants, mat_info, resources.pants_type, itemdefs.pants, {permissible = filter})
resource_reactions(reactions, 117, mat_info, resources.gloves_type, itemdefs.gloves, {permissible = filter}) resource_reactions(reactions, job_types.MakeGloves, mat_info, resources.gloves_type, itemdefs.gloves, {permissible = filter})
resource_reactions(reactions, 102, mat_info, resources.helm_type, itemdefs.helms, {permissible = filter}) resource_reactions(reactions, job_types.MakeHelm, mat_info, resources.helm_type, itemdefs.helms, {permissible = filter})
resource_reactions(reactions, 118, mat_info, resources.shoes_type, itemdefs.shoes, {permissible = filter}) resource_reactions(reactions, job_types.MakeShoes, mat_info, resources.shoes_type, itemdefs.shoes, {permissible = filter})
end end
-- Find the reaction types that should be listed in the management interface. -- Find the reaction types that should be listed in the management interface.
@ -230,10 +236,12 @@ function collect_reactions()
materials.tooth.adjective = "ivory/tooth" materials.tooth.adjective = "ivory/tooth"
materials.leather.clothing_flag = "LEATHER" materials.leather.clothing_flag = "LEATHER"
local jobs = {12, 22, 219, 31, 32} -- Collection and Entrapment
for _, job_id in ipairs(jobs) do table.insert(result, reaction_entry(job_types.CollectWebs))
table.insert(result, reaction_entry(job_id)) table.insert(result, reaction_entry(job_types.CollectSand))
end table.insert(result, reaction_entry(job_types.CollectClay))
table.insert(result, reaction_entry(job_types.CatchLiveLandAnimal))
table.insert(result, reaction_entry(job_types.CatchLiveFish))
-- Cutting, encrusting, and metal extraction. -- Cutting, encrusting, and metal extraction.
local rock_types = df.global.world.raws.inorganics local rock_types = df.global.world.raws.inorganics
@ -241,21 +249,24 @@ function collect_reactions()
local material = rock_types[rock_id].material local material = rock_types[rock_id].material
local rock_name = material.state_adj.Solid local rock_name = material.state_adj.Solid
if material.flags.IS_STONE or material.flags.IS_GEM then if material.flags.IS_STONE or material.flags.IS_GEM then
table.insert(result, reaction_entry(85, {mat_type = 0, mat_index = rock_id}, "Cut "..rock_name)) table.insert(result, reaction_entry(job_types.CutGems, {
mat_type = 0,
mat_index = rock_id,
}, "Cut "..rock_name))
table.insert(result, reaction_entry(87, { table.insert(result, reaction_entry(job_types.EncrustWithGems, {
mat_type = 0, mat_type = 0,
mat_index = rock_id, mat_index = rock_id,
item_category = {finished_goods = true}, item_category = {finished_goods = true},
}, "Encrust Finished Goods With "..rock_name)) }, "Encrust Finished Goods With "..rock_name))
table.insert(result, reaction_entry(87, { table.insert(result, reaction_entry(job_types.EncrustWithGems, {
mat_type = 0, mat_type = 0,
mat_index = rock_id, mat_index = rock_id,
item_category = {furniture = true}, item_category = {furniture = true},
}, "Encrust Furniture With "..rock_name)) }, "Encrust Furniture With "..rock_name))
table.insert(result, reaction_entry(87, { table.insert(result, reaction_entry(job_types.EncrustWithGems, {
mat_type = 0, mat_type = 0,
mat_index = rock_id, mat_index = rock_id,
item_category = {ammo = true}, item_category = {ammo = true},
@ -263,11 +274,11 @@ function collect_reactions()
end end
if #rock_types[rock_id].metal_ore.mat_index > 0 then if #rock_types[rock_id].metal_ore.mat_index > 0 then
table.insert(result, reaction_entry(90, {mat_type = 0, mat_index = rock_id}, "Smelt "..rock_name.." Ore")) table.insert(result, reaction_entry(job_types.SmeltOre, {mat_type = 0, mat_index = rock_id}, "Smelt "..rock_name.." Ore"))
end end
if #rock_types[rock_id].thread_metal.mat_index > 0 then if #rock_types[rock_id].thread_metal.mat_index > 0 then
table.insert(result, reaction_entry(92, {mat_type = 0, mat_index = rock_id})) table.insert(result, reaction_entry(job_types.ExtractMetalStrands, {mat_type = 0, mat_index = rock_id}))
end end
end end
@ -285,19 +296,19 @@ function collect_reactions()
management = {mat_type = glass_id}, management = {mat_type = glass_id},
}) })
table.insert(result, reaction_entry(86, {mat_type = glass_id}, "Cut "..glass_name)) table.insert(result, reaction_entry(job_types.CutGlass, {mat_type = glass_id}, "Cut "..glass_name))
table.insert(result, reaction_entry(88, { table.insert(result, reaction_entry(job_types.EncrustWithGlass, {
mat_type = glass_id, mat_type = glass_id,
item_category = {finished_goods = true}, item_category = {finished_goods = true},
}, "Encrust Finished Goods With "..glass_name)) }, "Encrust Finished Goods With "..glass_name))
table.insert(result, reaction_entry(88, { table.insert(result, reaction_entry(job_types.EncrustWithGlass, {
mat_type = glass_id, mat_type = glass_id,
item_category = {furniture = true}, item_category = {furniture = true},
}, "Encrust Furniture With "..glass_name)) }, "Encrust Furniture With "..glass_name))
table.insert(result, reaction_entry(88, { table.insert(result, reaction_entry(job_types.EncrustWithGlass, {
mat_type = glass_id, mat_type = glass_id,
item_category = {ammo = true}, item_category = {ammo = true},
}, "Encrust Ammo With "..glass_name)) }, "Encrust Ammo With "..glass_name))
@ -305,48 +316,54 @@ function collect_reactions()
end end
-- Dyeing -- Dyeing
table.insert(result, reaction_entry(192)) table.insert(result, reaction_entry(job_types.DyeThread))
table.insert(result, reaction_entry(193)) table.insert(result, reaction_entry(job_types.DyeCloth))
-- Sew Image -- Sew Image
cloth_mats = {materials.cloth, materials.silk, materials.yarn, materials.leather} cloth_mats = {materials.cloth, materials.silk, materials.yarn, materials.leather}
for _, material in ipairs(cloth_mats) do for _, material in ipairs(cloth_mats) do
material_reactions(result, {{194, "Sew", "Image"}}, material) material_reactions(result, {{job_types.SewImage, "Sew", "Image"}}, material)
end end
for _, spec in ipairs{materials.bone, materials.shell, materials.tooth, materials.horn, materials.pearl} do for _, spec in ipairs{materials.bone, materials.shell, materials.tooth, materials.horn, materials.pearl} do
material_reactions(result, {{132, "Decorate With"}}, spec) material_reactions(result, {{job_types.DecorateWith, "Decorate With"}}, spec)
end end
-- Make Totem table.insert(result, reaction_entry(job_types.MakeTotem))
table.insert(result, reaction_entry(130)) table.insert(result, reaction_entry(job_types.ButcherAnimal))
-- Butcher an Animal table.insert(result, reaction_entry(job_types.MillPlants))
table.insert(result, reaction_entry(105)) table.insert(result, reaction_entry(job_types.MakePotashFromLye))
-- Mill Plants table.insert(result, reaction_entry(job_types.MakePotashFromAsh))
table.insert(result, reaction_entry(107))
-- Make Potash From Lye
table.insert(result, reaction_entry(189))
-- Make Potash From Ash
table.insert(result, reaction_entry(191))
-- Kitchen -- Kitchen
table.insert(result, reaction_entry(115, {mat_type = 2}, "Prepare Easy Meal")) table.insert(result, reaction_entry(job_types.PrepareMeal, {mat_type = 2}, "Prepare Easy Meal"))
table.insert(result, reaction_entry(115, {mat_type = 3}, "Prepare Fine Meal")) table.insert(result, reaction_entry(job_types.PrepareMeal, {mat_type = 3}, "Prepare Fine Meal"))
table.insert(result, reaction_entry(115, {mat_type = 4}, "Prepare Lavish Meal")) table.insert(result, reaction_entry(job_types.PrepareMeal, {mat_type = 4}, "Prepare Lavish Meal"))
-- Brew Drink -- Brew Drink
table.insert(result, reaction_entry(150)) table.insert(result, reaction_entry(job_types.BrewDrink))
-- Weaving -- Weaving
table.insert(result, reaction_entry(116, {material_category = {plant = true}}, "Weave Thread into Cloth")) table.insert(result, reaction_entry(job_types.WeaveCloth, {material_category = {plant = true}}, "Weave Thread into Cloth"))
table.insert(result, reaction_entry(116, {material_category = {silk = true}}, "Weave Thread into Silk")) table.insert(result, reaction_entry(job_types.WeaveCloth, {material_category = {silk = true}}, "Weave Thread into Silk"))
table.insert(result, reaction_entry(116, {material_category = {yarn = true}}, "Weave Yarn into Cloth")) table.insert(result, reaction_entry(job_types.WeaveCloth, {material_category = {yarn = true}}, "Weave Yarn into Cloth"))
-- Extracts, farmer's workshop, and wood burning -- Extracts, farmer's workshop, and wood burning
local jobs = {151, 152, 153, 106, 110, 109, 214, 215, 188, 111, 112, 113, 114, 186, 187} table.insert(result, reaction_entry(job_types.ExtractFromPlants))
for _, job_id in ipairs(jobs) do table.insert(result, reaction_entry(job_types.ExtractFromRawFish))
table.insert(result, reaction_entry(job_id)) table.insert(result, reaction_entry(job_types.ExtractFromLandAnimal))
end table.insert(result, reaction_entry(job_types.PrepareRawFish))
table.insert(result, reaction_entry(job_types.MakeCheese))
table.insert(result, reaction_entry(job_types.MilkCreature))
table.insert(result, reaction_entry(job_types.ShearCreature))
table.insert(result, reaction_entry(job_types.SpinThread))
table.insert(result, reaction_entry(job_types.MakeLye))
table.insert(result, reaction_entry(job_types.ProcessPlants))
table.insert(result, reaction_entry(job_types.ProcessPlantsBag))
table.insert(result, reaction_entry(job_types.ProcessPlantsVial))
table.insert(result, reaction_entry(job_types.ProcessPlantsBarrel))
table.insert(result, reaction_entry(job_types.MakeCharcoal))
table.insert(result, reaction_entry(job_types.MakeAsh))
-- Reactions defined in the raws. -- Reactions defined in the raws.
-- Not all reactions are allowed to the civilization. -- Not all reactions are allowed to the civilization.
@ -355,7 +372,7 @@ function collect_reactions()
for _, reaction_id in ipairs(entity.entity_raw.workshops.permitted_reaction_id) do for _, reaction_id in ipairs(entity.entity_raw.workshops.permitted_reaction_id) do
local reaction = df.global.world.raws.reactions[reaction_id] local reaction = df.global.world.raws.reactions[reaction_id]
local name = string.gsub(reaction.name, "^.", string.upper) local name = string.gsub(reaction.name, "^.", string.upper)
table.insert(result, reaction_entry(211, {reaction_name = reaction.code}, name)) table.insert(result, reaction_entry(job_types.CustomReaction, {reaction_name = reaction.code}, name))
end end
-- Metal forging -- Metal forging
@ -370,52 +387,52 @@ function collect_reactions()
} }
if material.flags.IS_METAL then if material.flags.IS_METAL then
table.insert(result, reaction_entry(104, mat_flags.management, "Stud With "..rock_name)) table.insert(result, reaction_entry(job_types.StudWith, mat_flags.management, "Stud With "..rock_name))
if material.flags.ITEMS_WEAPON then if material.flags.ITEMS_WEAPON then
-- Todo: Are these really the right flags to check? -- Todo: Are these really the right flags to check?
resource_reactions(result, 97, mat_flags, entity.resources.weapon_type, itemdefs.weapons, { resource_reactions(result, job_types.MakeWeapon, mat_flags, entity.resources.weapon_type, itemdefs.weapons, {
permissible = (function(itemdef) return itemdef.skill_ranged == -1 end), permissible = (function(itemdef) return itemdef.skill_ranged == -1 end),
}) })
-- Is this entirely disconnected from the entity? -- Is this entirely disconnected from the entity?
material_reactions(result, {{135, "Forge", "Ballista Arrow Head"}}, mat_flags) material_reactions(result, {{MakeBallistaArrowHead, "Forge", "Ballista Arrow Head"}}, mat_flags)
resource_reactions(result, 142, mat_flags, entity.resources.trapcomp_type, itemdefs.trapcomps, { resource_reactions(result, job_types.MakeTrapComponent, mat_flags, entity.resources.trapcomp_type, itemdefs.trapcomps, {
adjective = true, adjective = true,
}) })
resource_reactions(result, 136, mat_flags, entity.resources.siegeammo_type, itemdefs.siege_ammo, { resource_reactions(result, job_types.AssembleSiegeAmmo, mat_flags, entity.resources.siegeammo_type, itemdefs.siege_ammo, {
verb = "Assemble", verb = "Assemble",
}) })
end end
if material.flags.ITEMS_WEAPON_RANGED then if material.flags.ITEMS_WEAPON_RANGED then
resource_reactions(result, 97, mat_flags, entity.resources.weapon_type, itemdefs.weapons, { resource_reactions(result, job_types.MakeWeapon, mat_flags, entity.resources.weapon_type, itemdefs.weapons, {
permissible = (function(itemdef) return itemdef.skill_ranged >= 0 end), permissible = (function(itemdef) return itemdef.skill_ranged >= 0 end),
}) })
end end
if material.flags.ITEMS_DIGGER then if material.flags.ITEMS_DIGGER then
-- Todo: Ranged or training digging weapons? -- Todo: Ranged or training digging weapons?
resource_reactions(result, 97, mat_flags, entity.resources.digger_type, itemdefs.weapons, { resource_reactions(result, job_types.MakeWeapon, mat_flags, entity.resources.digger_type, itemdefs.weapons, {
}) })
end end
if material.flags.ITEMS_AMMO then if material.flags.ITEMS_AMMO then
resource_reactions(result, 131, mat_flags, entity.resources.ammo_type, itemdefs.ammo, { resource_reactions(result, job_types.MakeAmmo, mat_flags, entity.resources.ammo_type, itemdefs.ammo, {
name_field = "name_plural", name_field = "name_plural",
}) })
end end
if material.flags.ITEMS_ANVIL then if material.flags.ITEMS_ANVIL then
material_reactions(result, {{98, "Forge", "Anvil"}}, mat_flags) material_reactions(result, {{job_types.ForgeAnvil, "Forge", "Anvil"}}, mat_flags)
end end
if material.flags.ITEMS_ARMOR then if material.flags.ITEMS_ARMOR then
local metalclothing = (function(itemdef) return itemdef.props.flags.METAL end) local metalclothing = (function(itemdef) return itemdef.props.flags.METAL end)
clothing_reactions(result, mat_flags, metalclothing) clothing_reactions(result, mat_flags, metalclothing)
resource_reactions(result, 119, mat_flags, entity.resources.shield_type, itemdefs.shields, { resource_reactions(result, job_types.MakeShield, mat_flags, entity.resources.shield_type, itemdefs.shields, {
}) })
end end
@ -425,14 +442,14 @@ function collect_reactions()
end end
if material.flags.ITEMS_HARD then if material.flags.ITEMS_HARD then
resource_reactions(result, 218, mat_flags, entity.resources.tool_type, itemdefs.tools, { resource_reactions(result, job_types.MakeTool, mat_flags, entity.resources.tool_type, itemdefs.tools, {
permissible = (function(itemdef) return itemdef.flags.HARD_MAT end), permissible = (function(itemdef) return itemdef.flags.HARD_MAT end),
capitalize = true, capitalize = true,
}) })
end end
if material.flags.ITEMS_METAL then if material.flags.ITEMS_METAL then
resource_reactions(result, 218, mat_flags, entity.resources.tool_type, itemdefs.tools, { resource_reactions(result, job_types.MakeTool, mat_flags, entity.resources.tool_type, itemdefs.tools, {
permissible = (function(itemdef) return itemdef.flags.METAL_MAT end), permissible = (function(itemdef) return itemdef.flags.METAL_MAT end),
capitalize = true, capitalize = true,
}) })
@ -440,198 +457,198 @@ function collect_reactions()
if material.flags.ITEMS_HARD then if material.flags.ITEMS_HARD then
material_reactions(result, { material_reactions(result, {
{69, "Construct", "Door"}, {job_types.ConstructDoor, "Construct", "Door"},
{70, "Construct", "Floodgate"}, {job_types.ConstructFloodgate, "Construct", "Floodgate"},
{200, "Construct", "Hatch Cover"}, {job_types.ConstructHatchCover, "Construct", "Hatch Cover"},
{201, "Construct", "Grate"}, {job_types.ConstructGrate, "Construct", "Grate"},
{72, "Construct", "Throne"}, {job_types.ConstructThrone, "Construct", "Throne"},
{73, "Construct", "Sarcophagus"}, {job_types.ConstructCoffin, "Construct", "Sarcophagus"},
{74, "Construct", "Table"}, {job_types.ConstructTable, "Construct", "Table"},
{205, "Construct", "Splint"}, {job_types.ConstructSplint, "Construct", "Splint"},
{206, "Construct", "Crutch"}, {job_types.ConstructCrutch, "Construct", "Crutch"},
{77, "Construct", "Armor Stand"}, {job_types.ConstructArmorStand, "Construct", "Armor Stand"},
{78, "Construct", "Weapon Rack"}, {job_types.ConstructWeaponRack, "Construct", "Weapon Rack"},
{79, "Construct", "Cabinet"}, {job_types.ConstructCabinet, "Construct", "Cabinet"},
{123, "Forge", "Goblet"}, {job_types.MakeGoblet, "Forge", "Goblet"},
{124, "Forge", "Instrument"}, {job_types.MakeInstrument, "Forge", "Instrument"},
{125, "Forge", "Toy"}, {job_types.MakeToy, "Forge", "Toy"},
{80, "Construct", "Statue"}, {job_types.ConstructStatue, "Construct", "Statue"},
{81, "Construct", "Blocks"}, {job_types.ConstructBlocks, "Construct", "Blocks"},
{126, "Forge", "Animal Trap"}, {job_types.MakeAnimalTrap, "Forge", "Animal Trap"},
{127, "Forge", "Barrel"}, {job_types.MakeBarrel, "Forge", "Barrel"},
{128, "Forge", "Bucket"}, {job_types.MakeBucket, "Forge", "Bucket"},
{76, "Construct", "Bin"}, {job_types.ConstructBin, "Construct", "Bin"},
{195, "Forge", "Pipe Section"}, {job_types.MakePipeSection, "Forge", "Pipe Section"},
{120, "Forge", "Cage"}, {job_types.MakeCage, "Forge", "Cage"},
{84, "Mint", "Coins"}, {job_types.MintCoins, "Mint", "Coins"},
{75, "Construct", "Chest"}, {job_types.ConstructChest, "Construct", "Chest"},
{122, "Forge", "Flask"}, {job_types.MakeFlask, "Forge", "Flask"},
{121, "Forge", "Chain"}, {job_types.MakeChain, "Forge", "Chain"},
{83, "Make", "Crafts"}, {job_types.MakeCrafts, "Make", "Crafts"},
}, mat_flags) }, mat_flags)
end end
if material.flags.ITEMS_SOFT then if material.flags.ITEMS_SOFT then
material_reactions(result, { material_reactions(result, {
{133, "Make", "Backpack"}, {job_types.MakeBackpack, "Make", "Backpack"},
{134, "Make", "Quiver"}, {job_types.MakeQuiver, "Make", "Quiver"},
{99, "Construct", "Catapult Parts"}, {job_types.ConstructCatapultParts, "Construct", "Catapult Parts"},
{100, "Construct", "Ballista Parts"}, {job_types.ConstructBallistaParts, "Construct", "Ballista Parts"},
}, mat_flags) }, mat_flags)
end end
end end
end end
-- Traction Bench -- Traction Bench
table.insert(result, reaction_entry(207)) table.insert(result, reaction_entry(job_types.ConstructTractionBench))
-- Non-metal weapons -- Non-metal weapons
resource_reactions(result, 97, materials.wood, entity.resources.weapon_type, itemdefs.weapons, { resource_reactions(result, job_types.MakeWeapon, materials.wood, entity.resources.weapon_type, itemdefs.weapons, {
permissible = (function(itemdef) return itemdef.skill_ranged >= 0 end), permissible = (function(itemdef) return itemdef.skill_ranged >= 0 end),
}) })
resource_reactions(result, 97, materials.wood, entity.resources.training_weapon_type, itemdefs.weapons, { resource_reactions(result, job_types.MakeWeapon, materials.wood, entity.resources.training_weapon_type, itemdefs.weapons, {
}) })
resource_reactions(result, 97, materials.bone, entity.resources.weapon_type, itemdefs.weapons, { resource_reactions(result, job_types.MakeWeapon, materials.bone, entity.resources.weapon_type, itemdefs.weapons, {
permissible = (function(itemdef) return itemdef.skill_ranged >= 0 end), permissible = (function(itemdef) return itemdef.skill_ranged >= 0 end),
}) })
resource_reactions(result, 97, materials.rock, entity.resources.weapon_type, itemdefs.weapons, { resource_reactions(result, job_types.MakeWeapon, materials.rock, entity.resources.weapon_type, itemdefs.weapons, {
permissible = (function(itemdef) return itemdef.flags.CAN_STONE end), permissible = (function(itemdef) return itemdef.flags.CAN_STONE end),
}) })
-- Wooden items -- Wooden items
-- Closely related to the ITEMS_HARD list. -- Closely related to the ITEMS_HARD list.
material_reactions(result, { material_reactions(result, {
{69, "Construct", "Door"}, {job_types.ConstructDoor, "Construct", "Door"},
{70, "Construct", "Floodgate"}, {job_types.ConstructFloodgate, "Construct", "Floodgate"},
{200, "Construct", "Hatch Cover"}, {job_types.ConstructHatchCover, "Construct", "Hatch Cover"},
{201, "Construct", "Grate"}, {job_types.ConstructGrate, "Construct", "Grate"},
{72, "Construct", "Chair"}, {job_types.ConstructThrone, "Construct", "Chair"},
{73, "Construct", "Casket"}, {job_types.ConstructCoffin, "Construct", "Casket"},
{74, "Construct", "Table"}, {job_types.ConstructTable, "Construct", "Table"},
{77, "Construct", "Armor Stand"}, {job_types.ConstructArmorStand, "Construct", "Armor Stand"},
{78, "Construct", "Weapon Rack"}, {job_types.ConstructWeaponRack, "Construct", "Weapon Rack"},
{79, "Construct", "Cabinet"}, {job_types.ConstructCabinet, "Construct", "Cabinet"},
{123, "Make", "Cup"}, {job_types.MakeGoblet, "Make", "Cup"},
{124, "Make", "Instrument"}, {job_types.MakeInstrument, "Make", "Instrument"},
}, materials.wood) }, materials.wood)
resource_reactions(result, 218, materials.wood, entity.resources.tool_type, itemdefs.tools, { resource_reactions(result, job_types.MakeTool, materials.wood, entity.resources.tool_type, itemdefs.tools, {
-- permissible = (function(itemdef) return itemdef.flags.WOOD_MAT end), -- permissible = (function(itemdef) return itemdef.flags.WOOD_MAT end),
capitalize = true, capitalize = true,
}) })
material_reactions(result, { material_reactions(result, {
{125, "Make", "Toy"}, {job_types.MakeToy, "Make", "Toy"},
{81, "Construct", "Blocks"}, {job_types.ConstructBlocks, "Construct", "Blocks"},
{205, "Construct", "Splint"}, {job_types.ConstructSplint, "Construct", "Splint"},
{206, "Construct", "Crutch"}, {job_types.ConstructCrutch, "Construct", "Crutch"},
{126, "Make", "Animal Trap"}, {job_types.MakeAnimalTrap, "Make", "Animal Trap"},
{127, "Make", "Barrel"}, {job_types.MakeBarrel, "Make", "Barrel"},
{128, "Make", "Bucket"}, {job_types.MakeBucket, "Make", "Bucket"},
{76, "Construct", "Bin"}, {job_types.ConstructBin, "Construct", "Bin"},
{120, "Make", "Cage"}, {job_types.MakeCage, "Make", "Cage"},
{195, "Make", "Pipe Section"}, {job_types.MakePipeSection, "Make", "Pipe Section"},
}, materials.wood) }, materials.wood)
resource_reactions(result, 142, materials.wood, entity.resources.trapcomp_type, itemdefs.trapcomps, { resource_reactions(result, job_types.MakeTrapComponent, materials.wood, entity.resources.trapcomp_type, itemdefs.trapcomps, {
permissible = (function(itemdef) return itemdef.flags.WOOD end), permissible = (function(itemdef) return itemdef.flags.WOOD end),
adjective = true, adjective = true,
}) })
-- Rock items -- Rock items
material_reactions(result, { material_reactions(result, {
{69, "Construct", "Door"}, {job_types.ConstructDoor, "Construct", "Door"},
{70, "Construct", "Floodgate"}, {job_types.ConstructFloodgate, "Construct", "Floodgate"},
{200, "Construct", "Hatch Cover"}, {job_types.ConstructHatchCover, "Construct", "Hatch Cover"},
{201, "Construct", "Grate"}, {job_types.ConstructGrate, "Construct", "Grate"},
{72, "Construct", "Throne"}, {job_types.ConstructThrone, "Construct", "Throne"},
{73, "Construct", "Coffin"}, {job_types.ConstructCoffin, "Construct", "Coffin"},
{74, "Construct", "Table"}, {job_types.ConstructTable, "Construct", "Table"},
{77, "Construct", "Armor Stand"}, {job_types.ConstructArmorStand, "Construct", "Armor Stand"},
{78, "Construct", "Weapon Rack"}, {job_types.ConstructWeaponRack, "Construct", "Weapon Rack"},
{79, "Construct", "Cabinet"}, {job_types.ConstructCabinet, "Construct", "Cabinet"},
{123, "Make", "Mug"}, {job_types.MakeGoblet, "Make", "Mug"},
{124, "Make", "Instrument"}, {job_types.MakeInstrument, "Make", "Instrument"},
}, materials.rock) }, materials.rock)
resource_reactions(result, 218, materials.rock, entity.resources.tool_type, itemdefs.tools, { resource_reactions(result, job_types.MakeTool, materials.rock, entity.resources.tool_type, itemdefs.tools, {
permissible = (function(itemdef) return itemdef.flags.HARD_MAT end), permissible = (function(itemdef) return itemdef.flags.HARD_MAT end),
capitalize = true, capitalize = true,
}) })
material_reactions(result, { material_reactions(result, {
{125, "Make", "Toy"}, {job_types.MakeToy, "Make", "Toy"},
{203, "Construct", "Quern"}, {job_types.ConstructQuern, "Construct", "Quern"},
{204, "Construct", "Millstone"}, {job_types.ConstructMillstone, "Construct", "Millstone"},
{212, "Construct", "Slab"}, {job_types.ConstructSlab, "Construct", "Slab"},
{80, "Construct", "Statue"}, {job_types.ConstructStatue, "Construct", "Statue"},
{81, "Construct", "Blocks"}, {job_types.ConstructBlocks, "Construct", "Blocks"},
}, materials.rock) }, materials.rock)
-- Glass items -- Glass items
for _, mat_info in ipairs(glasses) do for _, mat_info in ipairs(glasses) do
material_reactions(result, { material_reactions(result, {
{69, "Construct", "Portal"}, {job_types.ConstructDoor, "Construct", "Portal"},
{70, "Construct", "Floodgate"}, {job_types.ConstructFloodgate, "Construct", "Floodgate"},
{200, "Construct", "Hatch Cover"}, {job_types.ConstructHatchCover, "Construct", "Hatch Cover"},
{201, "Construct", "Grate"}, {job_types.ConstructGrate, "Construct", "Grate"},
{72, "Construct", "Throne"}, {job_types.ConstructThrone, "Construct", "Throne"},
{73, "Construct", "Coffin"}, {job_types.ConstructCoffin, "Construct", "Coffin"},
{74, "Construct", "Table"}, {job_types.ConstructTable, "Construct", "Table"},
{77, "Construct", "Armor Stand"}, {job_types.ConstructArmorStand, "Construct", "Armor Stand"},
{78, "Construct", "Weapon Rack"}, {job_types.ConstructWeaponRack, "Construct", "Weapon Rack"},
{79, "Construct", "Cabinet"}, {job_types.ConstructCabinet, "Construct", "Cabinet"},
{123, "Make", "Goblet"}, {job_types.MakeGoblet, "Make", "Goblet"},
{124, "Make", "Instrument"}, {job_types.MakeInstrument, "Make", "Instrument"},
}, mat_info) }, mat_info)
resource_reactions(result, 218, mat_info, entity.resources.tool_type, itemdefs.tools, { resource_reactions(result, job_types.MakeTool, mat_info, entity.resources.tool_type, itemdefs.tools, {
permissible = (function(itemdef) return itemdef.flags.HARD_MAT end), permissible = (function(itemdef) return itemdef.flags.HARD_MAT end),
capitalize = true, capitalize = true,
}) })
material_reactions(result, { material_reactions(result, {
{125, "Make", "Toy"}, {job_types.MakeToy, "Make", "Toy"},
{80, "Construct", "Statue"}, {job_types.ConstructStatue, "Construct", "Statue"},
{81, "Construct", "Blocks"}, {job_types.ConstructBlocks, "Construct", "Blocks"},
{120, "Make", "Terrarium"}, {job_types.MakeCage, "Make", "Terrarium"},
{195, "Make", "Tube"}, {job_types.MakePipeSection, "Make", "Tube"},
}, mat_info) }, mat_info)
resource_reactions(result, 142, mat_info, entity.resources.trapcomp_type, itemdefs.trapcomps, { resource_reactions(result, job_types.MakeTrapComponent, mat_info, entity.resources.trapcomp_type, itemdefs.trapcomps, {
adjective = true, adjective = true,
}) })
end end
-- Bed, specified as wooden. -- Bed, specified as wooden.
table.insert(result, reaction_entry(71, materials.wood.management)) table.insert(result, reaction_entry(job_types.ConstructBed, materials.wood.management))
-- Windows -- Windows
for _, mat_info in ipairs(glasses) do for _, mat_info in ipairs(glasses) do
material_reactions(result, { material_reactions(result, {
{129, "Make", "Window"}, {job_types.MakeWindow, "Make", "Window"},
}, mat_info) }, mat_info)
end end
-- Rock Mechanisms -- Rock Mechanisms
table.insert(result, reaction_entry(141, materials.rock.management)) table.insert(result, reaction_entry(job_types.ConstructMechanisms, materials.rock.management))
resource_reactions(result, 136, materials.wood, entity.resources.siegeammo_type, itemdefs.siege_ammo, { resource_reactions(result, job_types.AssembleSiegeAmmo, materials.wood, entity.resources.siegeammo_type, itemdefs.siege_ammo, {
verb = "Assemble", verb = "Assemble",
}) })
for _, mat_info in ipairs(glasses) do for _, mat_info in ipairs(glasses) do
material_reactions(result, { material_reactions(result, {
{82, "Make Raw", nil}, {job_types.MakeRawGlass, "Make Raw", nil},
}, mat_info) }, mat_info)
end end
material_reactions(result, { material_reactions(result, {
{133, "Make", "Backpack"}, {job_types.MakeBackpack, "Make", "Backpack"},
{134, "Make", "Quiver"}, {job_types.MakeQuiver, "Make", "Quiver"},
}, materials.leather) }, materials.leather)
for _, material in ipairs(cloth_mats) do for _, material in ipairs(cloth_mats) do
@ -649,12 +666,12 @@ function collect_reactions()
} }
for _, boxmat in ipairs(boxmats) do for _, boxmat in ipairs(boxmats) do
for _, mat in ipairs(boxmat.mats) do for _, mat in ipairs(boxmat.mats) do
material_reactions(result, {{75, "Construct", boxmat.box}}, mat) material_reactions(result, {{job_types.ConstructChest, "Construct", boxmat.box}}, mat)
if boxmat.chain then if boxmat.chain then
material_reactions(result, {{121, "Make", boxmat.chain}}, mat) material_reactions(result, {{job_types.MakeChain, "Make", boxmat.chain}}, mat)
end end
if boxmat.flask then if boxmat.flask then
material_reactions(result, {{122, "Make", boxmat.flask}}, mat) material_reactions(result, {{job_types.MakeFlask, "Make", boxmat.flask}}, mat)
end end
end end
end end
@ -672,15 +689,15 @@ function collect_reactions()
materials.pearl, materials.pearl,
materials.yarn, materials.yarn,
} do } do
material_reactions(result, {{83, "Make", "Crafts"}}, mat) material_reactions(result, {{job_types.MakeCrafts, "Make", "Crafts"}}, mat)
end end
-- Siege engine parts -- Siege engine parts
table.insert(result, reaction_entry(99, materials.wood.management)) table.insert(result, reaction_entry(job_types.ConstructCatapultParts, materials.wood.management))
table.insert(result, reaction_entry(100, materials.wood.management)) table.insert(result, reaction_entry(job_types.ConstructBallistaParts, materials.wood.management))
for _, mat in ipairs{materials.wood, materials.bone} do for _, mat in ipairs{materials.wood, materials.bone} do
resource_reactions(result, 131, mat, entity.resources.ammo_type, itemdefs.ammo, { resource_reactions(result, job_types.MakeAmmo, mat, entity.resources.ammo_type, itemdefs.ammo, {
name_field = "name_plural", name_field = "name_plural",
}) })
end end
@ -690,11 +707,11 @@ function collect_reactions()
clothing_reactions(result, materials.shell, (function(itemdef) return itemdef.props.flags[4] end)) clothing_reactions(result, materials.shell, (function(itemdef) return itemdef.props.flags[4] end))
for _, mat in ipairs{materials.wood, materials.leather} do for _, mat in ipairs{materials.wood, materials.leather} do
resource_reactions(result, 119, mat, entity.resources.shield_type, itemdefs.shields, {}) resource_reactions(result, job_types.MakeShield, mat, entity.resources.shield_type, itemdefs.shields, {})
end end
-- Melt a Metal Object -- Melt a Metal Object
table.insert(result, reaction_entry(91)) table.insert(result, reaction_entry(job_types.MeltMetalObject))
return result return result
end end