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

## 42 statements 18 run 24 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 sk = self.associated_card

18 assert isinstance(sk, Find)

19 cards = sk.associated_cards

20 n = len(cards)

21 # card will be dropped at LaunchCard

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

23 tgt = self.target

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

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

26 return True

27

28 def is_valid(self):

29 try:

30 p = self.target

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

32 return False

33

34 g = self.game

35 sk = self.associated_card

36 assert isinstance(sk, Find)

37 cards = sk.associated_cards

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

39 return False

40

41 return True

42

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

44 return False

45

46

47 class Find(Skill):

48 associated_action = FindAction

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

50 target = t_Self()

51 usage = 'drop'

52

53 def check(self):

54 cl = self.associated_cards

55 return cl and all(

56 c.resides_in is not None and

57 c.resides_in.type in (

58 'cards', 'showncards', 'equips'

59 ) for c in self.associated_cards

60 )

61

62

63@register_character_to('common')

64 class Koakuma(Character):

65 skills = [Find]

66 maxlife = 4