Skip to content
TORNLIFE More

API attack logs

Started by tos [1976582] on in API Development.

3 replies · 107 views · thread synced · 6 days ago · View on torn.com
About this thread

Posts archived: 4 / 4 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
4
Discussion span
→
People posting
3
Likes on archived posts
0
Posts by staff, officers and moderators
1
Authority score
70 / 100
Historical score
16 / 100
Story score
23 / 100
Engagement score
41 / 100
tos [1976582]

I've noticed an issue with attack logs from the api, curious if any of you have had the same issue and how you tackled it.

 

The Problem:
Attack IDs are generated when an attack is started, and logs are listed in order of attack ID.  Logs are not posted to the API until the attack finishes and the player clicks a result button.  The issues comes if player A starts an attack, then player B does but player B finishes their attack first.  If the API call happens here before player A has finished their attack then there is a "hole" in the API data until that attack finishes at which point it will be inserted in its proper place.



Possible Solutions:
  1. If this were a database scenario then not much issue, can just grab a handful of the latest logged to the table and check against that.
  2. For something "live" like a discord bot where there is no place to reference the attack IDs that have been printed, you could store a list of the last handful of attacks printed and periodically remove items from the bottom of that list.
Solution #2 is the one I am more concerned with at the moment, reading the attack logs live and insuring all logs are printed and none doubled.  The application will be running 24/7 so I don't want to just store all attack IDs as this will bloat over time.  A rotating list of recent attack IDs is the best way I've been able to think of, wondering if any of you have other solutions.
Bug [1455582] Committee Committee

Solution: Instead of storing the attack id, store the timestamp_ended variable and compare that.
tos [1976582]

I'll need to test to double check, but I think the problem there is that timestamp ended is generated when the player gets the kill but the result not logged to api until a choice is made.
Pi77Bull [2082618]

I agree that it's not optimal as it is right now. Actually I have been dealing with the same problem as you have since I'm also making a Discord bot ^^. The problem is it can't be logged to the api until the player has made a choice because the choice is part of the object.