javascript - Slot game, how to print "win" or "lose" in Paragraph tag -


i'm quite new jquery, how make prints "you have won" or " have lost". want make if hit 3 same fruits prints have won.

	function ezslots(id,useroptions){  	var = this; //keep reference function use in callbacks  	//set variables options, or defaults.  	var options = useroptions ? useroptions : {};  	this.reelcount = options.reelcount ? options.reelcount : 3; //how many reels, assume 3   	this.symbols = options.symbols ? options.symbols : ['a','b','c'];  	this.samesymbolseachslot = true;  	this.startingset = options.startingset;  	this.winningset = options.winningset;  	this.width = options.width ? options.width : 100;  	this.height = options.width ? options.height : 100;  	this.howmanysymbolstoappend = 20; //how many symbols each spin adds  	this.endinglocation = 7; //location selected symbol... needs few smaller howmanysymbolstoappend  	this.time = 500; //time in millis spin take  	this.jqo = $("#"+id); //jquery object reference main wrapper  	this.jqosliders = []; //jquery object reference strips sliding , down    	//to initialize construct correct number of slot windows  	//and populate each strip once  	this.init = function(){  		this.jqo.addclass("ezslots"); //to css goodness  		//figure out if using same of symbols each window - assume if first   		//entry of symbols not string have array of arrays  		if(typeof this.symbols[0] != 'string'){  			this.samesymbolseachslot = false;  		}  		//make each slot window  		for(var = 0; < this.reelcount; i++){  			var jqoslider = $('<div class="slider"></div>');  			var jqowindow = $('<div class="window window_"'+i+'></div>');  			this.scalejqo(jqowindow).append(jqoslider); //make window right size , put slider in  			this.jqo.append(jqowindow); //add window main div  			this.jqosliders.push(jqoslider); //keep reference jqo of slider  			this.addsymbolstostrip(jqoslider,i, false, true); //and add initial set   		}  	};  	//convenience function since need apply width , height multiple parts  	this.scalejqo = function(jqo){  		jqo.css("height",this.height+"px").css("width",this.width+"px");  		return jqo;  	}  	//add various symbols - take care possibly add "winner" symbol chosen  	this.addsymbolstostrip = function(jqoslider, whichreel, shouldwin, isinitialcall){  		var symbolstouse = that.samesymbolseachslot ? that.symbols : that.symbols[whichreel];  		var chosen =  shouldwin ? that.winningset[whichreel] : math.floor(math.random()*symbolstouse.length);  		for(var = 0; < that.howmanysymbolstoappend; i++){  			var ctr = (i == that.endinglocation) ? chosen : math.floor(math.random()*symbolstouse.length);  			if(i == 0 && isinitialcall && that.startingset){  				ctr = that.startingset[whichreel];  			}  			//we nest "content" inside of "symbol" can vertical , horizontal centering more  			var jqocontent = $("<div class='content'>"+symbolstouse[ctr]+"</div>");  			that.scalejqo(jqocontent);  			var jqosymbol = $("<div class='symbol'></div>");  			that.scalejqo(jqosymbol);  			jqosymbol.append(jqocontent);  			jqoslider.append(jqosymbol);  		}  		return chosen;  	}  	//to spin, add symbols strip, , bounce down  	this.spinone = function(jqoslider,whichreel,shouldwin){  		var heightbefore = parseint(jqoslider.css("height"), 10);   		var chosen = that.addsymbolstostrip(jqoslider,whichreel,shouldwin);  		var margintop = -(heightbefore + ((that.endinglocation) * that.height));  		jqoslider.stop(true,true).animate(  			{"margin-top":margintop+"px"},  			{'duration' : that.time + math.round(math.random()*1000), 'easing' : "easeoutelastic"});  		return chosen;  	}    	this.spinall = function(shouldwin){  		var results = [];  		for(var = 0; < that.reelcount; i++){  				results.push(that.spinone(that.jqosliders[i],i,shouldwin));  			}  		return results;  	}    	this.init();  	return {  		spin : function(){  			return that.spinall();  		},  		win : function(){  			return that.spinall(true);  		}  	}  }  $(function(){  	//setting sample set sof things can make slot machine of  	var images = ['<img src="images/seven.png">','<img src="images/banana.png">','<img src="images/cherries.png">','<img src="images/lemon.png">','<img src="images/orange.png">','<img src="images/plum.png">','<img src="images/watermelon.png">'];  	//using images instead, , more reels  	var ezslot2 = new ezslots("ezslots2",{"reelcount":3,"winningset":[0,0,0],"symbols":images,"height":126,"width":126});  	    	$(document).ready(function() { console.log(ezslot2.spin());});  });

i using template github that's made remaking own needs.

please easy on me i'm new jquery :)

thank much!


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -