1 import {movePlayer, updatePlayer} from "../../server/player";
2 import {getCityDetails, getAllServices, getAllPaths} from "../../server/map";
3 import {SocketEvent} from "../../server/socket-event.server";
5 export const travel: SocketEvent = {
6 eventName: 'city:travel',
7 handler: async (api, data: { args: string }) => {
8 const destinationCity = parseInt(data.args);
10 console.log(`${api.player.username} attempting travel to ${destinationCity}`);
12 if(!destinationCity || isNaN(destinationCity)) {
13 console.log('Bad input!');
18 const city = await getCityDetails(destinationCity);
21 console.log('Bad city input');
22 // do nothing.. not a real place
26 api.player.city_id = city.id;
28 await movePlayer(city.id, api.player.id);
30 const [locations, paths] = await Promise.all([
31 getAllServices(city.id),
35 api.socket.emit('city:travel', {