Ikariam kChen Overview

By kchen Last update Feb 18, 2009 — Installed 346,353 times.

Some problems that i seen + solving wine needed problem

in
Subscribe to Some problems that i seen + solving wine needed problem 3 posts, 2 voices



Hasan USLU Scriptwright

Hi, kchen. I want to tell you some problems of the script.
1. In tavern, the needed amount of wine is incorrect. Actually, if you didn't make a vineyard, it is correct. The vineyards decreases the needed wine amount for tavern, depending building level.
2. When workers is more than normal in the island camp, the table shows the wrong number of workers.
3. Army units attack and defense coefficients are not shown according to the unit growth level.
4. I think there is a small mistake in the calculation of general points.

I hope in the new version fix this problems.
I wish you success

 
Hasan USLU Scriptwright

Hi, i am sorry
Problem no 2 is not true in my message. I wrote without checking. Annnd i solve the problem 1 with some code. There is solve to needed wine amount.

- Change the updateTavern function in view.js as follows,

function updateTavern(res, root) {
function storeWineUsage() {
try {
var n = document.getElementById("wineAmount");
var city_id = getNode_value("//form[@id='wineAssignForm']/input[@type='hidden' and @name='id']");
var city = getCity(city_id);
city.wineUsage = tavernWineUsage[n.selectedIndex];
setVar("config", serialize(config));
} catch (e) {
log("Hiba: "+e);
}
}

var n = getNode("//form[@id='wineAssignForm']//*[@type='submit']");
n.addEventListener("click", storeWineUsage, false);
var n = document.getElementById("wineAmount");

wineUsage = tavernWineUsage[n.selectedIndex];
var cellarLevel = getArrValue(res.buildings["vineyard"], "level", "-");
if (cellarLevel >=0) {
wineSave = wineUsage * cellarLevel;
wineSave = wineSave / 100;
wineUsage = wineUsage - wineSave;
res.wineUsage = wineUsage ;
} else {
res.wineUsage = wineUsage ;
}
}

- Change the updateTownHall function in view.js as follows,

function updatetownHall(res, root) {
res.gold = Number($X("//div[@id='CityOverview']//li[contains(@class,'incomegold')]//span[@class='value']", root).textContent);
log("gold:"+res.gold);
res.corruption = $X("//div[@id='CityOverview']//li[@class='corruption']//span[contains(@class,'value')]//span", root).textContent;
log("corruption:"+res.corruption);
res.woodworkers = $X("//div[@id='PopulationGraph']//div[@class='woodworkers']//span[@class='count']", root).textContent;
log("woodworkers:"+res.woodworkers);
res.specialworkers = $X("//div[@id='PopulationGraph']//div[@class='specialworkers']//span[@class='count']", root).textContent;
log("specialworkers:"+res.specialworkers);
res.bonusspace = Number($X("//span[@class='value total']", root).textContent) - townHallSpaces[getArrValue(res.buildings["townHall"], "level")];
log("bonusspace:"+res.bonusspace);
res.happiness = Number($X("//div[contains(@class, 'happiness ')]/div[@class='value']", root).textContent) + res.population;
log("happiness:"+res.happiness);

var wineUsageP = $X("//div[@class='serving']//span", root);
if (wineUsageP != undefined) {
var winusage_basic = (gameVersion() < "0.3.0") ? 80 : 60;
var wineUsage = tavernWineUsage[Number(wineUsageP.textContent) / winusage_basic];
if (gameVersion() >= "0.3.0") {
var cellarLevel = getArrValue(res.buildings["vineyard"], "level", "-");
if (cellarLevel >= 0) {
wineSave = wineUsage * cellarLevel;
wineSave = wineSave / 100;
wineUsage = wineUsage - wineSave;
}
}
res.wineUsage = wineUsage;
}
log("wineUsage:" + res.wineUsage);

//var wineUsage = $X("//div[@class='serving']//span", root);
//if (wineUsage != undefined) {
// var winusage_basic = (gameVersion() < "0.3.0") ? 80 : 60;
// wineUsage = tavernWineUsage[Number(wineUsage.textContent) / winusage_basic]
//}
//res.wineUsage = wineUsage ;
//log("wineUsage:" + res.wineUsage);

res.scientists = Number($X("//div[@id='PopulationGraph']//div[@class='scientists']//span[@class='count']", root).textContent);
log("scientists:"+res.scientists);
res.efficiency = Number($X("//div[@id='PopulationGraph']//div[@class='scientists']//*[@class='production']/child::text()", root).textContent);
log("efficiency:"+res.efficiency);
}

And there is no solve for 3. and 4. problems now. Thank you

 
kchen Script's Author

this is a good solution, but it have decimal problem.
the new version maybe can solve.
you can read my code, and give me some suggestion if you want.
Anyway, thank you for help to solve the problem
and I like your script that is very useful.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel