chore(release): 0.3.2
[risinglegends.git] / src / events / explore / server.ts
1 import {Monster, MonsterForList} from "../../shared/monsters";
2 import {SocketEvent} from "../../server/socket-event.server";
3 import {getMonsterList} from "../../server/monster";
4
5 export const exploreInCity: SocketEvent = {
6   eventName: 'city:explore',
7   handler: async (api, data: { args: string }) => {
8     // @TODO add check to make sure player is in this town and can actually explore this area
9     const locationId = parseInt(data.args);
10
11     if(!locationId || isNaN(locationId)) {
12       return;
13     }
14
15     const monsters: Monster[] = await getMonsterList(locationId);
16     let monsterList: MonsterForList[] = monsters.map(monster => {
17       return {
18         id: monster.id,
19         name: monster.name,
20         level: monster.level
21       }
22     });
23
24     api.socket.emit('explore:fights', monsterList);
25   }
26 }