package game import ( "fmt" "strings" "thehouseoficarus/internal/net" ) func (g *Game) executeSummon(sess *net.Session, args []string, rawInput string) { if !g.checkAdmin(sess) { sess.WriteLine("Unknown command.") return } adminP := sess.Player if adminP == nil { return } if len(args) == 0 { sess.WriteLine("Summon whom?") return } targetName := args[0] g.charsMu.Lock() targetSess, ok := g.loggedInChars[targetName] g.charsMu.Unlock() if !ok { for _, other := range g.Hub.AllSessions() { if other.Player != nil && strings.EqualFold(other.Player.Name, targetName) { targetSess = other break } } } if targetSess == nil || targetSess.Player == nil { sess.WriteLine("Player not found.") return } if targetSess == sess { sess.WriteLine("You can't summon yourself.") return } tp := targetSess.Player adminRoom := adminP.RoomID oldRoom := tp.RoomID tp.ClearMoveState() if g.Combat.Get(tp.Name) != nil { g.stopCombat(tp.Name) } tp.Action = nil g.cancelRest(tp.Name) g.cancelSequences(tp.Name) if ss, ok := g.safespot.Get(tp.Name); ok { g.forceLeaveSafespot(targetSess, tp, &ss, "") } tp.RoomID = adminRoom tp.HazardTimer = 0 tp.Stats.RecordRoomVisit(adminRoom) g.AccountStore.SaveCharacter(tp) g.World.SeedGroundItems(adminRoom) g.seedRoomMobs(adminRoom) g.seedRoomObjects(adminRoom) if g.Hub != nil { for _, other := range g.Hub.PlayersInRoom(oldRoom) { if other != targetSess { other.WriteLine(fmt.Sprintf("%s vanishes.", tp.Name)) } } g.Hub.EnterRoom(targetSess, adminRoom) for _, other := range g.Hub.PlayersInRoom(adminRoom) { if other != targetSess { other.WriteLine(fmt.Sprintf("%s appears.", tp.Name)) } } } targetSess.WriteLine(fmt.Sprintf("You have been summoned by %s.", adminP.Name)) sess.WriteLine(fmt.Sprintf("Summoned %s.", tp.Name)) g.doLook(targetSess) g.runEnterSteps(targetSess, adminRoom) g.checkAggro(targetSess) }