src.dcss.connection.autobahn_game_connection

Module Contents

Classes

DCSSProtocol

Base class for asyncio-based WebSocket client protocols.

class src.dcss.connection.autobahn_game_connection.DCSSProtocol

Bases: autobahn.asyncio.websocket.WebSocketClientProtocol

Base class for asyncio-based WebSocket client protocols.

Implements:

  • autobahn.websocket.interfaces.IWebSocketChannel

onConnect(response)

Callback fired directly after WebSocket opening handshake when new WebSocket server connection was established.

Parameters:

response (instance of autobahn.websocket.types.ConnectionResponse) – WebSocket connection response information.

async onOpen()
onMessage(payload, isBinary)

Implements autobahn.websocket.interfaces.IWebSocketChannel.onMessage()

reset_before_next_game()
perform_state_checks(json_msg)
check_for_in_lobby(json_msg)
check_for_ping(json_msg)
check_for_enter_key(json_msg)
check_for_inventory_menu(json_msg)
check_for_all_spells_menu(json_msg)
check_for_skills_menu(json_msg)
get_spell_menu_options(json_msg)
get_skill_menu_options(json_msg)
check_for_attribute_increase(json_msg)
check_for_walk_into_teleport_trap(json_msg)
check_for_renounce_religion_prompt(json_msg)
check_for_are_you_sure_text_menu(json_msg)
check_for_no_longer_in_text_menu(json_msg)

After choosing an option in a text menu, getting one of the following messages means you are no longer in that text menu

check_for_ability_menu(json_msg)
get_ability_menu_options(json_msg)
{“msgs”:
[{“msg”:”input_mode”,”mode”:0},
{“msg”:”menu”,”ui-centred”:false,”tag”:”ability”,”flags”:3154,

“title”:{“text”:” <white>Ability - do what? Cost Failure”}, “more”:”Press ‘<white>!<lightgrey>’ or ‘<white>?<lightgrey>’ to toggle between ability selection and description.”, “total_items”:3, “chunk_start”:0, “items”:[{“text”:” Invocations - “,”colour”:1,”level”:1},

{“text”:” X - Renounce Religion None 0%”,”q”:1,”hotkeys”:[88],”level”:2,”tiles”:[{“t”:7696,”tex”:5}]}, {“text”:” a - Berserk None 0%”,”q”:1,”hotkeys”:[97],”level”:2,”tiles”:[{“t”:7795,”tex”:5}]}]}

check_for_sprint_map_menu(json_msg)
check_for_game_seed_menu(json_msg)
check_for_pregeneration_check_true(json_msg)
check_for_tutorial_menu(json_msg)
check_for_login_success(json_msg)
check_for_lobby_clear(json_msg)
check_for_game_started(json_msg)
check_received_map_data(json_msg)
check_if_player_died(json_msg)
check_for_death_message(json_msg)
check_for_species_selection_menu(json_msg)
get_species_options(json_msg)
check_for_background_selection_menu(json_msg)
get_background_options(json_msg)
check_for_weapon_selection_menu(json_msg)
get_weapon_options(json_msg)
check_for_action_limit_reached()
check_for_close_all_menus(json_msg)

Checks for the ‘close_all_menus’ message from server to exit out of menus

check_for_item_description_menu(json_msg)
{‘msgs’: [{‘msg’: ‘update_menu_items’,

‘chunk_start’: 1, ‘items’: [{‘text’: ‘ a + a +0 hand axe (weapon)’, ‘colour’: 10, ‘tiles’: [{‘t’: 4152, ‘tex’: 4}, {‘t’: 3041, ‘tex’: 4}]}]},

{‘title’: ‘a - a +0 hand axe (weapon).’,

‘body’: “A small axe.

Base accuracy: +3 Base damage: 7 Base attack delay: 1.3 This

weapon’s minimum attack delay (0.6) is reached at skill level 14.

Your skill: 3.6; use <white>(s)<lightgrey> to set

14.0 as a target for Axes.

At 100% training you would reach 14.0 in about 8.0 XLs.

At current training (39%) you reach 14.0 in about 10.6 XLs.

It hits all enemies adjacent to the wielder,

dealing less damage to those not targeted.

This weapon falls into the ‘Axes’ category. It is a one handed

weapon.

It can be maximally enchanted to +9.

Stash search prefixes: {inventory} {Axes} {one-handed} {melee weapon}

Menu/colouring prefixes: identified uncursed melee equipped weapon

“Lizzie Borden took an axe
And gave her

mother forty whacks.

When she saw what she had done She gave her father forty-one.”

-A popular skipping-rope

rhyme, after 1893.

SPELLSET_PLACEHOLDER”,

‘spellset’: [], ‘actions’: ‘(=)adjust, (u)nwield, (s)kill, (d)rop, or (i)nscribe.’, ‘tiles’: [{‘t’: 4152, ‘tex’: 4},

{‘t’: 3041, ‘tex’: 4}], ‘msg’: ‘ui-push’, ‘type’: ‘describe-item’, ‘ui-centred’: False, ‘generation_id’: 3}]}

check_for_identify_which_item_menu(json_msg)

When you read a scroll of identify, you will get to a special menu of all things you can identify.

This function checks for this menu.

data looks like:

into: {“msgs”:[{“msg”:”input_mode”,”mode”:0},
{“msg”:”menu”,”ui-centred”:false,”tag”:”inventory”,”flags”:2,

“title”:{“text”:”<white>Identify which item? (to view known items)”}, “more”:””,”total_items”:2,”chunk_start”:0, “items”:[{“text”:”Scrolls”,”colour”:1,”level”:1},

{“text”:” e - a scroll labelled AMAPPOAXZA”,”q”:1,”colour”:9,

“hotkeys”:[101,63],”level”:2,”tiles”:[{“t”:3424,”tex”:4}]}]}

,{“msg”:”player”,

“inv”:{“3”:{“sub_type”:0,”flags”:2,”name”:”scroll of identify”,”col”:-1,”tile”:[3424,3425]}}}

,{“msg”:”msgs”,”more”:false}

]}

check_for_close_nested_menu(json_msg)

{“msgs”:[{“msg”:”ui-pop”}

,{“msg”:”update_menu_items”,”chunk_start”:1,”items”:[{“text”:” a - a +0 hand axe (weapon)”,”colour”:10,”tiles”:[{“t”:4152,”tex”:4},{“t”:3041,”tex”:4}]}]}

get_hotkey_json_as_msg(hotkey)
get_gamestate()
check_agent_wants_to_start_next_game()
set_ai_class(agent_class)
load_ai_class()
onClose(wasClean, code, reason)

Implements autobahn.websocket.interfaces.IWebSocketChannel.onClose()