aboutsummaryrefslogtreecommitdiff
path: root/internal/game
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-30 19:27:37 -0400
committerhistoria <[not public]>2026-06-30 19:27:37 -0400
commitfee376102192dc6f24297a7b11324636ace3a07d (patch)
tree6c777cc71208b429eebdbdc5864b353d4af34a09 /internal/game
parent98bdef072c843fdd8ccdf85a9b54ab9d32d34187 (diff)
downloadthehouseoficarus-fee376102192dc6f24297a7b11324636ace3a07d.tar.gz
feat: admin gui object CRUD is much nicer
Diffstat (limited to 'internal/game')
-rw-r--r--internal/game/act_gather.go58
1 files changed, 34 insertions, 24 deletions
diff --git a/internal/game/act_gather.go b/internal/game/act_gather.go
index 826b901..ab59de0 100644
--- a/internal/game/act_gather.go
+++ b/internal/game/act_gather.go
@@ -32,8 +32,20 @@ func (g *Game) startGather(sess *net.Session, p *player.Player, obj *object.Obje
}
skillLevel := p.Level(player.SkillName(cfg.Skill))
- if cfg.Level > 0 && skillLevel < cfg.Level {
- sess.WriteLine(fmt.Sprintf("You need level %d %s to do that.", cfg.Level, cfg.Skill))
+
+ eligible := filterDropsByLevel(cfg.Drops, skillLevel)
+ if len(eligible) == 0 {
+ minLevel := 0
+ for _, d := range cfg.Drops {
+ if d.Level > 0 && (minLevel == 0 || d.Level < minLevel) {
+ minLevel = d.Level
+ }
+ }
+ if minLevel > 0 {
+ sess.WriteLine(fmt.Sprintf("You need level %d %s to do that.", minLevel, cfg.Skill))
+ } else {
+ sess.WriteLine("You are not skilled enough to do that.")
+ }
return
}
@@ -52,7 +64,7 @@ func (g *Game) startGather(sess *net.Session, p *player.Player, obj *object.Obje
return
}
- wait := cfg.BaseWait
+ var wait float64
var toolName string
if len(cfg.Tools) > 0 {
@@ -67,7 +79,7 @@ func (g *Game) startGather(sess *net.Session, p *player.Player, obj *object.Obje
return
}
toolName = name
- wait = cfg.BaseWait - toolSpeed
+ wait = toolSpeed
if wait < 1 {
wait = 1
}
@@ -97,12 +109,12 @@ func (g *Game) startGather(sess *net.Session, p *player.Player, obj *object.Obje
g.broadcastAction(sess, "%s starts %s the %s.", p.Name, verb, obj.Name)
d := &behavior.GatherData{
- ObjDefID: obj.ID,
- InstanceKey: g.World.ObjStateKey(st.RoomID, st.DefID, st.Index),
- InstanceIdx: st.Index + 1,
- EffectiveWait: wait,
- Verb: verb,
- ToolName: toolName,
+ ObjDefID: obj.ID,
+ InstanceKey: g.World.ObjStateKey(st.RoomID, st.DefID, st.Index),
+ InstanceIdx: st.Index + 1,
+ Wait: wait,
+ Verb: verb,
+ ToolName: toolName,
}
if cfg.DepleteTimer > 0 {
d.DepleteTimer = true
@@ -125,7 +137,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) {
}
step := d.Step
- wait := d.EffectiveWait
+ wait := d.Wait
instanceKey := d.InstanceKey
shared := d.DepleteTimer
@@ -177,7 +189,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) {
}
skillLevel := p.Level(player.SkillName(cfg.Skill))
- chance := behavior.SuccessChance(cfg.Success, skillLevel, cfg.Level)
+ chance := behavior.SuccessChance(cfg.Success, skillLevel, 0)
if rand.Float64() < chance {
eligible := filterDropsByLevel(cfg.Drops, skillLevel)
@@ -203,9 +215,6 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) {
p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: drop.ItemID, Quantity: qty})
xp := drop.XP
- if xp <= 0 {
- xp = cfg.XP
- }
if xp > 0 {
g.awardSkillXP(sess, p, player.SkillName(cfg.Skill), xp)
}
@@ -250,18 +259,22 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) {
st.DepleteTimer = float64(delay)
}
+ depletionMsg := cfg.ExhaustedMessage
+ if depletionMsg == "" {
+ depletionMsg = fmt.Sprintf("The %s was depleted by %s!", p.Action.TargetName, p.Name)
+ }
+
for _, other := range g.Hub.PlayersInRoom(p.RoomID) {
- if other == sess {
- continue
- }
op := other.Player
if op == nil || op.Action == nil || op.Action.Type != behavior.TypeGather {
continue
}
if gd, ok := op.Action.Data.(*behavior.GatherData); ok && gd.InstanceKey == instanceKey {
- other.WriteLine(fmt.Sprintf("The %s was depleted by %s!", g.colorize(sess, "item", p.Action.TargetName), g.colorize(sess, "player_name", p.Name)))
- g.cancelAction(op)
- g.writePrompt(other)
+ other.WriteLine(depletionMsg)
+ if other != sess {
+ g.cancelAction(op)
+ g.writePrompt(other)
+ }
}
}
@@ -298,9 +311,6 @@ func filterDropsByLevel(drops []behavior.DropEntry, level int) []behavior.DropEn
eligible = append(eligible, d)
}
}
- if len(eligible) == 0 {
- return drops
- }
return eligible
}