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

## 56 statements 19 run 37 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 from __future__ import annotations

3

4# -- stdlib --

5# -- third party --

6# -- own --

7 from thb.actions import DrawCards, PlayerTurn, PrepareStage, UserAction

8 from thb.cards.base import Skill, t_None

9 from thb.characters.base import Character, register_character_to

10 from thb.mode import THBEventHandler

11

12

13# -- code --

14 class UltimateSpeed(Skill):

15 associated_action = None

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

17 target = t_None()

18

19

20 class UltimateSpeedAction(UserAction):

21 def apply_action(self):

22 g = self.game

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

24

25

26 class UltimateSpeedHandler(THBEventHandler):

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

28

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

32

33 if evt_type == 'post_calcdistance':

34 src, card, dist = arg

35

36 if not is_card(card):

37 return arg

38

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

40 return arg

41

42 g = self.game

43 current = PlayerTurn.get_current(g).target

44 if current is not src:

45 return arg

46

47 for k in dist:

48 dist[k] = 0

49

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

54

55 elif evt_type == 'choose_target':

56 lca, _ = arg

57 g = self.game

58

59 if not is_card(lca.card):

60 return arg

61

62 src = lca.source

63

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

65

66 # if not isinstance(lca, ActionStageLaunchCard):

67 try:

68 current = PlayerTurn.get_current(g).target

69 except IndexError:

70 return arg

71

72 if current is not src:

73 return arg

74

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

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

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

78

79 return arg

80

81

82@register_character_to('common')

83 class Aya(Character):

84 skills = [UltimateSpeed]

85 eventhandlers = [UltimateSpeedHandler]

86 maxlife = 4