OD calculator

Discussion in 'Questions' started by Soft Stuff, Feb 16, 2009.

Share This Page

  1. jstuart

    jstuart Non-stop Poster

    Dec 15, 2008
    Likes Received:
    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?
  2. CORaven

    CORaven Guest

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

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

    Fluffy88 Guest

    Lets just run that through http://javascriptcompressor.com/ to tidy it up a bit:icon_wink:
    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);
  4. Soft Stuff

    Soft Stuff Contributing Poster

    Jan 22, 2009
    Likes Received:
    Just send scouts, many people dont have scouts if they have many villages
  5. servy

    servy Guest

    There's a lot that could be done to tidy that code up other than using a tool like that...it actually pains me to look at that switch statement.
  6. CORaven

    CORaven Guest

    Well what would you recommend doing instead?
  7. Fluffy88

    Fluffy88 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:)
  8. servy

    servy 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.
  9. Fluffy88

    Fluffy88 Guest

    nice idea, i will play around with it, it would help with the report renamer:icon_redface:
  10. wrighty07

    wrighty07 Guest

    if this is non premium how do i use it??
  11. Fluffy88

    Fluffy88 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.
  12. rocneasta

    rocneasta Guest

    just to be sure, ODA does not increase when you destroy the transit troops by taking enemy village
  13. NathanPotter

    NathanPotter Contributing Poster

    Oct 5, 2008
    Likes Received:
    Does that calculate ODA and ODD?
  14. Lol i still don't understand how to use the script. I have a Mac, does that make a difference?
  15. CORaven

    CORaven Guest

    It doesnt.
    Go to a report that you want to get the info on, throw the script into the url bar and hit enter.
  16. 3moons

    3moons Well-Known Member

    Apr 6, 2008
    Likes Received:
    Cool tool nice work. it works easy.
  17. *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 ...");
  18. Niko.

    Niko. Guest

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


    Check this out, mate :) !

    Last edited by a moderator: Sep 19, 2010
  19. pyker42

    pyker42 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:

    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);
  20. Niko.

    Niko. Guest

    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: ...