Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions src/app/mods/estimationprix/estimationprix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import {Mod} from "../mod";

export class EstimationPrix extends Mod {
private mapPrice;
private tableauitemid = []
private tableauitemprice = []
startMod(): void {


this.on(this.wGame.dofus.connectionManager, "ObjectAveragePricesMessage", (e) => {
this.tableauitemid = (e.ids)
this.tableauitemprice = (e.avgPrices)
});

setTimeout(() => {
this.getObjectAveragePrice(this.tableauitemid, this.tableauitemprice)
}, 2000);

this.wGame.gui.windowsContainer._childrenList.find(e=>e.id=="itemRecipes").on("open",(e)=>{
e = this.wGame.gui.windowsContainer._childrenList.find(e=>e.id=="itemRecipes")
let prix = this.getPrice(e.dbItemId)
setTimeout(() => {
this.afficherprix(prix);
}, 200);
})
}

private getObjectAveragePrice(array1, array2){
this.tableauitemid = array1
this.tableauitemprice = array2
this.createMap(this.tableauitemid, this.tableauitemprice);
}

private createMap(array1, array2) {
const length = array1.length;
this.mapPrice = new Map();
for (var k = 0; k < length; k++) {
this.mapPrice.set(array1[k], array2[k]);
}
}

private getPrice(id) {
return this.mapPrice.get(id);
}

formatNumber(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}


private getInformation() {
let monitem = this.wGame.gui.windowsContainer.getChildren().find(e=>e.id=="itemRecipes")
if(monitem.recipeBox == undefined || monitem.recipeBox == NaN){
return ;
}
let listeingredient = monitem.recipeBox.rawRecipe.ingredientIds;
let tableautotalprix = []
var listequantiter = monitem.recipeBox.rawRecipe.quantities;
let totalprix = 0
let totalpods = 0
let tableaupods = []
let podsreunit = []
let finish = []

for(var i = 0; i < listeingredient.length; i++){
listeingredient[i] = this.getPrice(listeingredient[i])
tableaupods[i] = monitem.recipeBox.ingredients[i].data.realWeight
}

for(var i = 0; i < listeingredient.length; i++){
let array3 = listeingredient[i] * listequantiter[i]
let pods3 = tableaupods[i] * listequantiter[i]
tableautotalprix.push(array3);
podsreunit.push(pods3);
}
for(var i = 0; i < tableautotalprix.length; i++){
totalprix += tableautotalprix[i]
totalpods += podsreunit[i]

}
finish.push(totalprix);
finish.push(totalpods);
return finish;

}

private afficherprix(prix): void {
let thePrice = this.getInformation()
let totalprix = thePrice[0]
let totalpods = thePrice[1]
if(totalprix != NaN && totalprix != null && totalprix != undefined && totalprix.toString() != "NaN"){
let estimationprix = document.createElement("div");
estimationprix.className = "estimationprix";
estimationprix.id = "estimationprix";
estimationprix.innerHTML = "Prix moyen du craft : " + this.formatNumber(totalprix) + ' <div style="background: url(./assets/ui/icons/kama.png) no-repeat;width: 20px;display: inline-block;height: 16px;background-size: 18px;"></div>' + " (" + totalpods + " Pods).";
requestAnimationFrame(() => {
this.wGame.document.getElementsByClassName("itemRecipeBox")[0].parentNode.insertBefore(estimationprix, null);
})
}
else {
return ;
}

};

reset(){
this.getObjectAveragePrice(this.tableauitemid, this.tableauitemprice)
}



}
6 changes: 0 additions & 6 deletions src/app/mods/general/index.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/app/mods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { General } from "../mods/general/general";

export { AutoGroup } from "./auto-group/auto-group";
export { DamageEstimator } from "../mods/damage-estimator/damage-estimator";
export { EstimationPrix } from "./estimationprix/estimationprix";
export { FightChronometer } from "./fight-chronometer/fight-chronometer";
export { GripPositionSave } from "./grip-position-save/grip-position-save";
export { Harvest } from "./harvest-bar/harvest";
Expand All @@ -17,4 +18,4 @@ export { Shortcuts } from "../mods/shortcuts/shortcuts";
export { ShowResources } from "./show-resources/show-resources";
export { VerticalTimeline } from "./vertical-timeline/vertical-timeline";
export { ZaapSearchFilter } from "./zaap-search-filter/zaap-search-filter";
export { RuneOpenerList } from "./rune-lister/runeOpenerLister"
export { RuneOpenerList } from "./rune-lister/runeOpenerLister";