def activate(self, action=None): self.i += 1 if self.i == 3: x = random.choice(range(1, 4)) if x == 1: if self.actor.max_energy < 10: self.actor.add_energy(1) self.string('use', format_dict={ 'actor': self.actor.name, 'skill': localization.LangTuple('utils', 'energy') }) elif x == 2: if self.actor.damage < 4: self.actor.damage += 1 self.string('use', format_dict={ 'actor': self.actor.name, 'skill': localization.LangTuple('utils', 'damage') }) elif x == 3: if self.actor.melee_accuracy < 5: self.actor.melee_accuracy += 2 self.actor.range_accuracy += 2 self.string('use', format_dict={ 'actor': self.actor.name, 'skill': localization.LangTuple('utils', 'accuracy') }) self.i = 0
def get_menu_string(self): if not self.burning: return localization.LangTuple(self.table_row, 'weapon_menu_1', format_dict={'chance': self.get_hit_chance()}) else: return localization.LangTuple(self.table_row, 'weapon_menu_2', format_dict={'chance': self.get_hit_chance()})
def get_menu_string(self, short_menu=False, target=None): if not short_menu: return localization.LangTuple(self.table_row, 'weapon_menu_1' , format_dict={'chance': self.get_hit_chance(), 'cripple_chance': self.get_cripple_chance()}) else: return localization.LangTuple(self.table_row, 'short_menu', format_dict={'chance': self.get_hit_chance(), 'target': target, 'cripple_chance': self.get_cripple_chance()})
def get_menu_string(self, sp_string=None): if self.loaded: return localization.LangTuple(self.table_row, 'weapon_menu_2', format_dict={'chance': self.get_hit_chance()}) else: return localization.LangTuple(self.table_row, 'weapon_menu_1', format_dict={'chance': self.get_hit_chance()})
def get_menu_string(self): if self.drown and self.draw_turn + 1 == self.unit.fight.turn: return localization.LangTuple(self.table_row, 'weapon_menu_2', format_dict={'chance': self.get_hit_chance(), 'drown': self.drown}) else: return localization.LangTuple(self.table_row, 'weapon_menu_1', format_dict={'chance': self.get_hit_chance()})
def get_menu_string(self): if self.aim_target is None: return localization.LangTuple(self.table_row, 'weapon_menu_1', format_dict={'chance': self.get_hit_chance()}) else: return localization.LangTuple(self.table_row, 'weapon_menu_2', format_dict={'chance': self.get_hit_chance(), 'target': self.aim_target.name, 'target_chance': self.get_target_hit_chance()})
def info_string(self): format_dict = { 'emote': emoji_utils.emote_dict['range_em' if not self.melee else 'melee_em'], 'name': localization.LangTuple(self.table_row, 'name'), 'min_dmg': self.damage + 1, 'max_dmg': self.dice_num + self.damage, 'energy': self.energy_cost, 'accuracy': self.accuracy, 'info': localization.LangTuple(self.table_row, 'info', format_dict=self.info_dict()), } return localization.LangTuple('utils', 'weapon-info', format_dict=format_dict)
def armor_string(self): action = 'armor' attack_dict = { 'actor': self.unit.name, 'target': self.target.name, 'armor_name': localization.LangTuple('armor' + '_' + self.armored.name, 'name') } attack_tuple = localization.LangTuple(self.weapon.table_row, action, attack_dict) self.fight.string_tuple.row(attack_tuple)
def activate(self): weapon = self.unit.pick_up_weapon() self.fight.string_tuple += localization.LangTuple( 'fight', 'pickup', { 'actor': self.unit.name, 'weapon': weapon.name_lang_tuple() })
def ask_options(self): keyboard = self.target_keyboard() self.unit.controller.edit_message(localization.LangTuple( self.table_row, 'weapon_menu_2', format_dict={'chance': self.get_hit_chance()}), reply_markup=keyboard)
def string(self, string_code, format_dict=None, order=0): format_dict = {} if None else format_dict lang_tuple = localization.LangTuple(self.table_row, string_code, format_dict=format_dict) if not order: self.unit.fight.string_tuple.row(lang_tuple) else: AddString(lang_tuple=lang_tuple, unit=self.unit, order=order)
def activate(self): keyboard = keyboards.form_keyboard( *keyboards.get_item_buttons(self.unit), keyboards.MenuButton(self.unit, 'back')) self.unit.controller.edit_message(localization.LangTuple( 'utils', 'items'), reply_markup=keyboard)
def activate(self): energy = Reload.activate(self) self.fight.string_tuple += localization.LangTuple( 'fight', 'ranged_reload', { 'actor': self.unit.name, 'energy': energy })
def string(self, hit_string): if self.armored is None: action = 'hit' if self.dmg_done > 0 else 'miss' if self.target == self.unit: action += '_self' if hit_string != '': action = hit_string + '_' + action attack_dict = { 'actor': self.unit.name, 'target': self.target.name, 'damage': self.dmg_done if not self.special_emotes else str(self.dmg_done) + ''.join(self.special_emotes) } self.attack_tuple = localization.LangTuple(self.weapon.table_row, action, attack_dict) self.fight.string_tuple.row(self.attack_tuple) self.target.death_lang_tuple = { 'tuple': self.attack_tuple, 'weapon': self.weapon, 'target': self.target } else: self.armor_string()
def __init__(self, actor): Status.__init__(self, actor) self.unit.lost_weapon = self.unit.weapon self.unit.weapon = self.unit.default_weapon self.additional_buttons_actions = [('pick-up', self.finish, localization.LangTuple('statuses_weapon-loss', 'damage'))] self.handle_dict['pick-up'] = self.finish standart_actions.Custom(self.string, 'use', order=30, unit=self.unit, format_dict={'actor': self.unit.name})
def call_dog(self): from fight import ai dog = ai.Dog(self.actor.fight) dog.name = localization.LangTuple( 'ai_hound', 'number', format_dict={'number': self.actor.name}) dog.stats() self.actor.fight.add_fighter(dog, team=self.actor.team) self.string('special', format_dict={'dog': dog.name})
def concentrate(self): self.check_combust() if self.check_casting(): standart_actions.AddString(localization.LangTuple('unit_' + self.unit.unit_name, 'cast', format_dict={'actor': self.unit.name}), order=10, unit=self.unit)
def to_string(self): self.string('use', format_dict={ 'actor': self.actor.name, 'weapon': localization.LangTuple( 'weapon_' + self.actor.weapon.name, 'with_name') })
def activate(self): keyboard = keyboards.form_keyboard( *[ ability.button() for ability in self.unit.abilities if ability.available() ], keyboards.MenuButton(self.unit, 'back')) self.unit.controller.edit_message(localization.LangTuple( 'utils', 'abilities'), reply_markup=keyboard)
def first_stage(self): standart_actions.AddString(localization.LangTuple( 'abilities_spellcast', 'use', format_dict={ 'actor': self.unit.name, 'emote': self.emote }), order=5, unit=self.unit)
def __init__(self, actor): if 'prone' not in actor.disarmed: actor.disarmed.append('prone') if 'prone' not in actor.rooted: actor.rooted.append('prone') Status.__init__(self, actor) self.additional_buttons_actions = [ ('free', self.finish, localization.LangTuple('buttons', 'get_up')) ]
def call_rat(self): from fight import ai self.rat_number += 1 rat = random.choice([ai.CrossbowRat, ai.HammerRat, ai.KnifeRat])(self.actor.fight.game) rat.name = localization.LangTuple( 'ai_rat', 'number', format_dict={'number': self.rat_number}) rat.stats() self.actor.fight.add_ai(rat, rat.name, team=self.actor.team) self.string('use', format_dict={'actor': self.actor.name})
def string(new, hit_string): atk_action = 'use' if new.dmg_done > 0 else 'fail' if hit_string != '': atk_action = hit_string + '_' + atk_action attack_dict = { 'actor': self.actor.name, 'target': new.target.name, 'damage': new.dmg_done if not new.special_emotes else str(new.dmg_done) + ''.join(new.special_emotes), 'weapon': localization.LangTuple( new.weapon.table_row, 'name' if not new.weapon.melee else 'with_name') } attack_tuple = localization.LangTuple(self.table_row, atk_action, attack_dict) new.fight.string_tuple.row(attack_tuple)
def string(new, hit_string): action = 'hit' if new.dmg_done > 0 else 'miss' if new.target == new.unit: action += '_self' if hit_string != '': action = hit_string + '_' + action attack_dict = {'actor': self.unit.name, 'target': self.target.name, 'damage': new.dmg_done if not new.special_emotes else str(new.dmg_done) + ''.join(new.special_emotes)} attack_tuple = localization.LangTuple(self.table_row, action, attack_dict) new.fight.string_tuple.row(attack_tuple)
def ask_options(self, action=None): self.unit.active = True keyboard = self.target_keyboard(action, row_width=3) current_spells = action.info[-1].split('-') current_spells = ['-'] if current_spells == ['spellcast' ] else current_spells self.unit.controller.edit_message(localization.LangTuple( self.table_row, 'options', format_dict={'spells': ' '.join(current_spells)}), reply_markup=keyboard)
def ask_start_option(self): buttons = [] weapon_list = [ weapon for weapon in weapons.weapon_list if 'arsenal' in weapon.types ] for w in weapon_list: buttons.append( keyboards.AbilityChoice(self, self.actor, option=w.name, name=localization.LangTuple( '_'.join(['weapon', w.name]), 'name').translate( self.actor.lang))) buttons.append(keyboards.WeaponInfo(w, self.actor)) keyboard = keyboards.form_keyboard(*buttons) self.actor.active = True self.actor.edit_message(localization.LangTuple('abilities_arsenal', 'options'), reply_markup=keyboard)
def ask_start_option(self): buttons = [] weapon_list = [ weapon for weapon in weapons.weapon_list if 'unique' not in weapon.types ] weapon_list = random.sample(set(weapon_list), 3) for w in weapon_list: buttons.append( keyboards.AbilityChoice(self, self.actor, option=w.name, name=localization.LangTuple( '_'.join(['weapon', w.name]), 'name').translate( self.actor.lang))) keyboard = keyboards.form_keyboard(*buttons) self.actor.active = True self.actor.edit_message(localization.LangTuple( 'abilities_weapon-master', 'options'), reply_markup=keyboard)
def activate_special_action(self, target=None): self.on_cd() targets = [target for target in self.targets() if any('attack' in action.action_type for action in target.actions()) and target.target == self.unit] if targets: standart_actions.Custom(self.counterattack, targets[0], order=10, unit=self.unit) else: standart_actions.AddString(localization.LangTuple(self.table_row, 'special_1_miss', format_dict={'actor': self.unit.name}), order=0, unit=self.unit) self.unit.waste_energy(self.special_energy_cost)
def __init__(self, actor): if 'animal' not in actor.types: return if 'prone' not in actor.disarmed: actor.disarmed.append('prone') if 'prone' not in actor.rooted: Status.__init__(self, actor) actor.rooted.append('prone') setattr(actor, 'evasion', getattr(actor, 'evasion') - 5) self.unit.boost_attribute('evasion', - 5) self.additional_buttons_actions = [('free', self.finish, localization.LangTuple('buttons', 'get_up'))] self.handle_dict['free'] = self.finish standart_actions.Custom(self.string, 'use', order=30, unit=self.unit, format_dict={'actor': self.unit.name})
def run(self): path = file_manager.my_path + '/files/images/backgrounds/camp.jpg' bot_methods.send_image(image_generator.create_dungeon_image(path, (self.get_image(key) for key in self.team)), self.chat_id) # len(self.teams) self.complexity = 1 self.create_dungeon_map() dynamic_dicts.dungeons[self.id] = self self.add_party(player_list=self.team) for member in self.party.members: dynamic_dicts.dungeons[member.chat_id] = self bot_methods.send_message(self.chat_id, localization.LangTuple('utils', 'fight_start') .translate(self.lang)) del dynamic_dicts.lobby_list[self.id] self.map.start()