diff options
Diffstat (limited to 'internal/game/action_gather.go')
| -rw-r--r-- | internal/game/action_gather.go | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/internal/game/action_gather.go b/internal/game/action_gather.go index 4e1e609..08d2589 100644 --- a/internal/game/action_gather.go +++ b/internal/game/action_gather.go @@ -6,6 +6,8 @@ import ( "strings" "thirdcollapse/internal/action" + "thirdcollapse/internal/color" + "thirdcollapse/internal/engine" "thirdcollapse/internal/net" "thirdcollapse/internal/object" "thirdcollapse/internal/player" @@ -176,6 +178,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { wait := p.Action.Data["effective_wait"].(float64) instanceKey := p.Action.Data["instance_key"].(string) _, shared := p.Action.Data["deplete_timer"] + mode := g.colorMode(sess) if step == 0 { if cfg.Bait != "" { @@ -184,28 +187,28 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { if def, err := g.ItemStore.Load(cfg.Bait); err == nil { baitName = def.Name } - sess.WriteLine(fmt.Sprintf("You've run out of %s.", baitName)) + sess.WriteLine(color.Wrap(mode, "red", fmt.Sprintf("You've run out of %s.", baitName))) g.CancelAction(p) return } } - sess.WriteLine(fmt.Sprintf("\n%s", cfg.GatherMsg)) + sess.WriteLine(fmt.Sprintf("\n%s", color.Tag(mode, cfg.GatherMsg))) p.Action.Data["step"] = 1 - p.Action.WaitLeft = g.computeTicks(wait) + p.Action.WaitLeft = engine.ToTicks(wait) return } if step == 2 { st := g.World.GetObjStateByKey(instanceKey) if st != nil && st.Depleted { - p.Action.WaitLeft = g.computeTicks(3) + p.Action.WaitLeft = engine.ToTicks(3) return } if cfg.RespawnMsg != "" { - sess.WriteLine(fmt.Sprintf("\n%s", cfg.RespawnMsg)) + sess.WriteLine(fmt.Sprintf("\n%s", color.Tag(mode, cfg.RespawnMsg))) } p.Action.Data["step"] = 0 - p.Action.WaitLeft = g.computeTicks(wait) + p.Action.WaitLeft = engine.ToTicks(wait) return } @@ -215,7 +218,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { if def, err := g.ItemStore.Load(cfg.Bait); err == nil { baitName = def.Name } - sess.WriteLine(fmt.Sprintf("You've run out of %s.", baitName)) + sess.WriteLine(color.Wrap(mode, "red", fmt.Sprintf("You've run out of %s.", baitName))) g.CancelAction(p) return } @@ -231,7 +234,7 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { if drop != nil { freeSlot := p.FirstFreeSlot() if freeSlot == -1 { - sess.WriteLine("Your inventory is too full!") + sess.WriteLine(color.Wrap(mode, "red", "Your inventory is too full!")) g.CancelAction(p) return } @@ -253,17 +256,19 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { } if xp > 0 { if newLevel := p.AddSkillXP(player.SkillName(cfg.Skill), xp); newLevel > 0 { - sess.WriteLine(fmt.Sprintf("*** You are now level %d %s! ***", newLevel, cfg.Skill)) + sess.WriteLine(color.Wrap(mode, "bright_yellow", fmt.Sprintf("*** You are now level %d %s! ***", newLevel, cfg.Skill))) } } g.AccountStore.SaveCharacter(p) msg := drop.Message if msg == "" { - msg = fmt.Sprintf("You manage to get some %s.", itemName) + msg = fmt.Sprintf("You manage to get some %s.", color.Wrap(mode, "green", itemName)) + } else { + msg = color.Tag(mode, msg) } if xp > 0 && p.OptionBool("xp_drops") { - msg += fmt.Sprintf(" (+%dxp %s)", xp, player.SkillAbbr[player.SkillName(cfg.Skill)]) + msg += color.Wrap(mode, "yellow", fmt.Sprintf(" (+%dxp %s)", xp, player.SkillAbbr[player.SkillName(cfg.Skill)])) } sess.WriteLine(msg) @@ -279,13 +284,13 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { playerNames: []string{p.Name}, }) p.Action.Data["step"] = 2 - p.Action.WaitLeft = g.computeTicks(1) + p.Action.WaitLeft = engine.ToTicks(1) return } } if !shared && drop.Depletes { - delay := g.computeTicks(cfg.RespawnTimer) + delay := engine.ToTicks(cfg.RespawnTimer) if delay <= 0 { delay = 10 } @@ -295,44 +300,45 @@ func (g *Game) advanceGather(sess *net.Session, p *player.Player) { st.DepleteTimer = float64(delay) } - for _, other := range g.Hub.PlayersInRoom(p.RoomID) { - if other == sess { - continue - } - op, ok := other.Player.(*player.Player) - if !ok || op.Action == nil || op.Action.Type != "gather" { - continue - } - if op.Action.Data["instance_key"] == instanceKey { - other.WriteLine(fmt.Sprintf("\nThe %s was depleted by %s!", p.Action.TargetName, p.Name)) - g.CancelAction(op) - } + for _, other := range g.Hub.PlayersInRoom(p.RoomID) { + if other == sess { + continue } + op, ok := other.Player.(*player.Player) + if !ok || op.Action == nil || op.Action.Type != "gather" { + continue + } + if op.Action.Data["instance_key"] == instanceKey { + other.WriteLine(fmt.Sprintf("\nThe %s was depleted by %s!", color.Wrap(mode, "green", p.Action.TargetName), color.Wrap(mode, "bright_white", p.Name))) + g.CancelAction(op) + g.writePrompt(other) + } + } p.Action.Data["step"] = 2 - p.Action.WaitLeft = g.computeTicks(1) + p.Action.WaitLeft = engine.ToTicks(1) return } if p.FirstFreeSlot() == -1 { - sess.WriteLine("Your inventory is too full!") + sess.WriteLine(color.Wrap(mode, "red", "Your inventory is too full!")) g.CancelAction(p) return } p.Action.Data["step"] = 0 - p.Action.WaitLeft = g.computeTicks(wait) + p.Action.WaitLeft = engine.ToTicks(wait) return } } - sess.WriteLine(cfg.FailMsg) + sess.WriteLine(color.Tag(mode, cfg.FailMsg)) if p.FirstFreeSlot() == -1 { - sess.WriteLine("Your inventory is too full!") + sess.WriteLine(color.Wrap(mode, "red", "Your inventory is too full!")) g.CancelAction(p) return } p.Action.Data["step"] = 0 - p.Action.WaitLeft = g.computeTicks(wait) + p.Action.WaitLeft = engine.ToTicks(wait) } func filterDropsByLevel(drops []action.DropEntry, level int) []action.DropEntry { @@ -350,7 +356,7 @@ func filterDropsByLevel(drops []action.DropEntry, level int) []action.DropEntry func (g *Game) depleteSharedTree(st *world.ObjState, cfg *action.GatherConfig, targetName string, playerNames []string) { st.Depleted = true - st.DepleteTimer = float64(g.computeTicks(cfg.RespawnTimer)) + st.DepleteTimer = float64(engine.ToTicks(cfg.RespawnTimer)) st.SharedTimer = 0 msg := cfg.ExhaustedMessage @@ -379,6 +385,7 @@ func (g *Game) depleteSharedTree(st *world.ObjState, cfg *action.GatherConfig, t } sess.WriteLine(fmt.Sprintf("\n%s", msg)) g.CancelAction(op) + g.writePrompt(sess) } } |
