js如何开发老虎机程序

点击进入测试连接

源代码如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>老虎机</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    


    <script type="text/javascript" src="/page/lanheActivity/script/jquery-1.11.1.min.js"></script>

    <script type="text/javascript" src="/js/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/newBrand/script/layer.js"></script>
    <script type="text/javascript" src="/newBrand/script/layer.ext.js"></script>
  </head>
 <style type="text/css"> 
      .table {
           border: 1px solid #ddd;
           border-collapse: collapse;
           margin: 0 auto;
       }

       .table thead tr th,
       .table tbody tr td {
           padding: 20px;
           text-align: center;
           color: #333;
           border: 2px solid #ddd;
           border-collapse: collapse;
           background-color: #fff;
       }
       
       html,body,div,img{
    margin:0;
    padding:0;
    border:0;
}
html,body{
    height:100%;
    width:100%;
}
.dil{
    margin: 0 auto; 
    width:350px;
    width:350px;
   
   
}
.li{ 
    width:80px;
    height:80px; 
    line-height:80px;
    float:left;  
    margin:6px 0 0 6px; 
    list-style:none;
    border:4px solid black;
    text-align: center;
}
.cur{ 
    border:4px solid red;
}
       
       
   </style>
  <body>
  <span  id="czxj">扫描二维码充值</span>
  <br>
  <img style="width:80px;height:80px; " src="/page/lanheActivity/images/43.png"/> 
  <br>
      你的财富值:<span  id ="totalmoney" style="font-size: 30px;">100</span>元<br> 
      <input οnclick="showcgdiv();" type="button" value="常规玩法">
      <input οnclick="showddxdiv();" type="button" value="赌大小玩法">
      
      <div class="dil" id="cg" style="display: block;margin:  0 auto; text-align: center;">
          
            <ul style="clear: both;">
            <li class="li" id="c1" style="width:80px;height:80px; ">苹果</li>
            <li class="li" id="c2" style="width:80px;height:80px; ">香蕉</li>
            <li class="li" id="c3" style="width:80px;height:80px; ">梨子</li>
            <li class="li" id="c8" style="width:80px;height:80px; ">花生</li>
            <li class="li" style="width:80px;height:80px; border: 4px solid white;" ></li>
            <li class="li" id="c4" style="width:80px;height:80px; ">西瓜</li>
            <li class="li" id="c7" style="width:80px;height:80px; ">可乐</li>
            <li class="li" id="c6" style="width:80px;height:80px; ">椰子</li>
            <li class="li" id="c5" style="width:80px;height:80px; ">菠萝</li>
           
        </ul>
        <div style="clear: both;" id="yavalue">
        
          <br>3倍苹果<input readonly="readonly" id="pg" style="width: 60px;" value="0"><input οnclick="pgadd(1);" type="button" id="pg" value="压点">
          <br>2倍香蕉<input readonly="readonly" id="xj" style="width: 60px;" value="0"><input οnclick="pgadd(2);"  type="button" id="pg" value="压点">
          <br>5倍梨子<input readonly="readonly" id="lz" style="width: 60px;" value="0"><input οnclick="pgadd(3);" type="button"  id="pg" value="压点">
          <br>3倍花生<input readonly="readonly" id="hs" style="width: 60px;" value="0"><input οnclick="pgadd(4);" type="button"  id="pg" value="压点">
          <br>6倍西瓜<input readonly="readonly" id="xg" style="width: 60px;" value="0"><input οnclick="pgadd(5);" type="button"  id="pg" value="压点">
          <br>4倍可乐<input readonly="readonly" id="kl" style="width: 60px;" value="0"><input οnclick="pgadd(6);" type="button"  id="pg" value="压点">
          <br>2倍椰子<input readonly="readonly" id="yz" style="width: 60px;" value="0"><input οnclick="pgadd(7);" type="button"  id="pg" value="压点">
          <br>8倍菠萝<input readonly="readonly" id="bl" style="width: 60px;" value="0"><input οnclick="pgadd(8);" type="button"  id="pg" value="压点">
          </div>
          <input οnclick="qidongcg();" type="button" style="width: 80px;height: 30px;" value="启动">
          <input id="hiv" type="hidden">
          
      </div>
      
      <div id="ddx" style="display: none;margin:  0 auto; text-align: center;">
          <input οnclick="getvalue();" type="button" value="投币"/><input οnclick="addvalue();" type="button" value="提现"/>
          <br>
          <input readonly="readonly" id="valuebi" type="text" value="0" style="width: 50px;height: 25px">
          <br>
          <br>
          <input  name="Fruit" type="radio" value="1" />
        <input  name="Fruit" type="radio" value="2" />
        
        <br>
          <span id="da" οnclick="xuan(1)" title="点击选择" style="border: 2px solid  #ddd;padding: 10px;width: 100px;height: 100px;line-height: 100px;cursor: pointer;">大</span>
          <span id="xia" οnclick="xuan(2)" title="点击选择" style="border: 2px solid  #ddd;padding: 10px;width: 100px;height: 100px;line-height: 100px;cursor: pointer;">小</span>
          
          <input style="display: none;" id="xuandx">
          <br>
          <input οnclick="qidong();" type="button" style="width: 80px;height: 30px;" value="启动">
      
      </div>
      
      
      
  </body>
  <script type="text/javascript">
  function pgadd(i){
      if(parseInt($("#totalmoney").text())<=0){
          alert("输光破产,活该,给潘少微信转账充值");
          return false;
      }
      if(i==1){
          $("#pg").val(parseInt($("#pg").val())+1);
          $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
        }else if(i==2){
            $("#xj").val(parseInt($("#xj").val())+1);
              $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
        }else if(i==3){
            $("#lz").val(parseInt($("#lz").val())+1);
              $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
        }else if(i==4){
            $("#hs").val(parseInt($("#hs").val())+1);
              $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
        }else if(i==5){
            $("#xg").val(parseInt($("#xg").val())+1);
              $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
        }else if(i==6){
            $("#kl").val(parseInt($("#kl").val())+1);
              $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
        }else if(i==7){
            $("#yz").val(parseInt($("#yz").val())+1);
              $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
        }else if(i==8){
            $("#bl").val(parseInt($("#bl").val())+1);
              $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
        }
      
  }
  
  
    var step1 = [['c1',0],['c1', 300],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 200],['c8', 150],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 100],['c8', 100],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 150],['c8', 150],['c1', 150],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 300],['c8', 300]];
    var step2 = [['c1',0],['c1', 300],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 200],['c8', 150],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 100],['c8', 100],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 150],['c7', 150],['c8', 150],['c1', 150],['c2', 200],['c3', 200],['c4', 200],['c5', 300],['c6', 300],['c7', 300]];
    var step3 = [['c1',0],['c1', 300],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 200],['c8', 150],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 100],['c8', 100],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 150],['c7', 150],['c8', 150],['c1', 150],['c2', 200],['c3', 200],['c4', 300],['c5', 300],['c6', 300]];
    var step4 = [['c1',0],['c1', 300],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 200],['c8', 150],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 100],['c8', 100],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 150],['c6', 150],['c7', 150],['c8', 150],['c1', 100],['c2', 200],['c3', 300],['c4', 300],['c5', 300]];
    var step5 = [['c1',0],['c1', 300],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 200],['c8', 150],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 100],['c8', 100],['c1', 100],['c2', 100],['c3', 100],['c4', 150],['c5', 150],['c6', 150],['c7', 150],['c8', 150],['c1', 200],['c2', 300],['c3', 300],['c4', 300]];
    var step6 = [['c1',0],['c1', 300],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 200],['c8', 150],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 100],['c8', 100],['c1', 100],['c2', 100],['c3', 150],['c4', 150],['c5', 150],['c6', 150],['c7', 150],['c8', 200],['c1', 300],['c2', 300],['c3', 300]];
    var step7 = [['c1',0],['c1', 300],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 200],['c8', 150],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 100],['c8', 100],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 150],['c6', 150],['c7', 200],['c8', 300],['c1', 300],['c2', 300]];
    var step8 = [['c1',0],['c1', 300],['c2', 200],['c3', 200],['c4', 200],['c5', 200],['c6', 200],['c7', 200],['c8', 150],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 100],['c6', 100],['c7', 100],['c8', 100],['c1', 100],['c2', 100],['c3', 100],['c4', 100],['c5', 150],['c6', 200],['c7', 200],['c8', 200],['c1', 200]];
    
    var numdsfg = 0;
    function qidongcg(){
        numdsfg  = Math.floor(Math.random()*(1 - 100) + 100);
        currentk = 1;
        runcg();
        
    }

    // 记录当前步数,即step数组的下标
    var currentk = 1;
    function runcg(){
         var i = 1;
        if(numdsfg>=1&&numdsfg<=10){
            i = 1;
        }else if(numdsfg>=11&&numdsfg<=20){
            i = 2;
        }else if(numdsfg>=21&&numdsfg<=30){
            i = 3;
        }else if(numdsfg>=31&&numdsfg<=40){
            i = 4;
        }else if(numdsfg>=41&&numdsfg<=50){
            i = 5;
        }else if(numdsfg>=51&&numdsfg<=60){
            i = 6;
        }else if(numdsfg>=61&&numdsfg<=70){
            i = 7;
        }else if(numdsfg>=71&&numdsfg<=100){
            i = 8;
        } 

        var stept = step1;
        if(i==1){
            stept = step1;
        }else if(i==2){
            stept = step2;
        }else if(i==3){
            stept = step3;
        }else if(i==4){
            stept = step4;
        }else if(i==5){
            stept = step5;
        }else if(i==6){
            stept = step6;
        }else if(i==7){
            stept = step7;
        }else if(i==8){
            stept = step8;
        }
        $("#hiv").val(i);
        
        // 删除之前设置的cur类
        $('#'+stept[currentk-1][0]).removeClass('cur');
        // 为当前元素设置cur类
        $('#'+stept[currentk][0]).addClass('cur');

        // 判断step数组所有步骤是否已经走完
        if(currentk == stept.length-1){  
            setTimeout(function(){
             if(parseInt($("#hiv").val())==1){
                if(parseInt($("#hs").val())==0){
                    alert("没中");
                }else{
                    alert("中奖3倍花生"+parseInt($("#hs").val())*3+"元");
                     $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#hs").val())*3);
                
                }
                
                
            }else if(parseInt($("#hiv").val())==2){
                if(parseInt($("#kl").val())==0){
                    alert("没中");
                }else{
                    alert("中奖4倍可乐"+parseInt($("#kl").val())*4+"元");
                     $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#kl").val())*4);
                
                }
                
                
            }else if(parseInt($("#hiv").val())==3){
                if(parseInt($("#yz").val())==0){
                    alert("没中");
                }else{
                    alert("中奖2倍椰子"+parseInt($("#yz").val())*2+"元");
                     $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#yz").val())*2);
                
                }
                
                
            }else if(parseInt($("#hiv").val())==4){
                if(parseInt($("#bl").val())==0){
                    alert("没中");
                }else{
                    alert("中奖8倍菠萝"+parseInt($("#bl").val())*8+"元");
                     $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#bl").val())*8);
                
                }
                
                
            }else if(parseInt($("#hiv").val())==5){
                if(parseInt($("#xg").val())==0){
                    alert("没中");
                }else{
                    alert("中奖6倍西瓜"+parseInt($("#xg").val())*6+"元");
                     $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#xg").val())*6);
                
                }
                
                
            }else if(parseInt($("#hiv").val())==6){
                if(parseInt($("#lz").val())==0){
                    alert("没中");
                }else{
                    alert("中奖5倍梨子"+parseInt($("#lz").val())*5+"元");
                     $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#lz").val())*5);
                
                }
                
                
            }else if(parseInt($("#hiv").val())==7){
                if(parseInt($("#xj").val())==0){
                    alert("没中");
                }else{
                    alert("中奖2倍香蕉"+parseInt($("#xj").val())*2+"元");
                     $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#xj").val())*2);
                
                }
                
                
            }else{
                if(parseInt($("#pg").val())==0){
                    alert("没中");
                }else{
                    alert("中奖3倍苹果"+parseInt($("#pg").val())*3+"元");
                     $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#pg").val())*3);
                
                }
                
                
            }
             
            
            
            var i =1;
            $("#yavalue").find("input").each(function (index,item) {
                i++;
                if(i%2==0){
                    $(item).val(0);
                }
            });
            
            
            },1000);
            
        }else{
            // 重新设置定时器
            setTimeout('runcg()', stept[currentk][1]);
            currentk++;
        }
    }
  
  var stepx = [['1',0],['2', 300],['1', 200],['2', 200],['1', 200],['2', 200],['1', 200],['2', 200],['1', 150],['2', 100],['1', 100],['2', 100],['1', 100],['2', 100],['1', 200],['2', 200],['1', 300],['2', 300],['1', 400],['2', 400],['1', 500]];
  var stepd = [['1',0],['2', 300],['1', 200],['2', 200],['1', 200],['2', 200],['1', 200],['2', 200],['1', 150],['2', 100],['1', 100],['2', 100],['1', 100],['2', 100],['1', 100],['2', 100],['1', 100],['2', 100],['1', 100],['2', 100],['1', 100],['2', 100]];
  //设置赌大小概率
  var numdsf = 0;
  
  function qidong(){
      numdsf =  Math.floor(Math.random()*(1 - 100) + 100);
      current = 1;
      run();
  }
  
    
  
  function addvalue(){
      $("#totalmoney").text(parseInt($("#totalmoney").text())+parseInt($("#valuebi").val()));
      $("#valuebi").val(0);
  }
  
    //记录当前步数,即step数组的下标
    var current = 1;
    //设置样式和重新设置定时器
    function run(){
        if(numdsf%2==0){
             //大 
              step = stepd;
        }else{
             //小
              step = stepx;
        }
        
        $("input[value='"+step[current-1][0]+"']").prop('checked', true);
        var xuandx =  $("#xuandx").val();
        // 判断step数组所有步骤是否已经走完
        if(current == step.length-1){
            
            if(numdsf%2==0){
                    //大 
                    if(xuandx==1){
                        $("#valuebi").val(parseInt($("#valuebi").val())*2);
                    }else{
                        $("#valuebi").val(0);
                    }
                 }else{
                    //小
                     if(xuandx==1){
                         $("#valuebi").val(0);
                    }else{
                        $("#valuebi").val(parseInt($("#valuebi").val())*2);
                        
                    }
                
               }
        }else{
            // 重新设置定时器
            setTimeout('run()', step[current][1]);
            current++;
        }
    }
  
  
 
  
  
  function xuan(data){
      $("#xuandx").val(data);
      if(data==1){
          $("#da").css("border","2px solid  red"); 
          $("#xia").css("border","2px solid  #ddd"); 
      }else{
          $("#da").css("border","2px solid  #ddd"); 
          $("#xia").css("border","2px solid  red"); 
      }
      
      
  }
  
  function getvalue(){
      if(parseInt($("#totalmoney").text())<=0){
          alert("输光破产,活该,给潘少微信转账充值");
          return false;
      }
      
      $("#valuebi").val(parseInt($("#valuebi").val())+1);
      $("#totalmoney").text(parseInt($("#totalmoney").text())-1);
      
  }
  function showcgdiv(){
      $("#cg").css("display","block");
      $("#ddx").css("display","none");
  }
  
  function showddxdiv(){
      $("#cg").css("display","none");
      $("#ddx").css("display","block");
  }
  
  
  
  
  
  
  
  </script>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值