app.get('/player/explore', authEndpoint, async (req: AuthRequest, res: Response) => {
const fight = await loadMonsterFromFight(req.player.id);
+ const travelPlan = await getTravelPlan(req.player.id);
let closestTown = req.player.city_id;
+ if(travelPlan) {
+ closestTown = (travelPlan.current_position / travelPlan.total_distance) > 0.5 ? travelPlan.destination_id : travelPlan.source_id;
+ }
+
const equippedItems = await getEquippedItems(req.player.id);
if(fight) {
const data: MonsterForFight = {
};
const location = await getMonsterLocation(fight.ref_id);
- res.send(renderPlayerBar(req.player, equippedItems) + renderFightPreRound(data, true, location));
+
+ res.send(renderPlayerBar(req.player, equippedItems) + renderFightPreRound(data, true, location, closestTown));
}
else {
- const travelPlan = await getTravelPlan(req.player.id);
if(travelPlan) {
// traveling!
- const travelPlan = await getTravelPlan(req.player.id);
-
- const closest: number = (travelPlan.current_position / travelPlan.total_distance) > 0.5 ? travelPlan.destination_id : travelPlan.source_id;
-
const chanceToSeeMonster = random(0, 100);
const things: any[] = [];
if(chanceToSeeMonster <= 30) {
- const monster = await getRandomMonster([closest]);
+ const monster = await getRandomMonster([closestTown]);
things.push(monster);
}
res.send(renderPlayerBar(req.player, equippedItems) + renderTravel({
things,
nextAction,
- closestTown: closest,
+ closestTown: closestTown,
walkingText: '',
travelPlan
}));
fight_trigger: fight.fight_trigger
};
- res.send(renderFightPreRound(data, true, location));
+ res.send(renderFightPreRound(data, true, location, location.city_id));
});
app.post('/travel/step', authEndpoint, async (req: AuthRequest, res: Response) => {
return html;
}
-export function renderFightPreRound(monster: MonsterForFight, displayFightActions: boolean = true, location: LocationWithCity) {
+export function renderFightPreRound(monster: MonsterForFight, displayFightActions: boolean = true, location: LocationWithCity, closestTown: number) {
const hpPercent = Math.floor((monster.hp / monster.maxHp) * 100);
let html = `
+<section id="explore" class="tab active" style="background-image: url('/assets/img/map/${closestTown}.jpeg')" hx-swap-oob="true">
<div class="city-title-wrapper">
<div class="city-title">${location.city_name}</div>
</div>
</div>
<div id="fight-results"></div>
</div>
-</div>`;
+</div>
+</section>
+`;
return html;
}