# Coverage for thb/meta/characters/chen.py : 33%

## 83 statements 30 run 53 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 from thb import actions, characters

10 from thb.meta.common import ui_meta

11 from utils.misc import BatchList

12 import thb.cards.classes as cards

13

14

15# -- code --

16@ui_meta(characters.chen.FlyingSkanda)

17 class FlyingSkanda:

18 # Skill

19 name = '飞翔韦驮天'

20 description = (

21 '出牌阶段限一次，你使用|G弹幕|r或单体符卡时，可以额外指定一个目标。\n'

22 '|B|R>> |r此处不能使用|G人形操控|r'

23 )

24

25 def clickable(self):

26 g = self.game

27 me = self.me

28 if me.tags['flying_skanda'] >= me.tags['turn_count']: return False

29 try:

30 act = g.action_stack[-1]

31 if isinstance(act, actions.ActionStage) and act.target is me:

32 return True

33 except IndexError:

34 pass

35 return False

36

37 def is_action_valid(self, sk, tl):

38 acards = sk.associated_cards

39 if len(acards) != 1:

40 return (False, '请选择一张牌！')

41 c = acards[0]

42

43 while True:

44 if c.is_card(cards.AttackCard): break

45

46 rst = True

47 rst = rst and not c.is_card(cards.RejectCard)

48 rst = rst and not c.is_card(cards.DollControlCard)

49 rst = rst and c.associated_action

50 rst = rst and issubclass(c.associated_action, cards.InstantSpellCardAction)

51 if rst: break

52

53 return (False, '请选择一张【弹幕】或者除【人形操控】与【好人卡】之外的非延时符卡！')

54

55 if len(tl) != 2:

56 return (False, '请选择目标（2名玩家）')

57

58 if self.me is tl[-1]:

59 return (False, '不允许选择自己')

60 else:

61 return (True, '喵！')

62

63 def effect_string(self, act: actions.LaunchCard):

64 # for LaunchCard.ui_meta.effect_string

65 src = act.source

66 card = cast(characters.chen.FlyingSkanda, act.card).associated_cards[0]

67 tl = BatchList(act.target_list)

68

69 if card.is_card(cards.AttackCard):

70 s = '弹幕掺了金坷垃，攻击范围一千八！'

71 else:

72 s = '符卡掺了金坷垃，一张能顶两张用！'

73

74 return '|G【%s】|r：“%s|G【%s】|r接招吧！”' % (

75 src.ui_meta.name,

76 s,

77 '】|r、|G【'.join(tl.ui_meta.name),

78 )

79

80 def sound_effect(self, act):

81 return 'thb-cv-chen_skanda'

82

83

84@ui_meta(characters.chen.Shikigami)

85 class Shikigami:

86 # Skill

87 name = '式神'

88 description = (

89 '|B限定技|r，出牌阶段，你可以令一名其他角色选择一项：|B|R>> |r摸两张牌，|B|R>> |r回复1点体力。\n'

90 '直到下次你的回合开始时，你与其可以在出牌阶段对对方攻击范围内的角色使用|G弹幕|r。'

91 )

92

93 def clickable(self):

94 g = self.game

95 me = self.me

96 if me.tags.get('shikigami_tag'): return False

97 try:

98 act = g.action_stack[-1]

99 if isinstance(act, actions.ActionStage) and act.target is me:

100 return True

101 except IndexError:

102 pass

103 return False

104

105 def is_action_valid(self, sk, tl):

106 cl = sk.associated_cards

107 if cl:

108 return (False, '请不要选择牌')

109

110 if not tl:

111 return (False, '请选择一名玩家')

112 else:

113 return (True, '发动【式神】')

114

115 def sound_effect(self, act):

116 return 'thb-cv-chen_shikigami'

117

118

119@ui_meta(characters.chen.ShikigamiAction)

120 class ShikigamiAction:

121 choose_option_buttons = (('摸2张牌', False), ('回复1点体力', True))

122 choose_option_prompt = '请为受到的【式神】选择效果'

123

124

125@ui_meta(characters.chen.Chen)

126 class Chen:

127 name = '橙'

128 title = '凶兆的黑喵'

129 illustrator = '和茶'

130 cv = 'shourei小N'

131

132 port_image = 'thb-portrait-chen'

133 figure_image = 'thb-figure-chen'

134 miss_sound_effect = 'thb-cv-chen_miss'