Fix goal calulcation

This commit is contained in:
Evert Prants 2019-11-29 20:45:52 +02:00
parent 85dd6cf45f
commit 5d3856f95a
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -2,6 +2,8 @@ import { canvas, ctx } from './canvas'
import { Level, Rock, Gold, Diamond, Lootbag } from './level' import { Level, Rock, Gold, Diamond, Lootbag } from './level'
import { randomi } from './utils' import { randomi } from './utils'
const MAP_CLEARANCE_PERCENTAGE = 80
const REWARD_TABLE = { const REWARD_TABLE = {
rock: 16, rock: 16,
gold: [129, 543, 2399], gold: [129, 543, 2399],
@ -16,6 +18,7 @@ export class Game {
this.roundTime = time this.roundTime = time
this.time = time this.time = time
this.score = 0 this.score = 0
this.lastGoal = 0
this.goal = 0 this.goal = 0
this.level = null this.level = null
@ -68,7 +71,8 @@ export class Game {
this.currentLevel++ this.currentLevel++
this.time = this.roundTime this.time = this.roundTime
this.level = Level.create(this.currentLevel, this.oh, this.gw, this.gh) this.level = Level.create(this.currentLevel, this.oh, this.gw, this.gh)
this.goal = Math.floor(this.score / 2 + Game.calculateLevelScore(this.level) * 0.65) this.lastGoal = this.goal
this.goal = Math.floor(this.lastGoal + Game.calculateLevelScore(this.level) * (MAP_CLEARANCE_PERCENTAGE / 100))
this.player.hook.clear() this.player.hook.clear()
} }
@ -142,6 +146,7 @@ export class Game {
setTimeout(() => { setTimeout(() => {
this.currentLevel = 0 this.currentLevel = 0
this.score = 0 this.score = 0
this.lastGoal = 0
this.nextLevel() this.nextLevel()
this.state = 0 this.state = 0
}, 500) }, 500)