package game import ( "fmt" "thehouseoficarus/internal/net" "thehouseoficarus/internal/player" ) func (g *Game) triggerTransport(sess *net.Session, p *player.Player, mod *ModDef) { if g.Combat.Get(p.Name) != nil { sess.WriteLine("You can't transport during combat!") return } // Transport would strand the player at a remote room while still seated at // a table or machine; require them to stop playing first. if _, playing := g.Casino.Participation(p.Name); playing { sess.WriteLine("You're playing a game. Type \"stop\" between rounds before transporting.") return } if p.Action != nil { g.cancelAction(p) } g.triggerModReward(sess, p, mod, 1.0) g.executeTransportEffect(sess, p, mod) } func (g *Game) executeTransportEffect(sess *net.Session, p *player.Player, mod *ModDef) { // Safety net: sequenced modules reach the effect from advanceTriggerModule // without re-entering triggerTransport. Never teleport a seated gambler. if g.inCasinoGame(p.Name) { sess.WriteLine("You're playing a game. Type \"stop\" between rounds before transporting.") return } if g.Hub != nil { for _, other := range g.Hub.PlayersInRoom(p.RoomID) { if other != sess { other.WriteLine(fmt.Sprintf("%s requests a transport shuttle and departs.", p.Name)) } } } // A transport changes rooms just like a walk or teleport, so it must // clear any safespot cover: the safespot predicates are room-agnostic, // so leaving the state active would grant melee/hazard immunity in the // destination and keep the player as a phantom occupant of the old cover. if ss, ok := g.safespot.Get(p.Name); ok { g.forceLeaveSafespot(sess, p, &ss, "") } sess.WriteLine(fmt.Sprintf("You activate %s...", mod.Name)) p.RoomID = mod.Destination p.Stats.RecordRoomVisit(mod.Destination) if g.Hub != nil { g.Hub.LeaveRoom(sess) g.Hub.EnterRoom(sess, p.RoomID) } // Seed the destination exactly as the other teleport paths do, or the // room's mobs, objects and ground spawns never appear. g.World.SeedGroundItems(p.RoomID) g.seedRoomMobs(p.RoomID) g.seedRoomObjects(p.RoomID) room, _ := g.World.LoadRoom(p.RoomID) destName := fmt.Sprintf("room %d", p.RoomID) if room != nil { destName = room.Name } sess.WriteLine(fmt.Sprintf("You arrive at %s.", destName)) g.saveCharacter(p) g.doLook(sess) g.runEnterSteps(sess, p.RoomID) g.writePrompt(sess) }