1 import { TravelDTO } from "../../shared/map";
3 export function travelButton(blockTime: number): string {
4 return `<button id="keep-walking" hx-post="/travel/step" class="${blockTime ? 'disabled': ''}" data-block="${blockTime}" ${blockTime ? 'disabled': ''}>Keep Walking</button>`;
7 export function renderTravel(data: TravelDTO): string {
9 let promptText = data.walkingText;
10 const blockTime = data.nextAction || 0;
12 let html = `<section id="explore" class="tab active" hx-swap-oob="true" style="background-image: url('/assets/img/map/${data.closestTown}.jpeg')">
14 <div id="travelling" class="city-details">`;
15 html += '<div id="travelling-actions">';
16 html += travelButton(blockTime);
17 if(data.things.length) {
18 // ok you found something, for now we only support
19 // monsters, but eventually that will change
20 promptText = `You see a ${data.things[0].name}`;
21 html += `<form hx-post="/fight" hx-target="#explore">
22 <input type="hidden" name="monsterId" value="${data.things[0].id}">
23 <button type="submit" class="red">Fight</button>
27 // end #travelling-actions
29 html += `<p>${promptText}</p>`;
31 html += `<p align="right"><a href="#" hx-post="/travel/return-to-source">Return to ${data.travelPlan.source_city_name}</a></p>`;
33 html += '</div></section>';