aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_agility.go
blob: e347322169b193dd6db1ee396406912e0617ac14 (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
26
27
28
29
30
31
32
33
34
35
36
37
package game

import (
	"fmt"

	"thehouseoficarus/internal/combat"
	"thehouseoficarus/internal/net"
	"thehouseoficarus/internal/player"
)

func (g *Game) doObstacle(sess *net.Session, verb string) {
	p := sess.Player

	if combat.GetCombat(p.Name) != nil {
		sess.WriteLine("You can't do that during combat!")
		return
	}

	info := g.CourseStore.GetObstacle(p.RoomID)
	if info == nil || info.Verb != verb {
		sess.WriteLine("You can't do that here.")
		return
	}

	agilityLevel := p.Level(player.Agility)
	if agilityLevel < info.RequiredLevel {
		sess.WriteLine(fmt.Sprintf("You need level %d agility to attempt this course.", info.RequiredLevel))
		return
	}

	if p.Action != nil {
		g.cancelAction(p)
	}
	g.cancelBgAction(p)

	g.startObstacle(sess, p, info)
}