# Coverage for thb/characters/nazrin.py : 100%

## 59 statements 59 run 0 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.actions import FatetellAction, FatetellStage, migrate_cards

7 from thb.cards.base import Card, Skill

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

9 from thb.characters.base import Character, register_character_to

10 from thb.inputlets import ChooseOptionInputlet

11 from thb.mode import THBEventHandler

12

13

14# -- code --

15 class TreasureHuntAction(FatetellAction):

16 def __init__(self, source, target):

17 self.source = source

18 self.target = target

19 self.fatetell_target = target

20

21 def fatetell_action(self, ft):

22 if ft.succeeded:

23 self.card = c = ft.card

24 migrate_cards([c], self.target.cards)

25 return True

26

27 return False

28

29 def fatetell_cond(self, c):

30 return c.color == Card.BLACK

31

32

33 class TreasureHunt(Skill):

34 associated_action = None

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

36 target = t_None()

37

38

39 class TreasureHuntHandler(THBEventHandler):

40 interested = ['action_before']

41 execute_before = ['CiguateraHandler']

42

43 def handle(self, evt_type, act):

44 if evt_type == 'action_before' and isinstance(act, FatetellStage):

45 tgt = act.target

46 if not tgt.has_skill(TreasureHunt): return act

47 g = self.game

48 while True:

49 if not g.user_input([tgt], ChooseOptionInputlet(self, (False, True))):

50 return act

51 if not g.process_action(TreasureHuntAction(tgt, tgt)):

52 return act

53 return act

54

55

56 class Agile(TreatAs, Skill):

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

58 treat_as = GrazeCard

59

60 def check(self):

61 cl = self.associated_cards

62 return (

63 cl and len(cl) == 1 and

64 cl[0].suit in (Card.SPADE, Card.CLUB) and

65 cl[0].resides_in.type in ('cards', 'showncards')

66 )

67

68

69 class AgileKOF(TreatAs, Skill):

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

71 treat_as = GrazeCard

72

73 def check(self):

74 cl = self.associated_cards

75 return (

76 cl and len(cl) == 1 and

77 cl[0].suit == Card.SPADE and

78 cl[0].resides_in.type in ('cards', 'showncards')

79 )

80

81

82@register_character_to('common', '-kof')

83 class Nazrin(Character):

84 skills = [TreasureHunt, Agile]

85 eventhandlers = [TreasureHuntHandler]

86 maxlife = 3

87

88

89@register_character_to('kof')

90 class NazrinKOF(Character):

91 skills = [TreasureHunt, AgileKOF]

92 eventhandlers = [TreasureHuntHandler]

93 maxlife = 3