Skip to content

Commit

Permalink
some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
PhoenixFire6934 committed Jan 28, 2021
1 parent c8e0602 commit f382487
Show file tree
Hide file tree
Showing 61 changed files with 224 additions and 229 deletions.
2 changes: 2 additions & 0 deletions Logic/Player.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ class Players:
gems = settings['Gems']
gold = settings['Gold']
tickets = settings['Tickets']
exp_points = settings['ExperiencePoints']
theme_id = 41000000 + settings['ThemeID']
content_creator = settings['SupportedContentCreator']
tokens = 0


Expand Down
61 changes: 0 additions & 61 deletions Packets/CommandFactory.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from Database.DataBase import DataBase
from Packets.Commands.Server.Buy_Brawl_Box_Callback import BuyBrawlBoxCallback
from Packets.Commands.Server.LogicBoxDataCommand import LogicBoxDataCommand

from Utils.Reader import BSMessageReader

class BuyBrawlBox(BSMessageReader):
class LogicPurchaseBoxCommand(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand All @@ -18,4 +18,4 @@ def decode(self):


def process(self):
BuyBrawlBoxCallback(self.client, self.player).send()
LogicBoxDataCommand(self.client, self.player).send()
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from Database.DataBase import DataBase
from Logic.Shop import Shop
from Packets.Messages.Server.Gameroom.Team_Gameroom_Data_Message import TeamGameroomDataMessage
from Packets.Messages.Server.Gameroom.TeamGameroomDataMessage import TeamGameroomDataMessage

from Utils.Reader import BSMessageReader

class BuyTokenDoubler(BSMessageReader):
class LogicPurchaseDoubleCoinsCommand(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from Utils.Reader import BSMessageReader

class BuyGold(BSMessageReader):
class LogicPurchaseHeroLvlUpMaterialCommand(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from Packets.Commands.Server.Buy_Brawl_Box_Callback import BuyBrawlBoxCallback
from Packets.Messages.Server.Out_Of_Sync_Message import OutOfSyncMessage
from Packets.Commands.Server.LogicBoxDataCommand import LogicBoxDataCommand
from Packets.Messages.Server.OutOfSyncMessage import OutOfSyncMessage
from Database.DataBase import DataBase
from Logic.Shop import Shop

from Utils.Reader import BSMessageReader

class BuyOffer(BSMessageReader):
class LogicPurchaseOfferCommand(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down Expand Up @@ -47,7 +47,7 @@ def res(type):

res(type)

BuyBrawlBoxCallback(self.client, self.player).send()
LogicBoxDataCommand(self.client, self.player).send()

else:
OutOfSyncMessage(self.client, self.player, f'Claiming offer with type {id} is not supported yet').send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from Utils.Reader import BSMessageReader
from Files.CsvLogic.Cards import Cards

class SelectBrawler(BSMessageReader):
class LogicSelectSkinCommand(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from Utils.Reader import BSMessageReader

class SelectNameColor(BSMessageReader):
class LogicSetPlayerNameColorCommand(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from Database.DataBase import DataBase
from Packets.Messages.Server.Gameroom.Team_Gameroom_Data_Message import TeamGameroomDataMessage
from Packets.Messages.Server.Gameroom.TeamGameroomDataMessage import TeamGameroomDataMessage

from Utils.Reader import BSMessageReader

class SelectStarpower(BSMessageReader):
class LogicSetPlayerStarpowerCommand(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from Utils.Reader import BSMessageReader

class SelectThumbnail(BSMessageReader):
class LogicSetPlayerThumbnailCommand(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from Database.DataBase import DataBase
from Logic.Shop import Shop

class BuyBrawlBoxCallback(Writer):
class LogicBoxDataCommand(Writer):

def __init__(self, client, player):
super().__init__(client)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from Utils.Writer import Writer
from Database.DataBase import DataBase

class ChangeNameCallback(Writer):
class LogicChangeAvatarNameCommand(Writer):

def __init__(self, client, player, state):
super().__init__(client)
Expand Down
44 changes: 0 additions & 44 deletions Packets/Factory.py

This file was deleted.

61 changes: 61 additions & 0 deletions Packets/LogicCommandManager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from Utils.Reader import BSMessageReader
from Packets.Commands.Client.LogicSetPlayerThumbnailCommand import LogicSetPlayerThumbnailCommand
from Packets.Commands.Client.LogicSetPlayerNameColorCommand import LogicSetPlayerNameColorCommand
from Packets.Commands.Client.LogicPurchaseBoxCommand import LogicPurchaseBoxCommand
from Packets.Commands.Client.LogicPurchaseOfferCommand import LogicPurchaseOfferCommand
from Packets.Commands.Client.LogicSelectSkinCommand import LogicSelectSkinCommand
from Packets.Commands.Client.LogicSetPlayerStarpowerCommand import LogicSetPlayerStarpowerCommand
from Packets.Commands.Client.LogicPurchaseHeroLvlUpMaterialCommand import LogicPurchaseHeroLvlUpMaterialCommand
from Packets.Commands.Client.LogicPurchaseDoubleCoinsCommand import LogicPurchaseDoubleCoinsCommand



class EndClientTurn(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.client = client
self.player = player

def decode(self):
self.read_Vint()
self.read_Vint()
self.read_Vint()
self.read_Vint()
self.commandID = self.read_Vint()


def process(self):
if self.commandID == 500 or self.commandID == 517 or self.commandID == 535:
LogicPurchaseBoxCommand.decode(self)
LogicPurchaseBoxCommand.process(self)

elif self.commandID == 519:
LogicPurchaseOfferCommand.decode(self)
LogicPurchaseOfferCommand.process(self)

elif self.commandID == 505:
LogicSetPlayerThumbnailCommand.decode(self)
LogicSetPlayerThumbnailCommand.process(self)

elif self.commandID == 506:
LogicSelectSkinCommand.decode(self)
LogicSelectSkinCommand.process(self)

elif self.commandID == 521:
LogicPurchaseHeroLvlUpMaterialCommand.decode(self)
LogicPurchaseHeroLvlUpMaterialCommand.process(self)

elif self.commandID == 509:
LogicPurchaseDoubleCoinsCommand.decode(self)
LogicPurchaseDoubleCoinsCommand.process(self)

elif self.commandID == 527:
LogicSetPlayerNameColorCommand.decode(self)
LogicSetPlayerNameColorCommand.process(self)

elif self.commandID == 529:
LogicSetPlayerStarpowerCommand.decode(self)
LogicSetPlayerStarpowerCommand.process(self)

elif self.commandID >= 0:
print("Command ID", self.commandID, "is not handled!")
44 changes: 44 additions & 0 deletions Packets/LogicMessageFactory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from Packets.Messages.Client.Login.ClientHelloMessage import ClientHelloMessage
from Packets.Messages.Client.Login.LoginMessage import LoginMessage
from Packets.Messages.Client.Alliance.ChatToAllianceStreamMessage import ChatToAllianceStreamMessage
from Packets.Messages.Client.KeepAliveMessage import KeepAliveMessage
from Packets.Messages.Client.Gameroom.TeamCreateMessage import TeamCreateMessage
from Packets.Messages.Client.Battle.GoHomeFromOfflinePractiseMessage import GoHomeFromOfflinePractiseMessage
from Packets.Messages.Client.Gameroom.TeamLeaveMessage import TeamLeaveMessage
from Packets.Messages.Client.Home.AskProfileMessage import AskProfileMessage
from Packets.Messages.Client.Alliance.AskForAllianceDataMessage import AskForAllianceDataMessage
from Packets.Messages.Client.Gameroom.TeamSetLocationMessage import TeamSetLocationMessage
from Packets.Messages.Client.Gameroom.TeamChangeMemberSettingsMessage import TeamChangeMemberSettingsMessage
from Packets.Messages.Client.AnalyticsEventMessage import AnalyticsEventMessage
from Packets.Messages.Client.Battle.AskForBattleEndMessage import AskForBattleEndMessage
from Packets.Messages.Client.SetNameMessage import SetNameMessage
from Packets.Messages.Client.Home.GetLeaderboardMessage import GetLeaderboardMessage
from Packets.Messages.Client.Home.AvatarNameCheckRequestMessage import AvatarNameCheckRequestMessage
from Packets.Messages.Client.Gameroom.TeamUseGadgetMessage import TeamUseGadgetMessage
from Packets.Messages.Client.Gameroom.Do_Not_Distrub_Message import DoNotDistrubMessage
from Packets.Messages.Client.Home.PlayerStatusMessage import PlayerStatusMessage
from Packets.LogicCommandManager import EndClientTurn

packets = {
10100: ClientHelloMessage,
10101: LoginMessage,
10108: KeepAliveMessage,
10110: AnalyticsEventMessage,
10212: SetNameMessage,
14102: EndClientTurn,
14109: GoHomeFromOfflinePractiseMessage,
14110: AskForBattleEndMessage,
14113: AskProfileMessage,
14403: GetLeaderboardMessage,
14302: AskForAllianceDataMessage,
14315: ChatToAllianceStreamMessage,
14350: TeamCreateMessage,
14353: TeamLeaveMessage,
14363: TeamSetLocationMessage,
14354: TeamChangeMemberSettingsMessage,
14372: TeamUseGadgetMessage,
14600: AvatarNameCheckRequestMessage,
14366: PlayerStatusMessage,
14777: DoNotDistrubMessage,

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from Packets.Messages.Server.Alliance.Alliance_Data_Message import AllianceDataMessage
from Packets.Messages.Server.Alliance.AllianceDataMessage import AllianceDataMessage

from Utils.Reader import BSMessageReader

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from Packets.Messages.Server.Alliance.Alliance_Chat_Server_Message import AllianceChatServerMessage
from Packets.Messages.Server.AllianceBot.Alliance_Bot_Chat_Server_Message import AllianceBotChatServerMessage
from Packets.Messages.Server.Out_Of_Sync_Message import OutOfSyncMessage
from Packets.Messages.Server.Alliance.AllianceStreamMessage import AllianceStreamMessage
from Packets.Messages.Server.AllianceBot.AllianceBotStreamMessage import AllianceBotStreamMessage
from Packets.Messages.Server.OutOfSyncMessage import OutOfSyncMessage
from Database.DataBase import DataBase

from Utils.Reader import BSMessageReader


class AllianceChatMessage(BSMessageReader):
class ChatToAllianceStreamMessage(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down Expand Up @@ -65,11 +65,11 @@ def decode(self):


def process(self):
AllianceChatServerMessage(self.client, self.player, self.msg).send()
AllianceStreamMessage(self.client, self.player, self.msg).send()
self.player.message_tick += 1

if self.bot_msg != '':
AllianceBotChatServerMessage(self.client, self.player, self.bot_msg).send()
AllianceBotStreamMessage(self.client, self.player, self.bot_msg).send()
self.player.message_tick += 1

if self.send_ofs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from Packets.Messages.Server.Battle.Battle_Result_Message import BattleResultMessage
from Packets.Messages.Server.Battle.Battle_Result2_Message import BattleResult2Message
from Packets.Messages.Server.Battle.BattleResultMessage import BattleResultMessage
from Packets.Messages.Server.Battle.BattleResult2Message import BattleResult2Message

from Utils.Reader import BSMessageReader


class BattleEndMessage(BSMessageReader):
class AskForBattleEndMessage(BSMessageReader):
def __init__(self, client, player, initial_bytes):
super().__init__(initial_bytes)
self.player = player
Expand Down
Loading

0 comments on commit f382487

Please sign in to comment.