const res = await db.raw(`
select
f.*, fa.id as faction_id, fa.name as faction_name,
- m.minLevel, m.maxLevel
+ m."minLevel", m."maxLevel"
from fight f
join monsters m on f.ref_id = m.id
left outer join factions fa on m.faction_id = fa.id
* having an equal probability of appearing
*/
export async function getRandomMonster(city_id: number[]): Promise<MonsterForList> {
- const res = await db.raw('select id,name,level from monsters where location_id in (select id from locations where city_id in (?)) order by random() limit 1', [city_id.join(',')])
+ const res = await db.raw('select id,name,floor(random() * ("maxLevel"-"minLevel"+1) + 1) as level from monsters where location_id in (select id from locations where city_id in (?)) order by random() limit 1', [city_id.join(',')])
return res.rows[0] as MonsterForList;
}