Hide keyboard shortcuts

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

6from thb.mode import THBEventHandler 

7from thb.actions import DrawCards, PlayerTurn, UserAction 

8from thb.cards.base import Skill, t_None 

9from thb.characters.base import Character, register_character_to 

10 

11 

12# -- code -- 

13class UltimateSpeed(Skill): 

14 associated_action = None 

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

16 target = t_None() 

17 

18 

19class UltimateSpeedAction(UserAction): 

20 def apply_action(self): 

21 g = self.game 

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

23 

24 

25class 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: 71 ↛ 72line 71 didn't jump to line 72, because the condition on line 71 was never true

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') 

82class Aya(Character): 

83 skills = [UltimateSpeed] 

84 eventhandlers = [UltimateSpeedHandler] 

85 maxlife = 4