blob: 205fd8d15b9106385872a163f40ca1352fe2889a (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package game
import (
"fmt"
"strings"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
)
func (g *Game) doAutocast(sess *net.Session, input string) {
p := sess.Player.(*player.Player)
input = strings.TrimSpace(input)
if input == "" {
if p.AutocastMod == "" {
sess.WriteLine("No autocast mod set. Use 'autocast <mod>' to set one.")
} else {
mod := GetMod(p.AutocastMod)
if mod == nil {
sess.WriteLine("Autocast: none (invalid mod)")
p.AutocastMod = ""
} else {
sess.WriteLine(fmt.Sprintf("Autocast: %s (Lv%d)", mod.Name, mod.Level))
}
}
return
}
if strings.ToLower(input) == "off" {
p.AutocastMod = ""
sess.WriteLine("Autocast disabled.")
return
}
mod := FindMod(strings.ToLower(input))
if mod == nil {
sess.WriteLine("Unknown mod.")
return
}
if mod.Category != ModCombat {
sess.WriteLine("You can only autocast combat mods.")
return
}
if p.Level(player.Science) < mod.Level {
sess.WriteLine(fmt.Sprintf("You need level %d science to autocast %s.", mod.Level, mod.Name))
return
}
p.AutocastMod = mod.ID
sess.WriteLine(fmt.Sprintf("Autocast set to: %s", mod.Name))
}
|