martincarrera / clash-royale-api

:crown: Clash Royale API that provides information about the game.
http://www.clashapi.xyz/
MIT License
353 stars 80 forks source link

[card.idCopy] In game copy-id of cards #109

Closed AmirSavand closed 6 years ago

AmirSavand commented 6 years ago

So I want users to open and copy the decks from web to game directly.

I think it would be good to add the id of the cards that is used in copy link structure like this:

https://link.clashroyale.com/deck/en?deck=26000002;26000001;26000013;26000005;28000000;26000012;26000015;26000016

That opens the game with this magnet link:

clashroyale://copyDeck?deck=26000002;26000001;26000013;26000005;28000000;26000012;26000015;26000016

Anyway, I'm using these for my website, if this feature is suitable for this API then it would be good to be included, these are the numbers of each card:

{
      "archers": 26000001,
      "arrows": 28000001,
      "baby-dragon": 26000015,
      "balloon": 26000006,
      "bandit": 26000046,
      "barbarian-hut": 27000005,
      "barbarians": 26000008,
      "bats": 26000049,
      "battle-ram": 26000036,
      "bomb-tower": 27000004,
      "bomber": 26000013,
      "bowler": 26000034,
      "cannon": 27000000,
      "cannon-cart": 26000054,
      "clone": 28000013,
      "dark-prince": 26000027,
      "dart-goblin": 26000040,
      "electro-wizard": 26000042,
      "elite-barbarians": 26000043,
      "elixir-collector": 27000007,
      "executioner": 26000045,
      "fire-spirits": 26000031,
      "fireball": 28000000,
      "flying-machine": 26000057,
      "freeze": 28000005,
      "furnace": 27000010,
      "giant": 26000003,
      "giant-skeleton": 26000020,
      "goblin-barrel": 28000004,
      "goblin-gang": 26000041,
      "goblin-hut": 27000001,
      "goblins": 26000002,
      "golem": 26000009,
      "graveyard": 28000010,
      "guards": 26000025,
      "heal": 28000016,
      "hog-rider": 26000021,
      "hunter": 26000044,
      "ice-golem": 26000038,
      "ice-spirit": 26000030,
      "ice-wizard": 26000023,
      "inferno-dragon": 26000037,
      "inferno-tower": 27000003,
      "knight": 26000000,
      "lava-hound": 26000029,
      "lightning": 28000007,
      "lumberjack": 26000035,
      "mega-knight": 26000055,
      "mega-minion": 26000039,
      "miner": 26000032,
      "mini-pekka": 26000018,
      "minion-horde": 26000022,
      "minions": 26000005,
      "mirror": 28000006,
      "mortar": 27000002,
      "musketeer": 26000014,
      "night-witch": 26000048,
      "pekka": 26000004,
      "poison": 28000009,
      "prince": 26000016,
      "princess": 26000026,
      "rage": 28000002,
      "rocket": 28000003,
      "royal-ghost": 26000050,
      "royal-giant": 26000024,
      "skeleton-army": 26000012,
      "skeleton-barrel": 26000056,
      "skeletons": 26000010,
      "sparky": 26000033,
      "spear-goblins": 26000019,
      "tesla": 27000006,
      "the-log": 28000011,
      "three-musketeers": 26000028,
      "tombstone": 27000009,
      "tornado": 28000012,
      "valkyrie": 26000011,
      "witch": 26000007,
      "wizard": 26000017,
      "x-bow": 27000008,
      "zap": 28000008,
      "zappies": 26000052
}

Until this is added to API, this is how I get em in my Card class:

    // ...
    this.id = id;
    this.idName = idName;
    this.idCopy = Main.card.copyId[idName];
    this.name = name;
    this.arena = arena;
    this.description = description;
    this.elixirCost = elixirCost;
    this.order = order;
    this.rarity = rarity;
    this.type = type;
    // ...
AmirSavand commented 6 years ago

If this is going to be added, I'd suggest naming this property idCopy because it is the id that used in copy link :wink:

@MaherFa what do you think?

MaherFa commented 6 years ago

I support this, I think it can be very beneficial. is there's an official source of mentioned id? something we can rely on for future cards and double checking?

AmirSavand commented 6 years ago

@MaherFa No I couldn't find an official source, all I could find was a reddit post :P

But I provided the list and for all current cards, we can just use the game and try to share a deck with the new card and it'll be revealed :)

I don't mind this key to have null for new cards.

MaherFa commented 6 years ago

good enough if you're willing to test all of them! and btw, this issue is a duplicate of (https://github.com/martincarrera/clash-royale-api/issues/92)

AmirSavand commented 6 years ago

Wow, didn't know about the duplicate, this issue can be closed but the list I provided should be mentioned so it's easier to add them when implementing the issue.

MaherFa commented 6 years ago

no worries, done!

AmirSavand commented 6 years ago

@MaherFa although, I didn't get my list from reddit, I got em from a live website using them, you could say I stole them :D but I use them for my website too, so if there's an issue with em (like incorrect id) I will know about it, so far no issue.

martincarrera commented 6 years ago

I will try to add the card ids this week, I'm currently super busy right now, so if you like you can add it on each card in the data generator as copyId and I'll update the API to support it, that way you could help A LOT!

AmirSavand commented 6 years ago

@martincarrera I tried to do so, but I couldn't figure out how to :( but I'll try again :D

HZooly commented 6 years ago

I will do this soon @AmirSavand

AmirSavand commented 6 years ago

@TorzuoliH I just figured out, I didn't know they were on https://github.com/martincarrera/clash-royale-api-data-generator

Anyway, cool thanks.

HZooly commented 6 years ago

Sorry for being late: here's the work : https://github.com/martincarrera/clash-royale-api-data-generator/pull/18

martincarrera commented 6 years ago

Thanks @TorzuoliH!

I will be working on this enhancement this week and I'll let you know when it is ready.

HZooly commented 6 years ago

Ok nice 😄

Maybe if you could merge Barbarian Barrel request (on the other repo), I will see for adding the missing ids.

martincarrera commented 6 years ago

Added copyId on each card.

Please if there is a wrong ID or something let me know as soon as possible.

AmirSavand commented 6 years ago

@martincarrera wooo! nice work.