Skip to content

Commit c2d849e

Browse files
authored
Allow character command at low level as long as they already have alts. (#350)
# Description The `character` command only works at level 5 and above. Creating an alt makes them level 1, not allowing them to switch back to their original character. This fixes it. ## Changes - Command works at level 5 OR if they have alt characters in storage. ## Issues #349
1 parent 42078f2 commit c2d849e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

internal/usercommands/character.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ func Character(rest string, user *users.UserRecord, room *rooms.Room, flags even
2727
return false, fmt.Errorf(`not in a IsCharacterRoom`)
2828
}
2929

30+
altNames := []string{}
31+
nameToAlt := map[string]characters.Character{}
32+
33+
for _, char := range characters.LoadAlts(user.UserId) {
34+
altNames = append(altNames, char.Name)
35+
nameToAlt[char.Name] = char
36+
}
37+
3038
// All possible commands:
3139
// new - reroll current character (if no alts enabled, or create a new one and store the current one)
3240
// change - change to another character in storage
@@ -43,7 +51,7 @@ func Character(rest string, user *users.UserRecord, room *rooms.Room, flags even
4351
return true, errors.New(`alt characters disabled`)
4452
}
4553

46-
if user.Character.Level < 5 {
54+
if user.Character.Level < 5 && len(nameToAlt) < 1 {
4755
user.SendText(`<ansi fg="203">You must reach level 5 with this character to access character alts.</ansi>`)
4856
return true, errors.New(`level 5 minimum`)
4957
}
@@ -62,14 +70,6 @@ func Character(rest string, user *users.UserRecord, room *rooms.Room, flags even
6270

6371
cmdPrompt, isNew := user.StartPrompt(`character`, rest)
6472

65-
altNames := []string{}
66-
nameToAlt := map[string]characters.Character{}
67-
68-
for _, char := range characters.LoadAlts(user.UserId) {
69-
altNames = append(altNames, char.Name)
70-
nameToAlt[char.Name] = char
71-
}
72-
7373
if isNew {
7474

7575
if len(altNames) > 0 {

0 commit comments

Comments
 (0)