def __init__(self, unit, attr, value, length, emoji=None): self.value = value self.attr = attr self.unit = unit setattr(self.unit, self.attr, getattr(self.unit, self.attr) + self.value) self.unit.boost_attribute(attr, value) CustomStatus(unit, delay=length, func=self.stop_buff, order=59, acting=True, name='buff_{}_{}'.format(attr, engine.rand_id()), emoji=emoji)
def __init__(self, unit=None, obj_dict=None): self.unit = unit self.table_row = None self.get_table_row() self.types = [*self.core_types, *self.types] self.ready_turn = 0 self.id = str(engine.rand_id()) if obj_dict is not None: self.from_dict(obj_dict)
def handle(call): call_data = call.data.split('_') action = call_data[2] try: lobby = dynamic_dicts.lobby_list[call_data[1]] except: return False if action == 'startlobby': dynamic_dicts.lobby_list[call_data[1]].start() elif action == 'equipment': user_id = call.from_user.id unit_dict = lobby[user_id]['unit_dict'] user = get_user(call.from_user.id) chat = get_chat(lobby.chat_id) item_type = call_data[3] item_name = call_data[-1] item = standart_actions.object_dict[item_name]() if item_name not in ['reset', 'ready'] else None if item_name == 'reset': if item_type == 'armor': for armor in unit_dict['armor']: chat.delete_used_item(armor['name']) unit_dict['armor'] = [] elif item_type == 'item': for item_unit in unit_dict['inventory'].values(): chat.delete_used_item(item_unit[0]['name'], value=item_unit[1]) unit_dict['inventory'] = {} user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id) elif item_name == 'ready': lobby[user_id]['equipment_choice'].pop() lobby.run_next_step(user_id, message_id=call.message.message_id) elif item_name not in chat.get_free_armory(): bot_methods.answer_callback_query(call, 'Этого предмета уже нет на складе') user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id) elif not item.try_placement(unit_dict): bot_methods.answer_callback_query(call, 'Вы не можете это экипировать.') elif item_type == 'weapon': chat.use_item(item_name) unit_dict['weapon'] = item.to_dict() lobby[user_id]['equipment_choice'].pop() lobby.run_next_step(user_id, message_id=call.message.message_id) elif item_type == 'armor': chat.use_item(item_name) unit_dict['armor'].append(item.to_dict()) user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id) elif item_type == 'item': chat.use_item(item_name) test = list(k for k, v in unit_dict['inventory'].items() if v[0]['name'] == item['name']) if test: unit_dict['inventory'][test[0]][1] += 1 else: unit_dict['inventory'][engine.rand_id()] = [item.to_dict(), 1] user.send_equipment_choice(call_data[1], chat.chat_id, item_type, message_id=call.message.message_id)
def __init__(self): self.stage = 'siege' self.stage_choices = [ 'siege', 'peace', 'before_attack', 'before_siege' ] self.war_actors = {} self.id = str(engine.rand_id()) self.attacked_dict = {} self.attacked_chat = {} self.attacking_lobby = {}
def __init__(self, chat_id, skip_armory=False): self.id = str(engine.rand_id()) self.chat_id = chat_id self.message_id = None self.teams = [{}] # Команда вида {chat_id: [unit_dict, False(ready_status)]} self.text = 'FILL THE TEXT' self.lang = 'rus' self.langs = [self.lang] self.started = False self.table_row = None dynamic_dicts.lobby_list[self.id] = self self.skip_armory = skip_armory self.start_checker = StartChecker(self)
def __init__(self, chat_id=None, test=False): self.turn = 1 self.id = str(engine.rand_id()) self.chat_id = [] if chat_id is None else [chat_id] self.units_dict = dict() self.units = list() self.langs = ['rus'] self.lang = self.langs[0] self.dead = {} self.teams = [] self.public = False self.first_turn = None self.listeners = list() self.action_queue = ActionQueue() self.string_tuple = FightString(self) dynamic_dicts.fight_dict[str(self.id)] = self
def __init__(self, name, controller=None, unit_dict=None, fight=None, complexity=None): # То, как осуществляется управление юнитом self.controller = controller self.unit_name_marker = self.unit_name if controller is not None: self.controller.unit = self self.done = False self.active = True self.loot = self.default_loot self.loot_chances = self.default_loot_chances # Список доступных действий для клавиатуры # Параметры игрока self.name = name self.id = engine.rand_id() self.fight = fight self.team = None self.lang = None self.melee_accuracy = 0 self.range_accuracy = 0 self.evasion = 0 self.damage = 0 self.spell_damage = 0 self.energy = 0 self.speed = 9 self.weapon = weapons.Fist(self) self.weapons = [] self.abilities = [] self.items = [] self.armor = [] self.inventory = [] # Параметры для боя self.default_weapon = weapons.Fist(self) self.lost_weapon = [] self.boosted_attributes = {} self.death_lang_tuple = None # Временные параметры self.blocked_damage = 0 self.dmg_received = 0 self.wasted_energy = 0 self.hp_delta = 0 self.melee_targets = [] self.statuses = {} self.target = None self.action = [] self.hp_changed = False self.weapon_to_member = [] # Параметры для отсутствия возможности действовать/ходить/атаковать/использовать магию self.disabled = [] self.rooted = [] self.disarmed = [] self.silenced = [] # Параметры для ai self.number = 1 self.named = True self.additional_actions = []
def start_attack(self): self.announce_attack() self.stage = 'attack' self.id = str(engine.rand_id())
def start_siege(self): self.announce_siege() self.stage = 'siege' self.id = str(engine.rand_id())