chore(release): 0.2.11
[risinglegends.git] / src / server / views / travel.ts
1 import { TravelDTO } from "../../shared/map";
2
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>`;
5 }
6
7 export function renderTravel(data: TravelDTO): string {
8
9   let promptText = data.walkingText;
10   const blockTime = data.nextAction || 0;
11
12   /*
13   if(blockTime) {
14     updateStepButton();
15   }
16   */
17
18   let html = `<section id="explore" class="tab active" hx-swap-oob="true" style="background-image: url('/assets/img/map/${data.closestTown}.jpeg')">
19
20 <div id="travelling" class="city-details">`;
21   html += '<div id="travelling-actions">';
22   html += travelButton(blockTime);
23   if(data.things.length) {
24     // ok you found something, for now we only support 
25     // monsters, but eventually that will change
26     promptText = `You see a ${data.things[0].name}`;
27     html += `<form hx-post="/fight" hx-target="#explore">
28 <input type="hidden" name="monsterId" value="${data.things[0].id}">
29 <button type="submit" class="red">Fight</button>
30 </form>`;
31   }
32
33   // end #travelling-actions
34   html += '</div>';
35   html += `<p>${promptText}</p>`;
36
37   html += '</div></section>';
38
39   return html;
40 }