Git Product home page Git Product logo

leaguereplayparser's Introduction

League Replay Parser

This is a library which allows you to easily parse a League of Legend replay file. Those files are default-located in your documents under League of Legends/Replays folder and have the .rofl (Replay of League) extention.

Getting started

GitHub release GitHub issues Github downloads   NuGet NuGet downloads

Installation

You will first need to install the library by either downloading it or installing it from NuGet.

Usage

At first, you will need to deal with the League object. It is the object that will give you informations about the installed League of Legends version and which will allow you to start a replay.

League

Initialization

First, instanciate it: League league = new League(@"C:\Riot Games");. It will check if the given repertory exists, and if not, it will throw an IOException.

You may overload League constructor with the replay directory: new League("@C:\Riot Games", @"D:\League\Replays");. By default, your replay directory is in your documents and the library will find it.

Also, League contains properties DefaultRiotDirectory and DefaultReplaysDirectory which contains the default paths for the game and the replays.

Loading replays

Once League is initialized, you will need to load the replays. It is recommended to load them asynchronously just in case you have a slow machine and the parsing take long enough to freeze an eventual UI.

// Async
await league.LoadReplaysAsync();

// Sync 
league.LoadReplays();

You can now access all available replays by using league.Replays property.

Starting replays

After getting your Replay object, you will be able to start it thanks to your League instance.

The following code will start all the playable replays in a row.

foreach (Replay replay in league.Replays)
  if (replay.CanBePlayed.GetDefaultOrValue(true))
    await league.StartReplayAsync(replay);

The nullable bool CanBePlayed property will return true if your League of Legends' version is equal (or lower but this should not happen, right?) to the replay's League version, but will return false if not or null if you never instanciated any League object.

In a simplier way, you can start a replay file by just using league.StartReplayAsync(@"C:\League\Replays\yourReplay.rofl");.

Replay

The Replay object contains some data about your replay file, such as informations about the two teams, their champions, their stuff, level, and other stuff.

// Display purple team informations
foreach (Player player in replay.PurpleTeam.Players)
{
    Console.WriteLine();
    Console.WriteLine($"{player.PlayerName} as {player.ChampionName}:");
    Console.WriteLine($"   Level: {player.Level}");
    Console.WriteLine($"   KDA: {player.KDA.Kills}/{player.KDA.Deaths}/{player.KDA.Assistances} ({player.KDA.Ratio})");
    Console.WriteLine($"   Lane: {player.Lane.ToString()}");
    Console.WriteLine($"   Minion score: {player.MinionScore}");
}

Example code

As an example, this code will display some data from the first available replay file as well as the stats from the wining team.

League league = new League(League.DefaultRiotDirectory);
  await league.LoadReplaysAsync(Encoding.UTF8);

  Console.WriteLine($"League version: {league.Version}");
  Console.WriteLine($"Found {league.Replays.Count} replays.");

  if (league.Replays.Count > 0)
  {
      Replay replay = league.Replays[0];
      Console.WriteLine($"Looking out first replay.");
      Console.WriteLine($"League version: {replay.GameVersion.ToString()}");
      Console.WriteLine($"Game duration: {replay.GameLength.ToString()}");
      Console.WriteLine($"Winning team: {replay.WiningTeam.Side.ToString()}");

      foreach (Player player in replay.WiningTeam.Players)
      {
          Console.WriteLine();
          Console.WriteLine($"+ {player.PlayerName} as {player.ChampionName}:");
          Console.WriteLine($"   Level: {player.Level}");
          Console.WriteLine($"   KDA: {player.KDA.Kills}/{player.KDA.Deaths}/{player.KDA.Assistances} ({player.KDA.Ratio})");
          Console.WriteLine($"   Lane: {player.Lane}");
          Console.WriteLine($"   Minion score: {player.MinionScore}");
      }

  }

To-do

  • Instead of having only one replay directory, add multiple ones.
  • Get more stats and data from the replay file (I'll do that if you ask me).

leaguereplayparser's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

triggeredge

leaguereplayparser's Issues

How to get location infomation

does it get some PosX, PosY(maybe PosZ) in the replay file (.rofl)?
or maybe only get movement speed, and we need to calculate the three X, Y, Z?

How can I kwon the structrue of the Rofl?

Thanks for your LeagueReplayParser!
I want to get more information about ROFL ,for example, your data is the result,if I want some data at one point,how can I parse the ROFL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.