Add: lowest is prefered app - highest record, ranking sorting sequence
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
// Chocoball.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
Chocoball.constructor = Chocoball;
|
||||
|
||||
function Chocoball(index, onClickHandler) {
|
||||
function Chocoball(index, difficulty, onClickHandler) {
|
||||
this.index = index;
|
||||
this.difficulty = difficulty;
|
||||
this.onClickHandler = onClickHandler;
|
||||
|
||||
this.initVariables();
|
||||
@@ -60,11 +61,11 @@ Chocoball.prototype.setNumber = function(number) {
|
||||
this.number = number;
|
||||
this.numberText.text = number;
|
||||
|
||||
this.setBodyColor(this.number, Chocoball.MODE_EASY);
|
||||
this.setBodyColor(this.number);
|
||||
}
|
||||
|
||||
Chocoball.prototype.setBodyColor = function(number, mode) {
|
||||
if(mode == Chocoball.MODE_DIFFICULT) {
|
||||
Chocoball.prototype.setBodyColor = function(number) {
|
||||
if(this.difficulty == Chocoball.MODE_DIFFICULT) {
|
||||
this.body.tint = Chocoball.COLOR_BLACK;
|
||||
return;
|
||||
}
|
||||
@@ -85,8 +86,11 @@ Chocoball.prototype.setBodyColor = function(number, mode) {
|
||||
|
||||
Chocoball.prototype.setActive = function(isActivated) {
|
||||
this.isActivated = isActivated;
|
||||
this.body.visible = isActivated;
|
||||
this.gloss.visible = isActivated;
|
||||
}
|
||||
|
||||
Chocoball.prototype.setVisible = function(visible) {
|
||||
this.body.visible = visible;
|
||||
this.gloss.visible = visible;
|
||||
}
|
||||
|
||||
Chocoball.prototype.onClick = function() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
var Game = {
|
||||
|
||||
create: function() {
|
||||
this.initVariables();
|
||||
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
sessionStorageManager.setRecord(0);
|
||||
|
||||
@@ -31,7 +33,6 @@ var Game = {
|
||||
|
||||
|
||||
// init game elements
|
||||
this.initVariables();
|
||||
this.drawObjects();
|
||||
|
||||
|
||||
@@ -47,8 +48,19 @@ var Game = {
|
||||
},
|
||||
|
||||
initVariables: function() {
|
||||
this.mode = "test";
|
||||
|
||||
this.nextNumber = 1;
|
||||
|
||||
this.difficulty = Chocoball.MODE_DIFFICULT;
|
||||
// if previous record is over 60 sec, play easy mode
|
||||
var prevRecord = sessionStorageManager.getRecord()
|
||||
// console.log(prevRecord);
|
||||
var secForEasyMode = this.mode == "test" ? 1 : 60;
|
||||
if(prevRecord > secForEasyMode) {
|
||||
this.difficulty = Chocoball.MODE_EASY;
|
||||
}
|
||||
|
||||
this.firstChocoballArray = this.makeChocoballArray(1, 25);
|
||||
this.secondChocoballArray = this.makeChocoballArray(26, 50);
|
||||
},
|
||||
@@ -58,6 +70,7 @@ var Game = {
|
||||
for(var i = 0; i < 25; i++) {
|
||||
var chocoball = new Chocoball(
|
||||
i,
|
||||
this.difficulty,
|
||||
(function(chocoball) { this.onClickChocoball(chocoball); }).bind(this)
|
||||
);
|
||||
chocoball.setNumber(this.firstChocoballArray[i]);
|
||||
@@ -92,6 +105,7 @@ var Game = {
|
||||
|
||||
this.nextChocoball = new Chocoball(
|
||||
100,
|
||||
this.difficulty,
|
||||
(function(chocoball) { console.log("no event") }).bind(this)
|
||||
);
|
||||
this.nextChocoball.setNumber(this.nextNumber);
|
||||
@@ -117,7 +131,7 @@ var Game = {
|
||||
|
||||
onClickChocoball: function(chocoball) {
|
||||
// console.log(chocoball.index);
|
||||
console.log(chocoball.number);
|
||||
// console.log(chocoball.number);
|
||||
|
||||
if(chocoball.number == 1)
|
||||
this.stopWatch.start();
|
||||
@@ -135,7 +149,15 @@ var Game = {
|
||||
chocoball.setNumber(this.secondChocoballArray[chocoball.index]);
|
||||
this.nextChocoball.setNumber(this.nextNumber);
|
||||
} else {
|
||||
chocoball.setActive(false);
|
||||
chocoball.setVisible(false);
|
||||
}
|
||||
|
||||
if(this.mode == "test") {
|
||||
if(this.nextNumber == 3) {
|
||||
console.log("time over");
|
||||
this.timeOver();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(chocoball.number == 50) {
|
||||
@@ -159,10 +181,6 @@ var Game = {
|
||||
},
|
||||
|
||||
timeOver: function() {
|
||||
var timeOverText = new TimeOverText();
|
||||
if(!isExperienceMaestroAccount())
|
||||
this.updateResultRecord();
|
||||
|
||||
var recordTime = this.stopWatch.stop();
|
||||
sessionStorageManager.setRecord(recordTime);
|
||||
if(!isExperienceMaestroAccount())
|
||||
@@ -173,9 +191,6 @@ var Game = {
|
||||
},
|
||||
|
||||
updateResultRecord: function() {
|
||||
console.log("update record : " + sessionStorageManager.getRecord());
|
||||
return;
|
||||
|
||||
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
||||
this.dbConnectManager.updateResultRecord(
|
||||
sessionStorageManager.getMaestroID(),
|
||||
@@ -187,7 +202,7 @@ var Game = {
|
||||
},
|
||||
|
||||
goResult: function() {
|
||||
location.href = '../../web/client/result.html';
|
||||
location.href = '../../web/client/result.html?update=1905101';
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user