Skip to content

Commit

Permalink
adjusted unit rarity to new cargoquery
Browse files Browse the repository at this point in the history
  • Loading branch information
arghblargh committed Aug 2, 2019
1 parent 15956bb commit 284484f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ app.get('/units/rarity', async (req, res) => {
action: 'cargoquery',
format: 'json',
limit: '500',
tables: 'Heroes',
fields: '_pageName=Name,Title,SummonRarities,RewardRarities'
tables: 'Distributions',
fields: 'Unit,Rarity'
}
request.post({ url:'https://feheroes.gamepedia.com/api.php', formData: formData }, function (err, response, body) {
if (err) {
Expand Down Expand Up @@ -253,10 +253,9 @@ function formatUnits(data, withSkills) {
function formatUnitRarity(data) {
var result = {};
for (var unit of data.cargoquery) {
var name = he.decode(unit.title.Name);
var summon = unit.title.SummonRarities ? parseInt(unit.title.SummonRarities[0], 10) : 5;
var reward = unit.title.RewardRarities ? parseInt(unit.title.RewardRarities[0], 10) : 5;
result[name] = Math.min(summon, reward);
var name = he.decode(unit.title.Unit);
var summon = parseInt(unit.title.Rarity[0], 10);
result[name] = summon;
}
return result;
}

0 comments on commit 284484f

Please sign in to comment.