Permalink
Browse files

Added more structures and implemented new commands

  • Loading branch information...
1 parent efc70ec commit cefe7a6ec3823fda0b963e2985455475564b17e1 @epicvrvs committed Feb 19, 2012
@@ -15,7 +15,8 @@
using com.riotgames.platform.clientfacade.domain;
using com.riotgames.platform.login;
-using com.riotgames.platform.summoner;
+using com.riotgames.platform.summoner;
+using com.riotgames.platform.statistics;
namespace LibOfLegends
{
@@ -146,7 +147,7 @@ private void GetSummonerByNameInternal(Responder<PublicSummoner> responder, obje
_netConnection.Call(_endpoint, _summonerService, null, "getSummonerByName", responder, arguments);
}
- private void GetRecentGamesInternal(Responder<object> responder, object[] arguments)
+ private void GetRecentGamesInternal(Responder<RecentGames> responder, object[] arguments)
{
_netConnection.Call(_endpoint, _playerStatsService, null, "getRecentGames", responder, arguments);
}
@@ -186,7 +187,7 @@ public void GetSummonerByNameAsync(string name, Responder<PublicSummoner> respon
GetSummonerByNameInternal(responder, new object[] { name });
}
- public void GetRecentGamesAsync(int accountID, Responder<object> responder)
+ public void GetRecentGamesAsync(int accountID, Responder<RecentGames> responder)
{
GetRecentGamesInternal(responder, new object[] { accountID });
}
@@ -220,6 +221,11 @@ public PublicSummoner GetSummonerByName(string name)
return (new InternalCallContext<PublicSummoner>(GetSummonerByNameInternal, new object[] { name })).Execute();
}
+ public RecentGames GetRecentGames(int accountID)
+ {
+ return (new InternalCallContext<RecentGames>(GetRecentGamesInternal, new object[] { accountID })).Execute();
+ }
+
#endregion
#region Delegates
@@ -59,6 +59,8 @@
<Compile Include="com.riotgames.platform\gameclient.domain\broadcast\BroadcastNotification.cs" />
<Compile Include="com.riotgames.platform\gameclient.domain\game\GameReconnectionInfo.cs" />
<Compile Include="com.riotgames.platform\login\Login.cs" />
+ <Compile Include="com.riotgames.platform\statistics\PlayerGameStats.cs" />
+ <Compile Include="com.riotgames.platform\statistics\RecentGames.cs" />
<Compile Include="com.riotgames.platform\summoner\PublicSummoner.cs" />
<Compile Include="com.riotgames.platform\statistics\Statistics.cs" />
<Compile Include="com.riotgames.platform\systemstate\ClientSystemStatesNotification.cs" />
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace com.riotgames.platform.statistics
+{
+ public class PlayerGameStats
+ {
+ public string skinName;
+ public bool ranked;
+ public int skinIndex;
+ public List<object> fellowPlayers;
+ public string gameType;
+ public int experienceEarned;
+ public string rawStatsJson;
+ public bool eligibleFirstWinOfDay;
+ public object difficulty;
+ public int gameMapId;
+ public bool leaver;
+ public int spell1;
+ public string gameTypeEnum;
+ public int teamId;
+ public int summonerId;
+ public List<object> statistics;
+ public int spell2;
+ public bool afk;
+ public int id;
+ public int boostXpEarned;
+ public int level;
+ public bool invalid;
+ public int dataVersion;
+ public int userId;
+ public DateTime createDate;
+ public int userServerPing;
+ public int adjustedRating;
+ public int premadeSize;
+ public int boostIpEarned;
+ public int gameId;
+ public int timeInQueue;
+ public int ipEarned;
+ public int eloChange;
+ public object futureData;
+ public string gameMode;
+ public string difficultyString;
+ public int KCoefficient;
+ public int teamRating;
+ public string subType;
+ public string queueType;
+ public bool premadeTeam;
+ public float predictedWinPct;
+ public int rating;
+ public int championId;
+
+ public PlayerGameStats()
+ {
+ }
+ }
+}
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace com.riotgames.platform.statistics
+{
+ public class RecentGames
+ {
+ public string recentGamesJson;
+ public List<PlayerGameStats> gameStatistics;
+ public int dataVersion;
+ public int userId;
+ public object futureData;
+
+ public RecentGames()
+ {
+ }
+ }
+}
@@ -9,6 +9,7 @@
using LibOfLegends;
using com.riotgames.platform.summoner;
+using com.riotgames.platform.statistics;
namespace LibOfLegendsExample
{
@@ -85,7 +86,8 @@ void InitialiseCommandDictionary()
{
CommandDictionary = new Dictionary<string, CommandInformation>()
{
- {"id", new CommandInformation(-1, GetAccountID, "<name>", "Retrieve the account ID of the given summoner name")},
+ {"id", new CommandInformation(-1, GetAccountID, "<name>", "Retrieve the account ID associated with the given summoner name")},
+ {"analyse", new CommandInformation(-1, AnalyseRecentGames, "<name>", "Analyse the recent games of the summoner given")},
{"help", new CommandInformation(0, PrintHelp, "", "Prints this help")},
};
}
@@ -101,7 +103,7 @@ void PrintHelp(List<string> arguments)
}
}
- void GetAccountID(List<string> arguments)
+ string GetNameFromArguments(List<string> arguments)
{
string summonerName = "";
bool first = true;
@@ -113,11 +115,56 @@ void GetAccountID(List<string> arguments)
summonerName += " ";
summonerName += argument;
}
+ return summonerName;
+ }
+
+ void NoSuchSummoner()
+ {
+ Console.WriteLine("No such summoner");
+ }
+
+ void GetAccountID(List<string> arguments)
+ {
+ string summonerName = GetNameFromArguments(arguments);
PublicSummoner summoner = RPC.GetSummonerByName(summonerName);
if (summoner != null)
Console.WriteLine(summoner.acctId);
else
- Console.WriteLine("No such summoner");
+ NoSuchSummoner();
+ }
+
+ static int CompareGames(PlayerGameStats x, PlayerGameStats y)
+ {
+ return - x.gameId.CompareTo(y.gameId);
+ }
+
+ void AnalyseRecentGames(List<string> arguments)
+ {
+ string summonerName = GetNameFromArguments(arguments);
+ PublicSummoner summoner = RPC.GetSummonerByName(summonerName);
+ if (summoner == null)
+ {
+ NoSuchSummoner();
+ return;
+ }
+ RecentGames recentGameData = RPC.GetRecentGames(summoner.acctId);
+ var recentGames = recentGameData.gameStatistics;
+ recentGames.Sort(CompareGames);
+ int normalElo = 0;
+ bool foundNormalElo = false;
+ foreach (var stats in recentGames)
+ {
+ if (stats.queueType == "NORMAL" && stats.gameMode == "CLASSIC" && !stats.ranked)
+ {
+ normalElo = stats.rating + stats.eloChange;
+ foundNormalElo = true;
+ break;
+ }
+ }
+ if (foundNormalElo)
+ Console.WriteLine("Normal Elo: " + normalElo);
+ else
+ Console.WriteLine("No normal games in match history");
}
}
}

0 comments on commit cefe7a6

Please sign in to comment.