Hide keyboard shortcuts

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 -*- 

2from __future__ import annotations 

3 

4# -- stdlib -- 

5from typing import cast 

6 

7# -- third party -- 

8# -- own -- 

9# -- errord -- 

10from thb.actions import DrawCards, MigrateCardsTransaction 

11from thb.cards.base import Skill 

12from thb.cards.classes import t_None 

13from thb.characters.base import Character, register_character_to 

14from thb.mode import THBEventHandler 

15 

16 

17# -- code -- 

18class Luck(Skill): 

19 associated_action = None 

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

21 target = t_None() 

22 

23 

24class LuckDrawCards(DrawCards): 

25 pass 

26 

27 

28class LuckHandler(THBEventHandler): 

29 interested = ['post_card_migration'] 

30 

31 def handle(self, evt_type, arg): 

32 if evt_type != 'post_card_migration': 32 ↛ 33line 32 didn't jump to line 33, because the condition on line 32 was never true

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 44 ↛ 39line 44 didn't jump to line 39, because the continue on line 44 wasn't executed

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') 

54class Tewi(Character): 

55 skills = [Luck] 

56 eventhandlers = [LuckHandler] 

57 maxlife = 4