diff --git a/AuthentesApp/src/app/valuesAlign/valuesAlign.page.html b/AuthentesApp/src/app/valuesAlign/valuesAlign.page.html index 3bb846b..a58cb7b 100644 --- a/AuthentesApp/src/app/valuesAlign/valuesAlign.page.html +++ b/AuthentesApp/src/app/valuesAlign/valuesAlign.page.html @@ -65,3 +65,9 @@ + + + + Continue + + diff --git a/AuthentesApp/src/app/valuesAlign/valuesAlign.page.ts b/AuthentesApp/src/app/valuesAlign/valuesAlign.page.ts index 20119f2..7e63b88 100644 --- a/AuthentesApp/src/app/valuesAlign/valuesAlign.page.ts +++ b/AuthentesApp/src/app/valuesAlign/valuesAlign.page.ts @@ -1,7 +1,6 @@ -import { Component, Input, ViewChildren, QueryList, ElementRef, EventEmitter, Output, Renderer2, ViewChild } from '@angular/core'; +import { Component, Renderer2 } from '@angular/core'; import { Router } from '@angular/router'; -import { GestureController } from '@ionic/angular'; -import { retry } from 'rxjs/operators'; +import { AlertService } from '../services/alert.service'; import { GameService } from '../services/game.service'; @Component({ @@ -11,7 +10,9 @@ import { GameService } from '../services/game.service'; }) export class ValuesAlignPage { - constructor(private router: Router, private game: GameService, private renderer: Renderer2) {} + mayContinue: boolean; + + constructor(private router: Router, private game: GameService, private renderer: Renderer2, public alert: AlertService) {} async checkValues(){ @@ -33,9 +34,32 @@ export class ValuesAlignPage { if(!(await this.checkValues())){ return; } - + this.mayContinue = true; // User may continue console.log("hihi go go"); }; + async continueGame(){ + // check one more time if the user may continue + if(!this.mayContinue){ + this.alert.presentToast("Give to all the cards a value first"); + return; + } + + this.alert.showLoader("Please wait"); + // remove all the cards with value false from array + for(var i = 0; i < this.game.cardset.length; i++){ + const card = this.game.cardset[i]; + console.log(card.id); + if(card.value == 2){ + this.game.cardset.splice(i,1); + i--; + } + } + + // set storage and go to the next page + await this.game.saveGameStorage("Values", "Insert", this.game.cardset); + this.alert.hideLoader(); + this.router.navigateByUrl(`/home`); + } }