From 0ea4eec5dd2122c6704216971eb1249276297867 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 19 Jun 2026 18:20:26 -0400 Subject: shop fixes, 'toggle' completely removed, movement speed increased --- internal/net/server.go | 95 ++++--------------------------------------------- internal/net/welcome.go | 82 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 88 deletions(-) create mode 100644 internal/net/welcome.go (limited to 'internal/net') diff --git a/internal/net/server.go b/internal/net/server.go index 7c7a18c..f82f82b 100644 --- a/internal/net/server.go +++ b/internal/net/server.go @@ -6,10 +6,10 @@ import ( "log" "net" "net/http" - "strings" - "thehouseoficarus/internal/color" + "thehouseoficarus/internal/action" "thehouseoficarus/internal/config" + "thehouseoficarus/internal/player" ) type SessionState int @@ -46,8 +46,8 @@ const ( type Session struct { Conn Conn State SessionState - Account *AccountEntry - Player interface{} + Account *player.Account + Player *player.Player PendingChar string PendingPass string PendingMenu []map[string]string @@ -57,17 +57,10 @@ type Session struct { PendingBackground bool Disconnecting bool DisconnectTicks int - Shop interface{} + Shop *action.ShopConfig } -type AccountEntry struct { - Name string - PasswordHash string - Characters []string - Aliases map[string]string - Colors map[string]string - Options map[string]any -} + type Server struct { config *config.Config @@ -281,53 +274,6 @@ func (s *Server) serveHTTPS() { } } -func artColor(r rune) string { - switch r { - case '@': - return color.FgCode("ansi", 4) - case '!', ':', '.': - return color.StyleCode("dim") + color.FgCode("ansi", 4) - case ',': - return color.FgCode("ansi", 5) - case '*': - return color.FgCode("ansi", 5) - case '+', '|', '-': - return color.FgCode("ansi", 3) - } - return "" -} - -func colorizeRunes(s string) string { - var sb strings.Builder - current := "" - for _, r := range s { - want := artColor(r) - if want != current { - if current != "" { - sb.WriteString(color.Reset) - } - if want != "" { - sb.WriteString(want) - } - current = want - } - sb.WriteRune(r) - } - if current != "" { - sb.WriteString(color.Reset) - } - return sb.String() -} - -func colorizeArt(art string) string { - welcomeText := "welcome to the house of icarus" - before, after, found := strings.Cut(art, welcomeText) - if found { - return colorizeRunes(before) + color.FgCode("ansi", 7) + welcomeText + color.Reset + colorizeRunes(after) - } - return colorizeRunes(art) -} - func (s *Server) handleSession(sess *Session, handler func(*Session, string)) { defer func() { if r := recover(); r != nil { @@ -339,34 +285,7 @@ func (s *Server) handleSession(sess *Session, handler func(*Session, string)) { sess.Conn.Write([]byte("\033[2J\033[H")) - welcomeart := colorizeArt(` - | * - * + -+- - . , | -. , . , - * - @@@@@@@ @@@ @@@ @@@@@@@@ @@@ @@@ @@@@@@ @@@ @@@ @@@@@@ @@@@@@@@ + - @@! @@! @@@ @@! + @@! @@@ @@! @@@ @@! @@@ !@@ @@! - @!! @!@!@!@! @!!!:! @!@!@!@! @!@ !@! @!@ !@! !@@!! @!!!:! * - !!: !!: !!! !!: . !!: !!! !!: !!! !!: !!! !:! !!: - : : : : : :: ::: : : : : :. : :.:: : ::.: : : :: ::: . - . + - * welcome to the house of icarus , , - , . - @@@@@@ @@@@@@@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@@ @@@@@@ - @@! @@@ @@! , @@! !@@ @@! @@@ @@! @@@ @@! @@@ !@@ - | @!@ !@! @!!!:! !!@ !@! @!@!@!@! @!@!!@! @!@ !@! !@@!! - -+- !!: !!! !!: !!: :!! !!: !!! !!: :!! !!: !!! !:! - | : :. : : . : :: :: : : : : : : : :.:: : ::.: : - , - . + , . - . , - * . , * - + -`) - - - sess.Write(welcomeart) + sess.Write(WelcomeBanner()) sess.Write("What's your account name? ") for { diff --git a/internal/net/welcome.go b/internal/net/welcome.go new file mode 100644 index 0000000..e17c82e --- /dev/null +++ b/internal/net/welcome.go @@ -0,0 +1,82 @@ +package net + +import ( + "strings" + + "thehouseoficarus/internal/color" +) + +func artColor(r rune) string { + switch r { + case '@': + return color.FgCode("ansi", 4) + case '!', ':', '.': + return color.StyleCode("dim") + color.FgCode("ansi", 4) + case ',': + return color.FgCode("ansi", 5) + case '*': + return color.FgCode("ansi", 5) + case '+', '|', '-': + return color.FgCode("ansi", 3) + } + return "" +} + +func colorizeRunes(s string) string { + var sb strings.Builder + current := "" + for _, r := range s { + want := artColor(r) + if want != current { + if current != "" { + sb.WriteString(color.Reset) + } + if want != "" { + sb.WriteString(want) + } + current = want + } + sb.WriteRune(r) + } + if current != "" { + sb.WriteString(color.Reset) + } + return sb.String() +} + +func colorizeArt(art string) string { + welcomeText := "welcome to the house of icarus" + before, after, found := strings.Cut(art, welcomeText) + if found { + return colorizeRunes(before) + color.FgCode("ansi", 7) + welcomeText + color.Reset + colorizeRunes(after) + } + return colorizeRunes(art) +} + +func WelcomeBanner() string { + return colorizeArt(` + | * + * + -+- + . , | +. , . , + * + @@@@@@@ @@@ @@@ @@@@@@@@ @@@ @@@ @@@@@@ @@@ @@@ @@@@@@ @@@@@@@@ + + @@! @@! @@@ @@! + @@! @@@ @@! @@@ @@! @@@ !@@ @@! + @!! @!@!@!@! @!!!:! @!@!@!@! @!@ !@! @!@ !@! !@@!! @!!!:! * + !!: !!: !!! !!: . !!: !!! !!: !!! !!: !!! :!; !!: + : : : : : :: ::: : : : : :. : :.:: : ::.: : : :: ::: . + . + + * welcome to the house of icarus , , + , . + @@@@@@ @@@@@@@@ @@@ @@@@@@@ @@@@@@ @@@@@@@ @@@ @@@ @@@@@@ + @@! @@@ @@! , @@! !@@ @@! @@@ @@! @@@ @@! @@@ !@@ + | @!@ !@! @!!!:! !!@ @!@ @!@!@!@! @!@!!@! @!@ !@! !@@!! + -+- !!: !!! !!: !!: :!! !!: !!! !!: :!! !!: !!! :!; + | : :. : : . : :: :: : : : : : : : :.:: : ::.: : + , + . + , . + . , + * . , * + + +`) +} -- cgit v1.2.3