Coverage for thb/characters/aya.py : 26%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2from __future__ import annotations
4# -- stdlib --
5# -- third party --
6# -- own --
7from thb.actions import DrawCards, PlayerTurn, PrepareStage, UserAction
8from thb.cards.base import Skill, t_None
9from thb.characters.base import Character, register_character_to
10from thb.mode import THBEventHandler
13# -- code --
14class UltimateSpeed(Skill):
15 associated_action = None
16 skill_category = ['character', 'passive']
17 target = t_None()
20class UltimateSpeedAction(UserAction):
21 def apply_action(self):
22 g = self.game
23 return g.process_action(DrawCards(self.target, 1))
26class UltimateSpeedHandler(THBEventHandler):
27 interested = ['action_apply', 'choose_target', 'post_calcdistance']
29 def handle(self, evt_type, arg):
30 def is_card(card):
31 return 'skill' not in card.category or 'treat_as' in card.category
33 if evt_type == 'post_calcdistance':
34 src, card, dist = arg
36 if not is_card(card):
37 return arg
39 if src.tags['aya_count'] < 2:
40 return arg
42 g = self.game
43 current = PlayerTurn.get_current(g).target
44 if current is not src:
45 return arg
47 for k in dist:
48 dist[k] = 0
50 elif evt_type == 'action_apply' and isinstance(arg, PrepareStage):
51 tags = arg.target.tags
52 tags['aya_count'] = 0
53 tags['aya_range_max'] = False
55 elif evt_type == 'choose_target':
56 lca, _ = arg
57 g = self.game
59 if not is_card(lca.card):
60 return arg
62 src = lca.source
64 if not src.has_skill(UltimateSpeed): return arg
66 # if not isinstance(lca, ActionStageLaunchCard):
67 try:
68 current = PlayerTurn.get_current(g).target
69 except IndexError:
70 return arg
72 if current is not src:
73 return arg
75 src.tags['aya_count'] += 1
76 if src.tags['aya_count'] == 2:
77 g.process_action(UltimateSpeedAction(src, src))
79 return arg
82@register_character_to('common')
83class Aya(Character):
84 skills = [UltimateSpeed]
85 eventhandlers = [UltimateSpeedHandler]
86 maxlife = 4