namespace Supercell.Laser.Logic.Message.Battle { using Supercell.Laser.Logic.Battle.Structures; using Supercell.Laser.Logic.Helper; using Supercell.Laser.Logic.Home.Quest; public class BattleEndMessage : GameMessage { public BattleEndMessage() : base() { ProgressiveQuests = new List(); RankedMatch = false; Rank = 0; UpRank = 0; ELO = 0; NewELO = 0; Add = 0; BlueTeamWins = 0; RedTeamWins = 0; Round = 0; } public int Result; public int TokensReward; public int TrophiesReward; public int DoubledTokensReward; public int TokenDoublersLeft; public int ExperienceReward; public int Experience; public int MilestoneReward; public int StarExperienceReward; public List Players; public BattlePlayer[] pp; public List ProgressiveQuests; public BattlePlayer OwnPlayer; public bool StarToken; public int UnderdogTrophies; public int PowerPlayScoreGained; public int PowerPlayEpicScoreGained; public List MilestoneRewards; public int GameMode; public bool HasNoTokens; public bool IsPvP; public bool IsPowerPlay; public bool RankedMatch; public int MatchType; public bool isMatchOver; public int Rank; public int UpRank; public int ELO; public int NewELO; public int BlueTeamWins; public int RedTeamWins; public int Round; public bool Solo; public int Add; public override void Encode() { Stream.WriteLong(1); Stream.WriteLong(1); Stream.WriteVInt(GameMode); // game mode Stream.WriteVInt(Result); Stream.WriteVInt(TokensReward); // tokens reward Stream.WriteVInt(TrophiesReward); // trophies reward Stream.WriteVInt(PowerPlayScoreGained); Stream.WriteVInt(DoubledTokensReward); Stream.WriteVInt(0); Stream.WriteVInt(TokenDoublersLeft); Stream.WriteVInt(0); Stream.WriteVInt(PowerPlayEpicScoreGained); Stream.WriteVInt(0); Stream.WriteVInt(0); Stream.WriteVInt(0); Stream.WriteVInt(0); Stream.WriteVInt(0); Stream.WriteVInt(0); Stream.WriteVInt(UnderdogTrophies); Stream.WriteBoolean(false);//gemofer Stream.WriteBoolean(false); // no experience Stream.WriteBoolean(HasNoTokens); // no tokens left Stream.WriteBoolean(false); Stream.WriteBoolean(IsPvP); // is PvP Stream.WriteBoolean(false); Stream.WriteBoolean(IsPowerPlay); Stream.WriteVInt(-1); Stream.WriteBoolean(false); Stream.WriteVInt(Players.Count); foreach (BattlePlayer player in Players) { Stream.WriteBoolean(player.AccountId == OwnPlayer.AccountId); // is own player Stream.WriteBoolean(player.TeamIndex != OwnPlayer.TeamIndex); // is enemy Stream.WriteBoolean(false); // Star player ByteStreamHelper.WriteDataReference(Stream, player.CharacterId); ByteStreamHelper.WriteDataReference(Stream, player.SkinIds[0]); // skin Stream.WriteVInt(player.Trophies); // trophies Stream.WriteVInt(0); Stream.WriteVInt(player.HeroPowerLevel + 1); // power level Stream.WriteVInt(player.Avatar?.RankedRank ?? 0); //rank before the match bool isOwn = player.AccountId == OwnPlayer.AccountId; Stream.WriteBoolean(isOwn); if (isOwn) { Stream.WriteLong(player.AccountId); } player.DisplayData.Encode(Stream); } Stream.WriteVInt(2); { Stream.WriteVInt(0); Stream.WriteVInt(ExperienceReward); Stream.WriteVInt(8); Stream.WriteVInt(StarExperienceReward); } Stream.WriteVInt(0); Stream.WriteVInt(2); { Stream.WriteVInt(1); Stream.WriteVInt(OwnPlayer.Trophies); // Trophies Stream.WriteVInt(OwnPlayer.HighestTrophies); // Highest Trophies Stream.WriteVInt(5); Stream.WriteVInt(Experience); Stream.WriteVInt(Experience); } ByteStreamHelper.WriteDataReference(Stream, 28000000); Stream.WriteBoolean(false); //play again // Stream.WriteBoolean(false);//quests if (Stream.WriteBoolean(ProgressiveQuests.Count > 0)) { Stream.WriteVInt(ProgressiveQuests.Count); foreach (Quest quest in ProgressiveQuests) { quest.Encode(Stream); } } Stream.WriteVInt(0); Stream.WriteVInt(0); //new in v33+ if (Stream.WriteBoolean(RankedMatch))//ranked { bool isMatchOver = (BlueTeamWins >= 2 || RedTeamWins >= 2); int nextRoundValue = isMatchOver ? 0 : (Round + 1); Stream.WriteVInt(3);//season? Stream.WriteVInt(Solo ? 0 : 1);//type (solo/team) //Stream.WriteVInt(7500);//old total progress //Stream.WriteVInt(17);//old rank // if(Result == 0) // { // Stream.WriteVInt(0); // old total progress // Stream.WriteVInt(0); // old rank // } // else // { Stream.WriteVInt(ELO); // old total progress Stream.WriteVInt(Rank); // old rank // } Stream.WriteVInt(NewELO);//new total progress Stream.WriteVInt(UpRank);//new rank Stream.WriteVInt(Add);//point gained or lost if (OwnPlayer.TeamIndex == 0) { Stream.WriteVInt(BlueTeamWins); Stream.WriteVInt(RedTeamWins); } else { Stream.WriteVInt(RedTeamWins); Stream.WriteVInt(BlueTeamWins); } Stream.WriteVInt(Round);//next round Stream.WriteVInt(10); //time Stream.WriteVInt(0);//quests?? // Stream.WriteVInt(isMatchOver ? 0 : 1); //показывать need rounds for win? Stream.WriteBoolean(false); Stream.WriteBoolean(false); //end } Stream.WriteVInt(-1); Stream.WriteBoolean(false); } /* if (Stream.WriteBoolean(RankedMatch)) { bool isMatchOver = (TrueBlueTeamWins >= 2 || TrueRedTeamWins >= 2); int nextRoundValue = isMatchOver ? 0 : (Round + 1); // Console.WriteLine($"[BattleEndMessage] Отправка ranked данных: MatchType={(Solo ? 0 : 1)}, oldProgress={ELO}, oldRank={Rank}, newProgress={NewELO}, newRank={UpRank}, Add={Add}"); Stream.WriteVInt(6); Stream.WriteVInt(Solo ? 0 : 1); // matchtype if(Result == 0) { Stream.WriteVInt(0); // old total progress (общий прогресс ДО боя) Stream.WriteVInt(0); // old rank } else { Stream.WriteVInt(ELO); // old total progress (общий прогресс ДО боя) Stream.WriteVInt(Rank); } // old rank Stream.WriteVInt(NewELO); // new total progress (общий прогресс ПОСЛЕ боя) Stream.WriteVInt(UpRank); // new rank Stream.WriteVInt(Add); // points gained/lost (MMR change) Stream.WriteVInt(TrueBlueTeamWins); // win true blue team Stream.WriteVInt(TrueRedTeamWins); // win true red team Stream.WriteVInt(Round); //next round Stream.WriteVInt(10); // time Stream.WriteVInt(0); // quest later bru //if (Stream.WriteBoolean(false)) //{ // if (Stream.WriteBoolean(true)) // { // Stream.WriteVInt(1); // Stream.WriteVInt(1); // } // Stream.WriteBoolean(true); // new GemOffer(1, 1, 0, 0).Encode(Stream); //} Stream.WriteVInt(isMatchOver ? 0 : 1); //показывать need rounds for win? //Stream.WriteBoolean(false); Stream.WriteVInt(0); //if (Stream.WriteBoolean(true)) //{ // if (Stream.WriteBoolean(true)) // { // Stream.WriteVInt(1); // total // Stream.WriteVInt(999); // goal // } // // Stream.WriteBoolean(true); // new GemOffer(16, 1, 0, 0).Encode(Stream); // } Stream.WriteVInt(0); //Stream.WriteBoolean(false); Stream.WriteBoolean(false); //Stream.WriteVInt(1); //Stream.WriteVInt(1); Stream.WriteBoolean(false); //Stream.WriteVInt(1); //Stream.WriteVInt(1); Stream.WriteBoolean(false); // debug? //for(int i = 0; i < 9; i++) //{ // Stream.WriteVInt(i); //} Stream.WriteVInt(2); // round needed Stream.WriteVInt(0); }*/ /* public override void Encode() { base.Encode(); Stream.WriteLong(Long1); // +136 Stream.WriteLong(Long2); // +144 Stream.WriteVInt(Int1); // +152 Stream.WriteVInt(Int2); // +156 Stream.WriteVInt(Int3); // +160 Stream.WriteVInt(Int4); // +164 Stream.WriteVInt(Int5); // +168 Stream.WriteVInt(Int6); // +172 Stream.WriteVInt(Int7); // +176 Stream.WriteVInt(Int8); // +180 Stream.WriteVInt(Int9); // +184 Stream.WriteVInt(Int10); // +188 Stream.WriteVInt(Int11); // +192 if (GemOffer != null) // +208 { Stream.WriteBoolean(true); GemOffer.Encode(Stream); } else { Stream.WriteBoolean(false); } Stream.WriteVInt(Int12); // +196 Stream.WriteVInt(Int13); // +200 Stream.WriteBoolean(Bool1); // +204 Stream.WriteVInt(Int14); // +216 Stream.WriteVInt(Int15); // +220 Stream.WriteBoolean(Bool2); // +224 Stream.WriteBoolean(Bool3); // +225 Stream.WriteBoolean(Bool4); // +226 Stream.WriteBoolean(Bool5); // +227 Stream.WriteBoolean(Bool6); // +228 Stream.WriteBoolean(Bool7); // +229 Stream.WriteBoolean(Bool8); // +230 Stream.WriteVInt(Int16); // +232 Stream.WriteBoolean(Bool9); // +236 // PlayerEntry list Stream.WriteVInt(PlayerEntries.Count); foreach (PlayerEntry entry in PlayerEntries) { entry.Encode(Stream); } // XpEntry list if (XpEntries != null) { Stream.WriteVInt(XpEntries.Count); foreach (XpEntry entry in XpEntries) { entry.Encode(Stream); } } else { Stream.WriteVInt(0); } // Milestone reward list (DataReference) if (MilestoneRewards != null) { Stream.WriteVInt(MilestoneRewards.Count); foreach (LogicData reward in MilestoneRewards) { ByteStreamHelper.WriteDataReference(Stream, reward); } } else { Stream.WriteVInt(0); } // LogicMilestoneProgress list if (MilestoneProgresses != null) { Stream.WriteVInt(MilestoneProgresses.Count); foreach (LogicMilestoneProgress progress in MilestoneProgresses) { progress.Encode(Stream); } } else { Stream.WriteVInt(0); } ByteStreamHelper.WriteDataReference(Stream, RewardData); // +272 // PlayAgainStatus Stream.WriteBoolean(PlayAgainStatus != null); if (PlayAgainStatus != null) { PlayAgainStatus.Encode(Stream); } // LogicQuests Stream.WriteBoolean(Quests != null); if (Quests != null) { Quests.Encode(Stream); } Stream.WriteVInt(Int17); // +304 Stream.WriteVInt(Int18); // +308 // Ranked state Stream.WriteBoolean(RankedRoundState != null); if (RankedRoundState != null) { RankedRoundState.Encode(Stream); } Stream.WriteVInt(Int19); // +312 // Chronos text Stream.WriteBoolean(ChronosText != null); if (ChronosText != null) { ChronosText.Encode(Stream); } }*/ public override int GetMessageType() { return 23456; } public override int GetServiceNodeType() { return 27; } } }