Php ajax játék működéséhez.

Php ajax játék működéséhez.
2014-04-21T21:07:25+02:00
2014-04-21T21:07:26+02:00
2022-10-22T15:00:37+02:00
  • Sziasztok.
    Van egy játék,amiben szeretnék segítséget kérni.

    php és js alapú.
    Az adatbázisommal sikerült összehangolni.
    Képileg és a fő tevékenységek meg vannak.
    De viszont elmondások szerint ezek a file-ok kellenének:

    points.php

    win.php

    hold.php

    fr.php

    reels.php

    setbox3.php

    numbers.php

    gamble.php

    bet.php

    close-risiko.php

    latest.php

    get-bid.php

    reset-points.php

    A kódom így néz ki:


    var movingreels=0; var dicereels=0; var fkockas=0; //------------------------------- //COIN //------------------------------- var t1; var d=0; var coinflash=0; function coin(){ coinflash=1; $('#coin2').css('opacity',d); if(d==0){d=1;}else{d=0;} t1=setTimeout(coin,250); }; //------------------------------- //STARTFLASH //------------------------------- var c=1; var t2; function startFlash(){ $('span#c'+c).toggleClass('light'); if(c>4){c=1}else{c++} t2=setTimeout("startFlash()",100); } //------------------------------- //GAMBLE //------------------------------- var t3; var gamblet=0; function gamble(){ $('#felir').addClass('light'); $('#risiko-st').click(); if(c==1){ $('#risiko-red').addClass('light'); $('#risiko-blue').removeClass('light'); }else{ $('#risiko-red').removeClass('light'); $('#risiko-blue').addClass('light'); } if(c>1){c=0}else{c++} gamblet=1; t3=setTimeout("gamble()",50); } //------------------------------- //GETBID //------------------------------- function getBid(){ $.get('ajax/get-bid.php', function(num){ $('#bets td').removeClass('light'); $('#bets td.bet'+num).addClass('light'); $('#xbet div').html(num); Cufon.refresh(); /*$('#status-bar span').removeClass('light'); $('#c'+num).addClass('light');*/ }); } //------------------------------- //DRAWNUMBERS //------------------------------- function drawNumbers(cl,target){ $.get('ajax/numbers.php', function(num){ startDraw(cl,target,num); }); } //------------------------------- //STARTDRAW //------------------------------- function startDraw(cl,target,num){ //num=num.toString(); $("#"+target).html(num); Cufon.refresh(); } //------------------------------- //GETGAMBLE //------------------------------- function getGamble(clr){ if(gamblet==1){ $.get('ajax/gamble.php?c='+clr, function(lr){ lr=lr.split('-'); clearTimeout(t3); $('#risiko-'+lr[0]).addClass('light'); $('#risiko-'+lr[1]).removeClass('light'); startDraw(0,'risiko div',lr[3]); if(lr[2]==1){ gamblet=1; $('#yeah-st').click(); setTimeout(gamble, 300); }else{ gamblet=0; $('#risiko-op').click(); $('#ooh-st').click(); getPoints(); $('#felir').removeClass('light'); } }); } } //------------------------------- //SETBET //------------------------------- function setBet(){ $('#bet-op').click();$('#bet-st').click(); $.get('ajax/bet.php', function(bk){ getBid(); }); } //------------------------------- //CLEARRISIKO //------------------------------- function clearRisiko(){ clearTimeout(t3); //console.log('g: '+gamblet+', fk: '+fkockas); if(gamblet==0){ fkockas=0; } gamblet=0; $('#risiko-op').click(); $('#z-money-st').click(); $.get('ajax/close-risiko.php?fk='+fkockas,function(){ $('#risiko-holder div').removeClass('light'); getPoints(); $('#felir').removeClass('light'); }); } //------------------------------- //GETLATEST //------------------------------- function getLatest(){ $.get('ajax/latest.php', function(rl){ rl=rl.split('-'); $('reel#r1').html('<img src="symbol/n-'+rl[0]+'.png">'); $('reel#r2').html('<img src="symbol/n-'+rl[1]+'.png">'); $('reel#r3').html('<img src="symbol/n-'+rl[2]+'.png">'); $('reel#r4').html('<img src="symbol/n-'+rl[3]+'.png">'); $('reel#r5').html('<img src="symbol/n-'+rl[4]+'.png">'); $('reel#r6').html('<img src="symbol/n-'+rl[5]+'.png">'); $('reel#r7').html('<img src="symbol/n-'+rl[6]+'.png">'); $('reel#r8').html('<img src="symbol/n-'+rl[7]+'.png">'); $('reel#r9').html('<img src="symbol/n-'+rl[8]+'.png">'); getPoints(); }); } //------------------------------- //GETPOINTS //------------------------------- function getPoints(){ $.get('ajax/points.php', function(rl){ rl=rl.split('|'); if(rl[0]<1000){if(coinflash==0)coin();}else{clearTimeout(t1);coinflash=0;} startDraw(0,'points div',rl[0]); startDraw(0,'risiko div',rl[1]); startDraw(0,'rank div',rl[2]); startDraw(0,'bank div',rl[3]); }); } //------------------------------- //GETWINS //------------------------------- function getWins(hld){ $.get('ajax/win.php', function(rh){ rh=rh.split('|'); rl=rh[0]; if(rl!=''){ rl=rl.split('-'); for(i=0; i<rl.length; i++){ $('reel#'+rl[i]).html('<img src="symbol/l-'+rl[(i+1)]+'.png">'); i++; } $('#hold > button').addClass('disabled2'); rd=rh[1]; rd=rd.split('-'); if(rd[0]=='kck'){ kocka(); }else if(rd[1]=='bns'){ getBonus(); }else if(rd[2]=='ebns'){ getExtra(); }else if(rd[2]=='rbns'){ gabmle(); }else if(rd[3]=='clck'){ movingreels=1; $('#z-clock-st').click(); var addclck=function(){ movingreels=0; clearRisiko(); } setTimeout(addclck,5000); }else if(rl!=''){ gamble(); } }else{ if(hld!='nohold'){ getHold(); }else{ $('#hold > button').addClass('disabled2'); } } getPoints(); }); } //------------------------------- //GETHOLD //------------------------------- function getHold(){ $.get('ajax/hold.php', function(rl){ if(rl!=''){ rl=rl.split('|'); rl1=rl[0].split('-'); for(i=0; i<rl1.length; i++){ $('reel#'+rl1[i]).html('<img src="symbol/s-'+rl1[(i+1)]+'.png">'); i++; } rl2=rl[1].split('-'); for(i=0;i<rl2.length;i++){ $('button#hold-'+rl2[i]).addClass('hold'); } $('#hold > button').addClass('disabled'); $('button#felir').addClass('light'); } }); } //------------------------------- //RESETPOINTS //------------------------------- function resetPoints(){ $.get('ajax/reset-points.php', function(){ getPoints(); }); } //------------------------------- //MESSAGEBOX //------------------------------- function messageBox(type, msg){ $('#message-holder').fadeIn('slow'); $('#message-box').removeClass('alert').removeClass('error').removeClass('success'); $('#message-box').addClass(type); $('#message-box #msg').html(msg); var w=$(window).width(); var h=$(window).height(); var t=$('#message-box').innerHeight(); var l=$('#message-box').innerWidth(); w=(w-l)/2; h=(h-t)/2; $('#message-box').css('top',h).css('left',w); } //------------------------------- //MESSAGEBOX2 //------------------------------- function messageBox2(){ $('#message-holder2').fadeIn('slow'); var w=$(window).width(); var h=$(window).height(); var t=$('#message-box2').innerHeight(); var l=$('#message-box2').innerWidth(); w=(w-l)/2; h=(h-t)/2; $('#message-box2').css('top',h).css('left',w); } //------------------------------- //CLOSEBOX //------------------------------- function closeBox(){ $('#message-holder').fadeOut('fast', function(){ $('#message-box').removeClass('alert').removeClass('error').removeClass('success'); $('#message-box #msg').html(''); }); } //------------------------------- //CLOSEBOX2 //------------------------------- function closeBox2(){ $('#message-holder2').fadeOut('fast'); } //------------------------------- //GETFR //------------------------------- function getFr(sst){ $.get('ajax/fr.php', function(rl){ var Fr=rl.split('_'); var stps=0; var tmo; var steps=Fr[1].split(';'); var mn=parseInt(Fr[0]); //console.log('FR: '+Fr); startDraw(0,'points div',Fr[5]); var stepDice = function(){ $('#table div').removeClass('light'); $('#fr'+steps[stps]).addClass('light'); if(stps<mn){ stps+=1; tmo=setTimeout(stepDice,25); }else{ clearTimeout(tmo); //return(Fr[2]); } } if(sst==1){ $('mdice').css('display','none'); $('#kkck').removeClass('kkck-1').removeClass('kkck-2').removeClass('kkck-3').removeClass('kkck-4').removeClass('kkck-5').removeClass('kkck-6'); $('#kkck').addClass('kkck-'+(Fr[0]>6?6:Fr[0])); startDraw(0,'bank div',Fr[3]); tmo=setTimeout(stepDice,100); }else{ var dicean=function(){ $('#kkck').removeClass('kkck-1').removeClass('kkck-2').removeClass('kkck-3').removeClass('kkck-4').removeClass('kkck-5').removeClass('kkck-6'); $('#kkck').addClass('kkck-'+(Fr[0]>6?6:Fr[0])); startDraw(0,'bank div',Fr[3]); $('mdice').css('display','none'); tmo=setTimeout(stepDice,100); } $('mdice').css('display','block'); setTimeout(dicean,400); } if(Fr[2]>1){fkockas=1;}else{fkockas=0;} }); } //------------------------------- //GETREELS //------------------------------- function getReels(){ $('#felir').removeClass('light'); $('#start').addClass('nl'); $('#bet').addClass('nl'); $('#reel-st').click(); movingreels=1; $('mdice').css('display','block'); if($('#hold-1').hasClass('hold')==false){ $('.hld1').css('display','block'); var sld1=$('.bxslider1').bxSlider({ mode: 'vertical', slideMargin: 14, minSlides: 4, maxSlides: 4, slideWidth: 90, speed: 800, controls: false, pager: false, autoDirection: 'prev', ticker: true }); } if($('#hold-2').hasClass('hold')==false){ $('.hld2').css('display','block'); var sld2=$('.bxslider2').bxSlider({ mode: 'vertical', slideMargin: 14, minSlides: 4, maxSlides: 4, slideWidth: 64, speed: 500, controls: false, pager: false, autoDirection: 'prev', ticker: true }); } if($('#hold-3').hasClass('hold')==false){ $('.hld3').css('display','block'); var sld3=$('.bxslider3').bxSlider({ mode: 'vertical', slideMargin: 14, minSlides: 4, maxSlides: 4, slideWidth: 64, speed: 650, controls: false, pager: false, autoDirection: 'prev', ticker: true }); } $('#hold > button').removeClass('disabled').removeClass('disabled2'); $('#risiko-holder div').removeClass('light'); var pl=''; $('#hold > button.hold').each(function(){ var id=$(this).attr('id'); id=id.split('-'); pl=pl+'-'+id[1]; }); if(pl!=''){ pl=pl.substr(1); pl='?hold='+pl; } $.get('ajax/reels.php'+pl, function(rl){ rl=rl.split('-'); if(rl[0]=='redirect'){ window.location.href=rl[1]; }else{ getPoints(); var doIt = function(){ movingreels=0; $('reel#r1').html('<img src="symbol/n-'+rl[0]+'.png">'); $('reel#r2').html('<img src="symbol/n-'+rl[1]+'.png">'); $('reel#r3').html('<img src="symbol/n-'+rl[2]+'.png">'); $('reel#r4').html('<img src="symbol/n-'+rl[3]+'.png">'); $('reel#r5').html('<img src="symbol/n-'+rl[4]+'.png">'); $('reel#r6').html('<img src="symbol/n-'+rl[5]+'.png">'); $('reel#r7').html('<img src="symbol/n-'+rl[6]+'.png">'); $('reel#r8').html('<img src="symbol/n-'+rl[7]+'.png">'); $('reel#r9').html('<img src="symbol/n-'+rl[8]+'.png">'); if(rl[9]=='nohold'){$('#hold button').removeClass('hold');} getFr(1); getWins(rl[9]); $('.bxslider').css('display','none'); if(sld1!=undefined){sld1.destroySlider();} if(sld2!=undefined){sld2.destroySlider();} if(sld3!=undefined){sld3.destroySlider();} $('#reelend-st').click(); $('#start').removeClass('nl'); $('#bet').removeClass('nl'); } setTimeout(doIt,400); } }); } function changeHold(){ var c=0; $('#hold > button.hold').each(function(){ c++; }); if(c>0){$('#felir').addClass('light');} if(c==3){$('#hold > button').removeClass('hold');$('#felir').removeClass('light');} if(c==0){$('#felir').removeClass('light');} } function forceFullscreen(){ top.resizeTo(window.screen.availWidth, window.screen.availHtight); top.moveTo(0,0); setTimeout("forceFullscreen()", 300); } //------------------------------- //MESSAGEBOX3 //------------------------------- function messageBox3(){ $('#message-holder3').fadeIn('slow'); var w=$(window).width(); var h=$(window).height(); var t=$('#message-box3').innerHeight(); var l=$('#message-box3').innerWidth(); w=(w-l)/2; h=(h-t)/2; $('#message-box3').css('top',h).css('left',w); } //------------------------------- //CLOSEBOX3 //------------------------------- function closeBox3(){ if($('#box3-pipa').is(':checked')){ $.get('ajax/setbox3.php',function(){ $('#message-holder3?
    Mutasd a teljes hozzászólást!
Tetszett amit olvastál? Szeretnél a jövőben is értesülni a hasonló érdekességekről?
abcd