Jroc Posted December 29, 2015 Share Posted December 29, 2015 (edited) Introduction I have been working on creating a C# Code Library that makes Sheepy's API sane and speeds up your development time. I have nations partially working but in a few days, I will have everything working. The hardest part is parsing the Json into objects, but I got that covered. So far, I am exposing an interface for Nation, called INation, you can choose to implement this interface which will auto fill your nation class that you create with the desired properties. Alternatively, you can pass in a class/type that you define. You will need to make sure it matches 100% with Sheepy's Json model (and also infer the correct types). In addition, you could also get the JSON that has been made sane instead of this. The idea is for ease of use in all use cases . I will provide documentation though with what I chose the types to be, so you will need to follow that. But, until then, since my code will be open source you can just follow the code. The benefit to the later method (defining your own type and not implementing INation), is that you won't need to implement all of INation just the tidbits you want. How do you do it? This is a bit technical and a bit less. I basically call sheepy's API with the info that you pass to it. For instance, since Nation is working, you can input an Id like 10054 (my nation Id) and it will return an object implementing INation or if you choose the one where it takes your class, your class will come back. The parsing is done by digging deep down into the rendered JSON and then it knows how to translate it to an object implementing INation internally. This will be the same for others. In order to return your class, I make use of automapper which maps it to your class. And now you have an object with just nation data or you can get sane json. The choice is yours License? This library will be licensed under GPL V3 Release Date? I will be releasing the first build soon, hopefully today. It will be basic and will work with Nation first. I will then add Alliance and everything else that comes from the API. This is just so that I can get feedback and start tweaking it. Can I help? Of course. It will be on github so fork it and send me a Pull Request. Other platforms/languages? I believe it is possible to use a special piece of tech to call an outside library written in C#. Not sure. Why CSharp? I write commercial software and other stuff in C# all the time. So, yeah. Edited December 29, 2015 by Jroc 1 Quote Link to comment Share on other sites More sharing options...
fistofdoom Posted December 29, 2015 Share Posted December 29, 2015 I dont know what you are doing but it seems great. Quote 01:05:55 <%fistofdoom> im out of wine 01:06:03 <%fistofdoom> i winsih i had port 01:06:39 <@JoshF{BoC}> fistofdoom: is the snowman drunk with you 01:07:32 <%fistofdoom> i knet i forgot somehnt Link to comment Share on other sites More sharing options...
Jroc Posted December 29, 2015 Author Share Posted December 29, 2015 (edited) I dont know what you are doing but it seems great. Basically, I am wrapping sheepy's API and making it easier to use from the start so you don't have to build the infrastructure to parse his json. Basically, you could use this in your own program you write. For instance if you wanted to save it to a database every hour you could do it. Basically you would do this, Create a type called Nation Have it implement INation, if it implements INation than .Net will enforce that you implement all methods and properties in the interface.Its pretty simple if you have resharper to do that. If not, I think VS will do it for you as well. then have Entity Framework (or even linq to sql) save it the database for you. This is assuming you have done a code-first migration and you have a table called Nations in the database. If you have a database and want to do it the other way, you would modify your approach as necessary. And, then call your code and methods to do analytical evaluation, etc... Edited December 29, 2015 by Jroc Quote Link to comment Share on other sites More sharing options...
Tim Armstrong Posted December 29, 2015 Share Posted December 29, 2015 Thanks Jroc <3 Quote Link to comment Share on other sites More sharing options...
Yosodog Posted December 30, 2015 Share Posted December 30, 2015 Ohhhh I've been looking to migrate my tools to c# (cuz !@#$ PHP). This is awesome dude! Quote [22:37:51] <&Yosodog> Problem is, everyone is too busy deciding which top gun character they are that no decision has been made BK in a nutshell Link to comment Share on other sites More sharing options...
Jroc Posted December 30, 2015 Author Share Posted December 30, 2015 Ohhhh I've been looking to migrate my tools to c# (cuz !@#$ PHP). This is awesome dude! Awesome man! I should also be able to nuget package it once I have everything working. That way, all you have to do is pull down the nuget package and you are good to go. Quote Link to comment Share on other sites More sharing options...
ELPINCHAZO Posted December 30, 2015 Share Posted December 30, 2015 it is Why CSharp? I write commercial software and other stuff in C# all the time. So, yeah. ALSO, I HATE LINUX eh, I just grab stuff in R with the Jsonlite package and it nicely converts everything to R lists. The only thing I need to do is pick out the information I find relevant and feed it the nation numbers. the API for AA REALLLLLYYY needs nation numbers included Quote Link to comment Share on other sites More sharing options...
Jroc Posted December 30, 2015 Author Share Posted December 30, 2015 (edited) eh, I just grab stuff in R with the Jsonlite package and it nicely converts everything to R lists. The only thing I need to do is pick out the information I find relevant and feed it the nation numbers. the API for AA REALLLLLYYY needs nation numbers included R is a nice programming language. I however don't know R but I know c# so ya know, And, I also run Arch Linux testing on a machine and I am a big linux guy as well. TYVM Edited December 30, 2015 by Jroc Quote Link to comment Share on other sites More sharing options...
Jroc Posted December 30, 2015 Author Share Posted December 30, 2015 eh, I just grab stuff in R with the Jsonlite package and it nicely converts everything to R lists. The only thing I need to do is pick out the information I find relevant and feed it the nation numbers. the API for AA REALLLLLYYY needs nation numbers included One way to do that would be to start from the beginning of all nationId's, poll the API to get all those nations and save that to the database with a nullable FK. And, then, poll the API to get all the alliances and save that to the database. And, then cross-reference all the nations with the alliance names and then update the nullable FK that you created in the nations table with the ID that was created when you added the alliances to the db. Now, you have an easy to use way. Albeit, you could also do it all in memory. Quote Link to comment Share on other sites More sharing options...
Dwynn Posted January 1, 2016 Share Posted January 1, 2016 I can't imagine it would be hard to add nation numbers from what I recall. Quote He's right, I'm such a stinker. Play my exceptional game! Link to comment Share on other sites More sharing options...
Jroc Posted January 5, 2016 Author Share Posted January 5, 2016 Due to having a busy work week. I have been delayed in releasing this as an early adopter build. But don't worry, once I have a window. I will go for it. Quote Link to comment Share on other sites More sharing options...
Buorhann Posted January 5, 2016 Share Posted January 5, 2016 ITT: Jroc offers us promises, blames laziness. 1 Quote Warrior of Dio https://www.youtube.com/watch?v=mfPCFQfOnLg Link to comment Share on other sites More sharing options...
Tiber Posted January 5, 2016 Share Posted January 5, 2016 This is awesome. I haven't actually used it yet, or even read the OP tbh, but I like C#, so I am just assuming this is awesome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.