限制随机图像以在指定的时间段内显示x时间

时间:2016-12-23 09:05:25

标签: javascript jquery arrays random

功能性:

随机游戏结果图像将根据用户玩的游戏结果显示在图像容器中。

但是,有一些标准与随机显示的游戏结果图像有关。他们是:

1。)随机显示的图像每天只显示x次。显示x次后,生成的图像将不再随机化。

2。)随机生成的图像将每天显示x次,持续一段时间:意思 - >图像A将从今天(2016年12月23日00:00:00)随机生成一个月,并将于(23/01/2017 23:59:59)结束。每天,图像只会随机生成6次。

问题:

此时,我已根据不同的游戏结果场景设置了随机生成的方法。它不会读取现在的时间段和次数。

我不知道如何处理以下条件:我所尝试的所有导致错误的是我设置了一个for循环但是我设置的以下for循环仅用于每日随机生成。

因此,我不知道如何使用所陈述的标准来实现以下目标。

请告知/帮助。

代码



//With reference to prize display for Jackpot Spin
var Prize_1 = ["lib/image/Prize/CeHK.png", "lib/image/Prize/CuSet.png"];
var Prize_2 = ["lib/image/Prize/Suunch.png", "lib/image/Prize/Esit.png", "lib/image/Prize/Mold's.png", "lib/image/Prize/Kiis.png", "lib/image/Prize/Ai.png", "lib/image/Prize/shra.png" ];
var Prize_3 = ["lib/image/Prize/Moto.png", "lib/image/Prize/Saung.png", "lib/image/Prize/Timnd.png", "lib/image/Prize/Blety.png", "lib/image/Prize/Raco.png", "lib/image/Prize/Chaai.png"];

/*Check the slot result: depending on slot result will display the respective result page*/
if ((that.items1[that.result1].id == 'goods-64') && (that.items2[that.result2].id == 'goods-64') && (that.items3[that.result3].id == 'gold-64')) {

    //Randomise Winning - Prize 1
    var random_Winning_1 = Math.floor(Math.random() * Prize_1.length);
    var showPrize_1 = Prize_1[random_Winning_1];

    //Display Winning Prize: Prize 1
    $("#Winnings_Description").attr('src', showPrize_1).show();

    $('#VoucherPreview').fadeIn();

} else if ((that.items1[that.result1].id == 'energy-64') && (that.items2[that.result2].id == 'energy-64') && (that.items3[that.result3].id == 'cash-64')) {

    //Randomise Winning - Prize 2
    var random_Winning_2 = Math.floor(Math.random() * Prize_2.length);
    var showPrize_2 = Prize_2[random_Winning_2];

    $("#Winnings_Description").attr('src', showPrize_2).show();

    $('#VoucherPreview').fadeIn();

} else if ((that.items1[that.result1].id == 'cash-64') && (that.items2[that.result2].id == 'cash-64') && (that.items3[that.result3].id == 'build-64')) {

    //Randomise Winning - Prize 3
    var random_Winning_3 = Math.floor(Math.random() * Prize_3.length);
    var showPrize_3 = Prize_3[random_Winning_3];

    //Display Winning Prize: Prize 3
    $("#Winnings_Description").attr('src', showPrize_3).show();

    $('#VoucherPreview').fadeIn();

} else if ((that.items1[that.result1].id == 'build-64') && (that.items2[that.result2].id == 'build-64') && (that.items3[that.result3].id == 'build-64')) {

    //Display GAP as Prize Winning
    //Display Winning Prize: GAP
    $("#Winnings_Description").attr('src', "lib/image/Prize/Gap.png").show();

    $('#VoucherPreview').fadeIn();

} else if ((that.items1[that.result1].id == 'staff-64') && (that.items2[that.result2].id == 'staff-64') && (that.items3[that.result3].id == 'staff-64')) {

    //Display Guess as Prize Winning
    //Display Winning Prize: Guess
    $("#Winnings_Description").attr('src', "lib/image/Prize/Guess.png").show();

    $('#VoucherPreview').fadeIn();

} else {

    //If user has got no winning sets
    alert("game lost: Loser");
}

<div id="VoucherPreview" align="center" style="position:absolute; width:1920px; height:1080px; background-repeat: no-repeat; display: none; z-index=14; top:0px; left:1921px; ">
  <img id="Winnings_Description" style="position:absolute; top:333px; left:543px; z-index=99; margin:auto;">
</div>
&#13;
&#13;
&#13;

Plunker:https://plnkr.co/edit/Iyai0QsJHTjjfODRzw21?p=catalogue

0 个答案:

没有答案