//---------------------------------------------------------------------- // Conquer Club - Dice Analyzer // version 1.4b //---------------------------------------------------------------------- // 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 = "
Attacker dice distribution | Defender dice distribution | |
"+(k+1)+"s | ";
for(i=0;i | ";
for(i=0;i |
Battle Outcomes | Win % | Tie % | Lose % |
3v2 ";
for(i=0;i | "+ ""+(stat[15]*100/(stat[15]+stat[16]+stat[17])).toFixed(2)+"% ("+ (stat[15]*100/(stat[15]+stat[16]+stat[17])-37.17).toFixed(2)+"%) | "+ " "+(stat[16]*100/(stat[15]+stat[16]+stat[17])).toFixed(2)+"% ("+ (stat[16]*100/(stat[15]+stat[16]+stat[17])-33.58).toFixed(2)+"%) | "+ " "+(stat[17]*100/(stat[15]+stat[16]+stat[17])).toFixed(2)+"% ("+ (stat[17]*100/(stat[15]+stat[16]+stat[17])-29.26).toFixed(2)+"%)"+ " |
3v1 ";
for(i=0;i | "+ ""+(stat[18]*100/(stat[18]+stat[19])).toFixed(2)+"% ("+ (stat[18]*100/(stat[18]+stat[19])-65.97).toFixed(2)+"%) | "+ " "+(stat[19]*100/(stat[18]+stat[19])).toFixed(2)+"% ("+ (stat[19]*100/(stat[18]+stat[19])-34.03).toFixed(2)+"%)"+ " | |
2v2 ";
for(i=0;i | "+ ""+(stat[20]*100/(stat[20]+stat[21]+stat[22])).toFixed(2)+"% ("+ (stat[20]*100/(stat[20]+stat[21]+stat[22])-22.76).toFixed(2)+"%) | "+ " "+(stat[21]*100/(stat[20]+stat[21]+stat[22])).toFixed(2)+"% ("+ (stat[21]*100/(stat[20]+stat[21]+stat[22])-32.41).toFixed(2)+"%) | "+ " "+(stat[22]*100/(stat[20]+stat[21]+stat[22])).toFixed(2)+"% ("+ (stat[22]*100/(stat[20]+stat[21]+stat[22])-44.83).toFixed(2)+"%)"+ " |
2v1 ";
for(i=0;i | "+ ""+(stat[23]*100/(stat[23]+stat[24])).toFixed(2)+"% ("+ (stat[23]*100/(stat[23]+stat[24])-57.87).toFixed(2)+"%) | "+ " "+(stat[24]*100/(stat[23]+stat[24])).toFixed(2)+"% ("+ (stat[24]*100/(stat[23]+stat[24])-42.13).toFixed(2)+"%)"+ " | |
1v2 ";
for(i=0;i | "+ ""+(stat[25]*100/(stat[25]+stat[26])).toFixed(2)+"% ("+ (stat[25]*100/(stat[25]+stat[26])-25.46).toFixed(2)+"%) | "+ " "+(stat[26]*100/(stat[25]+stat[26])).toFixed(2)+"% ("+ (stat[26]*100/(stat[25]+stat[26])-74.54).toFixed(2)+"%)"+ " | |
1v1 ";
for(i=0;i | "+ ""+(stat[27]*100/(stat[27]+stat[28])).toFixed(2)+"% ("+ (stat[27]*100/(stat[27]+stat[28])-41.67).toFixed(2)+"%) | "+ " "+(stat[28]*100/(stat[27]+stat[28])).toFixed(2)+"% ("+ (stat[28]*100/(stat[27]+stat[28])-58.33).toFixed(2)+"%)"+ " |
Overall stats |
Attacker threw "+attTotal+" dice. |
Defender threw "+defTotal+" dice. |
Wins / Ties / Loses ";
for(i=0;i |
█████ Attacker wins |
█████ Attacker wins 1, defender wins 1 |
█████ Defender wins |
"+ " | Worst case scenario | Ideal case scenario | Best case scenario |
Attacker loses | "; for (var i=0;i<3;i++) { if (attackerLoss[i] >= attackerArmies) { outString += "" + attackerArmies + " | "; } else { outString += "" + Math.round(attackerLoss[i]) + " | "; } } outString += "|
Defender loses | "; for (var i=0;i<3;i++) { if (attackerLoss[i] >= attackerArmies) { outString += "" + Math.round(defenderLoss[i]) + " | "; } else { outString += "" + defenderArmies + " | "; } } outString += "
Attacker: | |
Defender: | |
Warning!
* 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)
* 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.
"+ "* 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.