Skip to content

Commit

Permalink
Merge pull request #88 from GeekaN2/feat/private-servers
Browse files Browse the repository at this point in the history
Feat/private servers
  • Loading branch information
GeekaN2 authored Aug 31, 2024
2 parents 7e24460 + 7913945 commit 3b06c7f
Show file tree
Hide file tree
Showing 12 changed files with 19,171 additions and 468 deletions.
64 changes: 22 additions & 42 deletions components/transmutations/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { mapGetters, mapState } from "vuex";
import ItemRow from "./ItemRow";
import LongWayTransmutationRow from "./LongWayTransmutationRow";
import ItemRecipe from "./ItemRecipe.vue";
import { MARKET_SELL_ORDER_FEE } from '../../store/constants';
import { MARKET_SELL_ORDER_FEE } from "../../store/constants";
export default {
name: "Table",
Expand All @@ -75,17 +75,17 @@ export default {
],
transCostPrevSubtierFormula: [
[0, 0, 0, 0, 0],
[1980, 1760, 2640, 4230, 8450],
[3950, 3530, 5280, 8450, 16900],
[7920, 7040, 10560, 16900, 33800],
[79240, 70410, 105600, 168960, 337920]
[1500, 2000, 3000, 4800, 14400],
[3000, 4000, 6000, 15120, 45360],
[6000, 8000, 19800, 49896, 149688],
[24000, 32000, 79200, 199584, 748440],
],
transCostPrevTierFormula: [
[0, 1180, 1760, 2820, 5640],
[0, 2350, 3520, 5640, 11270],
[0, 4700, 7040, 11270, 22530],
[0, 9390, 14080, 22530, 45060], // [0, x, x, x, 45060]
[0, 93880, 140800, 225280, 450560],
[0, 781, 1250, 2500, 5000],
[0, 1563, 2500, 5000, 15000],
[0, 3125, 5000, 15750, 47250],
[0, 6250, 16500, 51975, 155925],
[0, 25000, 66000, 207900, 779625],
],
/**
* It's a bit weird but rocks only have prev tier formula
Expand All @@ -99,7 +99,7 @@ export default {
buyItems: "transmutations/buyItemPrices",
getItemName: "transmutations/getItemName",
loadingText: "transmutations/loadingText",
globalDiscount: 'transmutations/globalDiscount'
globalDiscount: "transmutations/globalDiscount",
}),
...mapState({
Expand All @@ -114,20 +114,14 @@ export default {
let bestWays = [];
// Started item, can't be T8.4
for (let tier = 4; tier <= 8; tier++) {
for (
let subtier = 0;
subtier <= 4 && !(tier == 8 && subtier == 4);
subtier++
) {
for (let subtier = 0; subtier <= 4 && !(tier == 8 && subtier == 4); subtier++) {
let allWays = this.getAllTransmuteWays(tier, subtier);
bestWays.push(...allWays);
}
}
bestWays.sort(
(row1, row2) => row2.profitPercentage - row1.profitPercentage
);
bestWays.sort((row1, row2) => row2.profitPercentage - row1.profitPercentage);
return bestWays;
},
Expand Down Expand Up @@ -189,8 +183,7 @@ export default {
const globalDiscount = this.globalDiscount;
const transmutationCost =
itemTransCost * globalDiscount +
((value * fee) / 100) * 0.1125;
itemTransCost * globalDiscount + ((value * fee) / 100) * 0.1125;
return transmutationCost;
},
Expand Down Expand Up @@ -222,12 +215,11 @@ export default {
}
const item = this.sellItems[itemName];
const price = Math.floor(item.sellPriceMin * (100 - MARKET_SELL_ORDER_FEE) / 100);
const price = Math.floor(
(item.sellPriceMin * (100 - MARKET_SELL_ORDER_FEE)) / 100
);
const fee = Math.floor(
this.getTransmutationFee(
itemName,
this.getItemTransCostPrevTierFormula
)
this.getTransmutationFee(itemName, this.getItemTransCostPrevTierFormula)
);
const materialName =
`T${tier - 1}_${this.baseItemName}` +
Expand Down Expand Up @@ -284,10 +276,7 @@ export default {
const item = this.sellItems[itemName];
const price = Math.floor(item.sellPriceMin * 0.955);
const fee = Math.floor(
this.getTransmutationFee(
itemName,
this.getItemTransCostPrevSubtierFormula
)
this.getTransmutationFee(itemName, this.getItemTransCostPrevSubtierFormula)
);
const materialName =
`T${tier}_${this.baseItemName}` +
Expand Down Expand Up @@ -351,27 +340,18 @@ export default {
if (t - 1 >= tier) {
prevTierFee =
cells[s][t - 1].transmutationFee +
this.getTransmutationFee(
itemName,
this.getItemTransCostPrevTierFormula
);
this.getTransmutationFee(itemName, this.getItemTransCostPrevTierFormula);
}
if (s - 1 >= subtier) {
prevSubtierFee =
cells[s - 1][t].transmutationFee +
this.getTransmutationFee(
itemName,
this.getItemTransCostPrevSubtierFormula
);
this.getTransmutationFee(itemName, this.getItemTransCostPrevSubtierFormula);
}
cells[s][t].cost = 0;
if (
(prevTierFee < prevSubtierFee && prevTierFee != 0) ||
prevSubtierFee == 0
) {
if ((prevTierFee < prevSubtierFee && prevTierFee != 0) || prevSubtierFee == 0) {
cells[s][t] = {
transmutationFee: prevTierFee,
prevTier: t - 1,
Expand Down
10 changes: 5 additions & 5 deletions components/utils/ServersSelect.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template>
<template>
<select
v-model="currentServerId"
class="servers-select"
Expand All @@ -8,12 +8,12 @@
:key="server.id"
:value="server.id"
>
{{ $t(`servers.${server.id}`) }}
{{ server.name }}
</option>
</template>
</select>
</template>

<script>
import { mapState } from 'vuex';
Expand All @@ -40,7 +40,7 @@ export default {
}
};
</script>
<style scoped lang="scss">
.servers-select {
margin-right: var(--space-s);
Expand All @@ -58,4 +58,4 @@ export default {
border-color: var(--color-contrast-analog);
}
}
</style>
</style>
27 changes: 4 additions & 23 deletions node-scripts/getItemsFromDumps.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
const axios = require('axios');
const fs = require('fs');
const { getAllFoodAndPotionNames } = require('./utils');

/**
* Get data from albion online dumps repository
*/
async function getItems() {
console.log('Downloading items dump...');

try {
const request = await axios.get('https://raw.githubusercontent.com/broderickhyman/ao-bin-dumps/master/items.json');

console.log('Dump downloaded');

return request.data;
} catch {
console.log('Something went wrong while downloading');

return [];
}
}
const { getAllFoodAndPotionNames, getItems } = require('./utils');

async function main() {
const itemNames = getAllFoodAndPotionNames();
Expand All @@ -30,12 +11,12 @@ async function main() {

try {
fs.writeFileSync("./static/jsonAutomatic/foodAndPotionsTreeItems.json", JSON.stringify(filteredItems));

itemNames.forEach(itemName => console.log('Added', itemName));
} catch (error) {
console.log('Writing aborted', error);
}

}

main();
main();
69 changes: 69 additions & 0 deletions node-scripts/getTransmutationValues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const axios = require('axios');
const fs = require('fs');
const { getAllFoodAndPotionNames, getItems } = require('./utils');

function getResourceUniqueNames() {
const resource = 'ORE';
const names = [];

for (let tier = 4; tier <= 8; tier++) {
for (let subtier = 0; subtier <= 4; subtier++) {
// skip 4.0 resource, cause it have no craftinrequirements
if (tier === 4 && subtier === 0) {
continue;
}

names.push(`T${tier}_${resource}${subtier === 0 ? '' : '_LEVEL' + subtier}`);
}
}

return names;
}

function getTierAndSubtierByResourceName(resourceName) {
const regex = /T(\d)_ORE(?:_LEVEL)?(\d)?/;
const [, tier, subtier] = resourceName.match(regex);

return {
tier,
subtier: subtier ?? 0
}
}

async function main() {
let dump = (await getItems());
const resourceNames = getResourceUniqueNames();

const transCostPrevSubtierFormula = JSON.parse(JSON.stringify(new Array(5).fill(new Array(5).fill(0))));
const transCostPrevTierFormula = JSON.parse(JSON.stringify(new Array(5).fill(new Array(5).fill(0))));

resourceNames.forEach(resourceName => {
const resource = dump.items.simpleitem.find((item) => {
return item['@uniquename'] === resourceName && item['@shopcategory'] === 'resources'
});

const { tier, subtier } = getTierAndSubtierByResourceName(resourceName);
const recipes = [resource.craftingrequirements].flat();
recipes.forEach(recipe => {
const recipeCost = Number(recipe['@silver']);
const tranmuteFromResource = recipe['craftresource']['@uniquename'];

const { tier: transmuteFromTier, subtier: transmuteFromSubtier} = getTierAndSubtierByResourceName(tranmuteFromResource);

if (transmuteFromTier < tier) {
transCostPrevTierFormula[subtier][tier - 4] = recipeCost;
}

if (transmuteFromSubtier < subtier) {
transCostPrevSubtierFormula[subtier][tier - 4] = recipeCost;
}
})
});


console.log('transCostPrevSubtierFormula', transCostPrevSubtierFormula);

console.log('transCostPrevTierFormula', transCostPrevTierFormula);
}

main();
29 changes: 26 additions & 3 deletions node-scripts/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require('fs');
const axios = require('axios');

/**
* @returns {string[]} - array of all base food and potion names that we need with tiers
Expand Down Expand Up @@ -38,7 +39,7 @@ function getAllFoodAndPotionNames() {

/**
* Creates an array with all names of full journals of all tiers and subtiers
*
*
* @param {string} root - journals branch: WARRIOR, MAGE etc.
* @returns {string[]} - array with all tiers and subtiers for empty and full journals
*/
Expand All @@ -55,7 +56,7 @@ function createArrayOfAllJournals(root) {

/**
* Creates and array with all names of food, potions and relative items in their branches
*
*
* @returns {string[]}
*/
function createArrayOfAllFoodAndPotions() {
Expand Down Expand Up @@ -116,8 +117,30 @@ function createArrayOfAllFoodAndPotions() {
return allNames;
}

/**
* Get items from ao-bin-dumps
*/
async function getItems() {
console.log('Downloading items dump...');

try {
const request = await axios.get('https://raw.githubusercontent.com/ao-data/ao-bin-dumps/master/items.json');

console.log('Dump downloaded');

return request.data;
} catch (error) {
console.log('Something went wrong while downloading', error);

return [];
}
}


module.exports = {
getItems,
createArrayOfAllJournals,
getAllFoodAndPotionNames,
createArrayOfAllFoodAndPotions
}
}

Loading

0 comments on commit 3b06c7f

Please sign in to comment.