All locations default to a min level of 1, so they're always visible.
but some things (stores, dungeons) can have a higher level where they
will not be visible until the player meets the requirement.
type: r.fields.Type,
city_id: r.fields.city_id[0],
display_order: r.fields["Display Order"],
- event_name: r.fields['event_name']
+ event_name: r.fields['event_name'],
+ min_level: Math.max(parseInt(r.fields['Min Level'].toString()), 1)
}
})).onConflict('id').merge();
// display the default explore view
const [city, locations, paths] = await Promise.all([
getCityDetails(req.player.city_id),
- getAllServices(req.player.city_id),
+ getAllServices(req.player.city_id, req.player.level),
getAllPaths(req.player.city_id)
]);
const [city, locations, paths] = await Promise.all([
getCityDetails(travel.destination_id),
- getAllServices(travel.destination_id),
+ getAllServices(travel.destination_id, req.player.level),
getAllPaths(travel.destination_id)
]);
else {
const [city, locations, paths] = await Promise.all([
getCityDetails(req.player.city_id),
- getAllServices(req.player.city_id),
+ getAllServices(req.player.city_id, req.player.level),
getAllPaths(req.player.city_id)
]);
roundData.monster.hp = 0;
roundData.winner = 'player';
+ addEvent('MONSTER_KILLED', player.id, {
+ monster_id: roundData.monster.ref_id,
+ monster_name: roundData.monster.name,
+ level: roundData.monster.level,
+ fightTrigger: roundData.monster.fight_trigger
+ });
+
const expGained = exponentialExp(monster.exp, monster.level, player.level);
roundData.rewards.exp = expGained;
import { db } from './lib/db';
import { random } from 'lodash';
-export async function getAllServices(city_id: number): Promise<Location[]> {
+export async function getAllServices(city_id: number, min_level: number): Promise<Location[]> {
return db.select('*')
.from<Location>('locations')
.where({city_id})
+ .andWhere('min_level', '<=', min_level)
.orderBy('type')
.orderBy('display_order');
}