Comments (24)
Option 1: Getting info from Wikia
I managed to write a simple code that extracts stats and info from wikia page tables without the images in th, it also includes name
, idName
and statsDate
to keep track of latest update.
if we agree to use this method I will write special rules store numerical values as integers instead of strings
how to test:
go to http://clashroyale.wikia.com/wiki/Knight, open console and paste the following code
var myRows = [];
var $headers = $("#unit-statistics-table th");
var $rows = $("#unit-statistics-table tr:not(:first-child)").each(function(index) {
$cells = $(this).find("td");
myRows[index] = {};
$cells.each(function(cellIndex) {
myRows[index][$($headers[cellIndex]).clone().children().remove().end().text().trim().toLowerCase().split(" ").join("-")] = $(this).text().trim();
});
});
var myObj = {}
myObj.name = $(".header-title h1").text().trim();
myObj.idName = $(".header-title h1").text().trim().toLowerCase().split(" ").join("-")
$("#unit-attributes-table tr th").each(function(index) {
var thisTH = $(this).clone().children().remove().end().text().trim().toLowerCase().split(" ").join("-")
var thisTD = $("#unit-attributes-table tr td").eq(index).text().trim()
myObj[thisTH] = thisTD
});
myObj.stats = myRows;
myObj.statsDate = new Date().toISOString()
console.log(myObj);
you will get and object called myObj
that looks like this:
{
"name": "Knight",
"idName": "knight",
"cost": "3",
"hit-speed": "1.1 sec",
"speed": "Medium (60)",
"deploy-time": "1 sec",
"range": "Melee",
"target": "Ground",
"count": "x1",
"transport": "Ground",
"type": "Troop",
"rarity": "Common",
"stats": [
{
"level": "1",
"hitpoints": "660",
"damage": "75",
"damage-per-second": "68"
},
{
"level": "2",
"hitpoints": "726",
"damage": "82",
"damage-per-second": "74"
},
{
"level": "3",
"hitpoints": "798",
"damage": "90",
"damage-per-second": "81"
},
{
"level": "4",
"hitpoints": "877",
"damage": "99",
"damage-per-second": "90"
},
{
"level": "5",
"hitpoints": "963",
"damage": "109",
"damage-per-second": "99"
},
{
"level": "6",
"hitpoints": "1,056",
"damage": "120",
"damage-per-second": "109"
},
{
"level": "7",
"hitpoints": "1,161",
"damage": "132",
"damage-per-second": "120"
},
{
"level": "8",
"hitpoints": "1,273",
"damage": "144",
"damage-per-second": "130"
},
{
"level": "9",
"hitpoints": "1,399",
"damage": "159",
"damage-per-second": "144"
},
{
"level": "10",
"hitpoints": "1,537",
"damage": "174",
"damage-per-second": "158"
},
{
"level": "11",
"hitpoints": "1,689",
"damage": "192",
"damage-per-second": "174"
},
{
"level": "12",
"hitpoints": "1,854",
"damage": "210",
"damage-per-second": "190"
},
{
"level": "13",
"hitpoints": "2,039",
"damage": "231",
"damage-per-second": "210"
}
],
"statsDate": "2017-03-22T08:20:55.031Z"
}
from clash-royale-api.
- Use camelCase if it's possible, such as
hitSpeed
instead ofhit-speed
. dps
should be ok- Take into account that some cards may have a range in some attributes, such as the inferno damage
20-400
instead of a simple value, or the goblin gang hitpoints80/52
. In this cases, use a string if possible. - I think the best would be to multiply it by
1000
so that all units are in milliseconds.
from clash-royale-api.
I'm already on it, I decoded characters.csv and found so many ordered useful information. I will not leave this issue until I have them all ordered in a table and ready to be implemented, It'll take some time tho. I will keep you guys updated here.
from clash-royale-api.
it's a duplicate of your cards.json with same order and length with new keys.
also I spent some time to create a help file to clear everything for users, including units, types and special cases.
one thing to note, there was two cards with "needs confirmation" tags that we might need to confirm later.
Mega Minions Damage and Dark Prince Hitpoints
I hope you guys take a look at the file and point any possible issues and I'll work on them.
but YEAH we finally have it!!!!!
from clash-royale-api.
@martincarrera Yes, it's almost impossible to do so unless people can contribute info or something like that which is not needed.
Need to change the issue title to something proper.
from clash-royale-api.
@MaherFa I agree, a tiny code can achieve that.
I use a class for each card, so it'll be like: card.getTournyStats()
which will do the work.
from clash-royale-api.
+1
from clash-royale-api.
It is a great suggestion, but unluckily there is a LOT of different options like hitpoints, damage, dps, etc. and as Supercell updates the balance of the game really often it is quite difficult for me to keep that information updated.
I will leave this issue open, feel free to submit a pull request if you want help with this, I will try to work on this feature in the future.
Thanks!
from clash-royale-api.
At least, could be possible to have cards level at tournament rules? It should be easier
from clash-royale-api.
does anyone have an idea where the game store card stats? I can decode csv files and gather that info.
another option is getting them from the wikia. I can also do that but we would echo any errors they have in their database so I'd prefer the 1st option.
from clash-royale-api.
Option 2: Getting info from game files
I managed to extract and decode official csv files, I narrowed down related files to these:
https://github.com/MaherFa/temp-csv-files
characters.decoded.csv
includes data like Rarity
SightRange
DeployTime
ChargeRange
Speed
Hitpoints
HitSpeed
LoadTime
Damage
DamageSpecial
CrownTowerDamagePercent
• DPS is calculated using HitSpeed
and Damage
• Ranged units doesn't have Damage
value, but they have a Projectile
value that can be used to get data from projectiles.decoded.csv
projectiles.decoded.csv
includes data about ranged units and some direct damage spells
character_buffs.decoded.csv
includes information about elements that affect characters like Rage, Heal, Poison and Freeze
buildings.decoded.csv
buildings
area_effect_objects.decoded.csv
area effect spells and cards
• some cards are listed with different names from game names, for example Executioner
is called AxeMan
• stats are listed for Level 1 cards, sowe need to figure out the formula (multiplayer) to calculate stats for each level.
I believe this method is much better than the first option but it'll require more initial work. but once we have the script that extracts data from files we can automate the whole proccess for future updates.
from clash-royale-api.
@martincarrera I have no experience with MongoDB, but I can loop through wikia pages and generate a JSON with all the info they have, and I think it should be easy to merge the result with the existing database. what do you think?
from clash-royale-api.
Hi, I think the best way should be the first one.
If you could provide me a JSON with the complete data of all the cards, I can update the API model to support that information and update the API.
I could try to create a tiny script to run your code, but as I don't have a lot of time this days, it may take a couple of weeks.
Thanks!
from clash-royale-api.
already on it, I'm writing a node.js script that takes card names from an array and generate wikia links and http rquest them. I'm also using jsdom and jquery to run the code inside of node.
it should be ready within 48 hours max, depending on my free time.
Some mico issues:
• should key names be like hit-speed
or hitSpeed
?
• should I use damage-per-second
/damagePerSecond
or dps
• should speed
include an integer or a string or both? I think using a number is better for combaring cards
• I'm also thinking about removing the unit sec
from time values and maybe multiply by 1000
to get rid of the decimals so "1.1 sec"
would become 1100
from clash-royale-api.
@martincarrera Full JSON file is ready, where should I upload it?
from clash-royale-api.
Could you create a public gist and share the url?
I can work on that.
Thanks!
from clash-royale-api.
Is there a way to get tournament standards stats?
Like torLevel: 9
and we'll know to get level 9.
from clash-royale-api.
@amirm3hdi
I don't know if Martin have plans of implementing this but I see no point in adding this to every card, maybe a separate call with a value for each rarity?
{
common: 9,
rare: 7,
epic: 4,
legendary: 1
}
for others looking for a way to handle this, you can use conditions with hard coded indexes to get what you want for now:
console.log(getTournyStats(cardObject))
function getTournyStats(myCard) {
switch (myCard.rarity) {
case "Common":
return myCard.stats[8];
break;
case "Rare":
return myCard.stats[6];
break;
case "Epic":
return myCard.stats[3];
break;
case "Legendary":
return myCard.stats[0];
break;
}
}
from clash-royale-api.
Can you add soon the levels to your API? All members of my clan are waiting for the levels of each card to add to my bot ;)
https://gist.github.com/MaherFa/2d143da0a707caa7532dfff708643a6d
from clash-royale-api.
@martincarrera if that JSON is hard to work with I can help if you point me to the recommended format you like the data in. I'm also perfecting the StatGrab bot for future updates, requests are welcomed.
from clash-royale-api.
added all available icons to be used with stats (1d27efa)
from clash-royale-api.
- Should be a exception for in range for Mortar
range [ number ] Except "Goblin Gang" and Mortar
range [ string ] Goblin Gang, Mortar separated by a "/" min and max range values.
It says, 311 and should be "3/11" or something like that.
- Lifetime in Barbarian Hut is 1 sec.
- Elixir Collector lifetime is 110 sec, should be 70000 (ms).
from clash-royale-api.
Is this still happening? Is anyone actively working on this api?
from clash-royale-api.
Hi @BenC14! I am working on this API on my free time - and to be honest I don't have much since a couple of months ago.
I will try to make this feature as soon as possible, but I can't promise any date or anything.
I will post any news in this thread.
Thanks!
from clash-royale-api.
Related Issues (20)
- Card: Magic Archer HOT 3
- Royal Ghost bad image HOT 1
- Error 500 Internal Server Error HOT 6
- Markdown standards for README.md
- Wrong Name and URL for Donate App
- Bad card image (Hunter) HOT 1
- Proposal to lower the load and improve stability HOT 1
- [card.idCopy] In game copy-id of cards HOT 16
- not an actual api for clash royale HOT 10
- Rascals?? HOT 2
- Clan Information HOT 4
- Can you add my app to read me please. HOT 3
- Add new cards and reorder existing cards
- [Discussion][Improvement]Add the new emotes
- The skeletons' description is wrong? HOT 1
- Official Clash Royale API HOT 6
- Update API to support 12/12 update HOT 1
- Provide localized card names HOT 2
- Improve images HOT 3
- Consume API via HTTPS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clash-royale-api.