Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //allow the die to roll only once
- var rolled=false;
- //get the game id from the php to the javascript
- function roll(){
- if(!rolled){
- var xmlhttp;
- if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else{// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4 && xmlhttp.status==200){
- var resp = xmlhttp.responseText;
- document.getElementById("die").innerHTML=resp;
- senddata(resp);
- }
- }
- xmlhttp.open("GET","die.php" ,true);
- xmlhttp.send();
- rolled=true;
- }
- }
- function nextgo(gid){
- var xmlhttp;
- if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else{// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4 && xmlhttp.status==200){
- var resp = xmlhttp.responseText;
- rolled=false;
- }
- }
- xmlhttp.open("GET","nextgo.php?gid=" + gid ,true);
- xmlhttp.send();
- }
- function trade(gid,uid){
- loading();
- var xmlhttp;
- if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else{// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4 && xmlhttp.status==200){
- var resp = xmlhttp.responseText;
- document.getElementById("the").innerHTML=resp;
- }
- }
- xmlhttp.open("GET","tradesfriend.php?gid=" + gid + "&uid=" + uid ,true);
- xmlhttp.send();
- }
- function moveme(gid,uid,roll){
- var req = "move.php?gid=" + gid + "&uid=" + uid + "&roll=" + roll;
- //alert(req);
- var xmlhttp;
- if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else{// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4 && xmlhttp.status==200){
- var resp = xmlhttp.responseText;
- }
- }
- xmlhttp.open("GET",req,true);
- xmlhttp.send();
- }
- function splayerstraid(uid,id,gid){
- loading();
- var req = "tradingfloor.php?gid=" + gid + "&uid=" + uid + "&id=" + id;
- var xmlhttp;
- if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else{// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4 && xmlhttp.status==200){
- var resp = xmlhttp.responseText;
- document.getElementById("the").innerHTML=resp;
- }
- }
- xmlhttp.open("GET",req,true);
- xmlhttp.send();
- }
- //code used in the tradesfriend script to make the pictures have a yellow border onmousover
- function createbd(id){
- $("#" + id).css({"border-style":"solid","border-width":"5px"});
- }
- function erasebd(id){
- $("#" + id).css({"color":"black","border":"0","border-color":"yellow"});
- }
- //global variable lines, holds each player's position in case of update
- var lines;
- function getPos(gid){
- var xmlhttp;
- if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }else{// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4 && xmlhttp.status==200){
- //returns a list of positions split by comma
- var resp = xmlhttp.responseText;
- //if this is the first time the function is called then inisiate lines
- if(lines ==null){
- lines = resp.split(",");
- //fill the array FBID so that it can be referenced to
- //pausable cause of error gid is initiated in the parent function
- FBIDret(gid);
- //start construction of players in their positions
- for(i=0;i<lines.length;i++){
- }
- }else{
- //otherwise check the new set of positions against the old ones
- var income;
- income = resp.split(",");
- //for loop through each player
- for (i=0;i<income.length;i++){
- //if there is a change from the old value to the new one
- if(income[i]!=lines[i]){//found the changed position
- if(doesListCont(lines[i],income)){//if contained in list 2 rewrite the innerHTML for that cell
- //rewrite cell by looking for the users who are still in that cell
- //look through to see who is in the square and generate the image of the square
- //update cell with new innerhtml
- chan(lines[i],stri);
- }else{
- chan(lines[i],0);
- }
- }//end of if change from old list to new list
- }//end of for loop through players
- }//end of else line != null
- } //end of ajax returned
- }//end of ajax onready state
- xmlhttp.open("GET","getpos.php?gid=" + gid ,true);
- xmlhttp.send();
- }//end of getpos function
- //variable to store the PID -> FBID
- var FBID;
- //the start of a function that gets the FBID of a user and adds it to a locally stored array so profile pics can be referenced to when the game finds changes in the position on the board
- function FBIDret(gid){
- var xmlhttp;
- if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }
- else{// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4 && xmlhttp.status==200){
- var resp = xmlhttp.responseText;
- FBID = resp.split(",");
- }
- }
- xmlhttp.open("GET","scripts/pidtoid.php?gid=" + gid ,true);
- xmlhttp.send();
- }
- //global array to store the property names to save time when updating player positions
- var propnames;
- //filling the array above
- function getPropNames(){
- var xmlhttp;
- if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- }else{// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function(){
- if (xmlhttp.readyState==4 && xmlhttp.status==200){
- var resp = xmlhttp.responseText;
- //returns a list of positions split by comma
- propnames = resp.split(",");
- }
- }
- xmlhttp.open("GET","scripts/getpropertylist.php",true);
- xmlhttp.send();
- }
- //function to update the text on properties when players move around the board
- function chan(propertyID,text){
- if(text==0){
- text = propnames[propertyID];
- }
- var x = document.getElementById("P" + propertyID);
- //check for default text
- x.innerHTML = text;
- }
- //find a string in an array
- function doesListCont(needle,hay){
- var contains;
- contains = 0;
- for (i=0;i<hay.length;i++){
- if(needle==hay){
- contains = 1;
- }
- }
- return contains;
- }
- //draw people in the right places
- function drwPlyrs(income){
- var ardd; // string of all the lines[] that has alredy been used in past builds
- ardd = ".";
- for (i=0;i<income.length-1;i++){
- if(ardd.indexOf("." + i + ".") == -1){
- for (n=0;n<income.length;n++){
- if(income[n]==income[i]){
- stri = stri + '<img class="profileimage" name="" src="https://graph.facebook.com/' + FBID[n] + '/picture" width="10" height="10" alt="">';
- ardd = ardd + n + ".";
- }
- chan(income[i],stri);
- }//end for(n)
- }
- }//end for(i)
- }//end of drwplyrs function
- //clear the squars in which people has exited
- function clrplyrs(lines,income){
- for (i=0;i<lines.length;i++){
- if(doeslistcont(lines[i],income) == 0){
- chan(line,0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment