aboutsummaryrefslogtreecommitdiff
path: root/internal/game/action_clean.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/action_clean.go')
-rw-r--r--internal/game/action_clean.go43
1 files changed, 16 insertions, 27 deletions
diff --git a/internal/game/action_clean.go b/internal/game/action_clean.go
index b85a3e0..77b6ea3 100644
--- a/internal/game/action_clean.go
+++ b/internal/game/action_clean.go
@@ -6,6 +6,7 @@ import (
"thehouseoficarus/internal/engine"
"thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/object"
"thehouseoficarus/internal/player"
)
@@ -21,7 +22,7 @@ func (g *Game) advanceClean(sess *net.Session, p *player.Player) {
items := g.CraftIndex.ByType("clean")
- var match *cleanMatch
+ var matchItem *object.ItemDef
for _, item := range items {
c := item.FirstCraft()
if filter != "" {
@@ -39,41 +40,36 @@ func (g *Game) advanceClean(sess *net.Session, p *player.Player) {
if !craftHasAllItems(c, p.HasItem) {
continue
}
- match = &cleanMatch{c.Consume[0].Items[0], item.ID, c.XP, c.Message}
+ matchItem = item
break
}
- if match == nil {
- sess.WriteLine("\nYou've finished cleaning herbs.")
+ if matchItem == nil {
+ sess.WriteLine("You've finished cleaning herbs.")
g.cancelBgAction(p)
return
}
+ craft := matchItem.FirstCraft()
+ consumeID := craft.Consume[0].Items[0]
+
for i := 0; i < 28; i++ {
slot := p.InvSlot(i)
- if slot != nil && slot.ItemID == match.consumeID {
- slot.ItemID = match.outputID
+ if slot != nil && slot.ItemID == consumeID {
+ slot.ItemID = matchItem.ID
break
}
}
- if match.xp > 0 {
- g.awardSkillXP(sess, p, player.Pharmacy, match.xp)
+ if craft.XP > 0 {
+ g.awardSkillXP(sess, p, player.Pharmacy, craft.XP)
}
g.AccountStore.SaveCharacter(p)
- msg := match.message
- if msg == "" {
- outDef, _ := g.ItemStore.Load(match.outputID)
- outputName := match.outputID
- if outDef != nil {
- outputName = outDef.Name
- }
- msg = fmt.Sprintf("You clean a %s.", outputName)
- }
- if p.OptionBool("xp_drops") && match.xp > 0 {
+ msg := g.resolveCraftMessage(sess, craft.Message, "You clean the %i1.", craft, matchItem.ID, nil, p.HasItem)
+ if p.OptionBool("xp_drops") && craft.XP > 0 {
abbr := player.SkillAbbr[player.Pharmacy]
- msg += g.colorize(sess, "xp", fmt.Sprintf(" (+%dxp %s)", match.xp, abbr))
+ msg += g.colorize(sess, "xp", fmt.Sprintf(" (+%dxp %s)", craft.XP, abbr))
}
sess.WriteLine(msg)
@@ -96,17 +92,10 @@ func (g *Game) advanceClean(sess *net.Session, p *player.Player) {
}
if !hasMore {
- sess.WriteLine("\nYou've finished cleaning herbs.")
+ sess.WriteLine("You've finished cleaning herbs.")
g.cancelBgAction(p)
return
}
p.BackgroundAction.WaitLeft = engine.ToTicks(2)
}
-
-type cleanMatch struct {
- consumeID string
- outputID string
- xp int
- message string
-}