give an alert when went through deck
This commit is contained in:
parent
1314344fd1
commit
0adca2722b
@ -25,6 +25,8 @@ export class ValuesSortingPage {
|
||||
isHearts: boolean;
|
||||
heartVisible: 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) {}
|
||||
|
||||
@ -34,6 +36,7 @@ export class ValuesSortingPage {
|
||||
this.cards.changes.subscribe(()=>{
|
||||
this.cardsArray = this.cards.toArray();
|
||||
})
|
||||
this.deckAmount = this.game.cardset.length;
|
||||
this.swiper();
|
||||
};
|
||||
|
||||
@ -169,8 +172,10 @@ export class ValuesSortingPage {
|
||||
async handleShift() {
|
||||
this.transitionInProgress = false;
|
||||
this.toggleChoiceIndicator(false,false)
|
||||
|
||||
if (this.shiftRequired) {
|
||||
this.shiftRequired = false;
|
||||
|
||||
// If the answer is true keep in stack
|
||||
if(this.isHearts){
|
||||
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.");
|
||||
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) {
|
||||
this.choiceMade.emit({
|
||||
choice: heart,
|
||||
|
Loading…
x
Reference in New Issue
Block a user