give an alert when went through deck

This commit is contained in:
Ryan Bakkes 2022-01-06 19:20:23 +01:00
parent 1314344fd1
commit 0adca2722b

View File

@ -25,6 +25,8 @@ export class ValuesSortingPage {
isHearts: boolean; isHearts: boolean;
heartVisible: boolean; heartVisible: boolean;
crossVisible: boolean; crossVisible: boolean;
deckAmount: number;
deckCount: number = 0;
constructor(private router: Router, private renderer: Renderer2, private gestureCtrl: GestureController, public alertService: AlertService, public game: GameService, public alert: AlertService) {} constructor(private router: Router, private renderer: Renderer2, private gestureCtrl: GestureController, public alertService: AlertService, public game: GameService, public alert: AlertService) {}
@ -34,6 +36,7 @@ export class ValuesSortingPage {
this.cards.changes.subscribe(()=>{ this.cards.changes.subscribe(()=>{
this.cardsArray = this.cards.toArray(); this.cardsArray = this.cards.toArray();
}) })
this.deckAmount = this.game.cardset.length;
this.swiper(); this.swiper();
}; };
@ -169,8 +172,10 @@ export class ValuesSortingPage {
async handleShift() { async handleShift() {
this.transitionInProgress = false; this.transitionInProgress = false;
this.toggleChoiceIndicator(false,false) this.toggleChoiceIndicator(false,false)
if (this.shiftRequired) { if (this.shiftRequired) {
this.shiftRequired = false; this.shiftRequired = false;
// If the answer is true keep in stack // If the answer is true keep in stack
if(this.isHearts){ if(this.isHearts){
this.game.cardset[this.game.cardset.push(this.game.cardset.shift())-1]; this.game.cardset[this.game.cardset.push(this.game.cardset.shift())-1];
@ -184,10 +189,27 @@ export class ValuesSortingPage {
await this.alertService.presentAlert("Done!","You've selected 5 cards, continue to the next page."); await this.alertService.presentAlert("Done!","You've selected 5 cards, continue to the next page.");
this.router.navigateByUrl(`/valuesAlign`); this.router.navigateByUrl(`/valuesAlign`);
} }
await this.cycleCount();
}; };
}; };
async cycleCount(){
// set deck counter +1
this.deckCount++;
// check if the deck count reached the max of the deck
if(this.deckCount >= this.deckAmount){
await this.alertService.presentAlert("End of the deck reached","Make sure there are only 5 cards left");
// reset the values
this.deckCount = 0;
this.deckAmount = this.game.cardset.length;
}
}
async emitChoice(heart, card) { async emitChoice(heart, card) {
this.choiceMade.emit({ this.choiceMade.emit({
choice: heart, choice: heart,