Moderator: Tech Team
lancehoch wrote:Since the guy who created this seems to have left the site, does anyone have the code for the dice analyzer? I am unsure if I have the time to make some changes, but if someone could that would be great. I would definitely offer to help with some of the coding too.
//----------------------------------------------------------------------
// Conquer Club - Dice Analyzer
// version 1.5a
//----------------------------------------------------------------------
// Description
//----------------------------------------------------------------------
// * Adds a table with dice statistics that the attacker and the
// defender throw
// * Simulates dice rolls
//----------------------------------------------------------------------
// Meta Data
//----------------------------------------------------------------------
// ==UserScript==
// @name Dice Analyzer
// @namespace http://cyberdaniel.50webs.com/diceanalyzer/
// @description Dice statistics and simulator
// @include http://*conquerclub.com/*
// ==/UserScript==
//----------------------------------------------------------------------
// User Settings
//----------------------------------------------------------------------
var OPTIONS = new Object();
OPTIONS['defaultCookie'] = "conquerclub";
OPTIONS['storageCookie'] = "gamedatabase";
//----------------------------------------------------------------------
function myCookie()
{
private:
var cookieInfo="";
var cookieName="";
var days = 50;
public:
this.open = function(name)
{
var nameEQ = name + "=";
cookieName = name;
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) cookieInfo = c.substring(nameEQ.length,c.length);
}
return "";
}
this.eof = function()
{
if (cookieInfo.length == 0)
return true;
return false;
}
this.erase = function()
{
document.cookie = cookieName+"="+"; path=/";
}
this.write = function(info)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
this.erase();
document.cookie = cookieName+"="+info+expires+"; path=/";
this.open(cookieName);
}
this.read = function()
{
var info=-1;
if (this.eof())
return 0;
if (cookieInfo.indexOf(" ")!=-1)
{
info = parseInt(cookieInfo.substring(0,cookieInfo.indexOf(" ")));
cookieInfo = cookieInfo.substring(cookieInfo.indexOf(" ")+1,cookieInfo.length);
}
else
{
info = parseInt(cookieInfo);
cookieInfo = "";
}
return info;
}
}
function loadStatistics(game)
{
var sCookie = new myCookie();
var stats = "";
var statLen = 25;
var stat = new Array();
sCookie.open(game);
if (sCookie.eof())
{
stats = "<center><b>Game not found!! Cookie name: '"+game+"'</b></center><br>";
}
else
{
stats = "<center><b>Game name: '"+game+"'</b></center>";
}
/*
num wins / num ties / num loses / att 1s / att 2s / att 3s / att 4s / att 5s / att 6s / def 1s / def 2s /
def 3s / def 4s / def 5s / def 6s / 3v2 win / 3v2 tie / 3v2 loss / 3v1 win / 3v1 loss / 2v2 win / 2v2 loss /
2v1 win / 2v1 loss / 1v2 win / 1v2 loss / 1v1 win / 1v1 loss
*/
for(var i=0;i<29;i++)
stat[i]=sCookie.read();
var attTotal=stat[3]+stat[4]+stat[5]+stat[6]+stat[7]+stat[8];
var defTotal=stat[9]+stat[10]+stat[11]+stat[12]+stat[13]+stat[14];
stats+="<p><table align=center style='width:100%;border:1px solid #FFF;background:#eee;' rules=rows>" +
"<tr style='font-weight:bold;'><td></td><td>Attacker dice distribution</td><td>Defender dice distribution</td></tr>";
for(var k=0;k<6;k++)
{
stats+="<tr style='font-weight:bold;'><td>"+(k+1)+"s</td><td>";
for(var i=0;i<statLen;i++)
if(4*stat[3+k]/attTotal*statLen>i)
stats+="<font color='blue'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" " + stat[3+k] +" / "+attTotal+" ("+Math.round(stat[3+k]*10000/attTotal)/100+"%)</td><td>";
for(var i=0;i<statLen;i++)
if(4*stat[9+k]/defTotal*statLen>i)
stats+="<font color='blue'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" "+ stat[9+k] + " / "+defTotal+" ("+Math.round(stat[9+k]*10000/defTotal)/100+"%)</td></tr>";
}
stats+="</table>";
stats+="<p><table align=center style='width:100%;border:1px solid #FFF;background:#eee;' rules=rows>"+
"<tr style='font-weight:bold;'><td>Battle Outcomes</td><td>Actual Stats</td><td>Ideal Stats</td></tr>"+
"<tr style='font-weight:bold;'><td>3v2 ";
for(var i=0;i<statLen;i++)
if(i<stat[15]*statLen/(stat[15]+stat[16]+stat[17]))
stats+="<font color='blue'>█</font>";
else
if(i<(stat[15]+stat[16])*statLen/(stat[15]+stat[16]+stat[17]))
stats+="<font color='yellow'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" "+stat[15]+" / "+stat[16]+" / "+stat[17]+" </td><td>"+
"(<font color='blue'>"+Math.round(stat[15]*10000/(stat[15]+stat[16]+stat[17]))/100+"%</font> /"+
" <font color='#ffcc00'>"+Math.round(stat[16]*10000/(stat[15]+stat[16]+stat[17]))/100+"%</font> /"+
" <font color='red'>"+Math.round(stat[17]*10000/(stat[15]+stat[16]+stat[17]))/100+"%</font>"+
")</td><td>(<font color='blue'>37.17%</font> / <font color='#ffcc00'>33.58%</font> / <font color='red'>29.26%</font>)</td></tr><tr style='font-weight:bold;'><td>3v1 ";
for(var i=0;i<statLen;i++)
if(i<stat[18]*statLen/(stat[18]+stat[19]))
stats+="<font color='blue'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" "+stat[18]+" / "+stat[19]+" </td><td>"+
"(<font color='blue'>"+Math.round(stat[18]*10000/(stat[18]+stat[19]))/100+"%</font> /"+
" <font color='red'>"+Math.round(stat[19]*10000/(stat[18]+stat[19]))/100+"%</font>"+
")</td><td>(<font color='blue'>65.97%</font> / <font color='red'>34.03%</font>)</td></tr><tr style='font-weight:bold;'><td>2v2 ";
for(var i=0;i<statLen;i++)
if(i<stat[20]*statLen/(stat[20]+stat[21]+stat[22]))
stats+="<font color='blue'>█</font>";
else
if(i<(stat[20]+stat[21])*statLen/(stat[20]+stat[21]+stat[22]))
stats+="<font color='yellow'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" "+stat[20]+" / "+stat[21]+" / "+stat[22]+" </td><td>"+
"(<font color='blue'>"+Math.round(stat[20]*10000/(stat[20]+stat[21]+stat[22]))/100+"%</font> /"+
" <font color='#ffcc00'>"+Math.round(stat[21]*10000/(stat[20]+stat[21]+stat[22]))/100+"%</font> /"+
" <font color='red'>"+Math.round(stat[22]*10000/(stat[20]+stat[21]+stat[22]))/100+"%</font>"+
")</td><td>(<font color='blue'>22.76%</font> / <font color='#ffcc00'>32.41%</font> / <font color='red'>44.83%</font>)</td></tr><tr style='font-weight:bold;'><td>2v1 ";
for(var i=0;i<statLen;i++)
if(i<stat[23]*statLen/(stat[23]+stat[24]))
stats+="<font color='blue'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" "+stat[23]+" / "+stat[24]+" </td><td>"+
"(<font color='blue'>"+Math.round(stat[23]*10000/(stat[23]+stat[24]))/100+"%</font> /"+
" <font color='red'>"+Math.round(stat[24]*10000/(stat[23]+stat[24]))/100+"%</font>"+
")</td><td>(<font color='blue'>57.87%</font> / <font color='red'>42.13%</font>)</td></tr><tr style='font-weight:bold;'><td>1v2 ";
for(var i=0;i<statLen;i++)
if(i<stat[25]*statLen/(stat[25]+stat[26]))
stats+="<font color='blue'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" "+stat[25]+" / "+stat[26]+" </td><td>"+
"(<font color='blue'>"+Math.round(stat[25]*10000/(stat[25]+stat[26]))/100+"%</font> /"+
" <font color='red'>"+Math.round(stat[26]*10000/(stat[25]+stat[26]))/100+"%</font>"+
")</td><td>(<font color='blue'>25.46%</font> / <font color='red'>74.54%</font>)</td></tr><tr style='font-weight:bold;'><td>1v1 ";
for(var i=0;i<statLen;i++)
if(i<stat[27]*statLen/(stat[27]+stat[28]))
stats+="<font color='blue'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" "+stat[27]+" / "+stat[28]+" </td><td>"+
"(<font color='blue'>"+Math.round(stat[27]*10000/(stat[27]+stat[28]))/100+"%</font> /"+
" <font color='red'>"+Math.round(stat[28]*10000/(stat[27]+stat[28]))/100+"%</font>"+
")</td><td>(<font color='blue'>41.67%</font> / <font color='red'>58.33%</font>)</td></tr></table>";
stats+="<p><table align=center style='width:100%;border:1px solid #FFF;background:#eee;' rules=rows>" +
"<tr style='font-weight:bold;'><td>Overall stats</td></tr>" +
"<tr style='font-weight:bold;'><td>Attacker threw "+attTotal+" dice.</td></tr>" +
"<tr style='font-weight:bold;'><td>Defender threw "+defTotal+" dice.</td></tr>" +
"<tr style='font-weight:bold;'><td>Wins / Ties / Loses ";
for(var i=0;i<statLen;i++)
if(i<stat[0]*statLen/(stat[0]+stat[1]+stat[2]))
stats+="<font color='blue'>█</font>";
else
if(i<(stat[0]+stat[1])*statLen/(stat[0]+stat[1]+stat[2]))
stats+="<font color='yellow'>█</font>";
else
stats+="<font color='red'>█</font>";
stats+=" "+stat[0]+" / "+stat[1]+" / "+stat[2]+"</td></tr>"+
"<tr><td><font color='blue'>█████</font> Attacker wins</td></tr>" +
"<tr><td><font color='yellow'>█████</font> Attacker wins 1, defender wins 1</td></tr>" +
"<tr><td><font color='red'>█████</font> Defender wins</td></tr>" +
"</table>";
return stats;
}
function addStatistics(id, game)
{
var stats = loadStatistics(game);
var el = win.document.getElementById(id);
el.innerHTML = stats;
}
function addStyles()
{
var style = "<style>\n"+
"body\n"+
"{\n"+
" font: normal 12px arial;\n"+
" margin: 25px 5px 0 5px;\n"+
"}\n"+
"td\n"+
"{\n"+
" font: bold 12px arial;\n"+
"}\n"+
"#menu\n"+
"{\n"+
" background-color:#cdc;width:100%;position:fixed;top:0px;left:0px;white-space:nowrap;text-align:center;padding:2px 0 2px 0;border: solid 1px #000;\n"+
"}\n"+
"#menu ul\n"+
"{\n"+
" margin: 0;padding: 0;border: solid 0px #000;display: block;\n"+
"}\n"+
"#menu ul li\n"+
"{\n"+
" display:inline;border: solid 1px #000;background-color:#cdc;padding:2px 10px 2px 10px;margin:0 -5px 0 0;cursor:pointer;text-align:center;\n"+
"}\n"+
"#menu ul li:hover\n"+
"{\n"+
" display:inline;color:#fff;border: solid 1px #000;background-color:#aba;padding:2px 10px 2px 10px;margin:0 -5px 0 0;\n"+
"}\n"+
"#menu ul li a\n"+
"{\n"+
" text-decoration: none;\n"+
"}\n"+
"</style>";
return style;
}
function addBody()
{
var body = "<html>\n"+
"<head>\n"+
" <title>Conquer Club - Dice Analyzer</title>\n"+
"</head>\n"+
"<body>\n"+
" <div id='menu'>\n"+
" </div>"+
" <div id='body'>\n"+
" </div>\n"+
"</body>\n"+
"</html>";
return body;
}
function testCookies()
{
var database = new myCookie();
database.open(OPTIONS['storageCookie']);
var info = "";
while(!database.eof())
{
var game = new myCookie();
var gameName = database.read();
game.open(gameName);
if (!game.eof())
info += gameName + " ";
}
database.write(info);
}
function selectGame()
{
testCookies();
var database = new myCookie();
database.open(OPTIONS['storageCookie']);
var body = win.document.getElementById('body');
if (database.eof())
{
body.innerHTML = "The game database is empty!!!";
return;
}
body.innerHTML = "";
var table = win.document.createElement('table');
table.style.border = "thin none #000";
table.width = "100%";
table.height = "100%";
var tr = win.document.createElement('tr');
var td = win.document.createElement('td');
td.style.verticalAlign = "top";
td.innerHTML = "<div><b>Select a game:</b></div><br>";
var tdDiv = win.document.createElement('div');
td.width = "120px";
tdDiv.style.height = "420px";
tdDiv.style.overflow = "auto";
while (!database.eof())
{
var el = win.document.createElement('font');
var game = database.read();
var div = win.document.createElement("div");
div.innerHTML = "• Game ";
el.innerHTML = game;
el.style.font = "bold 12px arial;";
el.style.cursor = "pointer;";
el.style.textDecoration = "underline;";
el.style.color = "#aba";
el.addEventListener('click', function(){addStatistics("tbody", this.innerHTML+"");}, false);
div.appendChild(el);
tdDiv.appendChild(div);
}
td.appendChild(tdDiv);
var td2 = win.document.createElement('td');
td2.id = "tbody";
tr.appendChild(td);
tr.appendChild(td2);
table.appendChild(tr);
body.appendChild(table);
}
function simulateRolls()
{
var diceStats = new myCookie();
diceStats.open(OPTIONS['defaultCookie']);
var idealStats = new Array(37.17, 33.58, 29.26);
for (var i=0;i<=14;i++)
diceStats.read();
var wins = diceStats.read();
var ties = diceStats.read();
var loses = diceStats.read();
var total = wins + ties + loses;
wins = wins * 100 / total;
ties = ties * 100 / total;
loses = loses * 100 / total;
var attackerArmies = parseInt(win.document.getElementsByTagName('input')[0].value) - 3;
var defenderArmies = parseInt(win.document.getElementsByTagName('input')[1].value);
var attackerLoss = new Array();
var defenderLoss = new Array();
attackerLoss[0] = ((idealStats[1] + Math.abs(idealStats[1] - ties))/2 + idealStats[2] + Math.abs(idealStats[2] - loses)) * defenderArmies /
((idealStats[1] - Math.abs(idealStats[1] - ties))/2 + idealStats[0] - Math.abs(idealStats[0] - wins));
//alert(((idealStats[1] - Math.abs(idealStats[1] - ties))/2 ));
defenderLoss[0] = ((idealStats[1] - Math.abs(idealStats[1] - ties))/2 + idealStats[0] - Math.abs(idealStats[0] - wins)) * attackerArmies /
((idealStats[1] + Math.abs(idealStats[1] - ties))/2 + idealStats[2] + Math.abs(idealStats[2] - loses));
attackerLoss[1] = (idealStats[1]/2 + idealStats[2]) * defenderArmies / (idealStats[1]/2 + idealStats[0]);
defenderLoss[1] = (idealStats[1]/2 + idealStats[0]) * attackerArmies / (idealStats[1]/2 + idealStats[2]);
attackerLoss[2] = ((idealStats[1] - Math.abs(idealStats[1] - ties))/2 + idealStats[2] - Math.abs(idealStats[2] - loses)) * defenderArmies /
((idealStats[1] + Math.abs(idealStats[1] - ties))/2 + idealStats[0] + Math.abs(idealStats[0] - wins));
defenderLoss[2] = ((idealStats[1] + Math.abs(idealStats[1] - ties))/2 + idealStats[0] + Math.abs(idealStats[0] - wins)) * attackerArmies /
((idealStats[1] - Math.abs(idealStats[1] - ties))/2 + idealStats[2] - Math.abs(idealStats[2] - loses));
attackerLoss[3] = (idealStats[1]/2 + idealStats[2]) * defenderArmies / (idealStats[1]/2 + idealStats[0]);
defenderLoss[3] = (idealStats[1]/2 + idealStats[0]) * attackerArmies / (idealStats[1]/2 + idealStats[2]);
var outString = "<p><table align=center style='width:100%;border:1px solid #FFF;background:#eee;' rules=all><tr><td></td>"+
"<td>Worst case scenario</td><td>Ideal case scenario</td><td>Best case scenario</td></tr>";
outString += "<tr><td>Attacker loses</td>";
for (var i=0;i<3;i++)
{
if (attackerLoss[i] >= attackerArmies)
{
outString += "<td>" + attackerArmies + "</td>";
}
else
{
outString += "<td>" + Math.round(attackerLoss[i]) + "</td>";
}
}
outString += "</tr><tr><td>Defender loses</td>";
for (var i=0;i<3;i++)
{
if (attackerLoss[i] >= attackerArmies)
{
outString += "<td>" + Math.round(defenderLoss[i]) + "</td>";
}
else
{
outString += "<td>" + defenderArmies + "</td>";
}
}
outString += "</tr></table>";
var output = win.document.getElementById('output');
output.innerHTML = outString;
}
function diceRollSimulator()
{
var body = win.document.getElementById("body");
body.innerHTML = "<center><div style='font:bold 13px arial'>Dice Roll Simulator</div></center>"+
"<p><div style='font:bold 12px arial'>Enter the number of troops for attacker and defender:</div>"+
"<table><tr><td>Attacker: </td><td><input type='text' style='border:1px solid;'></td></tr>"+
"<tr><td>Defender: </td><td><input type='text' style='border:1px solid;'></td></tr>"+
"<tr><td colspan=2 align='center'><input type='button' value='Start simulation' "+
"style='color:black;border:1px solid;background-color:#eee;'></td></tr></table><div id='output'></div>"+
"<div style='position:fixed;top:350px;'><p><b>Warning!</b><p>* These statistics are only an estimate, "+
"they don't necessary give a real output and since the dice are random large deviations from the norm can "+
"occur (eg: 15v2 and attacker loses or 15v30 and attacker wins)<p>* In case the attacker gets down to 3 armies "+
"and the defender still has armies then the simulation stops since the odds of wining change.<p>"+
"* The worst case scenario and best case scenario is based on the statistics the player has at that moment and the "+
"distance from the norm. The ideal statistics are based on the norm percentages.</div>";
var button = win.document.getElementsByTagName('input')[2];
button.addEventListener('click', simulateRolls, false);
}
function createMenu()
{
var menu = win.document.getElementById("menu");
menu.innerHTML = "<ul><li>General Statistics</li><!--<li>Detailed Game Statistics</li>--><li>Dice Roll Simulator</li></ul>";
var menuItem = menu.getElementsByTagName("li");
menuItem[0].addEventListener("click", function(){addStatistics("body", OPTIONS['defaultCookie']);}, false);
//menuItem[1].addEventListener("click", selectGame, false);
menuItem[1].addEventListener("click", diceRollSimulator, false);
}
function createWindow()
{
win = window.open("","ccstats","height=500, width=950, toolbar=no, scrollbars=yes, menubar=no");
win.document.write(addStyles());
win.document.write(addBody());
win.document.close();
createMenu();
addStatistics("body", OPTIONS['defaultCookie']);
}
function createButton()
{
var leftBar = document.getElementById("leftColumn");
var ul = leftBar.getElementsByTagName("ul");
var li = document.createElement("li");
var a = document.createElement("a");
a.innerHTML = "Dice Analyzer";
a.setAttribute("href","javascript:void(0);");
li.addEventListener("click", createWindow, false);
li.appendChild(a);
ul[2].appendChild(li);
}
function saveDiceRolls(attackerRolls, defenderRolls, cookieName)
{
var sCookie = new myCookie();
sCookie.open(cookieName);
var info = new Array();
if (!sCookie.eof())
{
for (var i=0;i<29;i++)
{
info[i]= sCookie.read();
}
}
else
{
for (var i=0;i<29;i++)
{
info[i]= 0;
}
}
// order the dice so that the largest values are the first ones
for (var i=0;i<attackerRolls.length;i++)
for (var j=i+1;j<attackerRolls.length;j++)
if (attackerRolls[i]<attackerRolls[j])
{
var tmp = attackerRolls[i];
attackerRolls[i] = attackerRolls[j];
attackerRolls[j] = tmp;
}
for (var i=0;i<defenderRolls.length;i++)
for (var j=i+1;j<defenderRolls.length;j++)
if (defenderRolls[i]<defenderRolls[j])
{
var tmp = defenderRolls[i];
defenderRolls[i] = defenderRolls[j];
defenderRolls[j] = tmp;
}
var score = 0;
for (var i=0;i<Math.min(defenderRolls.length, attackerRolls.length);i++)
{
if (attackerRolls[i] > defenderRolls[i])
score++;
else
score--;
}
for (var i=0;i<attackerRolls.length;i++)
info[attackerRolls[i] + 2]++;
for (var i=0;i<defenderRolls.length;i++)
info[defenderRolls[i] + 8]++;
if (attackerRolls.length == 3 && defenderRolls.length == 2)
{
switch(score)
{
case 0: info[16] += 1; info[1] += 1; break; //tie
case 2: info[15] += 1; info[0] += 1; break; //win
case -2:info[17] += 1; info[2] += 1; break; //loss
}
}
if (attackerRolls.length == 3 && defenderRolls.length == 1)
{
switch(score)
{
case 1: info[18] += 1; info[0] += 1; break; //win
case -1:info[19] += 1; info[2] += 1; break; //loss
}
}
if (attackerRolls.length == 2 && defenderRolls.length == 2)
{
switch(score)
{
case 0: info[21] += 1; info[1] += 1; break; //tie
case 2: info[20] += 1; info[0] += 1; break; //win
case -2:info[22] += 1; info[2] += 1; break; //loss
}
}
if (attackerRolls.length == 2 && defenderRolls.length == 1)
{
switch(score)
{
case 1: info[23] += 1; info[0] += 1; break; //win
case -1:info[24] += 1; info[2] += 1; break; //loss
}
}
if (attackerRolls.length == 1 && defenderRolls.length == 2)
{
switch(score)
{
case 1: info[25] += 1; info[0] += 1; break; //win
case -1:info[26] += 1; info[2] += 1; break; //loss
}
}
if (attackerRolls.length == 1 && defenderRolls.length == 1)
{
switch(score)
{
case 1: info[27] += 1; info[0] += 1; break; //win
case -1:info[28] += 1; info[2] += 1; break; //loss
}
}
var str = "";
for (var i=0;i<info.length;i++)
{
str += info[i] + " ";
}
sCookie.write(str);
}
function getDice(info)
{
var dice = new Array();
var diceRolls = info.getElementsByTagName("li");
for (var i=0;i<diceRolls.length;i++)
{
dice[i] = parseInt(diceRolls[i].innerHTML);
}
return dice;
}
function getGameName()
{
var gameDiv = document.getElementById('right_hand_side');
var game = gameDiv.getElementsByTagName('h3');
var num = game[0].innerHTML.substring(game[0].innerHTML.indexOf(' ')+1);
return num;
}
function saveGameName(game)
{
var database = new myCookie();
database.open(OPTIONS['storageCookie']);
if (database.eof())
{
database.write(game);
}
else
{
var info = "";
while(!database.eof())
{
var gm = database.read();
if (gm == game)
return;
info += gm + " ";
}
database.write(info + game);
}
}
function analyzeDiceRolls(diceInfo)
{
var roll = diceInfo.getElementsByTagName("div");
for (var i=0;i<roll.length;i++)
{
var dice = roll[i].getElementsByTagName("ul");
saveDiceRolls(getDice(dice[0]), getDice(dice[1]), OPTIONS['defaultCookie']);
//saveDiceRolls(getDice(dice[0]), getDice(dice[1]), getGameName());
//saveGameName(getGameName());
}
}
function main()
{
createButton();
var dashboard = document.getElementById('dashboard');
var log = document.getElementById('log');
if( !(dashboard && log)) return;
var handle = unsafeWindow.handleResponse;
unsafeWindow.handleResponse = function()
{
var request = unsafeWindow.request;
if (request.readyState == 4)
{
var elem = document.createElement("div");
elem.innerHTML = request.responseText;
var divs = elem.getElementsByTagName("div");
for (var i = 0; i < divs.length; i++)
if (divs[i].id == "rolls")
{
analyzeDiceRolls(divs[i]);
break;
}
}
return handle();
}
}
var start = new main();
It's a greasemonkey script... which uses Javascript maybe?? I'm not entirely sure, but I thought it was JSlancehoch wrote:That looks like what I was looking for. Do you know what language that is in? I guess I was looking to add my suggestion from a few posts back, but I did not realize that the code was this complex.
Stoney229 wrote:can there be a tab that tells you the stats for the specific game you're in??
cyberdaniel wrote:Stoney229 wrote:can there be a tab that tells you the stats for the specific game you're in??
There can be, and I actually have that implemented, however it is still unstable. By unstable, I mean that if too many games need to be stored, firefox will start deleting cookies to make up space. In my case it deleted the most important cookie, the one with the general stats.
lancehoch wrote:cyberdaniel, I am not sure if you have read through all the posts since you got back, but up at the top of this page (page 25) I made a post asking about an expected results bar at the bottom of the analyzer. I was wondering if you saw that, or had any comments on the idea.
yeti_c wrote:CyberDaniel... Can I advise against storing in Cookies...
For AJAX BOB - (and indeed the previous BOB) the GM_setValue GM_getValue functionality is used...
What I would do is - check for cookie if it's there read it in - then save it with GM_setValue - then delete cookie.
Then read with GM_getValue... (if it's still blank then assume no stats...)
For examples on how these functions work - then feel free to look at BOB and check out functions SERIALIZE & DESERIALIZE - and also most of the "snapshot" functions (at the bottom of the script) use these functions too.
C.
yeti_c wrote:CyberDaniel... Can I advise against storing in Cookies...
For AJAX BOB - (and indeed the previous BOB) the GM_setValue GM_getValue functionality is used...
What I would do is - check for cookie if it's there read it in - then save it with GM_setValue - then delete cookie.
Then read with GM_getValue... (if it's still blank then assume no stats...)
For examples on how these functions work - then feel free to look at BOB and check out functions SERIALIZE & DESERIALIZE - and also most of the "snapshot" functions (at the bottom of the script) use these functions too.
C.
lancehoch wrote:cyberdaniel, I am not sure if you have read through all the posts since you got back, but up at the top of this page (page 25) I made a post asking about an expected results bar at the bottom of the analyzer. I was wondering if you saw that, or had any comments on the idea.
lancehoch wrote:I have had this happen twice now: I opened the dice analyzer through the tab on the side menu and the stats have been reset. Does anyone know why this might happen? I had not reached the limit of 50 days between turns, so I am not sure what is causing the problem. One theory I have is that I had the dice analyzer window open while I took a turn, could this have caused the problem?
Pedronicus wrote:Welcome back Daniel. I tried clicking on get 'Get Dice analyzer' 1.5 on my new mac, and don't have a clue what to do next.
Han Solo wrote:I advised Daniel months ago about my data erased each time i close Firefox - while my C.C. cookies are not deleted.
Unfortunately he never answered.
Does anyone else get this problem ?
Thx, HS.
lancehoch wrote:My stats just reset again. Not sure what happened, but this time I definitely did not have the window open while I was rolling. Any progress on this situation? Also, is there going to be an update soon, I saw you mentioned that you were working on some changes to the plugin.
lancehoch wrote:cyberdaniel, what is the difference between the versions? Also, will this reset my statistics when I download the new version?
lancehoch wrote:cyberdaniel, looks great. One thing I noticed though was the expected results are in percentages, but the original bar is in actual stats. For the next update, could we get the percentages of the actual stats somewhere?
Users browsing this forum: No registered users