aboutsummaryrefslogtreecommitdiff
path: root/internal/game/production_engine.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-01 02:21:42 -0400
committerhistoria <[not public]>2026-07-01 02:21:42 -0400
commit5f37dc9b6f6b79da04da70ae0c33ec8d02998587 (patch)
treef7c309e36267a4c456fcf5bca800e614507a80af /internal/game/production_engine.go
parentfee376102192dc6f24297a7b11324636ace3a07d (diff)
downloadthehouseoficarus-5f37dc9b6f6b79da04da70ae0c33ec8d02998587.tar.gz
feat: qol improvements to items crud in admin gui
Diffstat (limited to 'internal/game/production_engine.go')
-rw-r--r--internal/game/production_engine.go32
1 files changed, 21 insertions, 11 deletions
diff --git a/internal/game/production_engine.go b/internal/game/production_engine.go
index c30e7bb..048e152 100644
--- a/internal/game/production_engine.go
+++ b/internal/game/production_engine.go
@@ -25,7 +25,7 @@ func (g *Game) resolveCraftVar(sess *net.Session, varSpec string, craft *item.Cr
}
varSpec = strings.ReplaceAll(varSpec, "%n", outputName)
- for i, e := range craft.Consume {
+ for i, e := range craft.Ingredients {
key := fmt.Sprintf("%%i%d", i+1)
if !strings.Contains(varSpec, key) {
continue
@@ -134,14 +134,19 @@ func (g *Game) startProductionFromItem(sess *net.Session, p *player.Player, item
stationName = "inventory"
}
- info, ok := productionTypes[craft.Type]
+ cKey := craft.Subtype
+ if cKey == "" {
+ cKey = craft.Type
+ }
+
+ info, ok := productionTypes[cKey]
if !ok {
info = productionTypeInfo{
- ActionType: behavior.ActionType(craft.Type),
- DisplayVerb: craft.Type,
- StartMessage: "You start " + craft.Type + " %i1.",
+ ActionType: behavior.ActionType(cKey),
+ DisplayVerb: cKey,
+ StartMessage: "You start " + cKey + " %i1.",
SuccessMessage: "You produce %n.",
- EndMessage: "You've finished " + craft.Type + ".",
+ EndMessage: "You've finished " + cKey + ".",
}
}
@@ -215,7 +220,12 @@ func (g *Game) advanceProduction(sess *net.Session, p *player.Player) bool {
chance = behavior.SuccessChance(behavior.SuccessFormula(*craft.Success), skillLevel, craft.Level)
}
- info, _ := productionTypes[craft.Type]
+ cKey := craft.Subtype
+ if cKey == "" {
+ cKey = craft.Type
+ }
+
+ info, _ := productionTypes[cKey]
if rand.Float64() < chance {
outputQty := craft.OutputQty
@@ -231,7 +241,7 @@ func (g *Game) advanceProduction(sess *net.Session, p *player.Player) bool {
for i := 0; i < 28; i++ {
slot := p.InvSlot(i)
if slot != nil && slot.ItemID == item.ID {
- craftConsumeAll(craft, p.HasItem, p.RemoveItem)
+ consumeIngredients(craft, p.HasItem, p.RemoveItem)
slot.Quantity += outputQty
placed = true
break
@@ -239,7 +249,7 @@ func (g *Game) advanceProduction(sess *net.Session, p *player.Player) bool {
}
}
if !placed {
- craftConsumeAll(craft, p.HasItem, p.RemoveItem)
+ consumeIngredients(craft, p.HasItem, p.RemoveItem)
freeSlot := p.FirstFreeSlot()
if freeSlot == -1 {
sess.WriteLine("Your inventory is too full!")
@@ -274,7 +284,7 @@ func (g *Game) advanceProduction(sess *net.Session, p *player.Player) bool {
}
sess.WriteLine(msg)
} else {
- craftConsumeAll(craft, p.HasItem, p.RemoveItem)
+ consumeIngredients(craft, p.HasItem, p.RemoveItem)
if craft.Fail != "" {
freeSlot := p.FirstFreeSlot()
@@ -320,7 +330,7 @@ func (g *Game) collectByproducts(p *player.Player, item *item.ItemDef) []string
return nil
}
var byproducts []string
- for _, e := range craft.Consume {
+ for _, e := range craft.Ingredients {
if len(e.Byproducts) == 0 {
continue
}