Skip to content

Commit

Permalink
Update to 11.11.1
Browse files Browse the repository at this point in the history
Add team presets
-> saving/loading
Add side swap
Add team per side colors
Add scoreboard
-> including score, logo, tag, best of series
Add Player gold display
Add Player XP display

Fix crash when farsight config cannot be found
Fix crash after LiveEvents connection issue
FIx crash when determining if spectator game

UI tweaks
Update default pickban logo
  • Loading branch information
floh22 committed May 26, 2021
1 parent 65c4901 commit 2985d4d
Show file tree
Hide file tree
Showing 88 changed files with 2,789 additions and 408 deletions.
4 changes: 2 additions & 2 deletions LCUSharp/LCUSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>1.2.1.0</AssemblyVersion>
<FileVersion>1.2.1.21133</FileVersion>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.21146</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions LeagueBroadcast.Common/LeagueBroadcast.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>1.2.6.0</AssemblyVersion>
<FileVersion>1.2.6.21133</FileVersion>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.21146</FileVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
3 changes: 1 addition & 2 deletions LeagueBroadcast.Common/Utils/StringUtils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace LeagueBroadcast.Common.Utils
{
Expand All @@ -18,6 +17,6 @@ public static List<int> AllIndexesOf(this string str, string value)
return indexes;
indexes.Add(index);
}
}
}
}
}
4 changes: 2 additions & 2 deletions LeagueBroadcast.Farsight/LeagueBroadcast.Farsight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
<AssemblyVersion>1.2.6.0</AssemblyVersion>
<FileVersion>1.2.6.21133</FileVersion>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.21146</FileVersion>
<OutputType>Library</OutputType>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions LeagueBroadcast.Trinket/LeagueBroadcast.Trinket.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>1.2.2.0</AssemblyVersion>
<FileVersion>1.2.2.21133</FileVersion>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.21146</FileVersion>
<OutputType>Library</OutputType>
</PropertyGroup>

Expand Down
89 changes: 50 additions & 39 deletions LeagueBroadcast.Trinket/LiveEventConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,55 +27,66 @@ public LiveEventConnector()

public void Connect()
{
new Task(async () => {
soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

try
{
soc.Connect("127.0.0.1", 34243);
}
catch (Exception e)
new Task(async () =>
{
OnConnectionError?.Invoke(this, e.Message);
soc = null;
return;
}
soc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

OnConnect?.Invoke(this, EventArgs.Empty);
_run = true;
while (_run)
{
if (soc.Available > 0)
try
{
int size = soc.Available;
byte[] bytes = new byte[size];
soc.Receive(bytes, 0, size, SocketFlags.None);
string responseContent = Encoding.UTF8.GetString(bytes);

var chars = responseContent.ToCharArray();
soc.Connect("127.0.0.1", 34243);
}
catch (Exception e)
{
OnConnectionError?.Invoke(this, e.Message);
soc = null;
return;
}

//Debug.WriteLine($"LiveEvent content: {responseContent}");
int openBrackets = 0;
int startOfEvent = 0;
for (int i = 0; i < chars.Length; i++)
OnConnect?.Invoke(this, EventArgs.Empty);
_run = true;
while (_run)
{
if (soc.Available > 0)
{
char c = chars[i];
if (c == '{')
int size = soc.Available;
string responseContent = "";
byte[] bytes = new byte[size];
try
{
soc.Receive(bytes, 0, size, SocketFlags.None);
responseContent = Encoding.UTF8.GetString(bytes);
} catch
{
openBrackets++;
continue;
return;
}
if (c == '}')

var chars = responseContent.ToCharArray();

//Debug.WriteLine($"LiveEvent content: {responseContent}");
int openBrackets = 0;
int startOfEvent = 0;
for (int i = 0; i < chars.Length; i++)
{
openBrackets--;
if(openBrackets == 0)
char c = chars[i];
if (c == '{')
{
openBrackets++;
continue;
}
if (c == '}')
{
openBrackets--;
if (openBrackets == 0)
{
var length = i - startOfEvent + 1;
char[] e = new char[length];
Array.Copy(chars, startOfEvent, e, 0, length);
LiveEvent response = JsonSerializer.Deserialize<LiveEvent>(new string(e));
startOfEvent = i + 1;
OnLiveEvent?.Invoke(this, response);
if (length != 0)
{
char[] e = new char[length];
Array.Copy(chars, startOfEvent, e, 0, length);
LiveEvent response = JsonSerializer.Deserialize<LiveEvent>(new string(e));
startOfEvent = i + 1;
OnLiveEvent?.Invoke(this, response);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions LeagueBroadcast.Update/LeagueBroadcast.Update.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>1.2.6.0</AssemblyVersion>
<FileVersion>1.2.6.21133</FileVersion>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.21146</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion LeagueBroadcast/ChampSelect/Data/Config/PickBanConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private PickBanConfig CreateDefault()
return new PickBanConfig() { FileVersion = CurrentVersion, frontend = FrontendConfig.CreateDefaultConfig(), contentPatch = "latest", contentCdn = "https://ddragon.leagueoflegends.com/cdn" };
}

public override void UpdateConfigVersion(string oldVersion, dynamic oldValues)
public override void UpdateConfigVersion(string oldVersion, string oldValues)
{
//No format change to correct
return;
Expand Down
4 changes: 3 additions & 1 deletion LeagueBroadcast/ChampSelect/Data/Config/TeamConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace LeagueBroadcast.ChampSelect.Data.Config
public class TeamConfig
{
public string name;
public string nameTag;
public int score;
public string coach;
public string color;
Expand All @@ -17,7 +18,8 @@ public static string RGBToString(Color c)

public static TeamConfig DefaultConfig(string TeamName, string c)
{
return new TeamConfig() { name = TeamName, score = 0, coach = "G2 Grabz", color = c };
string nameTag = TeamName.Length >= 3 ? TeamName.Substring(0, 3) : "TeamName";
return new TeamConfig() { name = TeamName, score = 0, coach = "G2 Grabz", color = c, nameTag = nameTag };
}
}
}
40 changes: 34 additions & 6 deletions LeagueBroadcast/Common/Controllers/IngameController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LeagueBroadcast.Common.Data.RIOT;
using LeagueBroadcast.Http;
using LeagueBroadcast.Ingame.Data.LBH;
using LeagueBroadcast.Ingame.Data.Provider;
using LeagueBroadcast.Ingame.Data.RIOT;
using LeagueBroadcast.Ingame.Events;
Expand Down Expand Up @@ -111,7 +112,7 @@ public async void DoTick()
//Set current cs to clostest old known value
var keys = new List<double>(p.csHistory.Keys);
var closestCsIndex = keys.BinarySearch(gameData.gameTime);
if(closestCsIndex != -1)
if(closestCsIndex >= -1)
p.scores.creepScore = p.csHistory[closestCsIndex];

//Roll back cs history
Expand Down Expand Up @@ -182,6 +183,8 @@ public async void DoTick()
var snapshot = BroadcastController.Instance.MemoryController.CreateSnapshot(gameState.stateData.gameTime);
gameState.UpdateEvents(LoLDataProvider.GetEventData().Result, snapshot);
gameState.UpdateTeams(LoLDataProvider.GetPlayerData().Result, snapshot);
gameState.UpdateScoreboard();
UpdateInfoPage();
}
catch (Exception canceled)
{
Expand All @@ -192,6 +195,28 @@ public async void DoTick()
EmbedIOServer.socketServer.SendEventToAllAsync(new HeartbeatEvent(gameState.stateData));
}

private void UpdateInfoPage()
{
if(!CurrentSettings.SideGraph)
return;

if (CurrentSettings.EXP)
{
gameState.stateData.infoPage = new InfoSidePage("EXP per player", PlayerOrder.MaxToMin, PlayerTab.GetEXPTabs());
return;
}
if(CurrentSettings.PlayerGold)
{
gameState.stateData.infoPage = new InfoSidePage("Player Gold", PlayerOrder.MaxToMin, PlayerTab.GetGoldTabs());
return;
}
if(CurrentSettings.CSPerMin)
{
gameState.stateData.infoPage = new InfoSidePage("CS/min", PlayerOrder.MaxToMin, PlayerTab.GetCSPerMinTabs());
return;
}
}

private void LoadGame(GameMetaData gameData)
{
GameFound = true;
Expand Down Expand Up @@ -309,8 +334,8 @@ public void OnDragonTaken(object sender, ObjectiveTakenArgs e)
if(e.Type.Equals("Elder", StringComparison.OrdinalIgnoreCase))
{
gameState.stateData.backDragon.TakeGameTime = gameData.gameTime;
gameState.stateData.backDragon.BlueStartGold = gameState.blueTeam.GetGold();
gameState.stateData.backDragon.RedStartGold = gameState.redTeam.GetGold();
gameState.stateData.backDragon.BlueStartGold = gameState.blueTeam.GetGold(gameData.gameTime);
gameState.stateData.backDragon.RedStartGold = gameState.redTeam.GetGold(gameData.gameTime);
gameState.SetObjectiveData(gameState.stateData.backDragon, gameState.stateData.dragon, 150);
e.Team.hasElder = true;
}
Expand All @@ -320,8 +345,8 @@ public void OnBaronTaken(object sender, ObjectiveTakenArgs e)
{
Log.Info($"Baron Taken by {e.Team.teamName}");
gameState.stateData.backBaron.TakeGameTime = gameData.gameTime;
gameState.stateData.backBaron.BlueStartGold = gameState.blueTeam.GetGold();
gameState.stateData.backBaron.RedStartGold = gameState.redTeam.GetGold();
gameState.stateData.backBaron.BlueStartGold = gameState.blueTeam.GetGold(gameData.gameTime);
gameState.stateData.backBaron.RedStartGold = gameState.redTeam.GetGold(gameData.gameTime);
gameState.SetObjectiveData(gameState.stateData.backBaron, gameState.stateData.baron, 180);
e.Team.hasBaron = true;
}
Expand All @@ -341,6 +366,7 @@ private void OnGameStop(object sender, EventArgs e)
BroadcastController.CurrentLeagueState = "None";
//GameInfoPage.ClearPlayers();
BroadcastController.Instance.ToTick.Remove(this);
gameState.stateData.scoreboard.GameTime = -1;
EmbedIOServer.socketServer.SendEventToAllAsync(new HeartbeatEvent(gameState.stateData));
EmbedIOServer.socketServer.SendEventToAllAsync(new GameEnd());
Log.Info("Game ended");
Expand Down Expand Up @@ -402,11 +428,13 @@ public class CurrentSettings
public bool TeamNames => ConfigController.Component.Ingame.Teams.DoTeamNames;
public bool TeamIcons => ConfigController.Component.Ingame.Teams.DoTeamIcons;
public bool TeamStats => ConfigController.Component.Ingame.Teams.DoTeamScores;

public bool CS = false;
public bool CSPerMin = false;
public bool EXP = false;
public bool GoldGraph = false;
public bool PlayerGold = false;

public bool SideGraph => CS || CSPerMin || EXP || PlayerGold;
}
}
36 changes: 30 additions & 6 deletions LeagueBroadcast/Common/Data/Config/ComponentConfig.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using LeagueBroadcast.Common.Utils;
using LeagueBroadcast.Common.Controllers;
using LeagueBroadcast.Common.Utils;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using static LeagueBroadcast.Common.Log;

namespace LeagueBroadcast.Common.Data.Config
Expand All @@ -16,7 +18,7 @@ class ComponentConfig : JSONConfig
public override string FileVersion { get => _fileVersion; set => _fileVersion = value; }

[JsonIgnore]
public static new string CurrentVersion => "1.0";
public static new string CurrentVersion => "1.1";

public DataDragonConfig DataDragon;

Expand Down Expand Up @@ -62,13 +64,17 @@ private ComponentConfig CreateDefault()
PickBan = new PickBanConfig() {
IsActive = true,
DelayValue = 300,
UseDelay = false
UseDelay = false,
DefaultBlueColor = "rgb(66, 133, 244)",
DefaultRedColor = "rgb(234, 67, 53)"
},
Ingame = new IngameConfig() {
IsActive = true,
UseLiveEvents = true,
DoItemCompleted = true,
DoLevelUp = true,
UseCustomScoreboard = false,
SeriesGameCount = 3,
Objectives = new IngameConfig.ObjectiveConfig() {
DoBaronKill = true,
DoDragonKill = true,
Expand Down Expand Up @@ -108,10 +114,24 @@ public override string GETJson()
return SerializeIndented(this);
}

public override void UpdateConfigVersion(string oldVersion, dynamic oldValues)
public override void UpdateConfigVersion(string oldVersion, string oldValues)
{
//Currently v1.0
return;
//1.0 to 1.1
if(oldVersion.Equals("1.0"))
{
Task t = new Task(async () => {
await Task.Delay(100);
PickBan.DefaultBlueColor = ConfigController.PickBan.frontend.blueTeam.color;
PickBan.DefaultRedColor = ConfigController.PickBan.frontend.redTeam.color;

Ingame.SeriesGameCount = 3;

FileVersion = CurrentVersion;
JSONConfigProvider.Instance.WriteConfig(this);
Log.Info("Updated Component config from v1.0 to v1.1");
});
t.Start();
}
}

public override void UpdateValues(string readValues)
Expand All @@ -138,6 +158,8 @@ public class PickBanConfig
public bool IsActive;
public bool UseDelay;
public int DelayValue;
public string DefaultBlueColor;
public string DefaultRedColor;
}

public class IngameConfig
Expand All @@ -146,8 +168,10 @@ public class IngameConfig
public bool UseLiveEvents;
public bool DoLevelUp;
public bool DoItemCompleted;
public int SeriesGameCount;
public ObjectiveConfig Objectives;
public TeamInfoConfig Teams;
public bool UseCustomScoreboard;

public class ObjectiveConfig
{
Expand Down
Loading

0 comments on commit 2985d4d

Please sign in to comment.