Coverage for thb/characters/nazrin.py : 55%
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 -*-
3# -- stdlib --
4# -- third party --
5# -- own --
6from thb.actions import FatetellAction, FatetellStage, migrate_cards
7from thb.cards.base import Card, Skill
8from thb.cards.classes import GrazeCard, TreatAs, t_None
9from thb.characters.base import Character, register_character_to
10from thb.inputlets import ChooseOptionInputlet
11from thb.mode import THBEventHandler
14# -- code --
15class TreasureHuntAction(FatetellAction):
16 def __init__(self, source, target):
17 self.source = source
18 self.target = target
19 self.fatetell_target = target
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
27 return False
29 def fatetell_cond(self, c):
30 return c.color == Card.BLACK
33class TreasureHunt(Skill):
34 associated_action = None
35 skill_category = ['character', 'passive']
36 target = t_None()
39class TreasureHuntHandler(THBEventHandler):
40 interested = ['action_before']
41 execute_before = ['CiguateraHandler']
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
56class Agile(TreatAs, Skill):
57 skill_category = ['character', 'active']
58 treat_as = GrazeCard
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 )
69class AgileKOF(TreatAs, Skill):
70 skill_category = ['character', 'active']
71 treat_as = GrazeCard
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 )
82@register_character_to('common', '-kof')
83class Nazrin(Character):
84 skills = [TreasureHunt, Agile]
85 eventhandlers = [TreasureHuntHandler]
86 maxlife = 3
89@register_character_to('kof')
90class NazrinKOF(Character):
91 skills = [TreasureHunt, AgileKOF]
92 eventhandlers = [TreasureHuntHandler]
93 maxlife = 3