# Coverage for thb/characters/koakuma.py : 96%

## 38 statements 36 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 from __future__ import annotations

3

4# -- stdlib --

5# -- third party --

6# -- own --

7 from thb.actions import DrawCards, UserAction, ttags

8 from thb.cards.base import Skill

9 from thb.cards.classes import t_Self

10 from thb.characters.base import Character, register_character_to

11

12

13# -- code --

14 class FindAction(UserAction):

15 def apply_action(self):

16 g = self.game

17 cards = self.associated_card.associated_cards

18 n = len(cards)

19 # card will be dropped at LaunchCard

20 # g.process_action(DropCards(tgt, tgt, cards))

21 tgt = self.target

22 g.process_action(DrawCards(tgt, n))

23 ttags(tgt)['find'] = True

24 return True

25

26 def is_valid(self):

27 try:

28 p = self.target

29 if ttags(p)['find']:

30 return False

31

32 g = self.game

33 cards = self.associated_card.associated_cards

34 if not 0 < len(cards) <= len([i for i in g.players if not i.dead]):

35 return False

36

37 return True

38

39 except AttributeError: # well, some cards are skill?

40 return False

41

42

43 class Find(Skill):

44 associated_action = FindAction

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

46 target = t_Self()

47 usage = 'drop'

48

49 def check(self):

50 cl = self.associated_cards

51 return cl and all(

52 c.resides_in is not None and

53 c.resides_in.type in (

54 'cards', 'showncards', 'equips'

55 ) for c in self.associated_cards

56 )

57

58

59@register_character_to('common')

60 class Koakuma(Character):

61 skills = [Find]

62 maxlife = 4