finished align game
This commit is contained in:
parent
2e62c0f3f6
commit
93c3387afd
@ -65,3 +65,9 @@
|
|||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
||||||
|
<ion-footer>
|
||||||
|
<ion-toolbar>
|
||||||
|
<ion-button [disabled]="!this.mayContinue" (click)="continueGame()" color="primary" size="large" shape="round" expand="block">Continue</ion-button>
|
||||||
|
</ion-toolbar>
|
||||||
|
</ion-footer>
|
||||||
|
@ -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 { Router } from '@angular/router';
|
||||||
import { GestureController } from '@ionic/angular';
|
import { AlertService } from '../services/alert.service';
|
||||||
import { retry } from 'rxjs/operators';
|
|
||||||
import { GameService } from '../services/game.service';
|
import { GameService } from '../services/game.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -11,7 +10,9 @@ import { GameService } from '../services/game.service';
|
|||||||
})
|
})
|
||||||
export class ValuesAlignPage {
|
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(){
|
async checkValues(){
|
||||||
|
|
||||||
@ -33,9 +34,32 @@ export class ValuesAlignPage {
|
|||||||
if(!(await this.checkValues())){
|
if(!(await this.checkValues())){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.mayContinue = true;
|
||||||
// User may continue
|
// User may continue
|
||||||
console.log("hihi go go");
|
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`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user