OD calculator

Soft Stuff

Guest
Is their an OD calculator anywhere on a website that TW uses
 

jstuart

Guest
you still get oda, it just takes longer for it to register on a red report.

I believe they did this intentionally to keep people from calculating peoples remaining troop based on ODA change.

Wow this is quite useful! Is it possible to create one that says how many of each troop were killed on a red report or is this too hard/illegal?
 
Upvote 0

DeletedUser

Guest
Wow this is quite useful! Is it possible to create one that says how many of each troop were killed on a red report or is this too hard/illegal?

It would be way too hard as there would be so many unknown variables. In fact, its impossible without knowing them all.
Theres:
the amount of troops attacking
the amount of troops in the village
Wall Level
Tech Level
Pally effect
Faith
Luck

Without knowing all of these, you are unable to calculate the losses on the defenders side.
 
Upvote 0

DeletedUser

Guest
Code:
javascript:
    var doc=(window.frames.length>0)?window.main.document:document;
    
    attTable = doc.getElement("th:contains('Attacker:')").getParent('table');
    defTable = doc.getElement("th:contains('Defender:')").getParent('table');
    
    attLosses = attTable.getElement('table').getElement("td:contains('Losses:')").getParent();
    if (defTable.getElement('table') != null) {
        defLosses = defTable.getElement('table').getElement("td:contains('Losses:')").getParent();
        dl = defLosses.innerHTML.match(/\d+/g);
        }
    else {
        dl = new Array();
        }
    al = attLosses.innerHTML.match(/\d+/g);

    switch(al.length) {
        case 9:
            oda = dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*200;
            odd = al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*200;
            break;
        case 10:
            oda = dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*200;
            odd = al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*200;
            break;
        case 11:
            oda = dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*200;
            odd = al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*200;
            break;
        case 12:
            oda = dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*40+dl[11]*200;
            odd = al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*20+al[11]*200;
            break;
        }
    od=oda+odd;
    alert("Total OD gained from battle: " + od + "\n\nODA: " + oda + "\n\nODD: " + odd);
much cred to Fluffy


Lets just run that through http://javascriptcompressor.com/ to tidy it up a bit:icon_wink:
Code:
javascript:var doc=(window.frames.length>0)?window.main.document:document;attTable=doc.getElement("th:contains('Attacker:')").getParent('table');defTable=doc.getElement("th:contains('Defender:')").getParent('table');attLosses=attTable.getElement('table').getElement("td:contains('Losses:')").getParent();if(defTable.getElement('table')!=null){defLosses=defTable.getElement('table').getElement("td:contains('Losses:')").getParent();dl=defLosses.innerHTML.match(/\d+/g)}else{dl=new Array()}al=attLosses.innerHTML.match(/\d+/g);switch(al.length){case 9:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*200;break;case 10:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*200;break;case 11:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*200;break;case 12:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*40+dl[11]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*20+al[11]*200;break}od=oda+odd;alert("Total OD gained from battle: "+od+"\n\nODA: "+oda+"\n\nODD: "+odd);
 
Upvote 0

Soft Stuff

Guest
Wow this is quite useful! Is it possible to create one that says how many of each troop were killed on a red report or is this too hard/illegal?

Just send scouts, many people dont have scouts if they have many villages
 
Upvote 0

DeletedUser

Guest
Yeah that part is very messy i agree, but i dont know of any better way to do it, i would love to be able to get rid of it, slowtarget suggested using a XML request but i couldn't figure anything to do with that document that would help:icon_sad:

If you have a better way of doing it please do help me out:)
 
Upvote 0

DeletedUser

Guest
Have two variables that are size 12 arrays of the ODA and ODD values for each troop. For those cases where there are less than 12 units simply add in zeros for the missing units (Use the array splice function to add the zeros in.) and then simply use a for loop where you multiply the i-th value from the ODD and ODA arrays with the i-th values of the corresponding troop arrays. Not only does that greatly shrink the actual amount of code that you have but it's moving all of the hard coded values into one location.
 
Upvote 0

DeletedUser

Guest
nice idea, i will play around with it, it would help with the report renamer:icon_redface:
Thanks:icon_wink:
 
Upvote 0

DeletedUser

Guest
This only needs to be ran from a report screen, so yes it works for non-pa and to use just copy and paste the script into your address bar and it go.
Or make a new bookmark and set the script as the location.
 
Upvote 0

DeletedUser

Guest
just to be sure, ODA does not increase when you destroy the transit troops by taking enemy village
 
Upvote 0

DeletedUser50733

Guest
Lets just run that through http://javascriptcompressor.com/ to tidy it up a bit:icon_wink:
Code:
javascript:var doc=(window.frames.length>0)?window.main.document:document;attTable=doc.getElement("th:contains('Attacker:')").getParent('table');defTable=doc.getElement("th:contains('Defender:')").getParent('table');attLosses=attTable.getElement('table').getElement("td:contains('Losses:')").getParent();if(defTable.getElement('table')!=null){defLosses=defTable.getElement('table').getElement("td:contains('Losses:')").getParent();dl=defLosses.innerHTML.match(/\d+/g)}else{dl=new Array()}al=attLosses.innerHTML.match(/\d+/g);switch(al.length){case 9:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*200;break;case 10:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*200;break;case 11:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*200;break;case 12:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*40+dl[11]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*20+al[11]*200;break}od=oda+odd;alert("Total OD gained from battle: "+od+"\n\nODA: "+oda+"\n\nODD: "+odd);

Does that calculate ODA and ODD?
 
Upvote 0

DeletedUser

Guest
Lol i still don't understand how to use the script. I have a Mac, does that make a difference?
 
Upvote 0

DeletedUser

Guest
*BUMP*

Been looking for an ODA/ODD Calc, here's the previous one I used, but it's not working for me anymore, it used to work with IE but now it doesn't :icon_cry:

javascript:var purpose="Good shot man :p !";doc=(window.frames.length>0)?window.main.document:document;attTable=doc.getElement("th:contains('Attacker:')").getParent('table');defTable=doc.getElement("th:contains('Defender:')").getParent('table');attLosses=attTable.getElement('table').getElement("td:contains('Losses:')").getParent();if(defTable.getElement('table')!=null){defLosses=defTable.getElement('table').getElement("td:contains('Losses:')").getParent();dl=defLosses.innerHTML.match(/\d+/g)}else{dl=new Array()}al=attLosses.innerHTML.match(/\d+/g);switch(al.length){case 9:eek:da=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*200;break;case 10:eek:da=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*40+dl[9]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*20+al[9]*200;break;case 11:eek:da=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*200;break;case 12:eek:da=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*40+dl[11]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*20+al[11]*200;break}od=oda+odd;alert(purpose + "\n\nTotal 'Opponents Defeated' points gained from battle: "+od+ " points." + "\n\n'Opponents Defeated' for Attacker: "+oda+ " points." + "\n\n'Opponents Defeated' for Defender: "+odd + " points." + "\n\n ... d[o_O]b ...");
 
Upvote 0

DeletedUser

Guest
*BUMP*

Been looking for an ODA/ODD Calc, here's the previous one I used, but it's not working for me anymore, it used to work with IE but now it doesn't :icon_cry:

javascript:var purpose="Good shot man :p !";doc=(window.frames.length>0)?window.main.document:document;attTable=doc.getElement("th:contains('Attacker:')").getParent('table');defTable=doc.getElement("th:contains('Defender:')").getParent('table');attLosses=attTable.getElement('table').getElement("td:contains('Losses:')").getParent();if(defTable.getElement('table')!=null){defLosses=defTable.getElement('table').getElement("td:contains('Losses:')").getParent();dl=defLosses.innerHTML.match(/\d+/g)}else{dl=new Array()}al=attLosses.innerHTML.match(/\d+/g);switch(al.length){case 9:eek:da=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*200;break;case 10:eek:da=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*40+dl[9]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*20+al[9]*200;break;case 11:eek:da=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*200;break;case 12:eek:da=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*40+dl[11]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*20+al[11]*200;break}od=oda+odd;alert(purpose + "\n\nTotal 'Opponents Defeated' points gained from battle: "+od+ " points." + "\n\n'Opponents Defeated' for Attacker: "+oda+ " points." + "\n\n'Opponents Defeated' for Defender: "+odd + " points." + "\n\n ... d[o_O]b ...");

Tehehe ... I knowz that '... d[o_O]b ...' from somewhere :icon_wink: ...

P.S.

Check this out, mate :) !

Code:
javascript:var purpose="Good shot man :P !";var win=window.frames.length?window.main:window;var doc=win.document;var J=win.$;var oda=0;var odd=0;function fetch(x){x=J("table:has(th:contains('"+x+"')):last table td:contains('Losses:')").parent().html();return(x==null)?[]:x.match(/\d+/g)}var al=fetch('Attacker:');var dl=fetch('Defender:');switch(al.length){case 9:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*200;break;case 10:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*40+dl[9]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*20+al[9]*200;break;case 11:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*200;break;case 12:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*40+dl[11]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*20+al[11]*200;break;default:}oda=isNaN(oda)?0:oda;odd=isNaN(odd)?0:odd;od=oda+odd;alert(purpose + "\n\nTotal 'Opponents Defeated' points gained from battle: "+od+ " points." + "\n\n'Opponents Defeated' for Attacker: "+oda+ " points." + "\n\n'Opponents Defeated' for Defender: "+odd + " points." + "\n\n ... d[o_O]b ...");
 
Last edited by a moderator:
Upvote 0

DeletedUser

Guest
Here is the one I use. Don't know if it works in I.E. as I only use Chrome, but it works fine in Chrome:

[spoil]
Code:
javascript:var ls=$("table tr[class=center] td:contains('Losses:')");var al=((ls&&(ls.length>0))?ls[0].parentNode.innerHTML.match(/\d+/g):[]);var dl=((ls&&(ls.length>1))?ls[1].parentNode.innerHTML.match(/\d+/g):[]);switch(al.length){case 9:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*200;break;case 10:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*200;break;case 11:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*200;break;case 12:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*40+dl[11]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*20+al[11]*200;break;}od=oda+odd;alert("Total OD gained from battle: "+od+"\n\nODA: "+oda+"\n\nODD: "+odd);void(0);
[/spoil]
 
Upvote 0

DeletedUser

Guest
Here is the one I use. Don't know if it works in I.E. as I only use Chrome, but it works fine in Chrome:[...]

Well ... almost fine :icon_wink: .

To the point.
It's generally pretty the same script like mine (w/o my text improvements tho :) ), although it repeats old problem with proper calculations on classic worlds /without archers/ (without (case: 9) or with (case: 10) Pally), about which I was talking for example here -> [post=5206954]>CLICK<<<[/post] and here -> [post=4115368]>>>CLICK<<<[/post].

Really, to the point now :lol: :
Here you are. Your, but fixed one script :icon_cool: ...

Code:
javascript:var ls=$("table tr[class=center] td:contains('Losses:')");var al=((ls&&(ls.length>0))?ls[0].parentNode.innerHTML.match(/\d+/g):[]);var dl=((ls&&(ls.length>1))?ls[1].parentNode.innerHTML.match(/\d+/g):[]);switch(al.length){case 9:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*200;break;case 10:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*1+dl[4]*5+dl[5]*23+dl[6]*4+dl[7]*12+dl[8]*40+dl[9]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*13+al[5]*15+al[6]*8+al[7]*10+al[8]*20+al[9]*200;break;case 11:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*200;break;case 12:oda=dl[0]*4+dl[1]*5+dl[2]*1+dl[3]*5+dl[4]*1+dl[5]*5+dl[6]*6+dl[7]*23+dl[8]*4+dl[9]*12+dl[10]*40+dl[11]*200;odd=al[0]*1+al[1]*2+al[2]*4+al[3]*2+al[4]*2+al[5]*13+al[6]*12+al[7]*15+al[8]*8+al[9]*10+al[10]*20+al[11]*200;break;}od=oda+odd;alert("Total OD gained from battle: "+od+"\n\nODA: "+oda+"\n\nODD: "+odd);void(0);
 
Upvote 0
Top