# Coverage for thb/characters/aya.py : 97%

## 55 statements 53 run 2 missing 0 excluded 0 partial

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 -*-

2

3# -- stdlib --

4# -- third party --

5# -- own --

6 from thb.mode import THBEventHandler

7 from thb.actions import DrawCards, PlayerTurn, UserAction

8 from thb.cards.base import Skill, t_None

9 from thb.characters.base import Character, register_character_to

10

11

12# -- code --

13 class UltimateSpeed(Skill):

14 associated_action = None

15 skill_category = ['character', 'passive']

16 target = t_None()

17

18

19 class UltimateSpeedAction(UserAction):

20 def apply_action(self):

21 g = self.game

22 return g.process_action(DrawCards(self.target, 1))

23

24

25 class UltimateSpeedHandler(THBEventHandler):

26 interested = ['action_apply', 'choose_target', 'post_calcdistance']

27

28 def handle(self, evt_type, arg):

29 def is_card(card):

30 return 'skill' not in card.category or 'treat_as' in card.category

31

32 if evt_type == 'post_calcdistance':

33 src, card, dist = arg

34

35 if not is_card(card):

36 return arg

37

38 if src.tags['aya_count'] < 2:

39 return arg

40

41 g = self.game

42 current = PlayerTurn.get_current(g).target

43 if current is not src:

44 return arg

45

46 for k in dist:

47 dist[k] = 0

48

49 elif evt_type == 'action_apply' and isinstance(arg, PlayerTurn):

50 tags = arg.target.tags

51 tags['aya_count'] = 0

52 tags['aya_range_max'] = False

53

54 elif evt_type == 'choose_target':

55 lca, _ = arg

56 g = self.game

57

58 if not is_card(lca.card):

59 return arg

60

61 src = lca.source

62

63 if not src.has_skill(UltimateSpeed): return arg

64

65 # if not isinstance(lca, ActionStageLaunchCard):

66 try:

67 current = PlayerTurn.get_current(g).target

68 except IndexError:

69 return arg

70

71 if current is not src:

72 return arg

73

74 src.tags['aya_count'] += 1

75 if src.tags['aya_count'] == 2:

76 g.process_action(UltimateSpeedAction(src, src))

77

78 return arg

79

80

81@register_character_to('common')

82 class Aya(Character):

83 skills = [UltimateSpeed]

84 eventhandlers = [UltimateSpeedHandler]

85 maxlife = 4