Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe bug #72

Open
Mrfull opened this issue Jul 17, 2021 · 1 comment
Open

Maybe bug #72

Mrfull opened this issue Jul 17, 2021 · 1 comment

Comments

@Mrfull
Copy link

Mrfull commented Jul 17, 2021

When i try to handle lobby_changed and check all_members bot return this:

[2021-07-17 17:33:05,837] DEBUG Dota2Client.socache: Emit event: ('updated', <ESOType.CSODOTALobby: 2004>)
[2021-07-17 17:33:05,838] DEBUG Dota2Client: Emit event: 'lobby_changed'
[2021-07-17 17:33:05,838] INFO root: Event: Lobby Change: lobby_id: 27287648318433685
game_mode: 21
state: UI
leader_id: 76561199183817488
lobby_type: PRACTICE
allow_cheats: false
fill_with_bots: false
intro_mode: false
game_name: "CyberT | test"
server_region: 0
cm_pick: DOTA_CM_RANDOM
allow_spectating: true
bot_difficulty_radiant: BOT_DIFFICULTY_PASSIVE
game_version: GAME_VERSION_CURRENT
leagueid: 0
penalty_level_radiant: 0
penalty_level_dire: 0
series_type: 0
radiant_series_wins: 0
dire_series_wins: 0
allchat: false
dota_tv_delay: LobbyDotaTV_120
lan: false
visibility: DOTALobbyVisibility_Public
previous_match_override: 0
pause_setting: LobbyDotaPauseSetting_Unlimited
bot_difficulty_dire: BOT_DIFFICULTY_PASSIVE
bot_radiant: 0
bot_dire: 0
selection_priority_rules: k_DOTASelectionPriorityRules_Manual
league_node_id: 0
league_phase: 0
all_members {
  id: 76561199183817488
  team: DOTA_GC_TEAM_PLAYER_POOL
  name: "cybertbot3"
  slot: 0
  leaver_status: DOTA_LEAVER_DISCONNECTED
  partner_account_type: PARTNER_NONE
  favorite_team_packed: 0
  is_plus_subscriber: true
  was_mvp_last_game: false
}
all_members {
  id: 76561198254757677
  team: DOTA_GC_TEAM_PLAYER_POOL
  name: "Mr.full"
  leaver_status: DOTA_LEAVER_DISCONNECTED
  channel: 6
  partner_account_type: PARTNER_NONE
  favorite_team_packed: 0
  is_plus_subscriber: false
  was_mvp_last_game: false
}
member_indices: 0
member_indices: 1

[2021-07-17 17:33:05,838] INFO root: Event: State: 0
all members len: 2
All members: [id: 76561199183817488
team: DOTA_GC_TEAM_PLAYER_POOL
name: "cybertbot3"
slot: 0
leaver_status: DOTA_LEAVER_DISCONNECTED
partner_account_type: PARTNER_NONE
favorite_team_packed: 0
is_plus_subscriber: true
was_mvp_last_game: false
, id: 76561198254757677
team: DOTA_GC_TEAM_PLAYER_POOL
name: "Mr.full"
leaver_status: DOTA_LEAVER_DISCONNECTED
channel: 6
partner_account_type: PARTNER_NONE
favorite_team_packed: 0
is_plus_subscriber: false
was_mvp_last_game: false
]

And that is correct, but if player leave lobby i get:

[2021-07-17 17:33:12,487] DEBUG Dota2Client: Emit event: 'lobby_changed'
[2021-07-17 17:33:12,487] INFO root: Event: Lobby Change: lobby_id: 27287648318433685
game_mode: 21
state: UI
leader_id: 76561199183817488
lobby_type: PRACTICE
allow_cheats: false
fill_with_bots: false
intro_mode: false
game_name: "CyberT | test"
server_region: 0
cm_pick: DOTA_CM_RANDOM
allow_spectating: true
bot_difficulty_radiant: BOT_DIFFICULTY_PASSIVE
game_version: GAME_VERSION_CURRENT
leagueid: 0
penalty_level_radiant: 0
penalty_level_dire: 0
series_type: 0
radiant_series_wins: 0
dire_series_wins: 0
allchat: false
dota_tv_delay: LobbyDotaTV_120
lan: false
visibility: DOTALobbyVisibility_Public
previous_match_override: 0
pause_setting: LobbyDotaPauseSetting_Unlimited
bot_difficulty_dire: BOT_DIFFICULTY_PASSIVE
bot_radiant: 0
bot_dire: 0
selection_priority_rules: k_DOTASelectionPriorityRules_Manual
league_node_id: 0
league_phase: 0
all_members {
  id: 76561199183817488
  team: DOTA_GC_TEAM_PLAYER_POOL
  name: "cybertbot3"
  slot: 0
  leaver_status: DOTA_LEAVER_DISCONNECTED
  partner_account_type: PARTNER_NONE
  favorite_team_packed: 0
  is_plus_subscriber: true
  was_mvp_last_game: false
}
all_members {
}
member_indices: 0
free_member_indices: 1

[2021-07-17 17:33:12,487] INFO root: Event: State: 0
all members len: 2
All members: [id: 76561199183817488
team: DOTA_GC_TEAM_PLAYER_POOL
name: "cybertbot3"
slot: 0
leaver_status: DOTA_LEAVER_DISCONNECTED
partner_account_type: PARTNER_NONE
favorite_team_packed: 0
is_plus_subscriber: true
was_mvp_last_game: false
, ]

So, as you can see script don't clear array of all_members

My code:


  class DotaController:
      def  __init__(self):
          self.client = SteamClient()
          self.dota = Dota2Client(self.client)

        # get lobby proto
        CSODOTALobbyProto = so.find_so_proto(ESOType.CSODOTALobby)
        LobbyState = CSODOTALobbyProto.State

        # add this callback for event 'lobby_changed'
        self.dota.on('lobby_changed', self.lobby_change_handler)
        self.client.on('disconnected', self.reconnect_client)

        # lobby state handler dispatch
        self.state_handler_dispatch = dict([
            (LobbyState.UI, self.test),
            (LobbyState.READYUP, self.test),
            (LobbyState.NOTREADY, self.test),
            (LobbyState.SERVERSETUP, self.test),
            (LobbyState.RUN, self.test),
            (LobbyState.POSTGAME, self.post_game_handler),
            (LobbyState.SERVERASSIGN, self.test)
        ])

    def lobby_change_handler(self, message):
        logging.info(f"Event: Lobby Change: {message}")

        # if message field has state
        print("all members: " + str(len(message.all_members)))
        if message.HasField('state'):
            # call appropriate handler for lobby state

            self.state_handler_dispatch[message.state](message)

    def post_game_handler(self, message):
        print("message: " + str(message))
        print("match_outcome: " + str(message.match_outcome))

    def test(self, message):
        logging.info(f"Event: State: {message.state}")
@Mrfull
Copy link
Author

Mrfull commented Jul 18, 2021

For sure i'm authorised

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant