From ae6cd7f90632d1f3cf12bffefc429bc11745eb8c Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Sat, 14 Jan 2023 15:11:16 -0600 Subject: [PATCH] Added extension for grabbing multiplayer player count for features --- .../Extensions/MultiplayerInfoExtensions.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 LANCommander.Playnite.Extension/Extensions/MultiplayerInfoExtensions.cs diff --git a/LANCommander.Playnite.Extension/Extensions/MultiplayerInfoExtensions.cs b/LANCommander.Playnite.Extension/Extensions/MultiplayerInfoExtensions.cs new file mode 100644 index 0000000..ec4270f --- /dev/null +++ b/LANCommander.Playnite.Extension/Extensions/MultiplayerInfoExtensions.cs @@ -0,0 +1,26 @@ +using LANCommander.SDK; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LANCommander.PlaynitePlugin.Extensions +{ + internal static class MultiplayerInfoExtensions + { + internal static string GetPlayerCount(this MultiplayerInfo multiplayerInfo) + { + if (multiplayerInfo.MinPlayers == multiplayerInfo.MaxPlayers && multiplayerInfo.MinPlayers >= 2) + return $"({multiplayerInfo.MinPlayers} Players)"; + + if (multiplayerInfo.MinPlayers < multiplayerInfo.MaxPlayers && multiplayerInfo.MinPlayers >= 2) + return $"({multiplayerInfo.MinPlayers}-{multiplayerInfo.MaxPlayers} Players)"; + + if (multiplayerInfo.MinPlayers <= 1 && multiplayerInfo.MaxPlayers > 2) + return $"({multiplayerInfo.MaxPlayers} Players)"; + + return ""; + } + } +}