}
});
+app.post('/travel/return-to-source', authEndpoint, async (req: AuthRequest, res: Response) => {
+ // puts the player back in their starting town
+ // doesn't matter if they don't have one
+ // redirect them!
+ await clearTravelPlan(req.player.id);
+ const equippedItems = await getEquippedItems(req.player.id);
+
+ const fight = await loadMonsterFromFight(req.player.id);
+ if(fight) {
+ // go to the fight screen
+ const data: MonsterForFight = {
+ id: fight.id,
+ hp: fight.hp,
+ maxHp: fight.maxHp,
+ name: fight.name,
+ level: fight.level,
+ fight_trigger: fight.fight_trigger
+ };
+ const location = await getMonsterLocation(fight.ref_id);
+
+ res.send(renderPlayerBar(req.player, equippedItems) + renderFightPreRound(data, true, location, req.player.city_id));
+ }
+ else {
+ const [city, locations, paths] = await Promise.all([
+ getCityDetails(req.player.city_id),
+ getAllServices(req.player.city_id),
+ getAllPaths(req.player.city_id)
+ ]);
+
+ res.send(renderPlayerBar(req.player, equippedItems) + await renderMap({city, locations, paths}, req.player.city_id));
+
+ }
+
+});
+
app.post('/travel/:destination_id', authEndpoint, async (req: AuthRequest, res: Response) => {
- if(req.player.hp <= 0) {
+if(req.player.hp <= 0) {
logger.log(`Player didn\'t have enough hp`);
res.send(Alert.ErrorAlert('Sorry, you need some HP to start travelling.'));
return;
let promptText = data.walkingText;
const blockTime = data.nextAction || 0;
- /*
- if(blockTime) {
- updateStepButton();
- }
- */
-
let html = `<section id="explore" class="tab active" hx-swap-oob="true" style="background-image: url('/assets/img/map/${data.closestTown}.jpeg')">
<div id="travelling" class="city-details">`;
html += '</div>';
html += `<p>${promptText}</p>`;
+ html += `<p align="right"><a href="#" hx-post="/travel/return-to-source">Return to ${data.travelPlan.source_city_name}</a></p>`;
+
html += '</div></section>';
return html;