# Coverage for thb/characters/sakuya.py : 94%

## 48 statements 46 run 2 missing 0 excluded 2 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.actions import ActionStage, PlayerTurn, PrepareStage

7 from thb.cards.base import Skill

8 from thb.cards.classes import AttackCard, TreatAs, t_None

9 from thb.characters.base import Character, register_character_to

10 from thb.mode import THBEventHandler

11

12

13# -- code --

14 class Dagger(TreatAs, Skill):

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

16 treat_as = AttackCard

17 distance = 99999

18

19 def check(self):

20 cards = self.associated_cards

21 if len(cards) != 1:

22 return False

23

24 c = cards[0]

25 if c.resides_in is None: 25 ↛ 26 line 25 didn't jump to line 26, because the condition on line 25 was never true

26 return False

27

28 if c.resides_in.type not in ('cards', 'showncards', 'equips'): 28 ↛ 29 line 28 didn't jump to line 29, because the condition on line 28 was never true

29 return False

30

31 if 'equipment' not in c.category:

32 return False

33

34 return True

35

36

37 class LunaDialActionStage(ActionStage):

38 def apply_action(self):

39 tags = self.target.tags

40 tags['lunadial'] = True

41

42 try:

43 return super(LunaDialActionStage, self).apply_action()

44 finally:

45 tags['lunadial'] = False

46

47

48 class LunaDial(Skill):

49 associated_action = None

50 skill_category = ['character', 'passive', 'compulsory']

51 target = t_None()

52

53

54 class LunaDialHandler(THBEventHandler):

55 interested = ['action_after']

56 execute_after = ['CiguateraHandler']

57

58 def handle(self, evt_type, act):

59 if evt_type == 'action_after' and isinstance(act, PrepareStage):

60 src = act.target

61 if not src.has_skill(LunaDial):

62 return act

63

64 g = self.game

65 PlayerTurn.get_current(g).pending_stages.insert(0, LunaDialActionStage)

66

67 return act

68

69

70@register_character_to('common')

71 class Sakuya(Character):

72 skills = [Dagger, LunaDial]

73 eventhandlers = [LunaDialHandler]

74 maxlife = 4