大奖游戏未返回结果文本

时间:2018-12-31 03:56:12

标签: javascript jquery html

背景信息:

在每个回合结束时创建了头奖游戏-将显示输赢的文字

已完成的操作:

创建了一个switch语句来检查每个插槽的元素。创建了一个条件检查语句,以检查所有3个插槽是否相同-将是胜利,否则将是失败

问题:

在每次旋转结束时-没有赢或输的更新文本:

代码:

var BLURB_TBL = [
'JACKPOT!'
];
switch (this.state) {
case 1: // all slots spinning
if (now - this.lastUpdate > RUNTIME) {
    this.state = 2;
    this.lastUpdate = now;
}
break;
case 2: // slot 1
this.stopped1 = _check_slot( this.offset1, this.result1 );
if ( this.stopped1 ) {
    this.speed1 = 0;
    this.state++;
    this.lastUpdate = now;
}
break;
case 3: // slot 1 stopped, slot 2
this.stopped2 = _check_slot( this.offset2, this.result2 );
if ( this.stopped2 ) {
    this.speed2 = 0;
    this.state++;
    this.lastUpdate = now;
}
break;
case 4: // slot 2 stopped, slot 3
this.stopped3 = _check_slot( this.offset3, this.result3 );
if ( this.stopped3 ) {
    this.speed3 = 0;
    this.state++;
}
break;
case 5: // slots stopped 
if ( now - this.lastUpdate > 3000 ) {
    this.state = 6;
}
break;
case 6: // check results

if ((that.items1[that.result1].id == 'gold-64' && that.items2[that.result2].id == 'gold-64' && that.items3[that.result3].id == 'gold-64') || (that.items1[that.result1].id == 'cash-64' && that.items2[that.result2].id == 'cash-64' && that.items3[that.result3].id == 'cash-64') || (that.items1[that.result1].id == 'energy-64' && that.items2[that.result2].id == 'energy-64' && that.items3[that.result3].id == 'energy-64') || (that.items1[that.result1].id == 'staff-64' && that.items2[that.result2].id == 'staff-64' && that.items3[that.result3].id == 'staff-64') || (that.items1[that.result1].id == 'build-64' && that.items2[that.result2].id == 'build-64' && that.items3[that.result3].id == 'build-64') || (that.items1[that.result1].id == 'goods-64' && that.items2[that.result2].id == 'goods-64' && that.items3[that.result3].id == 'goods-64')){
    $('#status').text(BLURB_TBL);
}else {
    $('#status').text("GOOD TRY!!");
}




this.state = 7;
break;
case 7: // game ends
break;
default:
}
this.lastupdate = now;

1 个答案:

答案 0 :(得分:0)

您缺少返回函数。

对于此示例:

function a() {
    alert('A');
}
//alerts 'A', returns undefined

function b() {
    alert('B');
    return a;
}
//alerts 'B', returns function a

function c() {
    alert('C');
    return a();
}
//alerts 'C', alerts 'A', returns undefined

alert("Function 'a' returns " + a());
alert("Function 'b' returns " + b());
alert("Function 'c' returns " + c());