Skip to content

Commit

Permalink
feat(ui): add modals to confirm travel/walk
Browse files Browse the repository at this point in the history
closes #22
  • Loading branch information
seiyria committed Jul 18, 2023
1 parent 91d6b12 commit b2494c2
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions client/src/app/pages/travel/travel.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ILocation, IPlayerLocation } from '@interfaces';
import { AlertController } from '@ionic/angular';
import { Select } from '@ngxs/store';
import { ContentService } from '@services/content.service';
import { GameplayService } from '@services/gameplay.service';
Expand Down Expand Up @@ -37,6 +38,7 @@ export class TravelPage implements OnInit {
constructor(
private contentService: ContentService,
private gameplayService: GameplayService,
private alert: AlertController,
) {}

ngOnInit() {
Expand Down Expand Up @@ -72,12 +74,46 @@ export class TravelPage implements OnInit {
).length;
}

walkToLocation(location: ILocation) {
this.gameplayService.walk(location.name).subscribe();
async walkToLocation(location: ILocation) {
const alert = await this.alert.create({
header: 'Walk to Location',
message: `Are you sure you want to walk to ${
location.name
} in ${location.steps.toLocaleString()} steps?`,
buttons: [
{
text: 'Cancel',
role: 'cancel',
},
{
text: 'Walk',
handler: () => this.gameplayService.walk(location.name).subscribe(),
},
],
});

await alert.present();
}

travelToLocation(location: ILocation) {
this.gameplayService.travel(location.name).subscribe();
async travelToLocation(location: ILocation) {
const alert = await this.alert.create({
header: 'Travel to Location',
message: `Are you sure you want to travel to ${
location.name
} for ${location.cost.toLocaleString()} coins?`,
buttons: [
{
text: 'Cancel',
role: 'cancel',
},
{
text: 'Travel',
handler: () => this.gameplayService.travel(location.name).subscribe(),
},
],
});

await alert.present();
}

numCollectiblesDiscoveredAt(location: ILocation): number {
Expand Down

0 comments on commit b2494c2

Please sign in to comment.