Skip to content

Commit c524c27

Browse files
authored
Interactive container editing (#227)
# Changes * New command: `room edit containers` * Initiates an interactive series of menus to add/remove/edit containers * Fix for item Id generation on new item creation * Reduced default `TurnMs` config value to `50ms` from `100ms` * Added container recipes to feature screenshots section * Broadcasts now redraw prompts for users * Example: New day/night wasn't redrawing prompt after sending. Now it is.
1 parent e205bdb commit c524c27

File tree

18 files changed

+692
-29
lines changed

18 files changed

+692
-29
lines changed

_datafiles/config.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,10 @@ XPScale: 100
8787
# processed per turn. This is not the same as rounds, which is how often the
8888
# mobs choose their actions, but if multiple actions are queued up, they will
8989
# be processed in order once per turn.
90-
# The effect of this can be easily seen in the initial login to the game,
91-
# where several commands are queued up at once and processed in order for the
92-
# player.
93-
# 100 is a good balance between handling input from players and not bogging
90+
# 50 is a good balance between handling input from players and not bogging
9491
# down the server.
95-
TurnMs: 100
92+
# Note: If your automapper/walker seems slow, this is probably the culprit.
93+
TurnMs: 50
9694
# - RoundSeconds -
9795
# How many seconds per round. Anything gated by rounds will be affected by
9896
# this. This is the main setting for controlling the pace of the game.

_datafiles/world/default/templates/admincommands/help/command.room.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Set a property of the room. This updates basic properties of the room you are in
3131
<ansi fg="command">room nouns</ansi> - List all nouns for the room
3232
<ansi fg="command">room noun [name] [description]</ansi> - Add or overwrite a noun
3333

34+
Containers:
35+
You can interactively add/remove/edit containers using the command:
36+
<ansi fg="command">room edit containers</ansi>
37+
3438
<ansi fg="command">room exit [exit_name] [room_id]</ansi> - e.g. <ansi fg="command">room exit west 159</ansi>
3539
This will create a new exit that links to a specific room_id using the exit_name provided.
3640
<ansi fg="red-bold">!Beware!</ansi> if the spacial relationship with compass direction rooms is done incorrectly,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
{{ range $idx, $itemInfo := . }} <ansi fg="red-bold">{{ printf "%2d." (add $idx 1) }}</ansi> <ansi fg="yellow-bold">{{ printf "%-33s" $itemInfo.Name }}</ansi>{{ if eq (mod $idx 2) 1 }}{{ printf "\n" }}{{ end }}{{ end }}
2+
{{ range $idx, $itemInfo := . }} <ansi fg="red-bold">{{ printf "%2d." (add $idx 1) }}</ansi> {{ if $itemInfo.Marked }}<ansi fg="white-bold" bg="2">{{else}}<ansi fg="yellow-bold">{{end}}{{ if $itemInfo.Marked }}*{{ printf "%-32s" $itemInfo.Name }}{{else}}{{ printf "%-33s" $itemInfo.Name }}{{end}}</ansi>{{ if eq (mod $idx 2) 1 }}{{ printf "\n" }}{{ end }}{{ end }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
{{ range $idx, $itemInfo := . }} <ansi fg="red-bold">{{ printf "%2d." (add $idx 1) }}</ansi> <ansi fg="yellow-bold">{{ printf "%-17s" $itemInfo.Name }}</ansi>{{ if ne $itemInfo.Description "" }} - <ansi fg="black-bold">{{ splitstring $itemInfo.Description 54 " " }}</ansi>{{ end }}
2+
{{ range $idx, $itemInfo := . }} <ansi fg="red-bold">{{ printf "%2d." (add $idx 1) }}</ansi> {{ if $itemInfo.Marked }}<ansi fg="white-bold" bg="2">{{else}}<ansi fg="yellow-bold">{{end}}{{ if $itemInfo.Marked }}*{{ printf "%-16s" $itemInfo.Name }}{{else}}{{ printf "%-17s" $itemInfo.Name }}{{end}}</ansi>{{ if ne $itemInfo.Description "" }} - <ansi fg="black-bold">{{ splitstring $itemInfo.Description 54 " " }}</ansi>{{ end }}
33
{{ end }}

_datafiles/world/empty/templates/admincommands/help/command.room.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ Set a property of the room. This updates basic properties of the room you are in
3131
<ansi fg="command">room nouns</ansi> - List all nouns for the room
3232
<ansi fg="command">room noun [name] [description]</ansi> - Add or overwrite a noun
3333

34+
Containers:
35+
You can interactively add/remove/edit containers using the command:
36+
<ansi fg="command">room edit containers</ansi>
37+
3438
<ansi fg="command">room exit [exit_name] [room_id]</ansi> - e.g. <ansi fg="command">room exit west 159</ansi>
3539
This will create a new exit that links to a specific room_id using the exit_name provided.
3640
<ansi fg="red-bold">!Beware!</ansi> if the spacial relationship with compass direction rooms is done incorrectly,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
{{ range $idx, $itemInfo := . }} <ansi fg="red-bold">{{ printf "%2d." (add $idx 1) }}</ansi> <ansi fg="yellow-bold">{{ printf "%-33s" $itemInfo.Name }}</ansi>{{ if eq (mod $idx 2) 1 }}{{ printf "\n" }}{{ end }}{{ end }}
2+
{{ range $idx, $itemInfo := . }} <ansi fg="red-bold">{{ printf "%2d." (add $idx 1) }}</ansi> {{ if $itemInfo.Marked }}<ansi fg="white-bold" bg="2">{{else}}<ansi fg="yellow-bold">{{end}}{{ if $itemInfo.Marked }}*{{ printf "%-32s" $itemInfo.Name }}{{else}}{{ printf "%-33s" $itemInfo.Name }}{{end}}</ansi>{{ if eq (mod $idx 2) 1 }}{{ printf "\n" }}{{ end }}{{ end }}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
{{ range $idx, $itemInfo := . }} <ansi fg="red-bold">{{ printf "%2d." (add $idx 1) }}</ansi> <ansi fg="yellow-bold">{{ printf "%-17s" $itemInfo.Name }}</ansi>{{ if ne $itemInfo.Description "" }} - <ansi fg="black-bold">{{ splitstring $itemInfo.Description 54 " " }}</ansi>{{ end }}
2+
{{ range $idx, $itemInfo := . }} <ansi fg="red-bold">{{ printf "%2d." (add $idx 1) }}</ansi> {{ if $itemInfo.Marked }}<ansi fg="white-bold" bg="2">{{else}}<ansi fg="yellow-bold">{{end}}{{ if $itemInfo.Marked }}*{{ printf "%-16s" $itemInfo.Name }}{{else}}{{ printf "%-17s" $itemInfo.Name }}{{end}}</ansi>{{ if ne $itemInfo.Description "" }} - <ansi fg="black-bold">{{ splitstring $itemInfo.Description 54 " " }}</ansi>{{ end }}
33
{{ end }}

feature-screenshots/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ _Pets are special famliars that help the player and provide special bonuses or u
6565

6666
<a href="https://raw.githubusercontent.com/Volte6/GoMud/refs/heads/master/feature-screenshots/pets.png"><img src="https://raw.githubusercontent.com/Volte6/GoMud/refs/heads/master/feature-screenshots/pets.png" width="600" alt="accessibility text"></a>
6767

68+
## Containers & Recipes
69+
70+
_Containers hold stuff. Recipes turn containers into "Crafting machines"._
71+
72+
<a href="https://raw.githubusercontent.com/Volte6/GoMud/refs/heads/master/feature-screenshots/container-recipes.png"><img src="https://raw.githubusercontent.com/Volte6/GoMud/refs/heads/master/feature-screenshots/container-recipes.png" width="600" alt="accessibility text"></a>
73+
6874
## Custom Prompts
6975

7076
_Players can customize their prompts, including colors._
174 KB
Loading

internal/connections/connections.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ func Remove(id ConnectionId) (err error) {
146146
return errors.New("connection not found")
147147
}
148148

149-
func Broadcast(colorizedText []byte) {
149+
func Broadcast(colorizedText []byte) []ConnectionId {
150150

151151
lock.Lock()
152152

153153
removeIds := []ConnectionId{}
154+
sentToIds := []ConnectionId{}
154155

155156
for id, cd := range netConnections {
156157

@@ -169,12 +170,15 @@ func Broadcast(colorizedText []byte) {
169170
removeIds = append(removeIds, id)
170171
}
171172

173+
sentToIds = append(sentToIds, id)
172174
}
173175
lock.Unlock()
174176

175177
for _, id := range removeIds {
176178
Remove(id)
177179
}
180+
181+
return sentToIds
178182
}
179183

180184
func SendTo(b []byte, ids ...ConnectionId) {

0 commit comments

Comments
 (0)