# Coverage for thb/characters/tewi.py : 45%

## 35 statements 21 run 14 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 from typing import cast

6

7# -- third party --

8# -- own --

9# -- errord --

10 from thb.actions import DrawCards, MigrateCardsTransaction

11 from thb.cards.base import Skill

12 from thb.cards.classes import t_None

13 from thb.characters.base import Character, register_character_to

14 from thb.mode import THBEventHandler

15

16

17# -- code --

18 class Luck(Skill):

19 associated_action = None

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

21 target = t_None()

22

23

24 class LuckDrawCards(DrawCards):

25 pass

26

27

28 class LuckHandler(THBEventHandler):

29 interested = ['post_card_migration']

30

31 def handle(self, evt_type, arg):

32 if evt_type != 'post_card_migration':

33 return arg

34

35 trans = cast(MigrateCardsTransaction, arg)

36

37 candidates = {}

38

39 for m in trans.movements:

40 p = m.fr.owner

41 if not (p and p.has_skill(Luck)): continue

42 if m.fr not in (p.cards, p.showncards): continue

43 if p.cards or p.showncards: continue

44 if p.dead: continue

45 candidates[p] = 1

46

47 for p in candidates:

48 self.game.process_action(LuckDrawCards(p, 2))

49

50 return arg

51

52

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

54 class Tewi(Character):

55 skills = [Luck]

56 eventhandlers = [LuckHandler]

57 maxlife = 4