const blockSize = 16; function decimalToHex(decimalValue) { // Convertit la valeur décimale en hexadécimal let hexString = decimalValue.toString(16).toUpperCase(); // Divise la chaîne hexadécimale en deux parties let firstByte = "0x" + hexString.slice(0, -2); let secondByte = "0x" + hexString.slice(-2); return [firstByte, secondByte]; } function convertInGameLoctoLeafletLoc(landblockId, x, y) { let [lbx, lby] = decimalToHex(landblockId); lbx = lbx * blockSize; lby = lby * blockSize; let locx = lbx + x / 10; let locy = 4080 - (lby + y / 10) - 1; locx = locx / 16; locy = (locy / 16) * -1; // Renvoyer les coordonnées converties return { locx, locy }; } module.exports = { convertInGameLoctoLeafletLoc };