added check for ranking

This commit is contained in:
Ryan Bakkes 2022-02-04 15:55:29 +01:00
parent 84680362c3
commit 16db253fb4

View File

@ -11,6 +11,7 @@ import { GameService } from '../services/game.service';
export class ValuesAlignPage {
mayContinue: boolean;
nextGame: string;
constructor(private router: Router, private game: GameService, public alert: AlertService) {}
@ -46,9 +47,6 @@ export class ValuesAlignPage {
return;
}
let addvalues = await this.alert.presentAlertConfirm("Missing values?", "Do you want to add values to the list?", "yes", "no");
let nextGame = addvalues == "yes" ? "Add" : "Ranking";
this.alert.showLoader("Please wait");
// remove all the cards with value false from array
for(var i = 0; i < this.game.cardset.length; i++){
@ -60,8 +58,17 @@ export class ValuesAlignPage {
}
// set storage and go to the next page
await this.game.saveGameStorage("Values", nextGame, this.game.cardset);
this.alert.hideLoader();
this.router.navigateByUrl(`/values${nextGame}`);
if(this.game.cardset.length < 5){
let addvalues = await this.alert.presentAlertConfirm("Missing values?", "Do you want to add values to the list?", "yes", "no");
this.nextGame = addvalues == "yes" ? "Add" : "Ranking";
}else{
this.nextGame = "Ranking";
}
await this.game.saveGameStorage("Values", this.nextGame, this.game.cardset);
this.router.navigateByUrl(`/values${this.nextGame}`);
}
}