Skip to content

Commit a46d341

Browse files
authored
GMCP Updates, Custom Aliases (#311)
# Changes * Moved all GMCP functionality to a gmcp module. * Telnet IAC handlers can be defined by modules * Module callback added: `OnNetConnect` * Added custom user aliases: * Example: `alias don=equip` - Typing `don` will result in `equip` being executed. * Aliases can be more complex, such as `alias gp=give potion` can be used like: `gp dave`, which will expand to: `give potion dave` * Several new events created for things like health change, xp gains etc. * Fixed `teleport` admin command for when target room id is `0` or `<0` * Added `FilePaths.WebDomain` config * Moved module/plugin callback functions to `Callback` property function recevier. * Moved contents of `world` file that were mostly empty after so many code changes into world.go, deleted empty files. * Minor documentation updates * Added LRU caches for gmcp module data.
1 parent 51e6d96 commit a46d341

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1695
-813
lines changed

_datafiles/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ Timing:
182182
#
183183
################################################################################
184184
FilePaths:
185+
# - WebDomain -
186+
# This can be mysite.com, or www.mysite.com, etc.
187+
# Do not include the protocol such as http:// or https://
188+
WebDomain: "localhost"
185189
# - WebCDNLocation -
186190
# Optional alternative location to serve static files from such as audio
187191
# Example: http://files.gomud.net

_datafiles/guides/running/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ These guides assume you want to build from the source. You can also download the
44

55
- [Raspberry PI Zero 2W](RASPBERRY-PI.md)
66
- [Running via Docker](DOCKER.md)
7+
- [Setting Up an EC2 Instance](EC2.md)
78

89

910
# Quick Start

_datafiles/world/default/templates/help/alias.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ The <ansi fg="command">alias</ansi> command lists and sets aliases
55
<ansi fg="yellow">Usage: </ansi>
66

77
<ansi fg="command">alias</ansi> - List all aliases, including system defaults
8+
9+
<ansi fg="command">alias [name]=[value]</ansi> - Create a custom alias. Left of the '=' is the command, right of the '=' is the replacement.
810

11+
<ansi fg="command">alias [name]=</ansi> - Clear an alias (value of [name])

_datafiles/world/default/users/1.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ password: password
55
joined: 2024-10-31T13:28:45.395873-07:00
66
macros:
77
=1: e;e;e;e;e;e;e;e
8+
aliases:
9+
tp: teleport
810
character:
911
name: AdminAnt
1012
description: AdminAnt possesses the ability to manipulate the very fabric of the
@@ -63,16 +65,17 @@ character:
6365
- buffid: 28
6466
onstartevent: true
6567
permabuff: true
66-
roundcounter: 3
68+
roundcounter: 28
6769
triggersleft: 1000000000
6870
- buffid: 29
6971
onstartevent: true
7072
permabuff: true
71-
roundcounter: 11
73+
roundcounter: 6
7274
triggersleft: 1000000000
7375
- buffid: 39
7476
onstartevent: false
7577
permabuff: true
78+
roundcounter: 10
7679
triggersleft: 1000000000
7780
equipment:
7881
weapon:

_datafiles/world/empty/templates/help/alias.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ The <ansi fg="command">alias</ansi> command lists and sets aliases
55
<ansi fg="yellow">Usage: </ansi>
66

77
<ansi fg="command">alias</ansi> - List all aliases, including system defaults
8+
9+
<ansi fg="command">alias [name]=[value]</ansi> - Create a custom alias. Left of the '=' is the command, right of the '=' is the replacement.
810

11+
<ansi fg="command">alias [name]=</ansi> - Clear an alias (value of [name])

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ require (
2323
)
2424

2525
require (
26+
github.com/hashicorp/golang-lru/v2 v2.0.7
2627
github.com/mattn/go-runewidth v0.0.16
2728
github.com/nicksnyder/go-i18n/v2 v2.5.1
2829
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE
2323
github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg=
2424
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
2525
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
26+
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
27+
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
2628
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
2729
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
2830
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=

internal/characters/character.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ func (c *Character) ApplyHealthChange(healthChange int) int {
12111211
}
12121212

12131213
c.Health = newHealth
1214+
12141215
return newHealth - oldHealth
12151216
}
12161217

@@ -1291,7 +1292,10 @@ func (c *Character) LevelUp() (bool, stats.Statistics) {
12911292
return true, statsDelta
12921293
}
12931294

1294-
func (c *Character) Heal(hp int, mana int) {
1295+
func (c *Character) Heal(hp int, mana int) (int, int) {
1296+
startHP := c.Health
1297+
startMP := c.Mana
1298+
12951299
c.Health += hp
12961300
if c.Health > c.HealthMax.Value {
12971301
c.Health = c.HealthMax.Value
@@ -1300,6 +1304,8 @@ func (c *Character) Heal(hp int, mana int) {
13001304
if c.Mana > c.ManaMax.Value {
13011305
c.Mana = c.ManaMax.Value
13021306
}
1307+
1308+
return c.Health - startHP, c.Mana - startMP
13031309
}
13041310

13051311
func (c *Character) HealthPerRound() int {

internal/configs/config.filepaths.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package configs
22

33
type FilePaths struct {
4+
WebDomain ConfigString `yaml:"WebDomain"`
45
WebCDNLocation ConfigString `yaml:"WebCDNLocation"`
56
DataFiles ConfigString `yaml:"DataFiles"`
67
PublicHtml ConfigString `yaml:"PublicHtml"`
@@ -12,6 +13,7 @@ type FilePaths struct {
1213

1314
func (f *FilePaths) Validate() {
1415

16+
// Ignore WebDomain
1517
// Ignore WebCDNLocation
1618
// Ignore PublicHtml
1719
// Ignore AdminHtml

internal/connections/clientsettings.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ package connections
22

33
type ClientSettings struct {
44
Display DisplaySettings
5-
Discord DiscordSettings
65
Client ClientType // Client data provided by `Core.Hello` GMCP command
7-
// Enabled GMCP Modules
8-
GMCPModules map[string]int // Enabled GMCP Modules (if any)
96
// Is MSP enabled?
107
MSPEnabled bool // Do they accept sound in their client?
118
SendTelnetGoAhead bool // Defaults false, should we send a IAC GA after prompts?
@@ -15,10 +12,6 @@ type DisplaySettings struct {
1512
ScreenWidth uint32
1613
ScreenHeight uint32
1714
}
18-
type DiscordSettings struct {
19-
User string // person#1234
20-
Private bool
21-
}
2215

2316
type ClientType struct {
2417
Name string
@@ -34,14 +27,3 @@ func (c ClientSettings) IsMudlet() bool {
3427
func (c ClientSettings) IsMsp() bool {
3528
return c.MSPEnabled
3629
}
37-
38-
// Check whether a GMCP module is enabled on the client
39-
func (c ClientSettings) GmcpEnabled(moduleName string) bool {
40-
if len(c.GMCPModules) == 0 {
41-
return false
42-
}
43-
44-
_, ok := c.GMCPModules[moduleName]
45-
46-
return ok
47-
}

0 commit comments

Comments
 (0)