package game import ( "fmt" "thehouseoficarus/internal/combat" "thehouseoficarus/internal/net" "thehouseoficarus/internal/player" ) func (g *Game) triggerTransport(sess *net.Session, p *player.Player, mod *ModDef) { if combat.GetCombat(p.Name) != nil { sess.WriteLine("You can't teleport during combat!") return } if p.Action != nil { g.cancelAction(p) } g.triggerModReward(sess, p, mod, 1.0) if g.Hub != nil { for _, other := range g.Hub.PlayersInRoom(p.RoomID) { if other != sess { other.WriteLine(fmt.Sprintf("\n%s teleports away.", p.Name)) } } } 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) } room, _ := g.World.LoadRoom(p.RoomID) destName := fmt.Sprintf("room %d", p.RoomID) if room != nil { destName = room.Name } sess.WriteLine(fmt.Sprintf("You materialize at %s.", destName)) g.AccountStore.SaveCharacter(p) g.doLook(sess) }