aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_stop.go
blob: 4b287ce2ee0573504e16ee7ce96d92f67da8b4ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package game

import (
	"thehouseoficarus/internal/net"
)

func (g *Game) executeStop(sess *net.Session, args []string, rawInput string) {
	p := sess.Player
	// "stop" is an instant command, so it executes outside the command
	// queue; cancel a pending quit countdown explicitly.
	g.cancelRest(p.Name)
	if _, playing := g.Casino.Participation(p.Name); playing {
		g.leaveCasinoGames(p)
		return
	}
	ss, _ := g.safespot.Get(p.Name)
	if p.Action == nil && p.BackgroundAction == nil && g.Combat.Get(p.Name) == nil && p.MoveTicks == 0 && len(p.WalkSequence) == 0 && !ss.Active {
		sess.WriteLine("You're not doing anything.")
		return
	}
	g.cancelAction(p)
	g.cancelBgAction(p)
	g.queue.DeleteActive(p.Name)
	sess.WriteLine("You stop what you were doing.")
}