Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Examples #71

Open
mahousenshi opened this issue Apr 15, 2018 · 6 comments
Open

Code Examples #71

mahousenshi opened this issue Apr 15, 2018 · 6 comments

Comments

@mahousenshi
Copy link

mahousenshi commented Apr 15, 2018

Can you give us some examples how this library works on the documentation the programmatic way. Like

  • How to see the players actions.
  • How to see the players and see the winner.
  • How to get the chat log.
  • How to get the JSON of something above.

Can be a fake example one. But a snippet of code helps a lot when you don't know nothing about a library. I know this can change by protocol changes, but it's give us a idea how this library should work.

@FMorsbach
Copy link
Contributor

Just to let you guys know, I´m working on some small examples in order to add them to the documentation. I´m not an expert with this lib but I got a few things up and running during my experiments and I think I can save someone else some trouble.

@amartin916
Copy link
Contributor

Would it be helpful If I wrote up some examples on how I use it in php ? I export the data from s2protocol as json and than do all the logic I want in php.

@jrepp
Copy link
Contributor

jrepp commented May 10, 2018

This is a common question that comes up. The API of the library itself is not complicated but the structure of the data in the replay is fairly obtuse. I think a doc that describes the data in more detail would really help people a lot. We could also provide some small examples of consuming the data from different languages. There is Python, PHP, C# and Java users to my knowledge

@amartin916
Copy link
Contributor

Threw together some quick documentation #78 I will continue to add to it as I have time but should be a good starting point.

@mahousenshi

  • How to see the players actions
    -- Is a little more complicated but they come from the --gameevents flag and the events you are looking for are [_event] => NNet.Game.SCmdEvent.
  • How to see the players and see the winner.
    -- Check the pull request under the details flag, m_playerList->m_result will give you a good starting point.
  • How to get the chat log.
    -- Check out the pull request in the section messageevents thats how you get chat messages.
  • How to get the JSON of something above.
    -- python "./s2protocol/s2_cli.py" --messageevents --ndjson "REPLAY FILE"

@FMorsbach
Copy link
Contributor

@jrepp I just prototyped some documentation on how to use the API inside python. What do you think? (Look on my fork please, since this is just some prototyped stuff I dont want to open an PR.) I added two .rst in the /doc: tutorial_API.rst and events.rst.

The latter could be used to describe the data a bit more. What do you guys think about the format? Is this the right way to go ?

@jrepp
Copy link
Contributor

jrepp commented May 14, 2018

@FMorsbach Yes, this is great.

  • I love the idea of the examples in an interactive shell so people can explore. This is how I play with it as well.
  • Encouraging people to help fill in the event structures is a good approach. If I go through my email and the issues log I can fill in some additional details as well.

I'm ok with this going in in a partial state. Feel free to open a PR with the documentation changes.

Sorry for the slow reply, just getting back from vacation and trying to recover today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants