MattGibney / DarkThrone

Lovingly re-creating the DarkThrone experience.
https://darkthronereborn.com
1 stars 0 forks source link

Limit which players one can attack. #49

Closed fpopa closed 3 months ago

fpopa commented 4 months ago

https://github.com/MattGibney/DarkThrone/issues/31

Still to do backend validation.

I tried placing the attackable helper functions in a separate file but couldn't get the imports right for some reason πŸ€” any idea? it was a file at the same level named helpers.ts. I want to add it there so we can use it on the BE as well.


Highlight current player row

image

Showing attackable range:

image

11 attackable:

image

12 not:

image

also trying to replace player ID in url for attack action:

image

trying to attack using curl (by-passing FE validations):

➜  DarkThrone git:(31-restrict-attacking-to-players-within-a-range) βœ— >....
  -H 'Content-Type: application/json' \
  -H 'Cookie: DTAC=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySUQiOiJVU1ItMDFIUVAxNVZCNVZHSlk1SDlSMjVDRktGNUQiLCJpYXQiOjE3MDkzMjg4NTgsImV4cCI6MTcxMTkyMDg1OH0.TcTKQUrSE466sAuLQ_Qg8QAo4Ys7suZMvW3a56r-fsw' \
  -H 'DNT: 1' \
  -H 'Origin: http://localhost:4200' \
  -H 'Referer: http://localhost:4200/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-site' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw '{"targetID":"PLR-01HQY1KV2T8FMWHXHZT9D6VRQ5","attackTurns":1}' \
  --compressed
{"errors":[{"code":"attack_outside_range","title":"attacker outside range"}]}%