clashperk / clashofclans.js

JavaScript library for interacting with the Clash of Clans API
https://clashofclans.js.org/
MIT License
54 stars 23 forks source link

feat(ClanWar): add getMemberByMapPosition #189

Closed ryancundiff closed 3 weeks ago

ryancundiff commented 5 months ago

Add method to ClanWar to provide encapsulated functionality for getting a member by their map position in war.

csuvajit commented 5 months ago

can you please bump the version as well?

ryancundiff commented 5 months ago

can you please bump the version as well?

Done!

csuvajit commented 5 months ago

I would like to bring to your attention a slight inaccuracy in the mapPosition for CWL. When the team size is 30, but all 50 members were registered during the signup process, the mapPosition value exceeds 30.

csuvajit commented 5 months ago

The mapPosition is based on the registered member list for CWL

If you do getMemberByMapPosition(10), it might return a wrong member or just null (if they were excluded from that round)

ryancundiff commented 5 months ago

The mapPosition is based on the registered member list for CWL

If you do getMemberByMapPosition(10), it might return a wrong member or just null (if they were excluded from that round)

How do you recommend I work around that? If it can return the wrong member then there is no way (that I can think of) to work around that. I could remove the functionality for CWL by checking the ClanWar type and return null if it is equal to CWL. What do you think?

csuvajit commented 5 months ago

If you sort them by the mapPosition, the index + 1 becomes the actual mapPosition.

csuvajit commented 5 months ago

However, I'm not sure if the members are already sorted by the mapPosition. I can comfirm that in 2-3 hours.

ryancundiff commented 5 months ago

However, I'm not sure if the members are already sorted by the mapPosition. I can comfirm that in 2-3 hours.

Did you confirm?

csuvajit commented 5 months ago

It is not sorted.