Permalink
Browse files

Adds instructor edits

  • Loading branch information...
kbbushman
kbbushman committed Jan 11, 2019
1 parent 480c3d7 commit 397ce8d2474f8213a70191b814d15aca2a0c8ae4
Showing with 43 additions and 41 deletions.
  1. +43 −41 js/app.js
@@ -1,45 +1,60 @@
console.log('hi')
console.log('hi');

confirmDefault = ['no bun', 'no lettuce', 'no patty', 'no tomato', 'no cheese', 'no mayo'];

class HamburgerKing {
constructor(name, score, timer, customers, level, orders, confirm){
constructor(name, score, timer, customers, level, orders, confirm) {
this.name = name;
this.score = score;
this.timer = timer;
this.customers = customers;
this.level = level;
this.orders = orders;
this.requests = [null, null, null, null, null, null];
this.confirm = confirm;
this.confirm = [...confirm];
}


getInfo(){
const name = prompt('enter your name');
$('.info').show();
$('h3').eq(0).text(name);
$('#profile h3').show();
hamburger.start();
}
// getInfo(){
// const name = prompt('enter your name');
// $('.info').show();
// $('h3').eq(0).text(name);
// $('#profile h3').show();
// hamburger.start();
// }

start(){
//console.log('START THIS VALUE = ', this);//note: 'this' in this func !== class HamburgerKing
console.log(this)
let missionTimer;
if (this.level === 1) {
const name = prompt('enter your name');
$('.info').show();
$('h3').eq(0).text(name);
$('#profile h3').show();
this.play();
// hamburger.start();
}

clearInterval(missionTimer);

//1. h1 tag and start button should be gone;
$('h1').hide();
$('#startBtn').hide();

//2. timer should start at the profile messageBox
const missionTimer = setInterval(function() {
missionTimer = setInterval(function() {
//console.log('TIMER THIS VALUE = ', this);//note: check ()=>{} and function(){}
if(hamburger.timer <= 0){
clearInterval(missionTimer)
//alert('Time over');
$('#cook').hide();
$('#middle').append(`<img id="cook2" src="./css/burgermanv2.png">`);
hamburger.reset()
}else if(hamburger.score === hamburger.orders){
}
else if(hamburger.score === hamburger.orders){
clearInterval(missionTimer);
hamburger.levelTwo();
// hamburger.levelTwo();
}else{
hamburger.timer--;
$('#timer').show();
@@ -56,7 +71,7 @@ class HamburgerKing {
// hamburger.confirm = ['no bun', 'no lettuce', 'no patty', 'no tomato', 'no cheese', 'no mayo'];
hamburger.getRequest();
//5. make icons to be clickable
hamburger.play();
// this.play();
}

getRequest(){
@@ -188,20 +203,21 @@ class HamburgerKing {

if (orderArray.includes(false)) {
return alert('You lost...!');
}else{
} else {
this.score += 1;
this.customers += 1;
$('#left').text(`Burger : ${this.score}`);
//alert('Order is correct...!')
this.getRequest()
// this.getRequest()
// document.querySelector('.bunB').remove()
$('.order-wrapper').empty().append(`<img id="plate" src="./css/tray.png">`)
}
// }

if(this.score === this.orders){
// if(this.score === this.orders){
this.level += 1;
alert('Congrats! you are going to move level [ ' + this.level + ' ] now!')
$('#level').text(`Level : ${hamburger.level}`);
this.levelTwo();
};
});
};
@@ -219,7 +235,7 @@ class HamburgerKing {
$('.on-plate').remove();
$('#newMess').remove();
$('#againBtn').remove();
hamburger = new HamburgerKing(name, 0, 20, 1, 1, 5, ['no bun', 'no lettuce', 'no patty', 'no tomato', 'no cheese', 'no mayo']);
hamburger = new HamburgerKing(name, 0, 3, 1, 1, 5, ['no bun', 'no lettuce', 'no patty', 'no tomato', 'no cheese', 'no mayo']);
$('#cook').show();
$('#cook2').remove();
this.getInfo();
@@ -235,30 +251,16 @@ class HamburgerKing {
$('.on-plate').remove();
$('#levelUpMess').remove();
$('#next').remove();
hamburger = new HamburgerKing(name, 0, 30, 1, 2, 6, ['no bun', 'no lettuce', 'no patty', 'no tomato', 'no cheese', 'no mayo']);
// hamburger = new HamburgerKing(name, 0, 30, 1, 2, 6, confirmDefault);
this.start();
// this.level++;
this.orders = 6;
this.confirm = [...confirmDefault];
this.timer = 30;
this.start();
});
}

// nextLevel(){
// $('#request').hide();
// $('#timer').hide();
// $('#messageBox').append(`<div id="levelUpMess">congrats!</div>`);
// $('#messageBox').append(`<button id="next">next</button>`);
// $('#next').on('click', () =>{
// $('.on-plate').remove();
// $('#levelUpMess').remove();
// $('#next').remove();
//
// let prevTimer = hamburger.timer;
// let prevLevel = hamburger.level;
// let preOrders = hamburger.orders;
//
// hamburger = new HamburgerKing(name, 0, prevTimer-10, 1, prevLevel+1, preOrders+2);
// this.start();
// });
// }


}//class closer

@@ -267,7 +269,7 @@ class HamburgerKing {
//score => how many player made so far..
//orders => how many player should make each level
//customers => start from 1
let hamburger = new HamburgerKing(name, 0, 30, 1, 1, 1, ['no bun', 'no lettuce', 'no patty', 'no tomato', 'no cheese', 'no mayo']);
let hamburger = new HamburgerKing(name, 0, 20, 1, 1, 1, confirmDefault);

//variable
const $startBtn = $('#startBtn');
@@ -282,4 +284,4 @@ const $againBtn = $('#againBtn');


//event listner
$startBtn.on('click', hamburger.getInfo);
$startBtn.on('click', () => hamburger.start());

0 comments on commit 397ce8d

Please sign in to comment.