├── .github └── workflows │ └── dotnet-core.yml ├── LICENSE.txt ├── README.md ├── Server ├── BouncyCastle.Crypto.dll ├── BrawlStars.Utilities.dll ├── BrawlStars.Utilities.pdb ├── BrawlStars.deps.json ├── BrawlStars.dll ├── BrawlStars.exe ├── BrawlStars.pdb ├── BrawlStars.runtimeconfig.dev.json ├── BrawlStars.runtimeconfig.json ├── Colorful.Console.dll ├── DotNetty.Buffers.dll ├── DotNetty.Codecs.dll ├── DotNetty.Common.dll ├── DotNetty.Handlers.dll ├── DotNetty.Transport.dll ├── GameAssets │ ├── database.sql │ └── fingerprint.json ├── Google.Protobuf.dll ├── Microsoft.Extensions.Caching.Abstractions.dll ├── Microsoft.Extensions.Caching.Memory.dll ├── Microsoft.Extensions.DependencyInjection.Abstractions.dll ├── Microsoft.Extensions.Logging.Abstractions.dll ├── Microsoft.Extensions.Logging.dll ├── Microsoft.Extensions.Options.dll ├── Microsoft.Extensions.Primitives.dll ├── Microsoft.Win32.SystemEvents.dll ├── MySql.Data.dll ├── NLog.config ├── NLog.dll ├── Newtonsoft.Json.dll ├── Renci.SshNet.dll ├── SshNet.Security.Cryptography.dll ├── System.Configuration.ConfigurationManager.dll ├── System.Drawing.Common.dll ├── System.Security.Cryptography.ProtectedData.dll ├── System.Security.Permissions.dll ├── System.Windows.Extensions.dll ├── System.Xml.XPath.XmlDocument.dll ├── Ubiety.Dns.Core.dll ├── config.json └── runtimes │ ├── unix │ └── lib │ │ └── netcoreapp3.0 │ │ └── System.Drawing.Common.dll │ └── win │ └── lib │ ├── netcoreapp3.0 │ ├── Microsoft.Win32.SystemEvents.dll │ ├── System.Drawing.Common.dll │ └── System.Windows.Extensions.dll │ └── netstandard2.0 │ └── System.Security.Cryptography.ProtectedData.dll └── Source ├── BrawlStars.Utilities ├── BrawlStars.Utilities.csproj ├── Compression │ └── ZLib │ │ ├── CRC32.cs │ │ ├── Deflate.cs │ │ ├── DeflateStream.cs │ │ ├── GZipStream.cs │ │ ├── InfTree.cs │ │ ├── Inflate.cs │ │ ├── Iso8859Dash1Encoding.cs │ │ ├── ParallelDeflateOutputStream.cs │ │ ├── Tree.cs │ │ ├── Zlib.cs │ │ ├── ZlibBaseStream.cs │ │ ├── ZlibCodec.cs │ │ ├── ZlibConstants.cs │ │ └── ZlibStream.cs ├── Extensions.cs ├── Netty │ ├── Reader.cs │ └── Writer.cs ├── Utils │ ├── GameUtils.cs │ ├── ServerUtils.cs │ └── TimeUtils.cs └── obj │ ├── BrawlStars.Utilities.csproj.nuget.cache │ ├── BrawlStars.Utilities.csproj.nuget.dgspec.json │ ├── BrawlStars.Utilities.csproj.nuget.g.props │ ├── BrawlStars.Utilities.csproj.nuget.g.targets │ ├── ClashofClans.Utilities.csproj.nuget.dgspec.json │ ├── ClashofClans.Utilities.csproj.nuget.g.props │ ├── ClashofClans.Utilities.csproj.nuget.g.targets │ ├── Debug │ └── netstandard2.0 │ │ ├── BrawlStars.Utilities.AssemblyInfo.cs │ │ ├── BrawlStars.Utilities.AssemblyInfoInputs.cache │ │ ├── BrawlStars.Utilities.assets.cache │ │ ├── BrawlStars.Utilities.csproj.CoreCompileInputs.cache │ │ ├── BrawlStars.Utilities.csproj.FileListAbsolute.txt │ │ ├── BrawlStars.Utilities.csprojAssemblyReference.cache │ │ ├── BrawlStars.Utilities.dll │ │ ├── BrawlStars.Utilities.pdb │ │ ├── ClashofClans.Utilities.AssemblyInfo.cs │ │ ├── ClashofClans.Utilities.AssemblyInfoInputs.cache │ │ ├── ClashofClans.Utilities.assets.cache │ │ ├── ClashofClans.Utilities.csproj.CoreCompileInputs.cache │ │ ├── ClashofClans.Utilities.csproj.FileListAbsolute.txt │ │ ├── ClashofClans.Utilities.csprojAssemblyReference.cache │ │ ├── ClashofClans.Utilities.dll │ │ └── ClashofClans.Utilities.pdb │ ├── Release │ └── netstandard2.0 │ │ ├── ClashofClans.Utilities.AssemblyInfo.cs │ │ ├── ClashofClans.Utilities.AssemblyInfoInputs.cache │ │ ├── ClashofClans.Utilities.assets.cache │ │ ├── ClashofClans.Utilities.csproj.CoreCompileInputs.cache │ │ ├── ClashofClans.Utilities.csproj.FileListAbsolute.txt │ │ ├── ClashofClans.Utilities.csprojAssemblyReference.cache │ │ ├── ClashofClans.Utilities.dll │ │ └── ClashofClans.Utilities.pdb │ ├── project.assets.json │ └── project.nuget.cache ├── BrawlStars.sln └── BrawlStars ├── BrawlStars.csproj ├── BrawlStars.csproj.user ├── Core ├── Configuration.cs └── Network │ ├── Handlers │ ├── PacketEncoder.cs │ └── PacketHandler.cs │ ├── NettyService.cs │ └── Throttler.cs ├── Database ├── AllianceDb.cs ├── Cache │ ├── Alliances.cs │ └── Players.cs ├── ObjectCache.cs └── PlayerDb.cs ├── Extensions ├── ChatStreamEntry.cs ├── CustomWriter.cs └── GamePlayUtil.cs ├── Files ├── Csv.Files.cs ├── Csv.cs ├── CsvHelpers │ ├── Data.cs │ ├── DataTable.cs │ └── GlobalId.cs ├── CsvReader │ ├── Column.cs │ ├── Gamefiles.cs │ ├── Row.cs │ └── Table.cs ├── Fingerprint.cs ├── GameEvents.cs └── Logic │ ├── Accessorie.cs │ ├── AllianceBadge.cs │ ├── AllianceRole.cs │ ├── AreaEffect.cs │ ├── Boss.cs │ ├── Campaign.cs │ ├── Card.cs │ ├── Challenge.cs │ ├── Character.cs │ ├── Emote.cs │ ├── GameModeVariations.cs │ ├── Global.cs │ ├── Item.cs │ ├── Locale.cs │ ├── Resource.cs │ ├── Skill.cs │ └── Skin.cs ├── GameAssets ├── database.sql └── fingerprint.json ├── Logger.cs ├── Logic ├── Brawler.cs ├── Calendar.cs ├── Clan │ ├── Alliance.cs │ ├── AllianceInfo.cs │ ├── AllianceMember.cs │ └── StreamEntry │ │ ├── AllianceStreamEntry.cs │ │ └── Entries │ │ ├── AllianceEventStreamEntry.cs │ │ ├── ChallengeStreamEntry.cs │ │ ├── ChatStreamEntry.cs │ │ ├── DonateStreamEntry.cs │ │ └── JoinRequestAllianceStreamEntry.cs ├── Device.cs ├── Events.cs ├── Functions.cs ├── Home │ ├── Home.cs │ ├── Slots │ │ ├── DataSlots.cs │ │ ├── Items │ │ │ └── DataSlot.cs │ │ └── ResourceSlots.cs │ └── StreamEntry │ │ └── AvatarStreamEntry.cs ├── Player.cs ├── Sessions │ ├── Location.cs │ └── Session.cs ├── Time.cs └── Timer.cs ├── NLog.config ├── Program.cs ├── Protocol ├── Commands │ └── Server │ │ ├── LogicChangeAvatarName.cs │ │ └── LogicDiamondsAddedCommand.cs ├── LogicCommand.cs ├── LogicCommandManager.cs ├── LogicMagicMessageFactory.cs ├── Messages │ ├── Client │ │ ├── Alliance │ │ │ ├── ChatToClubMessage.cs │ │ │ └── ClanInviteLinkMessage.cs │ │ ├── AnalyticsEventMessage.cs │ │ ├── BattleEndMessage.cs │ │ ├── ChangeBrawlerInRoomMessage.cs │ │ ├── ChangeMapMessage.cs │ │ ├── ChangeNameMessage.cs │ │ ├── ClientActionMessage.cs │ │ ├── CreateGameroomMessage.cs │ │ ├── DoNotDistrubMessage.cs │ │ ├── EndClientTurnMessage.cs │ │ ├── Home │ │ │ ├── ProfileMessage.cs │ │ │ └── SetNameMessage.cs │ │ ├── Login │ │ │ ├── ClientHelloMessage.cs │ │ │ ├── ExitMessage.cs │ │ │ ├── KeepAliveMessage.cs │ │ │ └── LoginMessage.cs │ │ ├── OpenClubMessage.cs │ │ ├── QuitRoomMessage.cs │ │ └── UseGadgetInRoomMessage.cs │ └── Server │ │ ├── Alliance │ │ └── GenrateClanInviteLinkMessage.cs │ │ ├── Battle2_Result.cs │ │ ├── Battle_Result.cs │ │ ├── ChatBotServerMessage.cs │ │ ├── ChatServerMessage.cs │ │ ├── ClubOHD.cs │ │ ├── ClubServerMessage.cs │ │ ├── DoNotDistrubServer.cs │ │ ├── Gameroom_Data.cs │ │ ├── Home │ │ ├── BotProfileMessage.cs │ │ ├── OwnHomeDataMessage.cs │ │ ├── ProfileServerMessage.cs │ │ └── SetNameServer.cs │ │ ├── Login │ │ ├── Copyright.cs │ │ ├── KeepAliveOkMessage.cs │ │ ├── LoginFailedMessage.cs │ │ └── LoginOkMessage.cs │ │ ├── RoomDisconnect.cs │ │ └── ServerBox.cs └── PiranhaMessage.cs ├── Resources.cs ├── obj ├── BrawlStars.csproj.nuget.cache ├── BrawlStars.csproj.nuget.dgspec.json ├── BrawlStars.csproj.nuget.g.props ├── BrawlStars.csproj.nuget.g.targets └── Debug │ └── netcoreapp3.1 │ ├── BrawlStars.AssemblyInfo.cs │ ├── BrawlStars.AssemblyInfoInputs.cache │ └── BrawlStars.assets.cache └── server.ico /.github/workflows/dotnet-core.yml: -------------------------------------------------------------------------------- 1 | name: .NET Core 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Setup .NET Core 17 | uses: actions/setup-dotnet@v1 18 | with: 19 | dotnet-version: 3.1.101 20 | - name: Install dependencies 21 | run: dotnet restore ./Source/BrawlStars/ 22 | - name: Build 23 | run: dotnet build ./Source/BrawlStars/ --configuration Release --no-restore 24 | - name: Test 25 | run: dotnet test ./Source/BrawlStars/ --no-restore --verbosity normal 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ObjectBrawl ![.NET Core](https://github.com/VitalikObject/BrawlStars-Server/workflows/.NET%20Core/badge.svg?branch=master) 2 | A first open source .NET Core Brawl Stars Server for version 26! 3 | ![ScreenShot](https://cdn.discordapp.com/attachments/728556050285985823/734808267712364687/Screenshot_20200720-192532_BS_v26.jpg) 4 | 5 | ## Configuration 6 | You can change default name in config.json 7 | (```"default_name": "YOUR_NAME"```) 8 | And you can change the starting resources in config.json 9 | 10 | ## Client 11 | To connect to your server, you need a custom client. Here the only solution is to use a [pre-made client](https://drive.google.com/file/d/13CevFvqsLW2xzjEEOWGSh__1xRSXJmFh/view?usp=sharing). 12 | Just edit the IP in the frida-gadget config (```/lib/armeabi-v7a/libgg.config.so```) 13 | ```{"interaction":{"interaction":{"type":"script","path":"libscript.so","on_change":"reload","parameters":{"redirectHost":"YOUR_IP","relocate":true}}}``` 14 | 15 | ### Friendly reminder 16 | The server is in a very early state. Right now, it is NOT recommended to run this on a production environment. Please not open issues about missing features, i'm well aware of this. 17 | 18 | #### Thank you [Incredible](http://github.com/Incr3dible/) for yours [20Clash](https://github.com/Incr3dible/20Clash) 19 | 20 | #### Need help? Join [My Discord server](https://discord.gg/4FZrUFK4C6) 21 | 22 | #### My friends Discord servers: [Huza's Discord channel](https://discord.gg/VPWMxWm) and [Antz's Discord channel](https://discord.com/invite/RgYcF3b) 23 | 24 | -------------------------------------------------------------------------------- /Server/BouncyCastle.Crypto.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/BouncyCastle.Crypto.dll -------------------------------------------------------------------------------- /Server/BrawlStars.Utilities.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/BrawlStars.Utilities.dll -------------------------------------------------------------------------------- /Server/BrawlStars.Utilities.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/BrawlStars.Utilities.pdb -------------------------------------------------------------------------------- /Server/BrawlStars.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/BrawlStars.dll -------------------------------------------------------------------------------- /Server/BrawlStars.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/BrawlStars.exe -------------------------------------------------------------------------------- /Server/BrawlStars.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/BrawlStars.pdb -------------------------------------------------------------------------------- /Server/BrawlStars.runtimeconfig.dev.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "additionalProbingPaths": [ 4 | "C:\\Users\\Vitalik\\.dotnet\\store\\|arch|\\|tfm|", 5 | "C:\\Users\\Vitalik\\.nuget\\packages", 6 | "E:\\Microsoft\\Xamarin\\NuGet" 7 | ] 8 | } 9 | } -------------------------------------------------------------------------------- /Server/BrawlStars.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "netcoreapp3.1", 4 | "framework": { 5 | "name": "Microsoft.NETCore.App", 6 | "version": "3.1.0" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /Server/Colorful.Console.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Colorful.Console.dll -------------------------------------------------------------------------------- /Server/DotNetty.Buffers.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/DotNetty.Buffers.dll -------------------------------------------------------------------------------- /Server/DotNetty.Codecs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/DotNetty.Codecs.dll -------------------------------------------------------------------------------- /Server/DotNetty.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/DotNetty.Common.dll -------------------------------------------------------------------------------- /Server/DotNetty.Handlers.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/DotNetty.Handlers.dll -------------------------------------------------------------------------------- /Server/DotNetty.Transport.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/DotNetty.Transport.dll -------------------------------------------------------------------------------- /Server/GameAssets/database.sql: -------------------------------------------------------------------------------- 1 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 2 | SET time_zone = "+00:00"; 3 | 4 | CREATE TABLE IF NOT EXISTS `player` ( 5 | `Id` bigint(20) NOT NULL, 6 | `Trophies` bigint(20) NOT NULL, 7 | `Language` text CHARACTER SET utf8mb4 NOT NULL, 8 | `FacebookId` text CHARACTER SET utf8mb4, 9 | `Home` text CHARACTER SET utf8mb4 NOT NULL, 10 | `Sessions` text CHARACTER SET utf8mb4 NOT NULL, 11 | PRIMARY KEY (`Id`) 12 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 13 | 14 | CREATE TABLE IF NOT EXISTS `clan` ( 15 | `Id` bigint(20) NOT NULL, 16 | `Trophies` bigint(20) NOT NULL, 17 | `RequiredTrophies` bigint(20) NOT NULL, 18 | `Type` bigint(20) NOT NULL, 19 | `Region` text CHARACTER SET utf8mb4 NOT NULL, 20 | `Data` text CHARACTER SET utf8mb4 NOT NULL, 21 | PRIMARY KEY (`Id`) 22 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -------------------------------------------------------------------------------- /Server/Google.Protobuf.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Google.Protobuf.dll -------------------------------------------------------------------------------- /Server/Microsoft.Extensions.Caching.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Microsoft.Extensions.Caching.Abstractions.dll -------------------------------------------------------------------------------- /Server/Microsoft.Extensions.Caching.Memory.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Microsoft.Extensions.Caching.Memory.dll -------------------------------------------------------------------------------- /Server/Microsoft.Extensions.DependencyInjection.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Microsoft.Extensions.DependencyInjection.Abstractions.dll -------------------------------------------------------------------------------- /Server/Microsoft.Extensions.Logging.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Microsoft.Extensions.Logging.Abstractions.dll -------------------------------------------------------------------------------- /Server/Microsoft.Extensions.Logging.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Microsoft.Extensions.Logging.dll -------------------------------------------------------------------------------- /Server/Microsoft.Extensions.Options.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Microsoft.Extensions.Options.dll -------------------------------------------------------------------------------- /Server/Microsoft.Extensions.Primitives.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Microsoft.Extensions.Primitives.dll -------------------------------------------------------------------------------- /Server/Microsoft.Win32.SystemEvents.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Microsoft.Win32.SystemEvents.dll -------------------------------------------------------------------------------- /Server/MySql.Data.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/MySql.Data.dll -------------------------------------------------------------------------------- /Server/NLog.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | 7 | 11 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Server/NLog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/NLog.dll -------------------------------------------------------------------------------- /Server/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /Server/Renci.SshNet.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Renci.SshNet.dll -------------------------------------------------------------------------------- /Server/SshNet.Security.Cryptography.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/SshNet.Security.Cryptography.dll -------------------------------------------------------------------------------- /Server/System.Configuration.ConfigurationManager.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/System.Configuration.ConfigurationManager.dll -------------------------------------------------------------------------------- /Server/System.Drawing.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/System.Drawing.Common.dll -------------------------------------------------------------------------------- /Server/System.Security.Cryptography.ProtectedData.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/System.Security.Cryptography.ProtectedData.dll -------------------------------------------------------------------------------- /Server/System.Security.Permissions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/System.Security.Permissions.dll -------------------------------------------------------------------------------- /Server/System.Windows.Extensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/System.Windows.Extensions.dll -------------------------------------------------------------------------------- /Server/System.Xml.XPath.XmlDocument.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/System.Xml.XPath.XmlDocument.dll -------------------------------------------------------------------------------- /Server/Ubiety.Dns.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/Ubiety.Dns.Core.dll -------------------------------------------------------------------------------- /Server/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "mysql_database": "bsdb", 3 | "mysql_password": "", 4 | "mysql_server": "127.0.0.1", 5 | "mysql_user": "root", 6 | "server_port": 9339, 7 | "default_name": "Mr Vitalik", 8 | "default_region": "IL", 9 | "default_trophies": 99999, 10 | "patch_url": "", 11 | "use_content_patch": false 12 | } -------------------------------------------------------------------------------- /Server/runtimes/unix/lib/netcoreapp3.0/System.Drawing.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/runtimes/unix/lib/netcoreapp3.0/System.Drawing.Common.dll -------------------------------------------------------------------------------- /Server/runtimes/win/lib/netcoreapp3.0/Microsoft.Win32.SystemEvents.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/runtimes/win/lib/netcoreapp3.0/Microsoft.Win32.SystemEvents.dll -------------------------------------------------------------------------------- /Server/runtimes/win/lib/netcoreapp3.0/System.Drawing.Common.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/runtimes/win/lib/netcoreapp3.0/System.Drawing.Common.dll -------------------------------------------------------------------------------- /Server/runtimes/win/lib/netcoreapp3.0/System.Windows.Extensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/runtimes/win/lib/netcoreapp3.0/System.Windows.Extensions.dll -------------------------------------------------------------------------------- /Server/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Server/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/BrawlStars.Utilities.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | ..\..\..\..\..\.nuget\packages\dotnetty.transport\0.6.0\lib\netstandard1.3\DotNetty.Transport.dll 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/Compression/ZLib/Iso8859Dash1Encoding.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace BrawlStars.Utilities.Compression.ZLib 5 | { 6 | public class Iso8859Dash1Encoding : Encoding 7 | { 8 | public static int CharacterCount => 256; 9 | 10 | public override string WebName => "iso-8859-1"; 11 | 12 | public override int GetByteCount(char[] chars, int index, int count) 13 | { 14 | return count; 15 | } 16 | 17 | public override int GetBytes(char[] chars, int start, int count, byte[] bytes, int byteIndex) 18 | { 19 | if (chars == null) 20 | throw new ArgumentNullException(nameof(chars), "null array"); 21 | 22 | if (bytes == null) 23 | throw new ArgumentNullException(nameof(bytes), "null array"); 24 | 25 | if (start < 0) 26 | throw new ArgumentOutOfRangeException(nameof(start)); 27 | if (count < 0) 28 | throw new ArgumentOutOfRangeException(nameof(count)); 29 | 30 | if (chars.Length - start < count) 31 | throw new ArgumentOutOfRangeException(nameof(chars)); 32 | 33 | if (byteIndex < 0 || byteIndex > bytes.Length) 34 | throw new ArgumentOutOfRangeException(nameof(byteIndex)); 35 | 36 | for (var i = 0; i < count; i++) 37 | { 38 | var c = chars[start + i]; 39 | 40 | if (c >= '\x00FF') 41 | bytes[byteIndex + i] = (byte) '?'; 42 | else 43 | bytes[byteIndex + i] = (byte) c; 44 | } 45 | 46 | return count; 47 | } 48 | 49 | public override int GetCharCount(byte[] bytes, int index, int count) 50 | { 51 | return count; 52 | } 53 | 54 | public override int GetChars(byte[] bytes, int start, int count, char[] chars, int charIndex) 55 | { 56 | if (chars == null) 57 | throw new ArgumentNullException(nameof(chars), "null array"); 58 | 59 | if (bytes == null) 60 | throw new ArgumentNullException(nameof(bytes), "null array"); 61 | 62 | if (start < 0) 63 | throw new ArgumentOutOfRangeException(nameof(start)); 64 | if (count < 0) 65 | throw new ArgumentOutOfRangeException(nameof(count)); 66 | 67 | if (bytes.Length - start < count) 68 | throw new ArgumentOutOfRangeException(nameof(bytes)); 69 | 70 | if (charIndex < 0 || charIndex > chars.Length) 71 | throw new ArgumentOutOfRangeException(nameof(charIndex)); 72 | 73 | for (var i = 0; i < count; i++) 74 | chars[charIndex + i] = (char) bytes[i + start]; 75 | 76 | return count; 77 | } 78 | 79 | public override int GetMaxByteCount(int charCount) 80 | { 81 | return charCount; 82 | } 83 | 84 | public override int GetMaxCharCount(int byteCount) 85 | { 86 | return byteCount; 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/Compression/ZLib/ZlibConstants.cs: -------------------------------------------------------------------------------- 1 | namespace BrawlStars.Utilities.Compression.ZLib 2 | { 3 | public static class ZlibConstants 4 | { 5 | public const int WindowBitsMax = 15; 6 | public const int WindowBitsDefault = WindowBitsMax; 7 | 8 | public const int ZOk = 0; 9 | public const int ZStreamEnd = 1; 10 | public const int ZNeedDict = 2; 11 | public const int ZStreamError = -2; 12 | public const int ZDataError = -3; 13 | public const int ZBufError = -5; 14 | 15 | public const int WorkingBufferSizeDefault = 16384; 16 | 17 | public const int WorkingBufferSizeMin = 1024; 18 | } 19 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace BrawlStars.Utilities 6 | { 7 | public static class ExtensionMethods 8 | { 9 | public static void UpdateOrInsert(this List list, int index, T item) 10 | { 11 | if (list.ElementAtOrDefault(index) != null) 12 | list[index] = item; 13 | else 14 | list.Insert(index, item); 15 | } 16 | 17 | public static string ToReadableString(this TimeSpan span) 18 | { 19 | var formatted = 20 | $"{(span.Duration().Days > 0 ? $"{span.Days:0}d, " : string.Empty)}{(span.Duration().Hours > 0 ? $"{span.Hours:0}h, " : string.Empty)}{(span.Duration().Minutes > 0 ? $"{span.Minutes:0}m, " : string.Empty)}{(span.Duration().Seconds > 0 ? $"{span.Seconds:0}s" : string.Empty)}"; 21 | 22 | if (formatted.EndsWith(", ")) formatted = formatted.Substring(0, formatted.Length - 2); 23 | 24 | if (string.IsNullOrEmpty(formatted)) formatted = "0s"; 25 | 26 | return formatted; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/Netty/Reader.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using BrawlStars.Utilities.Compression.ZLib; 3 | using DotNetty.Buffers; 4 | 5 | namespace BrawlStars.Utilities.Netty 6 | { 7 | /// 8 | /// This implements a few extensions for games from Supercell 9 | /// 10 | public static class Reader 11 | { 12 | /// 13 | /// Decodes a string based on the length 14 | /// 15 | /// 16 | /// 17 | public static string ReadScString(this IByteBuffer byteBuffer) 18 | { 19 | var length = byteBuffer.ReadInt(); 20 | 21 | if (length <= 0 || length > 900000) 22 | return string.Empty; 23 | 24 | return byteBuffer.ReadString(length, Encoding.UTF8); 25 | } 26 | 27 | /// 28 | /// Decodes a compressed string 29 | /// 30 | /// 31 | /// 32 | /// 33 | public static string ReadCompressedString(this IByteBuffer byteBuffer, bool indicator = true) 34 | { 35 | if(indicator) 36 | byteBuffer.ReadByte(); 37 | 38 | var compressedLength = byteBuffer.ReadInt() - 4; 39 | byteBuffer.ReadIntLE(); 40 | 41 | var compressedBytes = byteBuffer.ReadBytes(compressedLength); 42 | 43 | return ZlibStream.UncompressString(compressedBytes.Array); 44 | } 45 | public static int ReadVInt(this IByteBuffer byteBuffer) 46 | { 47 | int b, sign = ((b = byteBuffer.ReadByte()) >> 6) & 1, i = b & 0x3F, offset = 6; 48 | 49 | for (var j = 0; j < 4 && (b & 0x80) != 0; j++, offset += 7) 50 | i |= ((b = byteBuffer.ReadByte()) & 0x7F) << offset; 51 | 52 | return (b & 0x80) != 0 ? -1 : i | (sign == 1 && offset < 32 ? i | (int)(0xFFFFFFFF << offset) : i); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/Netty/Writer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Text; 4 | using BrawlStars.Utilities.Compression.ZLib; 5 | using DotNetty.Buffers; 6 | 7 | namespace BrawlStars.Utilities.Netty 8 | { 9 | /// 10 | /// This implements a few extensions for games from Supercell 11 | /// 12 | public static class Writer 13 | { 14 | /// 15 | /// Encodes a string based on the length 16 | /// 17 | /// 18 | /// 19 | public static void WriteScString(this IByteBuffer buffer, string value) 20 | { 21 | if (value == null) 22 | { 23 | buffer.WriteInt(-1); 24 | } 25 | else if (value.Length == 0) 26 | { 27 | buffer.WriteInt(0); 28 | } 29 | else 30 | { 31 | var bytes = Encoding.UTF8.GetBytes(value); 32 | 33 | buffer.WriteInt(bytes.Length); 34 | buffer.WriteString(value, Encoding.UTF8); 35 | } 36 | } 37 | 38 | /// 39 | /// Encodes a VInt 40 | /// 41 | /// 42 | /// 43 | public static void WriteVInt(this IByteBuffer buffer, int value) 44 | { 45 | var temp = (value >> 25) & 0x40; 46 | var flipped = value ^ (value >> 31); 47 | 48 | temp |= value & 0x3F; 49 | value >>= 6; 50 | 51 | if ((flipped >>= 6) == 0) 52 | { 53 | buffer.WriteByte(temp); 54 | return; 55 | } 56 | 57 | buffer.WriteByte(temp | 0x80); 58 | 59 | do 60 | { 61 | buffer.WriteByte((value & 0x7F) | ((flipped >>= 7) != 0 ? 0x80 : 0)); 62 | value >>= 7; 63 | } while (flipped != 0); 64 | } 65 | 66 | /// 67 | /// Encode a ScId 68 | /// 69 | /// 70 | /// 71 | /// 72 | public static void WriteScId(this IByteBuffer buffer, int high, int low) 73 | { 74 | Writer.WriteVInt(buffer, high); 75 | Writer.WriteVInt(buffer, low); 76 | } 77 | 78 | /// 79 | /// Encode a compressed string 80 | /// 81 | /// 82 | /// 83 | /// 84 | public static void WriteCompressedString(this IByteBuffer buffer, string value, bool indicate = true) 85 | { 86 | var data = Encoding.UTF8.GetBytes(value); 87 | var compressed = ZlibStream.CompressBuffer(data, CompressionLevel.BestCompression); 88 | 89 | if (indicate) 90 | buffer.WriteByte(1); 91 | 92 | buffer.WriteInt(compressed.Length + 4); 93 | buffer.WriteIntLE(value.Length); 94 | 95 | buffer.WriteBytes(compressed); 96 | } 97 | 98 | /// 99 | /// This method should be only used for testing. 100 | /// 101 | /// 102 | /// 103 | public static void WriteHex(this IByteBuffer buffer, string value) 104 | { 105 | var tmp = value.Replace("-", string.Empty).Replace("-", string.Empty); 106 | buffer.WriteBytes(Enumerable.Range(0, tmp.Length).Where(x => x % 2 == 0) 107 | .Select(x => Convert.ToByte(tmp.Substring(x, 2), 16)).ToArray()); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/Utils/GameUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BrawlStars.Utilities.Utils 4 | { 5 | public class GameUtils 6 | { 7 | public static string GenerateToken 8 | { 9 | get 10 | { 11 | var random = new Random(); 12 | var token = string.Empty; 13 | 14 | for (var i = 0; i < 40; i++) 15 | token += "abcdefghijklmnopqrstuvwxyz0123456789"[random.Next(36)]; 16 | 17 | return token; 18 | } 19 | } 20 | 21 | public static bool IsHigherRoleThan(int role, int roleToCompare) 22 | { 23 | var table = new[] {1, 1, 4, 2, 3}; 24 | return role >= 5 || roleToCompare >= 5 || table[roleToCompare] < table[role]; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/Utils/ServerUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.InteropServices; 4 | using System.Security.Cryptography; 5 | using System.Text; 6 | 7 | namespace BrawlStars.Utilities.Utils 8 | { 9 | public class ServerUtils 10 | { 11 | public static string GetOsName() 12 | { 13 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 14 | return "Windows"; 15 | if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) 16 | return "MacOS"; 17 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) 18 | return "Linux"; 19 | 20 | return "Unknown-" + Environment.OSVersion; 21 | } 22 | 23 | public static bool IsLinux() 24 | { 25 | return RuntimeInformation.IsOSPlatform(OSPlatform.Linux); 26 | } 27 | 28 | public static string GetChecksum(string text) 29 | { 30 | using (var hasher = new SHA1CryptoServiceProvider()) 31 | { 32 | return hasher.ComputeHash(Encoding.UTF8.GetBytes(text)).Aggregate(string.Empty, 33 | (current, num) => current + num.ToString("x2")); 34 | } 35 | } 36 | 37 | public static string GetChecksum(byte[] data) 38 | { 39 | using (var hasher = new SHA1CryptoServiceProvider()) 40 | { 41 | return hasher.ComputeHash(data).Aggregate(string.Empty, 42 | (current, num) => current + num.ToString("x2")); 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/Utils/TimeUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BrawlStars.Utilities.Utils 4 | { 5 | public class TimeUtils 6 | { 7 | public static int GetSecondsUntilNextMonth 8 | { 9 | get 10 | { 11 | var now = DateTime.UtcNow; 12 | 13 | if (now.Month != 12) 14 | return (int) (new DateTime(now.Year, now.Month + 1, 1, now.Hour, 15 | now.Minute, now.Second) - now).TotalSeconds; 16 | 17 | return (int) (new DateTime(now.Year + 1, 1, 1, now.Hour, 18 | now.Minute, now.Second) - now).TotalSeconds; 19 | } 20 | } 21 | 22 | public static int GetSecondsUntilTomorrow 23 | { 24 | get 25 | { 26 | var now = DateTime.UtcNow; 27 | var tomorrow = now.AddDays(1).Date; 28 | 29 | return (int) (tomorrow - now).TotalSeconds; 30 | } 31 | } 32 | 33 | public static int CurrentUnixTimestamp => (int) DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; 34 | } 35 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/BrawlStars.Utilities.csproj.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dgSpecHash": "OJ2to3cVLIFHRq4RQUlEeQKmvPEygU8QU6Ykj5XdPDAxp5Y1A20SI45bhU/s1zKtPvUibjiseZbEm0W+oHxGLw==", 4 | "success": true 5 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/BrawlStars.Utilities.csproj.nuget.dgspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": 1, 3 | "restore": { 4 | "C:\\Users\\Vitalik\\Desktop\\Source\\BrawlStars.Utilities\\BrawlStars.Utilities.csproj": {} 5 | }, 6 | "projects": { 7 | "C:\\Users\\Vitalik\\Desktop\\Source\\BrawlStars.Utilities\\BrawlStars.Utilities.csproj": { 8 | "version": "1.0.0", 9 | "restore": { 10 | "projectUniqueName": "C:\\Users\\Vitalik\\Desktop\\Source\\BrawlStars.Utilities\\BrawlStars.Utilities.csproj", 11 | "projectName": "BrawlStars.Utilities", 12 | "projectPath": "C:\\Users\\Vitalik\\Desktop\\Source\\BrawlStars.Utilities\\BrawlStars.Utilities.csproj", 13 | "packagesPath": "C:\\Users\\Vitalik\\.nuget\\packages\\", 14 | "outputPath": "C:\\Users\\Vitalik\\Desktop\\Source\\BrawlStars.Utilities\\obj\\", 15 | "projectStyle": "PackageReference", 16 | "fallbackFolders": [ 17 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" 18 | ], 19 | "configFilePaths": [ 20 | "C:\\Users\\Vitalik\\AppData\\Roaming\\NuGet\\NuGet.Config", 21 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" 22 | ], 23 | "originalTargetFrameworks": [ 24 | "netstandard2.0" 25 | ], 26 | "sources": { 27 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, 28 | "https://api.nuget.org/v3/index.json": {} 29 | }, 30 | "frameworks": { 31 | "netstandard2.0": { 32 | "projectReferences": {} 33 | } 34 | }, 35 | "warningProperties": { 36 | "warnAsError": [ 37 | "NU1605" 38 | ] 39 | } 40 | }, 41 | "frameworks": { 42 | "netstandard2.0": { 43 | "dependencies": { 44 | "DotNetty.Buffers": { 45 | "target": "Package", 46 | "version": "[0.6.0, )" 47 | }, 48 | "MySql.Data": { 49 | "target": "Package", 50 | "version": "[8.0.19, )" 51 | }, 52 | "NETStandard.Library": { 53 | "suppressParent": "All", 54 | "target": "Package", 55 | "version": "[2.0.3, )", 56 | "autoReferenced": true 57 | }, 58 | "Newtonsoft.Json": { 59 | "target": "Package", 60 | "version": "[12.0.2, )" 61 | } 62 | }, 63 | "imports": [ 64 | "net461", 65 | "net462", 66 | "net47", 67 | "net471", 68 | "net472", 69 | "net48" 70 | ], 71 | "assetTargetFallback": true, 72 | "warn": true, 73 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.201\\RuntimeIdentifierGraph.json" 74 | } 75 | } 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/BrawlStars.Utilities.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | $(MSBuildThisFileDirectory)project.assets.json 7 | $(UserProfile)\.nuget\packages\ 8 | C:\Users\Vitalik\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder 9 | PackageReference 10 | 5.5.0 11 | 12 | 13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 14 | 15 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/BrawlStars.Utilities.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/ClashofClans.Utilities.csproj.nuget.dgspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": 1, 3 | "restore": { 4 | "E:\\BrawlStars\\src\\ClashofClans.Utilities\\ClashofClans.Utilities.csproj": {} 5 | }, 6 | "projects": { 7 | "E:\\BrawlStars\\src\\ClashofClans.Utilities\\ClashofClans.Utilities.csproj": { 8 | "version": "1.0.0", 9 | "restore": { 10 | "projectUniqueName": "E:\\BrawlStars\\src\\ClashofClans.Utilities\\ClashofClans.Utilities.csproj", 11 | "projectName": "ClashofClans.Utilities", 12 | "projectPath": "E:\\BrawlStars\\src\\ClashofClans.Utilities\\ClashofClans.Utilities.csproj", 13 | "packagesPath": "C:\\Users\\Vitalik\\.nuget\\packages\\", 14 | "outputPath": "E:\\BrawlStars\\src\\ClashofClans.Utilities\\obj\\", 15 | "projectStyle": "PackageReference", 16 | "fallbackFolders": [ 17 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" 18 | ], 19 | "configFilePaths": [ 20 | "C:\\Users\\Vitalik\\AppData\\Roaming\\NuGet\\NuGet.Config", 21 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" 22 | ], 23 | "originalTargetFrameworks": [ 24 | "netstandard2.0" 25 | ], 26 | "sources": { 27 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, 28 | "https://api.nuget.org/v3/index.json": {} 29 | }, 30 | "frameworks": { 31 | "netstandard2.0": { 32 | "projectReferences": {} 33 | } 34 | }, 35 | "warningProperties": { 36 | "warnAsError": [ 37 | "NU1605" 38 | ] 39 | } 40 | }, 41 | "frameworks": { 42 | "netstandard2.0": { 43 | "dependencies": { 44 | "DotNetty.Buffers": { 45 | "target": "Package", 46 | "version": "[0.6.0, )" 47 | }, 48 | "NETStandard.Library": { 49 | "suppressParent": "All", 50 | "target": "Package", 51 | "version": "[2.0.3, )", 52 | "autoReferenced": true 53 | }, 54 | "Newtonsoft.Json": { 55 | "target": "Package", 56 | "version": "[12.0.2, )" 57 | } 58 | }, 59 | "imports": [ 60 | "net461", 61 | "net462", 62 | "net47", 63 | "net471", 64 | "net472", 65 | "net48" 66 | ], 67 | "assetTargetFallback": true, 68 | "warn": true, 69 | "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.201\\RuntimeIdentifierGraph.json" 70 | } 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/ClashofClans.Utilities.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | $(MSBuildThisFileDirectory)project.assets.json 7 | $(UserProfile)\.nuget\packages\ 8 | C:\Users\Vitalik\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder 9 | PackageReference 10 | 5.5.0 11 | 12 | 13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 14 | 15 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/ClashofClans.Utilities.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("BrawlStars.Utilities")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("BrawlStars.Utilities")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("BrawlStars.Utilities")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 2d4c545f4d00364a2bbd2bd34286ac391cde2c09 2 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.assets.cache -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 76d97a11d5a2c8c4e6f23244b78539384a361e6e 2 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | E:\BS\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.deps.json 2 | E:\BS\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.dll 3 | E:\BS\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.pdb 4 | E:\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.csprojAssemblyReference.cache 5 | E:\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.csproj.CoreCompileInputs.cache 6 | E:\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.AssemblyInfoInputs.cache 7 | E:\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.AssemblyInfo.cs 8 | E:\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.dll 9 | E:\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.pdb 10 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.deps.json 11 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.dll 12 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.pdb 13 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.csprojAssemblyReference.cache 14 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.csproj.CoreCompileInputs.cache 15 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.AssemblyInfoInputs.cache 16 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.AssemblyInfo.cs 17 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.dll 18 | C:\Users\Vitalik\Desktop\BS\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.pdb 19 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.deps.json 20 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.dll 21 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\bin\Debug\netstandard2.0\BrawlStars.Utilities.pdb 22 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.csprojAssemblyReference.cache 23 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.csproj.CoreCompileInputs.cache 24 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.AssemblyInfoInputs.cache 25 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.AssemblyInfo.cs 26 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.dll 27 | C:\Users\Vitalik\Desktop\Source\BrawlStars.Utilities\obj\Debug\netstandard2.0\BrawlStars.Utilities.pdb 28 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.dll -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/BrawlStars.Utilities.pdb -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("ClashofClans.Utilities")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("ClashofClans.Utilities")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("ClashofClans.Utilities")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | ea4cb677b4af8d35d92b27ec4a341331ac655b91 2 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.assets.cache -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 7403864cafaed2a728f00ceee3c1398419914ee6 2 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | E:\20Clash-master\src\ClashofClans.Utilities\bin\Debug\netstandard2.0\ClashofClans.Utilities.deps.json 2 | E:\20Clash-master\src\ClashofClans.Utilities\bin\Debug\netstandard2.0\ClashofClans.Utilities.dll 3 | E:\20Clash-master\src\ClashofClans.Utilities\bin\Debug\netstandard2.0\ClashofClans.Utilities.pdb 4 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.csprojAssemblyReference.cache 5 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.AssemblyInfoInputs.cache 6 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.AssemblyInfo.cs 7 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.dll 8 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.pdb 9 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.csproj.CoreCompileInputs.cache 10 | E:\BrawlStars\src\ClashofClans.Utilities\bin\Debug\netstandard2.0\ClashofClans.Utilities.deps.json 11 | E:\BrawlStars\src\ClashofClans.Utilities\bin\Debug\netstandard2.0\ClashofClans.Utilities.dll 12 | E:\BrawlStars\src\ClashofClans.Utilities\bin\Debug\netstandard2.0\ClashofClans.Utilities.pdb 13 | E:\BrawlStars\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.csprojAssemblyReference.cache 14 | E:\BrawlStars\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.csproj.CoreCompileInputs.cache 15 | E:\BrawlStars\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.AssemblyInfoInputs.cache 16 | E:\BrawlStars\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.AssemblyInfo.cs 17 | E:\BrawlStars\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.dll 18 | E:\BrawlStars\src\ClashofClans.Utilities\obj\Debug\netstandard2.0\ClashofClans.Utilities.pdb 19 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.dll -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Debug/netstandard2.0/ClashofClans.Utilities.pdb -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("ClashofClans.Utilities")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("ClashofClans.Utilities")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("ClashofClans.Utilities")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 6afc444d22c58c07108dccaca99e4e84c99bfe69 2 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.assets.cache -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | c6e616abff42b709139c0e95fa4890c27b76eec2 2 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | E:\20Clash-master\src\ClashofClans.Utilities\bin\Release\netstandard2.0\ClashofClans.Utilities.deps.json 2 | E:\20Clash-master\src\ClashofClans.Utilities\bin\Release\netstandard2.0\ClashofClans.Utilities.dll 3 | E:\20Clash-master\src\ClashofClans.Utilities\bin\Release\netstandard2.0\ClashofClans.Utilities.pdb 4 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Release\netstandard2.0\ClashofClans.Utilities.csprojAssemblyReference.cache 5 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Release\netstandard2.0\ClashofClans.Utilities.csproj.CoreCompileInputs.cache 6 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Release\netstandard2.0\ClashofClans.Utilities.AssemblyInfoInputs.cache 7 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Release\netstandard2.0\ClashofClans.Utilities.AssemblyInfo.cs 8 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Release\netstandard2.0\ClashofClans.Utilities.dll 9 | E:\20Clash-master\src\ClashofClans.Utilities\obj\Release\netstandard2.0\ClashofClans.Utilities.pdb 10 | -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.dll -------------------------------------------------------------------------------- /Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars.Utilities/obj/Release/netstandard2.0/ClashofClans.Utilities.pdb -------------------------------------------------------------------------------- /Source/BrawlStars.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.28809.33 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrawlStars", "BrawlStars\BrawlStars.csproj", "{9D0CA4C8-4661-4D51-AE5D-5EDB16C9C796}" 6 | EndProject 7 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrawlStars.Utilities", "BrawlStars.Utilities\BrawlStars.Utilities.csproj", "{7F835EF1-3FC7-40A5-81C4-502071DBEB1F}" 8 | EndProject 9 | Global 10 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 11 | Debug|Any CPU = Debug|Any CPU 12 | Release|Any CPU = Release|Any CPU 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {9D0CA4C8-4661-4D51-AE5D-5EDB16C9C796}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 16 | {9D0CA4C8-4661-4D51-AE5D-5EDB16C9C796}.Debug|Any CPU.Build.0 = Debug|Any CPU 17 | {9D0CA4C8-4661-4D51-AE5D-5EDB16C9C796}.Release|Any CPU.ActiveCfg = Release|Any CPU 18 | {9D0CA4C8-4661-4D51-AE5D-5EDB16C9C796}.Release|Any CPU.Build.0 = Release|Any CPU 19 | {7F835EF1-3FC7-40A5-81C4-502071DBEB1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {7F835EF1-3FC7-40A5-81C4-502071DBEB1F}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {7F835EF1-3FC7-40A5-81C4-502071DBEB1F}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {7F835EF1-3FC7-40A5-81C4-502071DBEB1F}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | GlobalSection(ExtensibilityGlobals) = postSolution 28 | SolutionGuid = {EAFDB0A5-529C-498E-8A90-5389E2B0CF3B} 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /Source/BrawlStars/BrawlStars.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ProjectDebugger 5 | 6 | 7 | BrawlStars 8 | 9 | -------------------------------------------------------------------------------- /Source/BrawlStars/Core/Configuration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Newtonsoft.Json; 4 | 5 | namespace BrawlStars.Core 6 | { 7 | public class Configuration 8 | { 9 | [JsonIgnore] public static JsonSerializerSettings JsonSettings = new JsonSerializerSettings 10 | { 11 | ObjectCreationHandling = ObjectCreationHandling.Auto, 12 | MissingMemberHandling = MissingMemberHandling.Ignore, 13 | DefaultValueHandling = DefaultValueHandling.Ignore, 14 | NullValueHandling = NullValueHandling.Ignore, 15 | TypeNameHandling = TypeNameHandling.Auto, 16 | Formatting = Formatting.None 17 | }; 18 | 19 | [JsonProperty("mysql_database")] public string MySqlDatabase = "bsdb"; 20 | [JsonProperty("mysql_password")] public string MySqlPassword = ""; 21 | [JsonProperty("mysql_server")] public string MySqlServer = "127.0.0.1"; 22 | [JsonProperty("mysql_user")] public string MySqlUserId = "root"; 23 | [JsonProperty("server_port")] public int ServerPort = 9339; 24 | [JsonProperty("default_name")] public string Name = ""; 25 | [JsonProperty("default_region")] public string Region = ""; 26 | [JsonProperty("default_trophies")] public int Trophies = 99999; 27 | [JsonProperty("patch_url")] public string PatchUrl = ""; 28 | [JsonProperty("use_content_patch")] public bool UseContentPatch; 29 | /// 30 | /// Loads the configuration 31 | /// 32 | public void Initialize() 33 | { 34 | if (File.Exists("config.json")) 35 | try 36 | { 37 | var config = JsonConvert.DeserializeObject(File.ReadAllText("config.json")); 38 | 39 | MySqlUserId = config.MySqlUserId; 40 | MySqlServer = config.MySqlServer; 41 | MySqlPassword = config.MySqlPassword; 42 | MySqlDatabase = config.MySqlDatabase; 43 | ServerPort = config.ServerPort; 44 | Name = config.Name; 45 | Region = config.Region; 46 | Trophies = config.Trophies; 47 | PatchUrl = config.PatchUrl; 48 | UseContentPatch = config.UseContentPatch; 49 | } 50 | catch (Exception) 51 | { 52 | Console.WriteLine("Couldn't load configuration."); 53 | Console.ReadKey(true); 54 | Environment.Exit(0); 55 | } 56 | else 57 | try 58 | { 59 | Save(); 60 | 61 | Console.ForegroundColor = ConsoleColor.DarkGreen; 62 | Console.WriteLine("Server configuration has been created.\nNow update the config.json for your needs."); 63 | Console.ReadKey(); 64 | Environment.Exit(0); 65 | } 66 | catch (Exception) 67 | { 68 | Console.ForegroundColor = ConsoleColor.DarkRed; 69 | Console.WriteLine("Couldn't create config file."); 70 | Console.ReadKey(); 71 | Environment.Exit(0); 72 | } 73 | } 74 | 75 | public void Save() 76 | { 77 | File.WriteAllText("config.json", JsonConvert.SerializeObject(this, Formatting.Indented)); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Source/BrawlStars/Core/Network/Handlers/PacketEncoder.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using BrawlStars.Protocol; 3 | using DotNetty.Buffers; 4 | using DotNetty.Transport.Channels; 5 | 6 | namespace BrawlStars.Core.Network.Handlers 7 | { 8 | public class PacketEncoder : ChannelHandlerAdapter 9 | { 10 | public override Task WriteAsync(IChannelHandlerContext context, object msg) 11 | { 12 | var message = (PiranhaMessage) msg; 13 | 14 | message.Encode(); 15 | 16 | var header = PooledByteBufferAllocator.Default.Buffer(7); 17 | header.WriteUnsignedShort(message.Id); 18 | header.WriteMedium(message.Writer.ReadableBytes); 19 | header.WriteUnsignedShort(message.Version); 20 | 21 | message.EncodeCryptoBytes(); 22 | 23 | base.WriteAsync(context, header); 24 | return base.WriteAsync(context, message.Writer); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Core/Network/Handlers/PacketHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using BrawlStars.Logic; 4 | using DotNetty.Buffers; 5 | using DotNetty.Handlers.Timeout; 6 | using DotNetty.Transport.Channels; 7 | 8 | namespace BrawlStars.Core.Network.Handlers 9 | { 10 | public class PacketHandler : ChannelHandlerAdapter 11 | { 12 | public PacketHandler() 13 | { 14 | Throttler = new Throttler(10, 500); 15 | Device = new Device(this); 16 | } 17 | 18 | public Device Device { get; set; } 19 | public IChannel Channel { get; set; } 20 | public Throttler Throttler { get; set; } 21 | 22 | public override void ChannelRead(IChannelHandlerContext context, object message) 23 | { 24 | var buffer = (IByteBuffer) message; 25 | if (buffer == null) return; 26 | 27 | if (Throttler.CanProcess()) 28 | { 29 | Device.Process(buffer); 30 | } 31 | else 32 | { 33 | Logger.Log("Client reached ratelimit. Disconnecting...", GetType(), Logger.ErrorLevel.Warning); 34 | Device.Disconnect(); 35 | } 36 | } 37 | 38 | public override void ChannelRegistered(IChannelHandlerContext context) 39 | { 40 | Channel = context.Channel; 41 | 42 | var remoteAddress = (IPEndPoint) Channel.RemoteAddress; 43 | 44 | Logger.Log($"Client {remoteAddress.Address.MapToIPv4()}:{remoteAddress.Port} connected.", GetType(), 45 | Logger.ErrorLevel.Debug); 46 | 47 | base.ChannelRegistered(context); 48 | } 49 | 50 | public override async void ChannelUnregistered(IChannelHandlerContext context) 51 | { 52 | if (Device?.Player?.Home != null) 53 | { 54 | var player = await Resources.Players.GetPlayerAsync(Device.Player.Home.Id, true); 55 | if (player != null) 56 | if (player.Device.Session.SessionId == Device.Session.SessionId) 57 | Resources.Players.LogoutById(player.Home.Id); 58 | } 59 | 60 | var remoteAddress = (IPEndPoint) Channel.RemoteAddress; 61 | 62 | Logger.Log($"Client {remoteAddress.Address.MapToIPv4()}:{remoteAddress.Port} disconnected.", GetType(), 63 | Logger.ErrorLevel.Debug); 64 | 65 | base.ChannelUnregistered(context); 66 | } 67 | 68 | public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) 69 | { 70 | if (exception.GetType() != typeof(ReadTimeoutException) && 71 | exception.GetType() != typeof(WriteTimeoutException)) 72 | Logger.Log(exception, GetType(), Logger.ErrorLevel.Error); 73 | 74 | context.CloseAsync(); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Core/Network/NettyService.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Threading.Tasks; 3 | using BrawlStars.Core.Network.Handlers; 4 | using DotNetty.Codecs; 5 | using DotNetty.Handlers.Logging; 6 | using DotNetty.Handlers.Timeout; 7 | using DotNetty.Transport.Bootstrapping; 8 | using DotNetty.Transport.Channels; 9 | using DotNetty.Transport.Channels.Sockets; 10 | 11 | namespace BrawlStars.Core.Network 12 | { 13 | public class NettyService 14 | { 15 | public MultithreadEventLoopGroup BossGroup { get; set; } 16 | public MultithreadEventLoopGroup WorkerGroup { get; set; } 17 | 18 | public ServerBootstrap ServerBootstrap { get; set; } 19 | public IChannel ServerChannel { get; set; } 20 | 21 | /// 22 | /// Run the server 23 | /// 24 | /// 25 | public async Task RunServerAsync() 26 | { 27 | BossGroup = new MultithreadEventLoopGroup(); 28 | WorkerGroup = new MultithreadEventLoopGroup(); 29 | 30 | ServerBootstrap = new ServerBootstrap(); 31 | ServerBootstrap.Group(BossGroup, WorkerGroup); 32 | ServerBootstrap.Channel(); 33 | 34 | ServerBootstrap 35 | .Option(ChannelOption.SoBacklog, 100) 36 | .Option(ChannelOption.TcpNodelay, true) 37 | .Option(ChannelOption.SoKeepalive, true) 38 | .Handler(new LoggingHandler("SRV-ICR")) 39 | .ChildHandler(new ActionChannelInitializer(channel => 40 | { 41 | var pipeline = channel.Pipeline; 42 | pipeline.AddFirst("FrameDecoder", new LengthFieldBasedFrameDecoder(4096, 2, 3, 2, 0)); 43 | pipeline.AddFirst("ReadTimeoutHandler", new ReadTimeoutHandler(30)); 44 | pipeline.AddLast("PacketHandler", new PacketHandler()); 45 | pipeline.AddLast("WriteTimeoutHandler", new WriteTimeoutHandler(30)); 46 | pipeline.AddLast("PacketEncoder", new PacketEncoder()); 47 | })); 48 | 49 | ServerChannel = await ServerBootstrap.BindAsync(Resources.Configuration.ServerPort); 50 | var endpoint = (IPEndPoint) ServerChannel.LocalAddress; 51 | 52 | Logger.Log( 53 | $"Listening on {endpoint.Address.MapToIPv4()}:{endpoint.Port}. Let's play Brawl Stars!", 54 | GetType()); 55 | } 56 | 57 | /// 58 | /// Close all channels and disconnects clients 59 | /// 60 | /// 61 | public async Task Shutdown() 62 | { 63 | await ServerChannel.CloseAsync(); 64 | } 65 | 66 | /// 67 | /// Shutdown all workers of netty 68 | /// 69 | /// 70 | public async Task ShutdownWorkers() 71 | { 72 | await WorkerGroup.ShutdownGracefullyAsync(); 73 | await BossGroup.ShutdownGracefullyAsync(); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Core/Network/Throttler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BrawlStars.Core.Network 4 | { 5 | public class Throttler 6 | { 7 | private readonly int _interval; 8 | private readonly int _maxPackets; 9 | private int _count; 10 | private DateTime _lastReset = DateTime.UtcNow; 11 | 12 | /// 13 | /// Throttle packets by checking if we can process it or if the ratelimit is reached 14 | /// 15 | /// 16 | /// 17 | public Throttler(int maxPackets, int interval) 18 | { 19 | _maxPackets = maxPackets; 20 | _interval = interval; 21 | } 22 | 23 | public bool CanProcess() 24 | { 25 | if (_count++ < _maxPackets) return true; 26 | if (GetMillisecondsSinceLastReset() < _interval) return false; 27 | 28 | _count = 1; 29 | _lastReset = DateTime.UtcNow; 30 | return true; 31 | } 32 | 33 | private int GetMillisecondsSinceLastReset() 34 | { 35 | return (int) DateTime.UtcNow.Subtract(_lastReset).TotalMilliseconds; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Database/Cache/Alliances.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BrawlStars.Logic.Clan; 3 | using System.Threading.Tasks; 4 | 5 | namespace BrawlStars.Database.Cache 6 | { 7 | public class Alliances : Dictionary 8 | { 9 | private readonly object _syncObject = new object(); 10 | 11 | /// 12 | /// Add an alliance to the server 13 | /// 14 | /// 15 | public void Add(Alliance alliance) 16 | { 17 | lock (_syncObject) 18 | { 19 | if (!ContainsKey(alliance.Id)) Add(alliance.Id, alliance); 20 | } 21 | } 22 | 23 | /// 24 | /// Remove an alliance from the server and save it 25 | /// 26 | /// 27 | public new void Remove(long allianceId) 28 | { 29 | lock (_syncObject) 30 | { 31 | if (ContainsKey(allianceId)) 32 | { 33 | var alliance = this[allianceId]; 34 | 35 | alliance.Save(); 36 | 37 | var result = base.Remove(allianceId); 38 | 39 | if (!result) 40 | Logger.Log($"Couldn't remove alliance {allianceId}", GetType(), Logger.ErrorLevel.Error); 41 | } 42 | } 43 | } 44 | public async Task GetAllianceAsync(long allianceId, bool onlineOnly = false) 45 | { 46 | lock (_syncObject) 47 | { 48 | if (ContainsKey(allianceId)) 49 | return this[allianceId]; 50 | } 51 | 52 | if (onlineOnly) return null; 53 | 54 | var alliance = Resources.ObjectCache.GetCachedAlliance(allianceId); 55 | 56 | if (alliance != null) return alliance; 57 | 58 | alliance = await AllianceDb.GetAsync(allianceId); 59 | 60 | Resources.ObjectCache.CacheAlliance(alliance); 61 | 62 | return alliance; 63 | } 64 | 65 | /// 66 | /// Get an alliance from cache or database 67 | /// 68 | /// 69 | /// 70 | /// 71 | /*public async Task GetAllianceAsync(long allianceId, bool onlineOnly = false) 72 | { 73 | lock (_syncObject) 74 | { 75 | if (ContainsKey(allianceId)) 76 | return this[allianceId]; 77 | } 78 | 79 | if (onlineOnly) return null; 80 | 81 | if (!Redis.IsConnected) return await AllianceDb.GetAsync(allianceId); 82 | 83 | var alliance = await Redis.GetAllianceAsync(allianceId); 84 | 85 | if (alliance != null) return alliance; 86 | 87 | alliance = await AllianceDb.GetAsync(allianceId); 88 | 89 | await Redis.CacheAsync(alliance); 90 | 91 | return alliance; 92 | } 93 | 94 | /// 95 | /// Returns a list of random cached Alliances 96 | /// 97 | /// 98 | /// 99 | public async Task> GetRandomAlliancesAsync(int count = 40, bool notFull = true) 100 | { 101 | var alliances = new List(count); 102 | 103 | for (var i = 0; i < count; i++) 104 | { 105 | var alliance = await Redis.GetRandomAllianceAsync(); 106 | 107 | if (alliance != null && alliances.FindIndex(a => a.Id == alliance.Id) == -1) 108 | { 109 | if (notFull) 110 | { 111 | if (alliance.Members.Count < 50) alliances.Add(alliance); 112 | } 113 | else 114 | { 115 | alliances.Add(alliance); 116 | } 117 | } 118 | } 119 | 120 | return alliances; 121 | }*/ 122 | } 123 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Database/Cache/Players.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using BrawlStars.Logic; 4 | 5 | namespace BrawlStars.Database.Cache 6 | { 7 | public class Players : Dictionary 8 | { 9 | public readonly object SyncObject = new object(); 10 | 11 | /// 12 | /// Login a player 13 | /// 14 | /// 15 | /// 16 | public async Task Login(long userId, string token) 17 | { 18 | Player player; 19 | 20 | if (userId <= 0 && string.IsNullOrEmpty(token)) 21 | { 22 | player = await PlayerDb.CreateAsync(); 23 | } 24 | else 25 | { 26 | //var p = await Redis.GetPlayerAsync(userId); 27 | var p = Resources.ObjectCache.GetCachedPlayer(userId); 28 | 29 | if (p != null) 30 | player = p; 31 | else 32 | player = await PlayerDb.GetAsync(userId); 33 | 34 | if (player == null) return null; 35 | if (player.Home.UserToken != token) return null; 36 | } 37 | 38 | lock (SyncObject) 39 | { 40 | if (player == null) return null; 41 | 42 | Logout(ref player); 43 | 44 | var result = TryAdd(player.Home.Id, player); 45 | 46 | if (!result) return null; 47 | 48 | //Logger.Log($"User {player.Home.Id} logged in.", GetType(), ErrorLevel.Debug); 49 | 50 | return player; 51 | } 52 | } 53 | 54 | /// 55 | /// Called when a player logs out 56 | /// 57 | /// 58 | public void Logout(ref Player player) 59 | { 60 | lock (SyncObject) 61 | { 62 | if (!ContainsKey(player.Home.Id)) return; 63 | 64 | var p = this[player.Home.Id]; 65 | p.ValidateSession(); 66 | p.Save(); 67 | 68 | player = p; 69 | 70 | var result = Remove(p.Home.Id); 71 | 72 | if (!result) Logger.Log($"Couldn't logout player {p.Home.Id}", GetType(), Logger.ErrorLevel.Error); 73 | //else Logger.Log($"User {player.UserId} logged out.", GetType(), ErrorLevel.Debug); 74 | } 75 | } 76 | 77 | /// 78 | /// Log out a player by the UserId 79 | /// 80 | /// 81 | /// 82 | public bool LogoutById(long userId) 83 | { 84 | lock (SyncObject) 85 | { 86 | if (!ContainsKey(userId)) return true; 87 | 88 | var player = this[userId]; 89 | player.ValidateSession(); 90 | player.Save(); 91 | 92 | var result = Remove(userId); 93 | 94 | if (!result) Logger.Log($"Couldn't logout player {userId}", GetType(), Logger.ErrorLevel.Error); 95 | 96 | return result; 97 | } 98 | } 99 | 100 | /// 101 | /// Get a player from cache or database 102 | /// 103 | /// 104 | /// 105 | /// 106 | public async Task GetPlayerAsync(long userId, bool onlineOnly = false) 107 | { 108 | lock (SyncObject) 109 | { 110 | if (ContainsKey(userId)) 111 | return this[userId]; 112 | } 113 | 114 | if (onlineOnly) return null; 115 | 116 | var player = Resources.ObjectCache.GetCachedPlayer(userId); 117 | 118 | if (player != null) return player; 119 | 120 | player = await PlayerDb.GetAsync(userId); 121 | 122 | Resources.ObjectCache.CachePlayer(player); 123 | 124 | return player; 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Extensions/ChatStreamEntry.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic.Clan.StreamEntry; 2 | using BrawlStars.Utilities.Netty; 3 | using DotNetty.Buffers; 4 | using Newtonsoft.Json; 5 | 6 | namespace BrawlStars.Extensions 7 | { 8 | public class ChatStreamEntry : AllianceStreamEntry 9 | { 10 | public ChatStreamEntry() 11 | { 12 | StreamEntryType = 2; 13 | } 14 | 15 | [JsonProperty("msg")] public string Message { get; set; } 16 | 17 | public override void Encode(IByteBuffer packet) 18 | { 19 | base.Encode(packet); 20 | 21 | packet.WriteScString(Message); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/BrawlStars/Extensions/CustomWriter.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using DotNetty.Buffers; 3 | 4 | namespace BrawlStars.Extensions 5 | { 6 | /// 7 | /// This implements a few extensions for games from supercell 8 | /// 9 | public static class CustomWriter 10 | { 11 | /// 12 | /// Encodes CsvData 13 | /// 14 | /// 15 | /// 16 | public static void WriteData(this IByteBuffer buffer, Data value) 17 | { 18 | buffer.WriteInt(value.GetDataType()); 19 | buffer.WriteInt(value.GetInstanceId()); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Csv.Files.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using BrawlStars.Files.CsvHelpers; 4 | using BrawlStars.Files.CsvReader; 5 | using BrawlStars.Files.Logic; 6 | 7 | namespace BrawlStars.Files 8 | { 9 | public partial class Csv 10 | { 11 | public enum Files 12 | { 13 | Locales = 1, 14 | Globals = 3, 15 | Resources = 5, 16 | AllianceBadges = 8, 17 | Characters = 16, 18 | AreaEffects = 17, 19 | Items = 18, 20 | Skills = 20, 21 | Campaign = 21, 22 | Bosses = 22, 23 | Cards = 23, 24 | AllianceRoles = 25, 25 | Skins = 29, 26 | } 27 | 28 | public static Dictionary DataTypes = new Dictionary(); 29 | 30 | static Csv() 31 | { 32 | DataTypes.Add(Files.Locales, typeof(Locale)); 33 | DataTypes.Add(Files.Globals, typeof(Global)); 34 | DataTypes.Add(Files.Resources, typeof(Resource)); 35 | DataTypes.Add(Files.AllianceBadges, typeof(AllianceBadge)); 36 | DataTypes.Add(Files.Characters, typeof(Character)); 37 | DataTypes.Add(Files.AreaEffects, typeof(AreaEffect)); 38 | DataTypes.Add(Files.Items, typeof(Item)); 39 | DataTypes.Add(Files.Skills, typeof(Skill)); 40 | DataTypes.Add(Files.Campaign, typeof(Campaign)); 41 | DataTypes.Add(Files.Bosses, typeof(Bosses)); 42 | DataTypes.Add(Files.Cards, typeof(Card)); 43 | DataTypes.Add(Files.AllianceRoles, typeof(AllianceRole)); 44 | DataTypes.Add(Files.Skins, typeof(Skin)); 45 | } 46 | 47 | public static Data Create(Files file, Row row, DataTable dataTable) 48 | { 49 | if (DataTypes.ContainsKey(file)) return Activator.CreateInstance(DataTypes[file], row, dataTable) as Data; 50 | 51 | return null; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Csv.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using BrawlStars.Files.CsvReader; 4 | 5 | namespace BrawlStars.Files 6 | { 7 | public partial class Csv 8 | { 9 | public static readonly List Gamefiles = new List(); 10 | public static Gamefiles Tables; 11 | 12 | public Csv() 13 | { 14 | /*Gamefiles.Add("GameAssets/csv_logic/locales.csv"); 15 | Gamefiles.Add("GameAssets/csv_logic/globals.csv"); 16 | Gamefiles.Add("GameAssets/csv_logic/resources.csv"); 17 | Gamefiles.Add("GameAssets/csv_logic/alliance_badges.csv"); 18 | Gamefiles.Add("GameAssets/csv_logic/characters.csv"); 19 | Gamefiles.Add("GameAssets/csv_logic/area_effects.csv"); 20 | Gamefiles.Add("GameAssets/csv_logic/items.csv"); 21 | Gamefiles.Add("GameAssets/csv_logic/skills.csv"); 22 | Gamefiles.Add("GameAssets/csv_logic/campaign.csv"); 23 | Gamefiles.Add("GameAssets/csv_logic/bosses.csv"); 24 | Gamefiles.Add("GameAssets/csv_logic/cards.csv"); 25 | Gamefiles.Add("GameAssets/csv_logic/alliance_roles.csv"); 26 | Gamefiles.Add("GameAssets/csv_logic/skins.csv");*/ 27 | 28 | Tables = new Gamefiles(); 29 | 30 | Parallel.ForEach(Gamefiles, 31 | file => { Tables.Initialize(new Table(file), (Files) Gamefiles.IndexOf(file) + 1); }); 32 | 33 | Logger.Log($"{Gamefiles.Count} Gamefile(s) loaded.", GetType()); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/CsvHelpers/Data.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.CsvHelpers 5 | { 6 | public class Data 7 | { 8 | private int _dataType; 9 | private int _id; 10 | protected DataTable DataTable; 11 | protected Row Row; 12 | 13 | public Data(Row row, DataTable dataTable) 14 | { 15 | Row = row; 16 | DataTable = dataTable; 17 | } 18 | 19 | public void LoadData(Data data, Type type, Row row, int dataType = 0) 20 | { 21 | _dataType = dataType; 22 | _id = GlobalId.CreateGlobalId(_dataType, DataTable.Count()); 23 | Row = row; 24 | Row.LoadData(data); 25 | } 26 | 27 | public int GetDataType() 28 | { 29 | return _dataType; 30 | } 31 | 32 | public int GetGlobalId() 33 | { 34 | return _id; 35 | } 36 | 37 | public int GetInstanceId() 38 | { 39 | return GlobalId.GetInstanceId(_id); 40 | } 41 | 42 | public string GetName() 43 | { 44 | return Row.GetName(); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/CsvHelpers/DataTable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.CsvHelpers 5 | { 6 | public class DataTable 7 | { 8 | public List Datas; 9 | public Csv.Files Index; 10 | 11 | public DataTable() 12 | { 13 | Datas = new List(); 14 | } 15 | 16 | public DataTable(Table table, Csv.Files index) 17 | { 18 | Index = index; 19 | Datas = new List(); 20 | 21 | for (var i = 0; i < table.GetRowCount(); i += 2) 22 | { 23 | var row = table.GetRowAt(i); 24 | var data = Csv.Create(Index, row, this); 25 | Datas.Add(data); 26 | } 27 | } 28 | 29 | public int Count() 30 | { 31 | return Datas?.Count ?? 0; 32 | } 33 | 34 | public List GetDatas() 35 | { 36 | return Datas; 37 | } 38 | 39 | public Data GetDataWithId(int id) 40 | { 41 | return Datas[GlobalId.GetInstanceId(id)]; 42 | } 43 | 44 | public T GetDataWithId(int id) where T : Data 45 | { 46 | return Datas[GlobalId.GetInstanceId(id)] as T; 47 | } 48 | 49 | public T GetDataWithInstanceId(int id) where T : Data 50 | { 51 | if (Datas.Count < id) return null; 52 | 53 | return Datas[id] as T; 54 | } 55 | 56 | public T GetData(string name) where T : Data 57 | { 58 | return Datas.Find(data => data.GetName() == name) as T; 59 | } 60 | 61 | public int GetIndex() 62 | { 63 | return (int) Index; 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/CsvHelpers/GlobalId.cs: -------------------------------------------------------------------------------- 1 | namespace BrawlStars.Files.CsvHelpers 2 | { 3 | public static class GlobalId 4 | { 5 | public static int CreateGlobalId(int classId, int instanceId) 6 | { 7 | return classId <= 0 ? 1000000 + instanceId : classId * 1000000 + instanceId; 8 | } 9 | 10 | public static int GetClassId(int globalId) 11 | { 12 | return globalId / 1000000; 13 | } 14 | 15 | public static int GetInstanceId(int globalId) 16 | { 17 | return globalId % 1000000; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/CsvReader/Column.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace BrawlStars.Files.CsvReader 5 | { 6 | public class Column 7 | { 8 | private readonly List _values; 9 | 10 | public Column() 11 | { 12 | _values = new List(); 13 | } 14 | 15 | public static int GetArraySize(int offset, int nOffset) 16 | { 17 | return nOffset - offset; 18 | } 19 | 20 | public void Add(string value) 21 | { 22 | if (value == null) 23 | _values.Add(_values.Count > 0 ? _values.Last() : string.Empty); 24 | else 25 | _values.Add(value); 26 | } 27 | 28 | public string Get(int row) 29 | { 30 | return _values[row]; 31 | } 32 | 33 | public int GetSize() 34 | { 35 | return _values.Count; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/CsvReader/Gamefiles.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using BrawlStars.Files.CsvHelpers; 4 | 5 | namespace BrawlStars.Files.CsvReader 6 | { 7 | public class Gamefiles : IDisposable 8 | { 9 | private readonly List _dataTables = new List(); 10 | 11 | public Gamefiles() 12 | { 13 | if (Csv.Gamefiles.Count <= 0) return; 14 | 15 | for (var i = 0; i < Csv.Gamefiles.Count; i++) 16 | _dataTables.Add(new DataTable()); 17 | } 18 | 19 | public void Dispose() 20 | { 21 | _dataTables.Clear(); 22 | } 23 | 24 | public DataTable Get(Csv.Files index) 25 | { 26 | return _dataTables[(int) index - 1]; 27 | } 28 | 29 | public DataTable Get(int index) 30 | { 31 | return _dataTables[index - 1]; 32 | } 33 | 34 | public void Initialize(Table table, Csv.Files index) 35 | { 36 | _dataTables[(int) index - 1] = new DataTable(table, index); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/CsvReader/Table.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.VisualBasic.FileIO; 3 | 4 | namespace BrawlStars.Files.CsvReader 5 | { 6 | public class Table 7 | { 8 | private readonly List _columns; 9 | private readonly List _headers; 10 | private readonly List _rows; 11 | private readonly List _types; 12 | 13 | public Table(string path) 14 | { 15 | _rows = new List(); 16 | _headers = new List(); 17 | _types = new List(); 18 | _columns = new List(); 19 | 20 | using (var reader = new TextFieldParser(path)) 21 | { 22 | reader.SetDelimiters(","); 23 | 24 | var columns = reader.ReadFields(); 25 | 26 | foreach (var column in columns) 27 | { 28 | _headers.Add(column); 29 | _columns.Add(new Column()); 30 | } 31 | 32 | var types = reader.ReadFields(); 33 | 34 | foreach (var type in types) _types.Add(type); 35 | 36 | while (!reader.EndOfData) 37 | { 38 | var values = reader.ReadFields(); 39 | 40 | if (!string.IsNullOrEmpty(values[0])) AddRow(new Row(this)); 41 | 42 | for (var i = 0; i < _headers.Count; i++) _columns[i].Add(values[i]); 43 | } 44 | } 45 | } 46 | 47 | public void AddRow(Row row) 48 | { 49 | _rows.Add(row); 50 | } 51 | 52 | public int GetArraySizeAt(Row row, int columnIndex) 53 | { 54 | var index = _rows.IndexOf(row) + 1; 55 | if (index == -1) return 0; 56 | 57 | int nextOffset; 58 | if (index + 1 >= _rows.Count) 59 | { 60 | nextOffset = _columns[columnIndex].GetSize(); 61 | } 62 | else 63 | { 64 | var nextRow = _rows[index + 1]; 65 | nextOffset = nextRow.Offset; 66 | } 67 | 68 | return Column.GetArraySize(row.Offset, nextOffset); 69 | } 70 | 71 | public int GetColumnIndexByName(string name) 72 | { 73 | return _headers.IndexOf(name); 74 | } 75 | 76 | public string GetColumnName(int index) 77 | { 78 | return _headers[index]; 79 | } 80 | 81 | public int GetColumnRowCount() 82 | { 83 | return _columns.Count > 0 ? _columns[0].GetSize() : 0; 84 | } 85 | 86 | public Row GetRowAt(int index) 87 | { 88 | return _rows[index]; 89 | } 90 | 91 | public int GetRowCount() 92 | { 93 | return _rows.Count; 94 | } 95 | 96 | public string GetValue(string name, int level) 97 | { 98 | var index = _headers.IndexOf(name); 99 | return GetValueAt(index, level); 100 | } 101 | 102 | public string GetValueAt(int column, int row) 103 | { 104 | return _columns[column].Get(row); 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Fingerprint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Linq; 7 | 8 | namespace BrawlStars.Files 9 | { 10 | public class Fingerprint 11 | { 12 | public const string Path = "GameAssets/fingerprint.json"; 13 | 14 | public Fingerprint() 15 | { 16 | try 17 | { 18 | if (File.Exists(Path)) 19 | { 20 | Json = File.ReadAllText(Path); 21 | Files = new List(); 22 | 23 | var json = JObject.Parse(Json); 24 | { 25 | Sha = json["sha"].ToObject(); 26 | Version = json["version"].ToObject().Split('.').Select(int.Parse).ToArray(); 27 | 28 | foreach (var file in json["files"]) Files.Add(file.ToObject()); 29 | 30 | Logger.Log($"Fingerprint [v{GetVersion}] loaded.", 31 | GetType()); 32 | } 33 | } 34 | else 35 | { 36 | Console.WriteLine("The Fingerprint cannot be loaded, the file does not exist."); 37 | Program.Exit(); 38 | } 39 | } 40 | catch (Exception) 41 | { 42 | Console.WriteLine("Failed to load the Fingerprint."); 43 | Program.Exit(); 44 | } 45 | } 46 | 47 | [JsonIgnore] public string Json { get; set; } 48 | [JsonIgnore] public int[] Version { get; set; } 49 | 50 | [JsonIgnore] public int GetMajorVersion => Version?[0] ?? 3; 51 | [JsonIgnore] public int GetBuildVersion => Version?[1] ?? 377; 52 | [JsonIgnore] public int GetContentVersion => Version?[2] ?? 1; 53 | 54 | [JsonProperty("files")] public List Files { get; set; } 55 | [JsonProperty("sha")] public string Sha { get; set; } 56 | 57 | [JsonProperty("version")] 58 | public string GetVersion => $"{GetMajorVersion}.{GetBuildVersion}.{GetContentVersion}"; 59 | 60 | public void Save() 61 | { 62 | var json = JsonConvert.SerializeObject(this, new JsonSerializerSettings 63 | { 64 | DefaultValueHandling = DefaultValueHandling.Include, 65 | Formatting = Formatting.None 66 | }); 67 | 68 | Json = json.Replace("/", "\\/").TrimEnd(); 69 | 70 | File.WriteAllText(Path, Json); 71 | } 72 | } 73 | 74 | public class Asset 75 | { 76 | [JsonProperty("file")] public string File { get; set; } 77 | [JsonProperty("sha")] public string Sha { get; set; } 78 | } 79 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Files/GameEvents.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using System.Text.RegularExpressions; 5 | using BrawlStars.Logic; 6 | using Newtonsoft.Json; 7 | 8 | namespace BrawlStars.Files 9 | { 10 | internal static class GameEvents 11 | { 12 | internal static string Events_Json = string.Empty; 13 | internal static Calendar Events_Calendar = new Calendar(); 14 | internal static string JsonPath = "Gamefiles/events.json"; 15 | 16 | internal static void Initialize() 17 | { 18 | if (!Directory.Exists("Gamefiles/")) 19 | { 20 | throw new DirectoryNotFoundException("Directory Gamefiles does not exist!"); 21 | } 22 | 23 | if (!File.Exists(GameEvents.JsonPath)) 24 | { 25 | throw new Exception($"{GameEvents.JsonPath} does not exist in current directory!"); 26 | } 27 | 28 | GameEvents.Events_Json = Regex.Replace(File.ReadAllText(GameEvents.JsonPath, Encoding.UTF8), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); 29 | JsonConvert.PopulateObject(GameEvents.Events_Json, GameEvents.Events_Calendar); 30 | Console.WriteLine("Game Events successfully loaded and stored in memory."); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Accessorie.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Accessorie : Data 7 | { 8 | public Accessorie(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string Type { get; set; } 16 | 17 | public int ChargeCount { get; set; } 18 | 19 | public int Cooldown { get; set; } 20 | 21 | public string UseEffect { get; set; } 22 | 23 | public string LoopingEffect { get; set; } 24 | 25 | public int ActivationDelay { get; set; } 26 | 27 | public int ActiveTicks { get; set; } 28 | 29 | public bool StopMovement { get; set; } 30 | 31 | public bool SetAttackAngle { get; set; } 32 | 33 | public int AimGuideType { get; set; } 34 | 35 | public bool ConsumesAmmo { get; set; } 36 | 37 | public string AreaEffect { get; set; } 38 | 39 | public string PetAreaEffect { get; set; } 40 | 41 | public bool InterruptsAction { get; set; } 42 | 43 | public bool AllowStunActivation { get; set; } 44 | 45 | public bool RequirePet { get; set; } 46 | 47 | public bool DestroyPet { get; set; } 48 | 49 | public int RequireEnemyDistance { get; set; } 50 | 51 | public int ShieldPercent { get; set; } 52 | 53 | public int ShieldTicks { get; set; } 54 | 55 | public bool SkipTypeCondition { get; set; } 56 | 57 | public string CustomObject { get; set; } 58 | 59 | public int CustomValue1 { get; set; } 60 | 61 | public int CustomValue2 { get; set; } 62 | 63 | public int CustomValue3 { get; set; } 64 | 65 | public int CustomValue4 { get; set; } 66 | 67 | public int CustomValue5 { get; set; } 68 | 69 | public int CustomValue6 { get; set; } 70 | 71 | public string MissingTargetText { get; set; } 72 | 73 | public string TargetTooFarText { get; set; } 74 | 75 | public string TargetAlreadyActiveText { get; set; } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/AllianceBadge.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class AllianceBadge : Data 7 | { 8 | public AllianceBadge(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string IconSWF { get; set; } 16 | 17 | public string IconExportName { get; set; } 18 | 19 | public string Category { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/AllianceRole.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class AllianceRole : Data 7 | { 8 | public AllianceRole(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public int Level { get; set; } 16 | 17 | public string TID { get; set; } 18 | 19 | public bool CanInvite { get; set; } 20 | 21 | public bool CanSendMail { get; set; } 22 | 23 | public bool CanChangeAllianceSettings { get; set; } 24 | 25 | public bool CanAcceptJoinRequest { get; set; } 26 | 27 | public bool CanKick { get; set; } 28 | 29 | public bool CanBePromotedToLeader { get; set; } 30 | 31 | public int PromoteSkill { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/AreaEffect.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class AreaEffect : Data 7 | { 8 | public AreaEffect(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string ParentAreaEffectForSkin { get; set; } 16 | 17 | public string FileName { get; set; } 18 | 19 | public string OwnExportName { get; set; } 20 | 21 | public string BlueExportName { get; set; } 22 | 23 | public string RedExportName { get; set; } 24 | 25 | public string NeutralExportName { get; set; } 26 | 27 | public string Layer { get; set; } 28 | 29 | public string ExportNameTop { get; set; } 30 | 31 | public string ExportNameObject { get; set; } 32 | 33 | public string Effect { get; set; } 34 | 35 | public string LoopingEffect { get; set; } 36 | 37 | public bool AllowEffectInterrupt { get; set; } 38 | 39 | public bool ServerControlsFrame { get; set; } 40 | 41 | public int Scale { get; set; } 42 | 43 | public int TimeMs { get; set; } 44 | 45 | public int Radius { get; set; } 46 | 47 | public int Damage { get; set; } 48 | 49 | public int CustomValue { get; set; } 50 | 51 | public string Type { get; set; } 52 | 53 | public bool IsPersonal { get; set; } 54 | 55 | public string BulletExplosionBullet { get; set; } 56 | 57 | public int BulletExplosionBulletDistance { get; set; } 58 | 59 | public string BulletExplosionItem { get; set; } 60 | 61 | public bool DestroysEnvironment { get; set; } 62 | 63 | public int PushbackStrength { get; set; } 64 | 65 | public int PushbackStrengthSelf { get; set; } 66 | 67 | public int PushbackDeadzone { get; set; } 68 | 69 | public bool CanStopGrapple { get; set; } 70 | 71 | public int FreezeStrength { get; set; } 72 | 73 | public int FreezeTicks { get; set; } 74 | 75 | public bool ShouldShowEvenIfOutsideScreen { get; set; } 76 | 77 | public int SameAreaEffectCanNotDamageMs { get; set; } 78 | 79 | public bool DontShowToEnemy { get; set; } 80 | 81 | public bool RequireLineOfSight { get; set; } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Boss.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Bosses : Data 7 | { 8 | public Bosses(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string TID { get; set; } 16 | 17 | public int PlayerCount { get; set; } 18 | 19 | public int RequiredCampaignProgressToUnlock { get; set; } 20 | 21 | public string Location { get; set; } 22 | 23 | public string AllowedHeroes { get; set; } 24 | 25 | public string Reward { get; set; } 26 | 27 | public int LevelGenerationSeed { get; set; } 28 | 29 | public string Map { get; set; } 30 | 31 | public string Boss { get; set; } 32 | 33 | public int BossLevel { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Campaign.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Campaign : Data 7 | { 8 | public Campaign(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string TID { get; set; } 16 | 17 | public string Location { get; set; } 18 | 19 | public string AllowedHeroes { get; set; } 20 | 21 | public string Reward { get; set; } 22 | 23 | public int LevelGenerationSeed { get; set; } 24 | 25 | public string Map { get; set; } 26 | 27 | public string Enemies { get; set; } 28 | 29 | public int EnemyLevel { get; set; } 30 | 31 | public string Boss { get; set; } 32 | 33 | public int BossLevel { get; set; } 34 | 35 | public string Base { get; set; } 36 | 37 | public int NumBases { get; set; } 38 | 39 | public int BaseLevel { get; set; } 40 | 41 | public string Tower { get; set; } 42 | 43 | public int NumTowers { get; set; } 44 | 45 | public int TowerLevel { get; set; } 46 | 47 | public int RequiredStars { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Card.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Card : Data 7 | { 8 | public Card(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string IconSWF { get; set; } 16 | 17 | public string IconExportName { get; set; } 18 | 19 | public string Target { get; set; } 20 | 21 | public bool LockedForChronos { get; set; } 22 | 23 | public int DynamicRarityStartSeason { get; set; } 24 | 25 | public int MetaType { get; set; } 26 | 27 | public string RequiresCard { get; set; } 28 | 29 | public string Type { get; set; } 30 | 31 | public string Skill { get; set; } 32 | 33 | public int Value { get; set; } 34 | 35 | public int Value2 { get; set; } 36 | 37 | public int Value3 { get; set; } 38 | 39 | public string Rarity { get; set; } 40 | 41 | public string TID { get; set; } 42 | 43 | public string PowerNumberTID { get; set; } 44 | 45 | public string PowerNumber2TID { get; set; } 46 | 47 | public string PowerNumber3TID { get; set; } 48 | 49 | public string PowerIcon1ExportName { get; set; } 50 | 51 | public string PowerIcon2ExportName { get; set; } 52 | 53 | public int SortOrder { get; set; } 54 | 55 | public bool DontUpgradeStat { get; set; } 56 | 57 | public bool HideDamageStat { get; set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Challenge.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Challenge : Data 7 | { 8 | public Challenge(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public int ChallengeId { get; set; } 16 | 17 | public string FileName { get; set; } 18 | 19 | public string EventAsset { get; set; } 20 | 21 | public string BannerSWF { get; set; } 22 | 23 | public string EventBanner { get; set; } 24 | 25 | public string RewardItem { get; set; } 26 | 27 | public string RewardUnlockedItem { get; set; } 28 | 29 | public string HeaderFrame { get; set; } 30 | 31 | public string TID { get; set; } 32 | 33 | public string StageTID { get; set; } 34 | 35 | public string RewardTID { get; set; } 36 | 37 | public string CompletedTID { get; set; } 38 | 39 | public string RewardPopupTID { get; set; } 40 | 41 | public string BattleEndHeaderTID { get; set; } 42 | 43 | public string BattleEndWinLabelTID { get; set; } 44 | 45 | public string BattleEndWinTID { get; set; } 46 | 47 | public string StartNotification { get; set; } 48 | 49 | public string ReminderNotification { get; set; } 50 | 51 | public string TeaserTitleTID { get; set; } 52 | 53 | public string TeaserInfoTID { get; set; } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Emote.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Emote : Data 7 | { 8 | public Emote(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public bool Disabled { get; set; } 16 | 17 | public string FileName { get; set; } 18 | 19 | public string ExportName { get; set; } 20 | 21 | public string Character { get; set; } 22 | 23 | public string Skin { get; set; } 24 | 25 | public int Type { get; set; } 26 | 27 | public int Rarity { get; set; } 28 | 29 | public bool LockedForChronos { get; set; } 30 | 31 | public int BundleCode { get; set; } 32 | 33 | public bool IsDefaultBattleEmote { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/GameModeVariations.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class GameModeVariation : Data 7 | { 8 | public GameModeVariation(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public int Variation { get; set; } 16 | 17 | public bool Disabled { get; set; } 18 | 19 | public string TID { get; set; } 20 | 21 | public string ChatSuggestionItemName { get; set; } 22 | 23 | public string GameModeRoomIconName { get; set; } 24 | 25 | public string GameModeIconName { get; set; } 26 | 27 | public string ScoreSfx { get; set; } 28 | 29 | public string OpponentScoreSfx { get; set; } 30 | 31 | public string ScoreText { get; set; } 32 | 33 | public string ScoreTextEnd { get; set; } 34 | 35 | public int FriendlyMenuOrder { get; set; } 36 | 37 | public string IntroText { get; set; } 38 | 39 | public string IntroDescText { get; set; } 40 | 41 | public string IntroDescText2 { get; set; } 42 | 43 | public string StartNotification { get; set; } 44 | 45 | public string EndNotification { get; set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Global.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Global : Data 7 | { 8 | public Global(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public int NumberValue { get; set; } 16 | 17 | public bool BooleanValue { get; set; } 18 | 19 | public string TextValue { get; set; } 20 | 21 | public string[] StringArray { get; set; } 22 | 23 | public int[] NumberArray { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Item.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Item : Data 7 | { 8 | public Item(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string ParentItemForSkin { get; set; } 16 | 17 | public string FileName { get; set; } 18 | 19 | public string ExportName { get; set; } 20 | 21 | public string ExportNameEnemy { get; set; } 22 | 23 | public string ShadowExportName { get; set; } 24 | 25 | public string GroundGlowExportName { get; set; } 26 | 27 | public string LoopingEffect { get; set; } 28 | 29 | public int Value { get; set; } 30 | 31 | public int Value2 { get; set; } 32 | 33 | public int TriggerRangeSubTiles { get; set; } 34 | 35 | public string TriggerAreaEffect { get; set; } 36 | 37 | public bool CanBePickedUp { get; set; } 38 | 39 | public string SpawnEffect { get; set; } 40 | 41 | public string ActivateEffect { get; set; } 42 | 43 | public string SCW { get; set; } 44 | 45 | public string SCWEnemy { get; set; } 46 | 47 | public string Layer { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Locale.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Locale : Data 7 | { 8 | public Locale(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string IconSWF { get; set; } 16 | 17 | public string IconExportName { get; set; } 18 | 19 | public string LocalizedName { get; set; } 20 | 21 | public int SortOrder { get; set; } 22 | 23 | public bool Enabled { get; set; } 24 | 25 | public string FileName { get; set; } 26 | 27 | public bool TestLanguage { get; set; } 28 | 29 | public string UsedSystemFont { get; set; } 30 | 31 | public string PreferedFallbackFont { get; set; } 32 | 33 | public string ForcedFontFullName { get; set; } 34 | 35 | public string HelpshiftSDKLanguage { get; set; } 36 | 37 | public string HelpshiftSDKLanguageAndroid { get; set; } 38 | 39 | public string[] TestExcludes { get; set; } 40 | 41 | public bool LoadAllLanguages { get; set; } 42 | 43 | public string ChampionshipRegisterUrl { get; set; } 44 | 45 | public string ChampionshipRegisterUrl_cn { get; set; } 46 | 47 | public string TermsAndServiceUrl { get; set; } 48 | 49 | public string ParentsGuideUrl { get; set; } 50 | 51 | public string PrivacyPolicyUrl { get; set; } 52 | 53 | public string LaserboxUrl { get; set; } 54 | 55 | public string LaserboxUrlCN { get; set; } 56 | 57 | public string LaserboxStagingUrl { get; set; } 58 | 59 | public string LaserboxStagingUrlCN { get; set; } 60 | 61 | public string LaserboxCommunityUrl { get; set; } 62 | 63 | public string LaserboxCommunityUrlCN { get; set; } 64 | 65 | public string LaserboxCommunityStagingUrl { get; set; } 66 | 67 | public string LaserboxCommunityStagingUrlCN { get; set; } 68 | 69 | public string LaserboxLangCode { get; set; } 70 | 71 | public string FaqUrl_ios { get; set; } 72 | 73 | public string FaqUrl_ios_cn { get; set; } 74 | 75 | public string FaqUrl_android { get; set; } 76 | 77 | public string FaqUrl_android_cn { get; set; } 78 | 79 | public string ContactUsUrl_ios { get; set; } 80 | 81 | public string ContactUsUrl_ios_cn { get; set; } 82 | 83 | public string ContactUsUrl_android { get; set; } 84 | 85 | public string ContactUsUrl_android_cn { get; set; } 86 | 87 | public bool LaserboxEnabled { get; set; } 88 | 89 | public bool IsRTL { get; set; } 90 | 91 | public bool isNounAdj { get; set; } 92 | 93 | public bool SeparateThousandsWithSpaces { get; set; } 94 | 95 | public string SelfHelpUrl { get; set; } 96 | 97 | public bool FallbackToHelpshift { get; set; } 98 | 99 | public bool FallbackToHelpshiftCN { get; set; } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Resource.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Resource : Data 7 | { 8 | public Resource(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string TID { get; set; } 16 | 17 | public string IconSWF { get; set; } 18 | 19 | public string CollectEffect { get; set; } 20 | 21 | public string IconExportName { get; set; } 22 | 23 | public string Type { get; set; } 24 | 25 | public string Rarity { get; set; } 26 | 27 | public bool PremiumCurrency { get; set; } 28 | 29 | public int TextRed { get; set; } 30 | 31 | public int TextGreen { get; set; } 32 | 33 | public int TextBlue { get; set; } 34 | 35 | public int Cap { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Skill.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Skill : Data 7 | { 8 | public Skill(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string BehaviorType { get; set; } 16 | 17 | public bool CanMoveAtSameTime { get; set; } 18 | 19 | public bool Targeted { get; set; } 20 | 21 | public bool CanAutoShoot { get; set; } 22 | 23 | public bool FaceMovement { get; set; } 24 | 25 | public int Cooldown { get; set; } 26 | 27 | public int ActiveTime { get; set; } 28 | 29 | public int CastingTime { get; set; } 30 | 31 | public int CastingRange { get; set; } 32 | 33 | public int RangeVisual { get; set; } 34 | 35 | public int RangeInputScale { get; set; } 36 | 37 | public int MaxCastingRange { get; set; } 38 | 39 | public int ForceValidTile { get; set; } 40 | 41 | public int RechargeTime { get; set; } 42 | 43 | public int MaxCharge { get; set; } 44 | 45 | public int Damage { get; set; } 46 | 47 | public int MsBetweenAttacks { get; set; } 48 | 49 | public int Spread { get; set; } 50 | 51 | public int AttackPattern { get; set; } 52 | 53 | public int NumBulletsInOneAttack { get; set; } 54 | 55 | public bool TwoGuns { get; set; } 56 | 57 | public bool ExecuteFirstAttackImmediately { get; set; } 58 | 59 | public int ChargePushback { get; set; } 60 | 61 | public int ChargeSpeed { get; set; } 62 | 63 | public int ChargeType { get; set; } 64 | 65 | public int NumSpawns { get; set; } 66 | 67 | public int MaxSpawns { get; set; } 68 | 69 | public bool BreakInvisibilityOnAttack { get; set; } 70 | 71 | public int SeeInvisibilityDistance { get; set; } 72 | 73 | public bool AlwaysCastAtMaxRange { get; set; } 74 | 75 | public string Projectile { get; set; } 76 | 77 | public string SummonedCharacter { get; set; } 78 | 79 | public string AreaEffectObject { get; set; } 80 | 81 | public string AreaEffectObject2 { get; set; } 82 | 83 | public string SpawnedItem { get; set; } 84 | 85 | public string IconSWF { get; set; } 86 | 87 | public string IconExportName { get; set; } 88 | 89 | public string LargeIconSWF { get; set; } 90 | 91 | public string LargeIconExportName { get; set; } 92 | 93 | public string ButtonSWF { get; set; } 94 | 95 | public string ButtonExportName { get; set; } 96 | 97 | public string AttackEffect { get; set; } 98 | 99 | public string UseEffect { get; set; } 100 | 101 | public string EndEffect { get; set; } 102 | 103 | public string LoopEffect { get; set; } 104 | 105 | public string LoopEffect2 { get; set; } 106 | 107 | public string ChargeMoveSound { get; set; } 108 | 109 | public bool MultiShot { get; set; } 110 | 111 | public bool SkillCanChange { get; set; } 112 | 113 | public bool ShowTimerBar { get; set; } 114 | 115 | public string SecondaryProjectile { get; set; } 116 | 117 | public int ChargedShotCount { get; set; } 118 | 119 | public int DamageModifier { get; set; } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Source/BrawlStars/Files/Logic/Skin.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Files.CsvHelpers; 2 | using BrawlStars.Files.CsvReader; 3 | 4 | namespace BrawlStars.Files.Logic 5 | { 6 | public class Skin : Data 7 | { 8 | public Skin(Row row, DataTable datatable) : base(row, datatable) 9 | { 10 | LoadData(this, GetType(), row); 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public string Conf { get; set; } 16 | 17 | public int Campaign { get; set; } 18 | 19 | public int ObtainType { get; set; } 20 | 21 | public int ObtainTypeCN { get; set; } 22 | 23 | public string PetSkin { get; set; } 24 | 25 | public string PetSkin2 { get; set; } 26 | 27 | public int CostLegendaryTrophies { get; set; } 28 | 29 | public int CostGems { get; set; } 30 | 31 | public string TID { get; set; } 32 | 33 | public string ShopTID { get; set; } 34 | 35 | public string Features { get; set; } 36 | 37 | public string CommunityCredit { get; set; } 38 | 39 | public string MaterialsFile { get; set; } 40 | 41 | public string BlueTexture { get; set; } 42 | 43 | public string RedTexture { get; set; } 44 | 45 | public string BlueSpecular { get; set; } 46 | 47 | public string RedSpecular { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Source/BrawlStars/GameAssets/database.sql: -------------------------------------------------------------------------------- 1 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 2 | SET time_zone = "+00:00"; 3 | 4 | CREATE TABLE IF NOT EXISTS `player` ( 5 | `Id` bigint(20) NOT NULL, 6 | `Trophies` bigint(20) NOT NULL, 7 | `Language` text CHARACTER SET utf8mb4 NOT NULL, 8 | `FacebookId` text CHARACTER SET utf8mb4, 9 | `Home` text CHARACTER SET utf8mb4 NOT NULL, 10 | `Sessions` text CHARACTER SET utf8mb4 NOT NULL, 11 | PRIMARY KEY (`Id`) 12 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 13 | 14 | CREATE TABLE IF NOT EXISTS `clan` ( 15 | `Id` bigint(20) NOT NULL, 16 | `Trophies` bigint(20) NOT NULL, 17 | `RequiredTrophies` bigint(20) NOT NULL, 18 | `Type` bigint(20) NOT NULL, 19 | `Region` text CHARACTER SET utf8mb4 NOT NULL, 20 | `Data` text CHARACTER SET utf8mb4 NOT NULL, 21 | PRIMARY KEY (`Id`) 22 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -------------------------------------------------------------------------------- /Source/BrawlStars/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using NLog; 4 | 5 | namespace BrawlStars 6 | { 7 | public class Logger 8 | { 9 | public enum ErrorLevel 10 | { 11 | Info = 1, 12 | Warning = 2, 13 | Error = 3, 14 | Debug = 4 15 | } 16 | #if DEBUG 17 | private static readonly object ConsoleSync = new object(); 18 | #endif 19 | 20 | private static NLog.Logger _logger; 21 | 22 | public Logger() 23 | { 24 | Directory.CreateDirectory("Logs"); 25 | 26 | _logger = LogManager.GetCurrentClassLogger(); 27 | } 28 | 29 | public static void Log(object message, Type type, ErrorLevel logType = ErrorLevel.Info) 30 | { 31 | switch (logType) 32 | { 33 | case ErrorLevel.Info: 34 | { 35 | _logger.Info(message); 36 | 37 | Console.ForegroundColor = ConsoleColor.DarkYellow; 38 | Console.Write($"[{logType.ToString()}] "); 39 | Console.ResetColor(); 40 | Console.WriteLine(message); 41 | break; 42 | } 43 | 44 | case ErrorLevel.Warning: 45 | { 46 | _logger.Warn(message); 47 | #if DEBUG 48 | lock (ConsoleSync) 49 | { 50 | Console.ForegroundColor = ConsoleColor.DarkMagenta; 51 | Console.Write($"[{logType.ToString()}] "); 52 | Console.ResetColor(); 53 | Console.WriteLine(message); 54 | } 55 | #endif 56 | break; 57 | } 58 | 59 | case ErrorLevel.Error: 60 | { 61 | _logger.Error(message); 62 | #if DEBUG 63 | 64 | lock (ConsoleSync) 65 | { 66 | Console.ForegroundColor = ConsoleColor.Red; 67 | Console.Write($"[{logType.ToString()}] "); 68 | Console.ResetColor(); 69 | Console.WriteLine(message); 70 | } 71 | #endif 72 | break; 73 | } 74 | 75 | case ErrorLevel.Debug: 76 | { 77 | #if DEBUG 78 | _logger.Debug(message); 79 | 80 | lock (ConsoleSync) 81 | { 82 | Console.ForegroundColor = ConsoleColor.Green; 83 | Console.Write($"[{logType.ToString()}] "); 84 | Console.ResetColor(); 85 | Console.WriteLine(message); 86 | } 87 | #endif 88 | break; 89 | } 90 | } 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Brawler.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic 5 | { 6 | internal class Brawler 7 | { 8 | [JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)] internal string name = string.Empty; 9 | 10 | [JsonProperty("skin", DefaultValueHandling = DefaultValueHandling.Ignore)] internal string Skin = string.Empty; 11 | 12 | [JsonProperty("hassSkin")] internal bool HassSkin; 13 | 14 | [JsonProperty("trophies")] internal int Trophies; 15 | 16 | [JsonProperty("highestTrophies")] internal int HighestTrophies; 17 | 18 | [JsonProperty("power")] internal int Power; 19 | 20 | [JsonProperty("rank")] internal int rank; 21 | } 22 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Calendar.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic 5 | { 6 | internal class Calendar 7 | { 8 | [JsonProperty("events")] internal List Events = new List(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Clan/AllianceInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic.Clan 5 | { 6 | public class AllianceInfo 7 | { 8 | [JsonProperty("name")] public string Name { get; set; } 9 | [JsonProperty("highId")] public int HighId { get; set; } 10 | [JsonProperty("lowId")] public int LowId { get; set; } 11 | [JsonProperty("badge")] public int Badge { get; set; } 12 | [JsonProperty("role")] public int Role { get; set; } 13 | 14 | [JsonIgnore] public bool HasAlliance => Id > 0; 15 | 16 | [JsonIgnore] 17 | public long Id 18 | { 19 | get => ((long) HighId << 32) | (LowId & 0xFFFFFFFFL); 20 | set 21 | { 22 | HighId = Convert.ToInt32(value >> 32); 23 | LowId = (int) value; 24 | } 25 | } 26 | 27 | public void Reset() 28 | { 29 | Id = 0; 30 | Name = string.Empty; 31 | Badge = 0; 32 | Role = 0; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Clan/AllianceMember.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using DotNetty.Buffers; 4 | using Newtonsoft.Json; 5 | 6 | namespace BrawlStars.Logic.Clan 7 | { 8 | public class AllianceMember 9 | { 10 | public AllianceMember(Player player, Alliance.Role role) 11 | { 12 | Id = player.Home.Id; 13 | Role = (int) role; 14 | Score = player.Home.Trophies; 15 | Name = player.Home.Name; 16 | } 17 | 18 | public AllianceMember() 19 | { 20 | // ... 21 | } 22 | 23 | [JsonProperty("highId")] public int HighId { get; set; } 24 | [JsonProperty("lowId")] public int LowId { get; set; } 25 | [JsonProperty("role")] public int Role { get; set; } 26 | [JsonProperty("score")] public int Score { get; set; } 27 | [JsonProperty("name")] public string Name { get; set; } 28 | [JsonProperty("donations")] public int Donations { get; set; } 29 | [JsonProperty("donationsReceived")] public int DonationsReceived { get; set; } 30 | 31 | [JsonIgnore] 32 | public long Id 33 | { 34 | get => ((long) HighId << 32) | (LowId & 0xFFFFFFFFL); 35 | set 36 | { 37 | HighId = Convert.ToInt32(value >> 32); 38 | LowId = (int) value; 39 | } 40 | } 41 | 42 | [JsonIgnore] public bool IsOnline => Resources.Players.ContainsKey(Id); 43 | 44 | public void AllianceMemberEntry(IByteBuffer packet) 45 | { 46 | // TODO 47 | } 48 | 49 | public async Task GetPlayerAsync(bool onlineOnly = false) 50 | { 51 | return await Resources.Players.GetPlayerAsync(Id, onlineOnly); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Clan/StreamEntry/AllianceStreamEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DotNetty.Buffers; 3 | using Newtonsoft.Json; 4 | 5 | namespace BrawlStars.Logic.Clan.StreamEntry 6 | { 7 | public class AllianceStreamEntry 8 | { 9 | [JsonProperty("creation")] public DateTime CreationDateTime = DateTime.UtcNow; 10 | [JsonProperty("id")] public int Id { get; set; } 11 | [JsonProperty("type")] public int StreamEntryType { get; set; } 12 | [JsonProperty("highId")] public int SenderHighId { get; set; } 13 | [JsonProperty("lowId")] public int SenderLowId { get; set; } 14 | [JsonProperty("sender_name")] public string SenderName { get; set; } 15 | [JsonProperty("sender_role")] public int SenderRole { get; set; } 16 | [JsonProperty("removed")] public bool IsRemoved { get; set; } 17 | 18 | [JsonIgnore] public int AgeSeconds => (int) (DateTime.UtcNow - CreationDateTime).TotalSeconds; 19 | 20 | [JsonIgnore] 21 | public long SenderId 22 | { 23 | get => ((long) SenderHighId << 32) | (SenderLowId & 0xFFFFFFFFL); 24 | set 25 | { 26 | SenderHighId = Convert.ToInt32(value >> 32); 27 | SenderLowId = (int) value; 28 | } 29 | } 30 | 31 | public virtual void Encode(IByteBuffer packet) 32 | { 33 | // TODO 34 | } 35 | 36 | public virtual void SetSender(Player player) 37 | { 38 | SenderName = player.Home.Name; 39 | SenderId = player.Home.Id; 40 | SenderRole = player.Home.AllianceInfo.Role; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Clan/StreamEntry/Entries/AllianceEventStreamEntry.cs: -------------------------------------------------------------------------------- 1 | using DotNetty.Buffers; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic.Clan.StreamEntry.Entries 5 | { 6 | public class AllianceEventStreamEntry : AllianceStreamEntry 7 | { 8 | public enum Type 9 | { 10 | Kick = 1, 11 | Accepted = 2, 12 | Join = 3, 13 | Leave = 4, 14 | Promote = 5, 15 | Demote = 6 16 | } 17 | 18 | public AllianceEventStreamEntry() 19 | { 20 | StreamEntryType = 4; 21 | } 22 | 23 | [JsonProperty("eventType")] public Type EventType { get; set; } 24 | [JsonProperty("targetHighId")] public int TargetHighId { get; set; } 25 | [JsonProperty("targetLowId")] public int TargetLowId { get; set; } 26 | [JsonProperty("targetName")] public string TargetName { get; set; } 27 | 28 | public override void Encode(IByteBuffer packet) 29 | { 30 | base.Encode(packet); 31 | 32 | // TODO 33 | } 34 | 35 | public void SetTarget(Player target) 36 | { 37 | TargetHighId = target.Home.HighId; 38 | TargetLowId = target.Home.LowId; 39 | TargetName = target.Home.Name; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Clan/StreamEntry/Entries/ChallengeStreamEntry.cs: -------------------------------------------------------------------------------- 1 | using DotNetty.Buffers; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic.Clan.StreamEntry.Entries 5 | { 6 | public class ChallengeStreamEntry : AllianceStreamEntry 7 | { 8 | public ChallengeStreamEntry() 9 | { 10 | StreamEntryType = 10; 11 | } 12 | 13 | [JsonProperty("msg")] public string Message { get; set; } 14 | [JsonProperty("sender_score")] public int SenderScore { get; set; } 15 | [JsonProperty("arena")] public int Arena { get; set; } 16 | [JsonProperty("closed")] public bool Closed { get; set; } 17 | [JsonProperty("active")] public bool Active { get; set; } 18 | [JsonProperty("target_name")] public string TargetName { get; set; } 19 | 20 | [JsonIgnore] public int Spectators { get; set; } 21 | 22 | public override void Encode(IByteBuffer packet) 23 | { 24 | base.Encode(packet); 25 | 26 | // TODO 27 | } 28 | 29 | public void SetTarget(Player target) 30 | { 31 | TargetName = target.Home.Name; 32 | } 33 | 34 | public override void SetSender(Player player) 35 | { 36 | base.SetSender(player); 37 | 38 | SenderScore = player.Home.Trophies; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Clan/StreamEntry/Entries/ChatStreamEntry.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Utilities.Netty; 2 | using DotNetty.Buffers; 3 | using Newtonsoft.Json; 4 | 5 | namespace BrawlStars.Logic.Clan.StreamEntry.Entries 6 | { 7 | public class ChatStreamEntry : AllianceStreamEntry 8 | { 9 | public ChatStreamEntry() 10 | { 11 | StreamEntryType = 2; 12 | } 13 | 14 | [JsonProperty("msg")] public string Message { get; set; } 15 | 16 | public override void Encode(IByteBuffer packet) 17 | { 18 | base.Encode(packet); 19 | 20 | packet.WriteScString(Message); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Clan/StreamEntry/Entries/DonateStreamEntry.cs: -------------------------------------------------------------------------------- 1 | using DotNetty.Buffers; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic.Clan.StreamEntry.Entries 5 | { 6 | public class DonateStreamEntry : AllianceStreamEntry 7 | { 8 | public DonateStreamEntry() 9 | { 10 | StreamEntryType = 1; 11 | } 12 | 13 | [JsonProperty("msg")] public string Message { get; set; } 14 | [JsonProperty("totalCapacity")] public int TotalCapacity { get; set; } 15 | [JsonProperty("usedCapacity")] public int UsedCapacity { get; set; } 16 | 17 | public override void Encode(IByteBuffer packet) 18 | { 19 | base.Encode(packet); 20 | 21 | // TODO 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Clan/StreamEntry/Entries/JoinRequestAllianceStreamEntry.cs: -------------------------------------------------------------------------------- 1 | using DotNetty.Buffers; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic.Clan.StreamEntry.Entries 5 | { 6 | public class JoinRequestAllianceStreamEntry : AllianceStreamEntry 7 | { 8 | public JoinRequestAllianceStreamEntry() 9 | { 10 | StreamEntryType = 3; 11 | } 12 | 13 | [JsonProperty("msg")] public string Message { get; set; } 14 | [JsonProperty("responder_name")] public string ResponderName { get; set; } 15 | [JsonProperty("state")] public int State { get; set; } 16 | 17 | public override void Encode(IByteBuffer packet) 18 | { 19 | base.Encode(packet); 20 | 21 | // TODO 22 | } 23 | 24 | public void SetTarget(Player target) 25 | { 26 | ResponderName = target.Home.Name; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Events.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace BrawlStars.Logic 6 | { 7 | internal class Event 8 | { 9 | [JsonProperty("boomboxEntry")] internal string BoomBoxEntry = string.Empty; 10 | 11 | [JsonProperty("endTime")] internal string EndTime = DateTime.UtcNow.ToString(); 12 | 13 | [JsonProperty("eventEntryName")] internal string EventEntryName = string.Empty; 14 | 15 | [JsonProperty("functions")] internal List Functions = new List(); 16 | [JsonProperty("id")] internal int ID; 17 | 18 | [JsonProperty("image", DefaultValueHandling = DefaultValueHandling.Ignore)] 19 | internal string Image = string.Empty; 20 | 21 | [JsonProperty("inboxEntryId")] internal int InboxEntryID; 22 | 23 | [JsonProperty("localization", DefaultValueHandling = DefaultValueHandling.Ignore)] 24 | internal string Localization = string.Empty; 25 | 26 | [JsonProperty("name")] internal string Name = string.Empty; 27 | 28 | [JsonProperty("notification", DefaultValueHandling = DefaultValueHandling.Ignore)] 29 | internal string Notification = string.Empty; 30 | 31 | [JsonProperty("sc", DefaultValueHandling = DefaultValueHandling.Ignore)] 32 | internal string SCFile = string.Empty; 33 | 34 | [JsonProperty("showUpcoming")] internal int ShowUpcoming = 1; 35 | 36 | [JsonProperty("startTime")] internal string StarTime = DateTime.UtcNow.ToString(); 37 | 38 | [JsonProperty("visibleTime")] internal string VisibleTime = DateTime.UtcNow.ToString(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Functions.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace BrawlStars.Logic 4 | { 5 | internal class Functions 6 | { 7 | [JsonProperty("name")] internal string Name = string.Empty; 8 | 9 | [JsonProperty("parameters")] internal string[] Parameters; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Home/Slots/DataSlots.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using BrawlStars.Logic.Home.Slots.Items; 3 | using DotNetty.Buffers; 4 | 5 | namespace BrawlStars.Logic.Home.Slots 6 | { 7 | public class DataSlots : List 8 | { 9 | /// 10 | /// Add a new dataslot or replace it 11 | /// 12 | /// 13 | /// 14 | public void Set(int id, int count) 15 | { 16 | var index = FindIndex(x => x.Id == id); 17 | if (index > -1) 18 | { 19 | var dataslot = this[index]; 20 | dataslot.Count = count; 21 | } 22 | else 23 | { 24 | Add(new DataSlot 25 | { 26 | Id = id, 27 | Count = count 28 | }); 29 | } 30 | } 31 | 32 | /// 33 | /// Add or create a new dataslot 34 | /// 35 | /// 36 | /// 37 | public void Add(int id, int count) 38 | { 39 | var index = FindIndex(x => x.Id == id); 40 | if (index > -1) 41 | { 42 | var dataslot = this[index]; 43 | dataslot.Count += count; 44 | } 45 | else 46 | { 47 | Add(new DataSlot 48 | { 49 | Id = id, 50 | Count = count 51 | }); 52 | } 53 | } 54 | 55 | /// 56 | /// Remove from a dataslot 57 | /// 58 | /// 59 | /// 60 | public void Remove(int id, int count) 61 | { 62 | var index = FindIndex(x => x.Id == id); 63 | if (index > -1) 64 | { 65 | var dataslot = this[index]; 66 | dataslot.Count -= count; 67 | } 68 | } 69 | 70 | /// 71 | /// Get the count of a dataslot by it's id 72 | /// 73 | /// 74 | /// 75 | public int GetCount(int id) 76 | { 77 | var index = FindIndex(x => x.Id == id); 78 | return index > -1 ? this[index].Count : 0; 79 | } 80 | 81 | /// 82 | /// Get a dataslot by it's id 83 | /// 84 | /// 85 | /// 86 | public DataSlot GetById(int id) 87 | { 88 | var index = FindIndex(x => x.Id == id); 89 | return index > -1 ? this[index] : null; 90 | } 91 | 92 | /// 93 | /// Encodes all dataslots 94 | /// 95 | /// 96 | public void Encode(IByteBuffer buffer) 97 | { 98 | buffer.WriteInt(Count); 99 | ForEach(x => x.Encode(buffer)); 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Home/Slots/Items/DataSlot.cs: -------------------------------------------------------------------------------- 1 | using DotNetty.Buffers; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic.Home.Slots.Items 5 | { 6 | public class DataSlot 7 | { 8 | [JsonProperty("id")] public int Id { get; set; } 9 | [JsonProperty("cnt")] public int Count { get; set; } 10 | 11 | /// 12 | /// Encodes this dataslot 13 | /// 14 | /// 15 | public virtual void Encode(IByteBuffer buffer) 16 | { 17 | buffer.WriteInt(Id); 18 | buffer.WriteInt(Count); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Home/Slots/ResourceSlots.cs: -------------------------------------------------------------------------------- 1 | namespace BrawlStars.Logic.Home.Slots 2 | { 3 | public class ResourceSlots : DataSlots 4 | { 5 | /// 6 | /// Sets the default resources to this dataslots 7 | /// 8 | public void InitializeDefault() 9 | { 10 | Set(5000001, 100); // Gold 11 | Set(5000002, 0); // owcAny 12 | Set(5000003, 0); // DarkElixir 13 | 14 | Set(5000007, 1000); // Dust 15 | Set(5000008, 1000); // Upgradium 16 | } 17 | 18 | /// 19 | /// Sets the max resources to this dataslots 20 | /// 21 | public void Initialize() 22 | { 23 | Set(5000001, 1000000000); 24 | Set(5000002, 1000000000); 25 | Set(5000003, 10000000); 26 | 27 | Set(5000007, 1000000000); 28 | Set(5000008, 1000000000); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Home/StreamEntry/AvatarStreamEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DotNetty.Buffers; 3 | using Newtonsoft.Json; 4 | 5 | namespace BrawlStars.Logic.Home.StreamEntry 6 | { 7 | public class AvatarStreamEntry 8 | { 9 | [JsonProperty("creation")] public DateTime CreationDateTime = DateTime.UtcNow; 10 | [JsonProperty("id")] public int Id { get; set; } 11 | [JsonProperty("type")] public int StreamEntryType { get; set; } 12 | [JsonProperty("highId")] public int SenderHighId { get; set; } 13 | [JsonProperty("lowId")] public int SenderLowId { get; set; } 14 | [JsonProperty("sender_name")] public string SenderName { get; set; } 15 | [JsonProperty("removed")] public bool IsRemoved { get; set; } 16 | [JsonProperty("new")] public bool IsNew { get; set; } 17 | 18 | [JsonIgnore] public int AgeSeconds => (int) (DateTime.UtcNow - CreationDateTime).TotalSeconds; 19 | 20 | [JsonIgnore] 21 | public long SenderId 22 | { 23 | get => ((long) SenderHighId << 32) | (SenderLowId & 0xFFFFFFFFL); 24 | set 25 | { 26 | SenderHighId = Convert.ToInt32(value >> 32); 27 | SenderLowId = (int) value; 28 | } 29 | } 30 | 31 | public virtual void Encode(IByteBuffer packet) 32 | { 33 | // TODO 34 | } 35 | 36 | public virtual void SetSender(Player player) 37 | { 38 | SenderName = player.Home.Name; 39 | SenderId = player.Home.Id; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Player.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BrawlStars.Database; 3 | using BrawlStars.Files.Logic; 4 | using BrawlStars.Utilities.Netty; 5 | using BrawlStars.Utilities.Utils; 6 | using DotNetty.Buffers; 7 | using Newtonsoft.Json; 8 | using BrawlStars.Files; 9 | 10 | namespace BrawlStars.Logic 11 | { 12 | public class Player 13 | { 14 | public Player(long id) 15 | { 16 | Home = new Home.Home(id, GameUtils.GenerateToken); 17 | } 18 | 19 | public Player() 20 | { 21 | // Player. 22 | } 23 | 24 | public Home.Home Home { get; set; } 25 | 26 | [JsonIgnore] public Device Device { get; set; } 27 | 28 | public void RankingEntry(IByteBuffer packet) 29 | { 30 | // TODO 31 | } 32 | 33 | public void LogicClientHome(IByteBuffer packet) 34 | { 35 | 36 | } 37 | 38 | public void LogicClientAvatar(IByteBuffer packet) 39 | { 40 | 41 | } 42 | 43 | /*public async void AddEntry(AvatarStreamEntry entry) 44 | { 45 | lock (Home.Stream) 46 | { 47 | while (Home.Stream.Count >= 40) 48 | Home.Stream.RemoveAt(0); 49 | 50 | var max = Home.Stream.Count == 0 ? 1 : Home.Stream.Max(x => x.Id); 51 | entry.Id = max == int.MaxValue ? 1 : max + 1; // If we ever reach that value... but who knows... 52 | 53 | Home.Stream.Add(entry); 54 | } 55 | 56 | await new AvatarStreamEntryMessage(Device) 57 | { 58 | Entry = entry 59 | }.SendAsync(); 60 | }*/ 61 | 62 | /// 63 | /// Validates this session 64 | /// 65 | public void ValidateSession() 66 | { 67 | var session = Device.Session; 68 | session.Duration = (int) DateTime.UtcNow.Subtract(session.SessionStart).TotalSeconds; 69 | 70 | Home.TotalPlayTimeSeconds += session.Duration; 71 | 72 | while (Home.Sessions.Count >= 50) Home.Sessions.RemoveAt(0); 73 | 74 | Home.Sessions.Add(session); 75 | } 76 | 77 | public async void Save() 78 | { 79 | Home.LastSaveTime = DateTime.UtcNow; 80 | 81 | /*#if DEBUG 82 | var st = new Stopwatch(); 83 | st.Start(); 84 | 85 | Resources.ObjectCache.CachePlayer(this); 86 | await PlayerDb.SaveAsync(this); 87 | 88 | st.Stop(); 89 | Logger.Log($"Player {Home.Id} saved in {st.ElapsedMilliseconds}ms.", GetType(), ErrorLevel.Debug); 90 | #else*/ 91 | Resources.ObjectCache.CachePlayer(this); 92 | await PlayerDb.SaveAsync(this); 93 | //#endif 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Sessions/Location.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading.Tasks; 4 | using Newtonsoft.Json; 5 | 6 | namespace BrawlStars.Logic.Sessions 7 | { 8 | public class Location 9 | { 10 | [JsonProperty("country")] public string CountryName { get; set; } 11 | [JsonProperty("countryCode")] public string CountryCode { get; set; } 12 | [JsonProperty("city")] public string City { get; set; } 13 | 14 | public static async Task GetByIpAsync(string ip) 15 | { 16 | try 17 | { 18 | //TODO: should check any local ip 19 | if (ip == "127.0.0.1" || ip.StartsWith("192")) return null; 20 | 21 | using (var client = new HttpClient()) 22 | { 23 | var json = await client.GetStringAsync("http://ip-api.com/json/" + ip); 24 | return JsonConvert.DeserializeObject(json); 25 | } 26 | } 27 | catch (Exception) 28 | { 29 | Logger.Log($"Couldn't track location of {ip}", null, Logger.ErrorLevel.Error); 30 | return null; 31 | } 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Sessions/Session.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Newtonsoft.Json; 3 | 4 | namespace BrawlStars.Logic.Sessions 5 | { 6 | public class Session 7 | { 8 | [JsonProperty("location")] public Location Location = new Location(); 9 | [JsonIgnore] public DateTime SessionStart = DateTime.UtcNow; 10 | [JsonProperty("ip")] public string Ip { get; set; } 11 | [JsonProperty("duration")] public int Duration { get; set; } 12 | [JsonProperty("startDate")] public string StartDate { get; set; } 13 | [JsonProperty("deviceCode")] public string DeviceCode { get; set; } 14 | [JsonProperty("gameVersion")] public string GameVersion { get; set; } 15 | [JsonProperty("sessionId")] public string SessionId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Time.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BrawlStars.Logic 4 | { 5 | public class Time 6 | { 7 | public int SubTick { get; set; } 8 | 9 | public int TotalMilliseconds => 16 * SubTick; 10 | 11 | public int TotalSeconds => SubTick > 0 ? Math.Max((int) (ulong) (16L * SubTick / 1000) + 1, 1) : 0; 12 | 13 | public static long GetSecondsInTicks(int seconds) 14 | { 15 | return (long) (seconds * 62.5); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Logic/Timer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BrawlStars.Logic 4 | { 5 | public class Timer 6 | { 7 | public int EndSubTick; 8 | 9 | public void StartTimer(Time time, int seconds) 10 | { 11 | EndSubTick = time.SubTick + (int) Time.GetSecondsInTicks(seconds); 12 | } 13 | 14 | public void IncreaseTimer(int seconds) 15 | { 16 | EndSubTick += (int) Time.GetSecondsInTicks(seconds); 17 | } 18 | 19 | public void StopTimer() 20 | { 21 | EndSubTick = -1; 22 | } 23 | 24 | public void FastForward(int seconds) 25 | { 26 | EndSubTick -= (int) Time.GetSecondsInTicks(seconds); 27 | } 28 | 29 | public void FastForwardSubTicks(int subTick) 30 | { 31 | if (EndSubTick > 0) EndSubTick -= subTick; 32 | } 33 | 34 | public int GetRemainingSeconds(Time time) 35 | { 36 | var subTicks = EndSubTick - time.SubTick; 37 | return subTicks > 0 ? Math.Max((int) (16L * subTicks / 1000) + 1, 1) : 0; 38 | } 39 | 40 | public int GetRemainingMilliseconds(Time time) 41 | { 42 | var subTicks = EndSubTick - time.SubTick; 43 | return subTicks > 0 ? 16 * subTicks : 0; 44 | } 45 | 46 | public void AdjustSubTick(Time time) 47 | { 48 | EndSubTick -= time.SubTick; 49 | if (EndSubTick < 0) EndSubTick = 0; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Source/BrawlStars/NLog.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | 7 | 11 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /Source/BrawlStars/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Threading; 4 | using BrawlStars.Utilities.Utils; 5 | 6 | namespace BrawlStars 7 | { 8 | public static class Program 9 | { 10 | public static int Version { get; set; } 11 | private static void Main() 12 | { 13 | Console.Title = $"By Mr Vitalik & PhoenixFire - {DateTime.Now.Year} ©"; 14 | 15 | 16 | Resources.Initialize(); 17 | 18 | if (ServerUtils.IsLinux()) 19 | { 20 | Thread.Sleep(Timeout.Infinite); 21 | } 22 | else 23 | { 24 | Logger.Log("Press any key to shutdown the server.", null); 25 | Console.Read(); 26 | } 27 | 28 | Shutdown(); 29 | } 30 | 31 | public static async void Shutdown() 32 | { 33 | Console.WriteLine("Shutting down..."); 34 | 35 | await Resources.Netty.Shutdown(); 36 | 37 | try 38 | { 39 | Console.WriteLine("Saving players..."); 40 | 41 | lock (Resources.Players.SyncObject) 42 | { 43 | foreach (var player in Resources.Players.Values) player.Save(); 44 | } 45 | 46 | Console.WriteLine("All players saved."); 47 | } 48 | catch (Exception) 49 | { 50 | Console.WriteLine("Couldn't save all players."); 51 | } 52 | 53 | await Resources.Netty.ShutdownWorkers(); 54 | } 55 | 56 | public static void Exit() 57 | { 58 | Environment.Exit(0); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Commands/Server/LogicChangeAvatarName.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | 4 | namespace BrawlStars.Protocol.Commands.Server 5 | { 6 | public class LogicChangeAvatarName : LogicCommand 7 | { 8 | public LogicChangeAvatarName(Device device) : base(device) 9 | { 10 | Type = 3; 11 | } 12 | 13 | public string Name { get; set; } 14 | 15 | public override void Encode() 16 | { 17 | Data.WriteScString(Name); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Commands/Server/LogicDiamondsAddedCommand.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | 4 | namespace BrawlStars.Protocol.Commands.Server 5 | { 6 | public class LogicDiamondsAddedCommand : LogicCommand 7 | { 8 | public LogicDiamondsAddedCommand(Device device) : base(device) 9 | { 10 | Type = 7; 11 | } 12 | 13 | public int Diamonds { get; set; } 14 | 15 | public override void Encode() 16 | { 17 | Data.WriteBoolean(false); // AllianceGift 18 | 19 | Data.WriteInt(Diamonds); 20 | 21 | Data.WriteInt(0); 22 | Data.WriteInt(0); 23 | Data.WriteInt(0); 24 | 25 | Data.WriteScString("GPA.0000-0000-0000-00000"); // Transaction Id 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/LogicCommand.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using DotNetty.Buffers; 3 | 4 | namespace BrawlStars.Protocol 5 | { 6 | public class LogicCommand 7 | { 8 | public LogicCommand(Device device) 9 | { 10 | Device = device; 11 | Data = Unpooled.Buffer(); 12 | } 13 | 14 | public LogicCommand(Device device, IByteBuffer buffer) 15 | { 16 | Device = device; 17 | Reader = buffer; 18 | Data = Unpooled.Buffer(); 19 | } 20 | 21 | public IByteBuffer Data { get; set; } 22 | public Device Device { get; set; } 23 | 24 | public int Type { get; set; } 25 | public int Tick { get; set; } 26 | public IByteBuffer Reader { get; set; } 27 | 28 | public virtual void Decode() 29 | { 30 | Tick = Reader.ReadInt(); 31 | } 32 | 33 | public virtual void Encode() 34 | { 35 | } 36 | 37 | public virtual void Process() 38 | { 39 | } 40 | 41 | public LogicCommand Handle() 42 | { 43 | Encode(); 44 | return this; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/LogicCommandManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace BrawlStars.Protocol 5 | { 6 | public class LogicCommandManager 7 | { 8 | public static Dictionary Commands; 9 | 10 | static LogicCommandManager() 11 | { 12 | Commands = new Dictionary 13 | { 14 | 15 | }; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/LogicMagicMessageFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using BrawlStars.Protocol.Messages.Client; 4 | using BrawlStars.Protocol.Messages.Client.Alliance; 5 | using BrawlStars.Protocol.Messages.Client.Home; 6 | using BrawlStars.Protocol.Messages.Client.Login; 7 | using BrawlStars.Protocol.Messages.Server; 8 | 9 | namespace BrawlStars.Protocol 10 | { 11 | public class LogicMagicMessageFactory 12 | { 13 | public static Dictionary Messages; 14 | 15 | static LogicMagicMessageFactory() 16 | { 17 | Messages = new Dictionary 18 | { 19 | {10100, typeof(ClientHelloMessage)}, 20 | {10101, typeof(LoginMessage)}, 21 | {10108, typeof(KeepAliveMessage)}, 22 | {10110, typeof(AnalyticsEventMessage)}, 23 | {10212, typeof(SetNameMessage)}, 24 | {10309, typeof(ClanInviteLinkMessage)}, 25 | {14102, typeof(EndClientTurnMessage)}, 26 | {14109, typeof(ExitMessage)}, 27 | {14110, typeof(BattleEndMessage)}, 28 | {14113, typeof(ProfileMessage)}, 29 | {14302, typeof(OpenClubMessage)}, 30 | {14315, typeof(ChatToClubMessage)}, 31 | {14350, typeof(CreateGameroomMessage)}, 32 | {14353, typeof(QuitRoomMessage)}, 33 | {14354, typeof(ChangeBrawlerInRoomMessage)}, 34 | {14363, typeof(ChangeMapMessage)}, 35 | {14366, typeof(ClientActionMessage)}, 36 | {14372, typeof(UseGadgetInRoomMessage)}, 37 | {14600, typeof(ChangeNameMessage)}, 38 | {14777, typeof(DoNotDistrubMessage)} 39 | }; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/Alliance/ChatToClubMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using DotNetty.Buffers; 5 | using System; 6 | using System.Linq; 7 | using BrawlStars.Utilities; 8 | using System.Runtime.InteropServices; 9 | using Google.Protobuf.WellKnownTypes; 10 | 11 | namespace BrawlStars.Protocol.Messages.Client.Alliance 12 | { 13 | class ChatToClubMessage : PiranhaMessage 14 | { 15 | public ChatToClubMessage(Device device, IByteBuffer buffer) : base(device, buffer) 16 | { 17 | RequiredState = Device.State.NotDefinied; 18 | } 19 | 20 | public string Messages { get; set; } 21 | private ChatServerMessage Chat { get; set; } 22 | 23 | public override void Decode() 24 | { 25 | Messages = Reader.ReadScString(); 26 | } 27 | 28 | public override async void Process() 29 | { 30 | string Botmsg = string.Empty; 31 | if (Messages.StartsWith("/")) 32 | { 33 | var cmd = Messages.Split(' '); 34 | var cmdType = cmd[0]; 35 | var cmdValue = 0; 36 | 37 | if (cmd.Length > 1) 38 | if (Messages.Split(' ')[1].Any(char.IsDigit)) 39 | int.TryParse(Messages.Split(' ')[1], out cmdValue); 40 | switch (cmdType) 41 | { 42 | case "/status": 43 | Resources.MessageTick++; 44 | Botmsg = $"Server status:\nBuild version: 1.2(for 26.165)\nFingerprint SHA:\n{ Resources.Fingerprint.Sha}\nUsed Ram: " + 45 | $"{System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024) + " MB"}"; 46 | Resources.ChatMessage = Messages; 47 | await new ChatServerMessage(Device) 48 | { 49 | Message = Resources.ChatMessage 50 | }.SendAsync(); 51 | Resources.MessageTick++; 52 | await new ChatBotServerMessage(Device) 53 | { 54 | Message = 55 | Botmsg 56 | }.SendAsync(); 57 | break; 58 | case "/about": 59 | Resources.MessageTick++; 60 | Botmsg = "By VitalikObject and PhoenixFire"; 61 | Resources.ChatMessage = Messages; 62 | await new ChatServerMessage(Device) 63 | { 64 | Message = Resources.ChatMessage 65 | }.SendAsync(); 66 | Resources.MessageTick++; 67 | await new ChatBotServerMessage(Device) 68 | { 69 | Message = 70 | Botmsg 71 | }.SendAsync(); 72 | break; 73 | case "/reset": 74 | Resources.Gems = 99999; 75 | Resources.Gold = 99999; 76 | Resources.Tickets = 99999; 77 | await new LoginFailedMessage(Device) 78 | { 79 | Reason = 80 | "You should re-enter the game to apply changes" 81 | }.SendAsync(); 82 | break; 83 | case "/help": 84 | Resources.MessageTick++; 85 | Resources.ChatMessage = Messages; 86 | await new ChatServerMessage(Device) 87 | { 88 | Message = Resources.ChatMessage 89 | }.SendAsync(); 90 | Resources.MessageTick++; 91 | Botmsg = "/status - shows server status\n/about - authors\n/reset - set resources by default"; 92 | await new ChatBotServerMessage(Device) 93 | { 94 | Message = 95 | Botmsg 96 | }.SendAsync(); 97 | break; 98 | } 99 | } 100 | else 101 | { 102 | Resources.ChatMessage = Messages; 103 | Resources.MessageTick++; 104 | await new ChatServerMessage(Device) 105 | { 106 | Message = Resources.ChatMessage 107 | }.SendAsync(); 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/Alliance/ClanInviteLinkMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server.Alliance; 3 | using DotNetty.Buffers; 4 | 5 | 6 | namespace BrawlStars.Protocol.Messages.Client.Alliance 7 | { 8 | class ClanInviteLinkMessage : PiranhaMessage 9 | { 10 | public ClanInviteLinkMessage(Device device, IByteBuffer buffer) : base(device, buffer) 11 | { 12 | RequiredState = Device.State.NotDefinied; 13 | } 14 | public override async void Process() 15 | { 16 | await new GenrateClanInviteLinkMessage(Device).SendAsync(); 17 | } 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/AnalyticsEventMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using DotNetty.Buffers; 5 | 6 | namespace BrawlStars.Protocol.Messages.Client 7 | { 8 | class AnalyticsEventMessage : PiranhaMessage 9 | { 10 | public AnalyticsEventMessage(Device device, IByteBuffer buffer) : base(device, buffer) 11 | { 12 | RequiredState = Device.State.NotDefinied; 13 | } 14 | 15 | public string EventName { get; set; } 16 | public string Event { get; set; } 17 | 18 | public override void Decode() 19 | { 20 | EventName = Reader.ReadScString(); 21 | Event = Reader.ReadScString(); 22 | } 23 | 24 | public override void Process() 25 | { 26 | Logger.Log($"Name: {EventName}, Event: {Event}", GetType(), Logger.ErrorLevel.Debug); 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/ChangeMapMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using DotNetty.Buffers; 5 | using System; 6 | 7 | namespace BrawlStars.Protocol.Messages.Client 8 | { 9 | class ChangeMapMessage : PiranhaMessage 10 | { 11 | public ChangeMapMessage(Device device, IByteBuffer buffer) : base(device, buffer) 12 | { 13 | RequiredState = Device.State.NotDefinied; 14 | } 15 | public int MapId { get; set; } 16 | 17 | public override void Decode() 18 | { 19 | Reader.ReadVInt(); 20 | MapId = Reader.ReadVInt(); 21 | } 22 | public override async void Process() 23 | { 24 | Resources.Map = MapId; 25 | await new Gameroom_Data(Device).SendAsync(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/ChangeNameMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Core; 2 | using BrawlStars.Logic; 3 | using BrawlStars.Protocol.Messages.Server; 4 | using BrawlStars.Utilities.Netty; 5 | using DotNetty.Buffers; 6 | using System; 7 | using System.Threading.Tasks; 8 | 9 | namespace BrawlStars.Protocol.Messages.Client 10 | { 11 | class ChangeNameMessage : PiranhaMessage 12 | { 13 | public ChangeNameMessage(Device device, IByteBuffer buffer) : base(device, buffer) 14 | { 15 | RequiredState = Device.State.NotDefinied; 16 | } 17 | public static string Name { get; set; } 18 | public override void Decode() 19 | { 20 | Name = Reader.ReadScString(); 21 | } 22 | public override async void Process() 23 | { 24 | await new LoginFailedMessage(Device) 25 | { 26 | Reason = 27 | "Not implemented yet" 28 | }.SendAsync(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/ClientActionMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using Colorful; 5 | using DotNetty.Buffers; 6 | 7 | namespace BrawlStars.Protocol.Messages.Client 8 | { 9 | class ClientActionMessage : PiranhaMessage 10 | { 11 | public ClientActionMessage(Device device, IByteBuffer buffer) : base(device, buffer) 12 | { 13 | RequiredState = Device.State.NotDefinied; 14 | } 15 | private int Unk { get; set; } 16 | public override void Decode() 17 | { 18 | Unk = Reader.ReadVInt(); 19 | } 20 | public override async void Process() 21 | { 22 | if(Unk == 4) 23 | { 24 | await new LoginFailedMessage(Device) 25 | { 26 | Reason = 27 | "Not implemented yet" 28 | }.SendAsync(); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/CreateGameroomMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using Colorful; 5 | using DotNetty.Buffers; 6 | 7 | 8 | namespace BrawlStars.Protocol.Messages.Client 9 | { 10 | class CreateGameroomMessage : PiranhaMessage 11 | { 12 | public CreateGameroomMessage(Device device, IByteBuffer buffer) : base(device, buffer) 13 | { 14 | RequiredState = Device.State.NotDefinied; 15 | } 16 | public int MapId { get; set; } 17 | public override void Decode() 18 | { 19 | Reader.ReadVInt(); 20 | MapId = Reader.ReadVInt(); 21 | } 22 | public override async void Process() 23 | { 24 | switch(MapId) 25 | { 26 | case 1: 27 | Resources.Map = 7; 28 | break; 29 | case 2: 30 | Resources.Map = 32; 31 | break; 32 | case 3: 33 | Resources.Map = 17; 34 | break; 35 | case 4: 36 | Resources.Map = 0; 37 | break; 38 | case 5: 39 | Resources.Map = 38; 40 | break; 41 | case 6: 42 | Resources.Map = 24; 43 | break; 44 | case 7: 45 | Resources.Map = 202; 46 | break; 47 | case 8: 48 | Resources.Map = 97; 49 | break; 50 | case 9: 51 | Resources.Map = 167; 52 | break; 53 | } 54 | Resources.Room = 1; 55 | await new Gameroom_Data(Device).SendAsync(); 56 | } 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/DoNotDistrubMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using DotNetty.Buffers; 5 | namespace BrawlStars.Protocol.Messages.Client 6 | { 7 | class DoNotDistrubMessage : PiranhaMessage 8 | { 9 | public DoNotDistrubMessage(Device device, IByteBuffer buffer) : base(device, buffer) 10 | { 11 | RequiredState = Device.State.NotDefinied; 12 | } 13 | private bool NotDistrub { get; set; } 14 | public override void Decode() 15 | { 16 | NotDistrub = Reader.ReadBoolean(); 17 | } 18 | public override async void Process() 19 | { 20 | await new DoNotDistrubServer(Device) 21 | { 22 | Distrub = NotDistrub 23 | }.SendAsync(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/Home/ProfileMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using Colorful; 5 | using DotNetty.Buffers; 6 | using System.Net.Http.Headers; 7 | 8 | namespace BrawlStars.Protocol.Messages.Client.Home 9 | { 10 | class ProfileMessage : PiranhaMessage 11 | { 12 | public ProfileMessage(Device device, IByteBuffer buffer) : base(device, buffer) 13 | { 14 | RequiredState = Device.State.NotDefinied; 15 | } 16 | public int HighId { get; set; } 17 | 18 | public override void Decode() 19 | { 20 | Reader.ReadVInt(); 21 | Reader.ReadVInt(); 22 | Reader.ReadVInt(); 23 | HighId = Reader.ReadVInt(); 24 | } 25 | 26 | public override async void Process() 27 | { 28 | if (HighId == 0) 29 | { 30 | await new ProfileServerMessage(Device).SendAsync(); 31 | } 32 | else 33 | { 34 | await new BotProfileMessage(Device).SendAsync(); 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/Home/SetNameMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using DotNetty.Buffers; 4 | using BrawlStars.Protocol.Messages.Server.Home; 5 | using BrawlStars.Utilities.Netty; 6 | 7 | namespace BrawlStars.Protocol.Messages.Client.Home 8 | { 9 | class SetNameMessage : PiranhaMessage 10 | { 11 | public SetNameMessage(Device device, IByteBuffer buffer) : base(device, buffer) 12 | { 13 | RequiredState = Device.State.NotDefinied; 14 | } 15 | 16 | public override void Decode() 17 | { 18 | Resources.Name = Reader.ReadScString(); 19 | } 20 | public override async void Process() 21 | { 22 | await new SetNameServer(Device).SendAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/Login/ClientHelloMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using DotNetty.Buffers; 5 | 6 | namespace BrawlStars.Protocol.Messages.Client.Login 7 | { 8 | public class ClientHelloMessage : PiranhaMessage 9 | { 10 | public ClientHelloMessage(Device device, IByteBuffer buffer) : base(device, buffer) 11 | { 12 | RequiredState = Device.State.Disconnected; 13 | } 14 | 15 | public int Protocol { get; set; } 16 | public int KeyVersion { get; set; } 17 | public int MajorVersion { get; set; } 18 | public int MinorVersion { get; set; } 19 | public int Build { get; set; } 20 | public string FingerprintSha { get; set; } 21 | public int DeviceType { get; set; } 22 | public int AppStore { get; set; } 23 | 24 | public override void Decode() 25 | { 26 | Protocol = Reader.ReadInt(); 27 | KeyVersion = Reader.ReadInt(); 28 | MajorVersion = Reader.ReadInt(); 29 | MinorVersion = Reader.ReadInt(); 30 | Build = Reader.ReadInt(); 31 | FingerprintSha = Reader.ReadScString(); 32 | DeviceType = Reader.ReadInt(); 33 | AppStore = Reader.ReadInt(); 34 | } 35 | 36 | public override async void Process() 37 | { 38 | await new LoginFailedMessage(Device) 39 | { 40 | ErrorCode = 8 41 | }.SendAsync(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/Login/ExitMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using BrawlStars.Logic; 4 | using BrawlStars.Logic.Sessions; 5 | using BrawlStars.Protocol.Messages.Server; 6 | using BrawlStars.Utilities.Netty; 7 | using DotNetty.Buffers; 8 | using BrawlStars; 9 | 10 | namespace BrawlStars.Protocol.Messages.Client.Login 11 | { 12 | class ExitMessage : PiranhaMessage 13 | { 14 | public ExitMessage(Device device, IByteBuffer buffer) : base(device, buffer) 15 | { 16 | RequiredState = Device.State.NotDefinied; 17 | } 18 | 19 | public override async void Process() 20 | { 21 | await new OwnHomeDataMessage(Device).SendAsync(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/Login/KeepAliveMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using DotNetty.Buffers; 4 | 5 | namespace BrawlStars.Protocol.Messages.Client.Login 6 | { 7 | public class KeepAliveMessage : PiranhaMessage 8 | { 9 | public KeepAliveMessage(Device device, IByteBuffer buffer) : base(device, buffer) 10 | { 11 | RequiredState = Device.State.NotDefinied; 12 | } 13 | 14 | public override async void Process() 15 | { 16 | await new KeepAliveOkMessage(Device).SendAsync(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/OpenClubMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using DotNetty.Buffers; 5 | 6 | namespace BrawlStars.Protocol.Messages.Client 7 | { 8 | class OpenClubMessage : PiranhaMessage 9 | { 10 | public OpenClubMessage(Device device, IByteBuffer buffer) : base(device, buffer) 11 | { 12 | RequiredState = Device.State.NotDefinied; 13 | } 14 | 15 | public override void Decode() 16 | { 17 | } 18 | public override async void Process() 19 | { 20 | await new ClubServerMessage(Device).SendAsync(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/QuitRoomMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using DotNetty.Buffers; 5 | 6 | namespace BrawlStars.Protocol.Messages.Client 7 | { 8 | class QuitRoomMessage : PiranhaMessage 9 | { 10 | public QuitRoomMessage(Device device, IByteBuffer buffer) : base(device, buffer) 11 | { 12 | RequiredState = Device.State.NotDefinied; 13 | } 14 | 15 | public override void Decode() 16 | { 17 | } 18 | public override async void Process() 19 | { 20 | Resources.Room = 0; 21 | Resources.RoomID = 0; 22 | await new RoomDisconnect(Device).SendAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Client/UseGadgetInRoomMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Protocol.Messages.Server; 3 | using BrawlStars.Utilities.Netty; 4 | using Colorful; 5 | using DotNetty.Buffers; 6 | 7 | namespace BrawlStars.Protocol.Messages.Client 8 | { 9 | class UseGadgetInRoomMessage : PiranhaMessage 10 | { 11 | public UseGadgetInRoomMessage(Device device, IByteBuffer buffer) : base(device, buffer) 12 | { 13 | RequiredState = Device.State.NotDefinied; 14 | } 15 | public override void Decode() 16 | { 17 | Resources.UseGadget = Reader.ReadBoolean(); 18 | } 19 | public override async void Process() 20 | { 21 | await new Gameroom_Data(Device).SendAsync(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/Alliance/GenrateClanInviteLinkMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | using System; 4 | 5 | namespace BrawlStars.Protocol.Messages.Server.Alliance 6 | { 7 | class GenrateClanInviteLinkMessage : PiranhaMessage 8 | { 9 | public GenrateClanInviteLinkMessage(Device device) : base(device) 10 | { 11 | Id = 23302; 12 | } 13 | public override async void Encode() 14 | { 15 | Random rnd = new Random(); 16 | int itoken = rnd.Next(1, 2147483647); 17 | string token = itoken.ToString(); 18 | Writer.WriteVInt(1); 19 | Writer.WriteScString(token); 20 | Writer.WriteVInt(-1040385); 21 | Writer.WriteVInt(0); 22 | Writer.WriteVInt(0); 23 | Writer.WriteVInt(0); 24 | Writer.WriteVInt(0); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/ChatBotServerMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | using System; 4 | 5 | namespace BrawlStars.Protocol.Messages.Server 6 | { 7 | class ChatBotServerMessage : PiranhaMessage 8 | { 9 | public string Message { get; set; } 10 | public ChatBotServerMessage(Device device) : base(device) 11 | { 12 | Id = 24312; 13 | } 14 | public override async void Encode() 15 | { 16 | Writer.WriteVInt(2); 17 | Writer.WriteVInt(0); 18 | Writer.WriteVInt(Resources.MessageTick); 19 | Writer.WriteVInt(1); 20 | Writer.WriteVInt(1); 21 | Writer.WriteScString("ObjectBrawlBot"); 22 | Writer.WriteVInt(3); 23 | Writer.WriteVInt(0); 24 | Writer.WriteVInt(0); 25 | Writer.WriteScString(Message); 26 | Writer.WriteVInt(-1040385); 27 | Writer.WriteVInt(0); 28 | Writer.WriteVInt(0); 29 | Writer.WriteVInt(0); 30 | Writer.WriteVInt(0); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/ChatServerMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | using System; 4 | 5 | namespace BrawlStars.Protocol.Messages.Server 6 | { 7 | class ChatServerMessage : PiranhaMessage 8 | { 9 | public string Message { get; set; } 10 | public ChatServerMessage(Device device) : base(device) 11 | { 12 | Id = 24312; 13 | } 14 | Random rnd = new Random(); 15 | public override async void Encode() 16 | { 17 | Writer.WriteVInt(2); 18 | Writer.WriteVInt(0); 19 | Writer.WriteVInt(Resources.MessageTick); 20 | Writer.WriteVInt(0); 21 | Writer.WriteVInt(1); 22 | Writer.WriteScString(Resources.Name); 23 | Writer.WriteVInt(2); 24 | Writer.WriteVInt(0); 25 | Writer.WriteVInt(0); 26 | Writer.WriteScString(Message); 27 | Writer.WriteVInt(-1040385); 28 | Writer.WriteVInt(0); 29 | Writer.WriteVInt(0); 30 | Writer.WriteVInt(0); 31 | Writer.WriteVInt(0); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/ClubServerMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | using System; 4 | 5 | namespace BrawlStars.Protocol.Messages.Server 6 | { 7 | class ClubServerMessage : PiranhaMessage 8 | { 9 | public ClubServerMessage(Device device) : base(device) 10 | { 11 | Id = 24301; 12 | } 13 | public override void Encode() 14 | { 15 | Writer.WriteVInt(1); 16 | Writer.WriteVInt(0); 17 | Writer.WriteVInt(0); 18 | Writer.WriteVInt(0); 19 | Writer.WriteVInt(0); 20 | Writer.WriteInt(1); 21 | Writer.WriteScString("Brawl Private Server"); 22 | Writer.WriteVInt(8); 23 | Writer.WriteVInt(5); 24 | Writer.WriteVInt(3); 25 | Writer.WriteVInt(1); 26 | Writer.WriteVInt(Resources.Trophies); 27 | Writer.WriteVInt(0); 28 | Writer.WriteVInt(0); 29 | Writer.WriteScString(Resources.Region); 30 | Writer.WriteVInt(0); 31 | Writer.WriteVInt(0); 32 | Writer.WriteScString("Server created by PhoenixFire and VitalikObject"); 33 | Writer.WriteVInt(1); 34 | Writer.WriteInt(0); 35 | Writer.WriteInt(1); //Low Id 36 | Writer.WriteVInt(2); 37 | Writer.WriteVInt(Resources.Trophies); 38 | Writer.WriteVInt(0); 39 | Writer.WriteVInt(0); 40 | Writer.WriteVInt(0); 41 | Writer.WriteScString(Resources.Name); 42 | Writer.WriteVInt(100); 43 | Writer.WriteVInt(28000000 + Resources.ProfileIcon); 44 | Writer.WriteVInt(43000000 + Resources.NameColor); 45 | Writer.WriteVInt(-1); 46 | Writer.WriteVInt(-1040385); 47 | Writer.WriteVInt(0); 48 | Writer.WriteVInt(0); 49 | Writer.WriteVInt(0); 50 | Writer.WriteVInt(0); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/DoNotDistrubServer.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | using System; 4 | using System.Text; 5 | 6 | namespace BrawlStars.Protocol.Messages.Server 7 | { 8 | class DoNotDistrubServer : PiranhaMessage 9 | { 10 | public DoNotDistrubServer(Device device) : base(device) 11 | { 12 | Id = 24111; 13 | } 14 | public bool Distrub { get; set; } 15 | public override async void Encode() 16 | { 17 | Writer.WriteVInt(213); 18 | Writer.WriteBoolean(Distrub); 19 | Writer.WriteVInt(0); 20 | Writer.WriteVInt(0); 21 | Writer.WriteVInt(0); 22 | Writer.WriteVInt(0); 23 | Writer.WriteVInt(0); 24 | Writer.WriteVInt(-1040385); 25 | Writer.WriteVInt(0); 26 | Writer.WriteVInt(0); 27 | Writer.WriteVInt(0); 28 | Writer.WriteVInt(0); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/Gameroom_Data.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | using System; 4 | using System.Text; 5 | 6 | namespace BrawlStars.Protocol.Messages.Server 7 | { 8 | class Gameroom_Data : PiranhaMessage 9 | { 10 | public Gameroom_Data(Device device) : base(device) 11 | { 12 | Id = 24124; 13 | } 14 | 15 | public override void Encode() 16 | { 17 | Writer.WriteVInt(1); 18 | Writer.WriteVInt(0); 19 | Writer.WriteVInt(1); 20 | Writer.WriteVInt(0); 21 | Writer.WriteVInt(0); 22 | Writer.WriteVInt(0); 23 | Writer.WriteVInt(0); 24 | Random rnd = new Random(); 25 | if (Resources.RoomID == 0) 26 | { 27 | int i = rnd.Next(0, 2147483647); 28 | Resources.RoomID = i; 29 | Writer.WriteInt(i); 30 | } 31 | else 32 | { 33 | Writer.WriteInt(Resources.RoomID); 34 | } 35 | Writer.WriteVInt(1557129593); 36 | Writer.WriteVInt(0); 37 | Writer.WriteVInt(0); 38 | Writer.WriteVInt(0); 39 | Writer.WriteVInt(15); 40 | Writer.WriteVInt(Resources.Map); 41 | Writer.WriteVInt(1); 42 | Writer.WriteVInt(1); 43 | Writer.WriteVInt(0); 44 | Writer.WriteVInt(0); 45 | Writer.WriteVInt(0); 46 | Writer.WriteVInt(0); //High id 47 | Writer.WriteInt(1); //Low Id 48 | Writer.WriteVInt(16); 49 | Writer.WriteVInt(Resources.Brawler); 50 | Writer.WriteVInt(0); 51 | Writer.WriteVInt(99999); 52 | Writer.WriteVInt(99999); 53 | Writer.WriteVInt(1); 54 | Writer.WriteVInt(3); 55 | Writer.WriteVInt(0); 56 | Writer.WriteVInt(0); 57 | Writer.WriteVInt(0); 58 | Writer.WriteVInt(0); 59 | Writer.WriteScString(Resources.Name); 60 | Writer.WriteVInt(100); 61 | Writer.WriteVInt(28000000); 62 | Writer.WriteVInt(43000000); 63 | Writer.WriteVInt(23); 64 | Writer.WriteVInt(Resources.StarPower); //star power 65 | if (Resources.UseGadget == true) 66 | { 67 | Writer.WriteVInt(23); 68 | Writer.WriteVInt(Resources.Gadget); //gadget 69 | } 70 | else 71 | { 72 | Writer.WriteVInt(0); 73 | Writer.WriteVInt(0); 74 | } 75 | Writer.WriteVInt(0); 76 | Writer.WriteVInt(0); 77 | Writer.WriteVInt(0); 78 | Writer.WriteVInt(6); 79 | Writer.WriteVInt(-1040385); 80 | Writer.WriteVInt(0); 81 | Writer.WriteVInt(0); 82 | Writer.WriteVInt(0); 83 | Writer.WriteVInt(0); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/Home/ProfileServerMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BrawlStars.Logic; 3 | using BrawlStars.Utilities.Netty; 4 | 5 | namespace BrawlStars.Protocol.Messages.Server 6 | { 7 | public class ProfileServerMessage : PiranhaMessage 8 | { 9 | public ProfileServerMessage(Device device) : base(device) 10 | { 11 | Id = 24113; 12 | } 13 | 14 | public override void Encode() 15 | { 16 | Writer.WriteVInt(0); //High Id 17 | Writer.WriteVInt(1); //Low Id 18 | Writer.WriteVInt(0); 19 | Writer.WriteVInt(7); 20 | Writer.WriteVInt(16); 21 | Writer.WriteVInt(0); 22 | Writer.WriteVInt(0); 23 | Writer.WriteVInt(99999); 24 | Writer.WriteVInt(99999); 25 | Writer.WriteVInt(2); 26 | Writer.WriteVInt(16); 27 | Writer.WriteVInt(1); 28 | Writer.WriteVInt(0); 29 | Writer.WriteVInt(99999); 30 | Writer.WriteVInt(99999); 31 | Writer.WriteVInt(2); 32 | Writer.WriteVInt(16); 33 | Writer.WriteVInt(9); 34 | Writer.WriteVInt(0); 35 | Writer.WriteVInt(99999); 36 | Writer.WriteVInt(99999); 37 | Writer.WriteVInt(2); 38 | Writer.WriteVInt(16); 39 | Writer.WriteVInt(22); 40 | Writer.WriteVInt(0); 41 | Writer.WriteVInt(99999); 42 | Writer.WriteVInt(99999); 43 | Writer.WriteVInt(2); 44 | Writer.WriteVInt(16); 45 | Writer.WriteVInt(14); 46 | Writer.WriteVInt(0); 47 | Writer.WriteVInt(99999); 48 | Writer.WriteVInt(99999); 49 | Writer.WriteVInt(2); 50 | Writer.WriteVInt(16); 51 | Writer.WriteVInt(7); 52 | Writer.WriteVInt(0); 53 | Writer.WriteVInt(99999); 54 | Writer.WriteVInt(99999); 55 | Writer.WriteVInt(2); 56 | Writer.WriteVInt(16); 57 | Writer.WriteVInt(8); 58 | Writer.WriteVInt(0); 59 | Writer.WriteVInt(99999); 60 | Writer.WriteVInt(99999); 61 | Writer.WriteVInt(2); 62 | Writer.WriteVInt(14); 63 | Writer.WriteVInt(1); 64 | Writer.WriteVInt(99999); //3v3 victories 65 | Writer.WriteVInt(2); 66 | Writer.WriteVInt(1262469); //exp 67 | Writer.WriteVInt(3); 68 | Writer.WriteVInt(99999); 69 | Writer.WriteVInt(4); 70 | Writer.WriteVInt(Resources.Trophies); //highest trophies 71 | Writer.WriteVInt(5); 72 | Writer.WriteVInt(7); 73 | Writer.WriteVInt(7); 74 | Writer.WriteVInt(28000000); 75 | Writer.WriteVInt(8); 76 | Writer.WriteVInt(99999); //solo victories 77 | Writer.WriteVInt(9); 78 | Writer.WriteVInt(21); 79 | Writer.WriteVInt(10); 80 | Writer.WriteVInt(99999); 81 | Writer.WriteVInt(11); 82 | Writer.WriteVInt(99999); //duo victories 83 | Writer.WriteVInt(12); 84 | Writer.WriteVInt(21); 85 | Writer.WriteVInt(13); 86 | Writer.WriteVInt(99999); 87 | Writer.WriteVInt(14); 88 | Writer.WriteVInt(1); 89 | Writer.WriteVInt(15); 90 | Writer.WriteVInt(99999); //most challenge wins 91 | Writer.WriteScString(Resources.Name); 92 | Writer.WriteVInt(100); 93 | Writer.WriteVInt(28000000); 94 | Writer.WriteVInt(43000000); 95 | Writer.WriteVInt(0); 96 | Writer.WriteVInt(0); 97 | Writer.WriteVInt(-1040385); 98 | Writer.WriteVInt(0); 99 | Writer.WriteVInt(0); 100 | Writer.WriteVInt(0); 101 | Writer.WriteVInt(0); 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/Home/SetNameServer.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | 4 | namespace BrawlStars.Protocol.Messages.Server.Home 5 | { 6 | class SetNameServer : PiranhaMessage 7 | { 8 | public SetNameServer(Device device) : base(device) 9 | { 10 | Id = 24111; 11 | } 12 | 13 | public override async void Encode() 14 | { 15 | Writer.WriteVInt(201); 16 | Writer.WriteScString(Resources.Name); 17 | Writer.WriteVInt(0); 18 | Writer.WriteVInt(0); 19 | Writer.WriteVInt(0); 20 | Writer.WriteVInt(0); 21 | Writer.WriteVInt(0); 22 | Writer.WriteVInt(0); 23 | Writer.WriteVInt(-1040385); 24 | Writer.WriteVInt(0); 25 | Writer.WriteVInt(0); 26 | Writer.WriteVInt(0); 27 | Writer.WriteVInt(0); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/Login/Copyright.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | using System.Text; 4 | 5 | namespace BrawlStars.Protocol.Messages.Server.Login 6 | { 7 | class Copyright : PiranhaMessage 8 | { 9 | public Copyright(Device device) : base(device) 10 | { 11 | Id = 9999; 12 | } 13 | 14 | public override void Encode() 15 | { 16 | Writer.WriteScString("Do not go there! It's dangerous there! Go away!\n"); 17 | Writer.WriteScString("(c) Mr Vitalik & PhoenixFire\n"); 18 | Writer.WriteScString("2020"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/Login/KeepAliveOkMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | 4 | namespace BrawlStars.Protocol.Messages.Server 5 | { 6 | public class KeepAliveOkMessage : PiranhaMessage 7 | { 8 | public KeepAliveOkMessage(Device device) : base(device) 9 | { 10 | Id = 20108; 11 | } 12 | 13 | public override void Encode() 14 | { 15 | Writer.WriteHex("FFFF0000000000"); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/Login/LoginFailedMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | 4 | namespace BrawlStars.Protocol.Messages.Server 5 | { 6 | public class LoginFailedMessage : PiranhaMessage 7 | { 8 | public LoginFailedMessage(Device device) : base(device) 9 | { 10 | Id = 20103; 11 | Version = 4; 12 | } 13 | 14 | public byte ErrorCode { get; set; } 15 | public int SecondsUntilMaintenanceEnds { get; set; } 16 | public string Reason { get; set; } 17 | public string ResourceFingerprintData { get; set; } 18 | public string ContentUrl { get; set; } 19 | public string UpdateUrl { get; set; } 20 | 21 | // 1 = Custom Message 22 | // 7 = Patch 23 | // 8 = Update Available 24 | // 9 = Failed to Connect 25 | // 10 = Maintenance 26 | // 11 = Banned 27 | // 13 = Acc Locked PopUp 28 | // 16 = Updating Cr/Maintenance 29 | // 18 = Chinese Text? 30 | 31 | public override void Encode() 32 | { 33 | Writer.WriteInt(ErrorCode); // ErrorCode 34 | Writer.WriteScString(ResourceFingerprintData); 35 | Writer.WriteScString(null); 36 | Writer.WriteScString(ContentUrl); 37 | Writer.WriteScString(UpdateUrl); // Update URL 38 | Writer.WriteScString(Reason); 39 | Writer.WriteHex("2E0000012C000000000000000000"); 40 | Writer.WriteScString(null); 41 | Writer.WriteScString(null); 42 | Writer.WriteScString(null); 43 | Writer.WriteScString(null); 44 | Writer.WriteHex("00FFFF0000000000"); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/Login/LoginOkMessage.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | 4 | namespace BrawlStars.Protocol.Messages.Server 5 | { 6 | public class LoginOkMessage : PiranhaMessage 7 | { 8 | public LoginOkMessage(Device device) : base(device) 9 | { 10 | Id = 20104; 11 | Version = 1; 12 | } 13 | 14 | public override void Encode() 15 | { 16 | 17 | 18 | Writer.WriteLong(1); 19 | Writer.WriteLong(1); 20 | 21 | Writer.WriteScString("jcdyo6zcyjuo1dch9jkpc14meft4siwmfq7iktss"); 22 | 23 | Writer.WriteVInt(1); 24 | Writer.WriteVInt(-8165); 25 | Writer.WriteVInt(0); 26 | Writer.WriteVInt(0); 27 | Writer.WriteVInt(1); 28 | Writer.WriteScString("prod"); 29 | Writer.WriteVInt(0); 30 | Writer.WriteVInt(0); 31 | Writer.WriteVInt(0); 32 | Writer.WriteVInt(2); 33 | Writer.WriteVInt(0); 34 | Writer.WriteVInt(0); 35 | Writer.WriteVInt(0); 36 | Writer.WriteVInt(44); 37 | Writer.WriteVInt(0); 38 | Writer.WriteVInt(0); 39 | Writer.WriteVInt(0); 40 | Writer.WriteVInt(0); 41 | Writer.WriteVInt(0); 42 | Writer.WriteVInt(0); 43 | Writer.WriteVInt(0); 44 | Writer.WriteScString("1589977040459"); 45 | Writer.WriteScString("1578395063000"); 46 | Writer.WriteVInt(0); 47 | Writer.WriteVInt(0); 48 | Writer.WriteVInt(0); 49 | Writer.WriteVInt(0); 50 | Writer.WriteHex("ffffffff"); 51 | Writer.WriteScString("EN"); 52 | Writer.WriteHex("ffffffff"); 53 | Writer.WriteVInt(0); 54 | Writer.WriteVInt(0); 55 | Writer.WriteVInt(0); 56 | Writer.WriteVInt(1); 57 | Writer.WriteHex("ffffffff"); 58 | Writer.WriteScString("https://game-assets.brawlstarsgame.com"); 59 | Writer.WriteScString("http://a678dbc1c015a893c9fd-4e8cc3b1ad3a3c940c504815caefa967.r87.cf2.rackcdn.com"); 60 | Writer.WriteScString("https://event-assets.brawlstars.com"); 61 | Writer.WriteScString("https://24b999e6da07674e22b0-8209975788a0f2469e68e84405ae4fcf.ssl.cf2.rackcdn.com/event-assets"); } 62 | } 63 | } -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/Messages/Server/RoomDisconnect.cs: -------------------------------------------------------------------------------- 1 | using BrawlStars.Logic; 2 | using BrawlStars.Utilities.Netty; 3 | using System; 4 | 5 | namespace BrawlStars.Protocol.Messages.Server 6 | { 7 | class RoomDisconnect : PiranhaMessage 8 | { 9 | public RoomDisconnect(Device device) : base(device) 10 | { 11 | Id = 24125; 12 | } 13 | 14 | public override async void Encode() 15 | { 16 | Writer.WriteHex("00000000"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Source/BrawlStars/Protocol/PiranhaMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Threading.Tasks; 4 | using BrawlStars.Logic; 5 | using DotNetty.Buffers; 6 | 7 | namespace BrawlStars.Protocol 8 | { 9 | public class PiranhaMessage 10 | { 11 | public Device.State RequiredState = Device.State.Home; 12 | 13 | public PiranhaMessage(Device device) 14 | { 15 | Device = device; 16 | Writer = Unpooled.Buffer(); 17 | } 18 | 19 | public PiranhaMessage(Device device, IByteBuffer buffer) 20 | { 21 | Device = device; 22 | Reader = buffer; 23 | } 24 | 25 | public IByteBuffer Writer { get; set; } 26 | public IByteBuffer Reader { get; set; } 27 | public Device Device { get; set; } 28 | public ushort Id { get; set; } 29 | public int Length { get; set; } 30 | public ushort Version { get; set; } 31 | public bool Save { get; set; } 32 | 33 | public virtual void Decode() 34 | { 35 | } 36 | 37 | public virtual void Encode() 38 | { 39 | } 40 | 41 | public virtual void Process() 42 | { 43 | } 44 | 45 | public void EncodeCryptoBytes() 46 | { 47 | Writer.WriteShort(-1); 48 | Writer.WriteByte(0); 49 | Writer.WriteInt(0); 50 | } 51 | 52 | /// 53 | /// Writes this message to the clients channel 54 | /// 55 | /// 56 | public async Task SendAsync() 57 | { 58 | try 59 | { 60 | await Device.Handler.Channel.WriteAndFlushAsync(this); 61 | 62 | Logger.Log($"[S] Message {Id} ({GetType().Name}) sent.", GetType(), Logger.ErrorLevel.Debug); 63 | } 64 | catch (Exception) 65 | { 66 | //Logger.Log($"Failed to send {Id}.", GetType(), Logger.ErrorLevel.Debug); 67 | } 68 | } 69 | 70 | public override string ToString() 71 | { 72 | Reader.SetReaderIndex(7); 73 | return ByteBufferUtil.HexDump(Reader.ReadBytes(Length)); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Source/BrawlStars/Resources.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using BrawlStars.Core; 4 | using BrawlStars.Core.Network; 5 | using BrawlStars.Database; 6 | using BrawlStars.Database.Cache; 7 | using BrawlStars.Files; 8 | using BrawlStars.Utilities.Utils; 9 | 10 | namespace BrawlStars 11 | { 12 | public static class Resources 13 | { 14 | public static Logger Logger { get; set; } 15 | public static Configuration Configuration { get; set; } 16 | 17 | public static PlayerDb PlayerDb { get; set; } 18 | 19 | //public static AllianceDb AllianceDb { get; set; } 20 | public static ObjectCache ObjectCache { get; set; } 21 | //public static Leaderboard Leaderboard { get; set; } 22 | 23 | public static NettyService Netty { get; set; } 24 | 25 | public static Fingerprint Fingerprint { get; set; } 26 | public static Csv Csv { get; set; } 27 | 28 | public static Players Players { get; set; } 29 | //public static Alliances Alliances { get; set; } 30 | 31 | public static DateTime StartTime { get; set; } 32 | public static string Name { get; set; } 33 | public static string Region { get; set; } 34 | public static int RoomID { get; set; } 35 | public static int Map { get; set; } 36 | public static int Brawler { get; set; } 37 | public static int Room { get; set; } 38 | public static int Trophies { get; set; } 39 | public static int Skin { get; set; } 40 | public static int SkinId { get; set; } 41 | public static int Box { get; set; } 42 | public static int Gold { get; set; } 43 | public static int Gems { get; set; } 44 | public static int ProfileIcon { get; set; } 45 | public static int NameColor { get; set; } 46 | public static int MessageTick { get; set; } 47 | public static string ChatMessage { get; set; } 48 | public static int Tickets { get; set; } 49 | public static int StarPower { get; set; } 50 | public static int Gadget { get; set; } 51 | public static bool UseGadget { get; set; } 52 | public static async void Initialize() 53 | { 54 | Logger = new Logger(); 55 | Logger.Log( 56 | $"Starting [{DateTime.Now.ToLongTimeString()} - {ServerUtils.GetOsName()}]...", 57 | null); 58 | 59 | Configuration = new Configuration(); 60 | Configuration.Initialize(); 61 | 62 | Fingerprint = new Fingerprint(); 63 | //Levels = new Levels(); 64 | Csv = new Csv(); 65 | 66 | //PlayerDb = new PlayerDb(); 67 | //AllianceDb = new AllianceDb(); 68 | /*for (int i = 0; i <= await PlayerDb.CountAsync() + 1; i++) 69 | { 70 | await PlayerDb.DeleteAsync(i); 71 | }*/ 72 | //PlayerDb = new PlayerDb(); 73 | 74 | /*Logger.Log( 75 | $"Successfully loaded MySql with {await PlayerDb.CountAsync()} player(s)", 76 | null);*/ 77 | 78 | ObjectCache = new ObjectCache(); 79 | 80 | //Players = new Players(); 81 | //Alliances = new Alliances(); 82 | 83 | //Leaderboard = new Leaderboard(); 84 | 85 | StartTime = DateTime.UtcNow; 86 | 87 | Netty = new NettyService(); 88 | 89 | if (Configuration.Name == "") 90 | { 91 | Logger.Log("The name must not be empty.", null, Logger.ErrorLevel.Warning); 92 | Program.Shutdown(); 93 | } 94 | else 95 | { 96 | Name = Configuration.Name; 97 | } 98 | 99 | Map = 7; 100 | 101 | Brawler = 0; 102 | 103 | Room = 0; 104 | 105 | Trophies = Configuration.Trophies; 106 | 107 | Skin = 0; 108 | 109 | Region = Configuration.Region; 110 | 111 | RoomID = 0; 112 | 113 | Box = 3; 114 | 115 | Tickets = 99999; 116 | 117 | Gold = 99999; 118 | 119 | Gems = 99999; 120 | 121 | Skin = 0; 122 | 123 | ProfileIcon = 0; 124 | 125 | NameColor = 0; 126 | 127 | ChatMessage = string.Empty; 128 | 129 | MessageTick = 0; 130 | 131 | StarPower = 76; 132 | 133 | Gadget = 255; 134 | 135 | UseGadget = true; 136 | 137 | await Task.Run(Netty.RunServerAsync); 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /Source/BrawlStars/obj/BrawlStars.csproj.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dgSpecHash": "f9aaRwQlhSijjpL3CnZ32bh1g8s2645/bs6xGJVpEJwFQPqNbxsAuaVSr5+nnXEFKMH8DWIj9i+VRtWnck8k5g==", 4 | "success": true 5 | } -------------------------------------------------------------------------------- /Source/BrawlStars/obj/BrawlStars.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | True 5 | NuGet 6 | $(MSBuildThisFileDirectory)project.assets.json 7 | $(UserProfile)\.nuget\packages\ 8 | C:\Users\Vitalik\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder 9 | PackageReference 10 | 5.5.0 11 | 12 | 13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 14 | 15 | 16 | 17 | 18 | 19 | C:\Users\Vitalik\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.9.10 20 | 21 | -------------------------------------------------------------------------------- /Source/BrawlStars/obj/BrawlStars.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Source/BrawlStars/obj/Debug/netcoreapp3.1/BrawlStars.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("BrawlStars")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("BrawlStars")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("BrawlStars")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Source/BrawlStars/obj/Debug/netcoreapp3.1/BrawlStars.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 870a87f929b82a7305ba02eeec43f2b74bb237f2 2 | -------------------------------------------------------------------------------- /Source/BrawlStars/obj/Debug/netcoreapp3.1/BrawlStars.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars/obj/Debug/netcoreapp3.1/BrawlStars.assets.cache -------------------------------------------------------------------------------- /Source/BrawlStars/server.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VitalikObject/BrawlStars-Server/4bf6528d42785dd7a4fe705d02a15ea27d5eafe3/Source/BrawlStars/server.ico --------------------------------------------------------------------------------