class questbutton extends Phaser.GameObjects.Image {
  constructor(scene, x, y, texture, corre, diff, num, explanation, sec, min) {
    super(scene, x, y, texture);
    var that = this
    that.setInteractive({ useHandCursor: true })
      .on('pointerover', () => that.enterButtonHoverState() )
      .on('pointerout', () => that.enterButtonRestState() )
      .on('pointerdown', () => that.enterButtonActiveState() )
      .on('pointerup', () => {
        that.enterButtonHoverState();
        if(patch == true){
          let points = 0
        }
        let started = true
        let padding = 20
        
        number = num
        diff++
        answs[0].setColor("#bf0000")
        answs[1].setColor("#bf0000")
        answs[2].setColor("#bf0000")
        answs[3].setColor("#bf0000")

        answs[correct-1].setColor("#008a2e")
        if(corre == true){
          if(patch == true){
            points = (diff * 100)
            buton = scene.add.image(500, 300, "ansButt")
            buton.setInteractive({ useHandCursor: true })
            buton.on('pointerover', () => buton.setTint(505050) )
            buton.on('pointerout', () => buton.clearTint() )
            buton.on('pointerdown', () => buton.setTint(252525) )
            let beenus = scene.add.text(400,300,"Correct! \n"+explanation+"\nPress to Continue.",{font: "18px Optima", fill: "#000000"})
            beenus.setAlign("center")
            beenus.setColor("#000000")
            buton.displayWidth = padding * 2 + beenus.displayWidth
            buton.displayHeight = padding * 2 + beenus.displayHeight
            Phaser.Display.Align.In.Center(beenus,buton)
            buton.on('pointerup', () => {
              if (quesArr[(quest * 6) - 1] != ")"){
                pic.destroy()
              }
              scene.scene.start("gameboard", {
                "points": points
                },{
                "number": number
                },{
                  "sec": sec
                },{
                  "min": min
              })
            })
          }
        }
        else if(corre == false){
          if(patch == true){
            points = (diff * 100)*-1
          
            buton = scene.add.image(500, 300, "ansButt")
            buton.setInteractive({ useHandCursor: true })
            buton.on('pointerover', () => buton.setTint(505050) )
            buton.on('pointerout', () => buton.clearTint() )
            buton.on('pointerdown', () => buton.setTint(252525) )
            let beenus = scene.add.text(400,300,"Incorrect. \n"+explanation+"\nPress to Continue.",{font: "18px Optima", fill: "#000000"})
            beenus.setColor("#000000")
            buton.displayWidth = padding * 2 + beenus.displayWidth
            buton.displayHeight = padding * 2 + beenus.displayHeight
            Phaser.Display.Align.In.Center(beenus,buton)
            buton.on('pointerup', () => {
              if (quesArr[(quest * 6) - 1] != ")"){
                pic.destroy()
              }
              scene.scene.start("gameboard", {
                "points": points
                },{
                "number": number
                },{
                  "sec": sec
                },{
                  "min": min
              })
            })
          }
        }
        patch = false

      });
  }

  enterButtonHoverState() {
    this.setTint(505050);
  }

  enterButtonRestState() {
    this.clearTint();
  }

  enterButtonActiveState() {
    this.setTint(252525);
  }
}