From: xangelo Date: Mon, 21 Aug 2023 19:06:54 +0000 (-0400) Subject: feat: return to town button while travelling X-Git-Tag: v0.2.12~2 X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=fd070de32a394fd3452dcf1d8202e5325ec170aa;p=risinglegends.git feat: return to town button while travelling When you're travelling between towns, there's always an option to return to the starting town. --- diff --git a/public/assets/css/game.css b/public/assets/css/game.css index 69187e7..4060899 100644 --- a/public/assets/css/game.css +++ b/public/assets/css/game.css @@ -478,7 +478,7 @@ h3 { } #travelling { - padding-top: 2rem; + padding: 2rem; } #travelling-actions { display: flex; diff --git a/src/server/api.ts b/src/server/api.ts index baed723..5c6a558 100644 --- a/src/server/api.ts +++ b/src/server/api.ts @@ -975,8 +975,43 @@ app.post('/travel/step', authEndpoint, async (req: AuthRequest, res: Response) = } }); +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; diff --git a/src/server/views/travel.ts b/src/server/views/travel.ts index cf2d7db..9aff00e 100644 --- a/src/server/views/travel.ts +++ b/src/server/views/travel.ts @@ -9,12 +9,6 @@ export function renderTravel(data: TravelDTO): string { let promptText = data.walkingText; const blockTime = data.nextAction || 0; - /* - if(blockTime) { - updateStepButton(); - } - */ - let html = `
`; @@ -34,6 +28,8 @@ export function renderTravel(data: TravelDTO): string { html += '
'; html += `

${promptText}

`; + html += `

Return to ${data.travelPlan.source_city_name}

`; + html += '
'; return html;