# Coverage for thb/meta/tags.py : 28%

## 70 statements 27 run 43 missing 2 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 List, TYPE_CHECKING, cast

6 import itertools

7

8# -- third party --

9 from typing_extensions import TypedDict

10

11# -- own --

12 from thb.actions import PlayerTurn

13 from thb.mode import THBattle

14

15# -- typing --

16 if TYPE_CHECKING:

17 from thb.characters.base import Character # noqa: F401

18

19

20# -- code --

21 tags = {}

22

23

24 def ui_meta(f):

25 tags[f.__name__] = f

26 return f

27

28

29 class TagAnimation(TypedDict):

30 sprite: str

31 desc: str

32

33

34 def get_display_tags(g: THBattle, ch: Character) -> List[TagAnimation]:

35 from thb.actions import ttags

36

37 rst: List[TagAnimation] = []

38

39 for t, v in itertools.chain(ch.tags.items(), ttags(ch).items()):

40 meta = tags.get(t)

41 if not meta:

42 continue

43

44 desc = meta(g, ch, v)

45 if not desc:

46 continue

47

48 sprite, s = desc

49 if sprite:

50 assert isinstance(sprite, str)

51 assert isinstance(s, str)

52 rst.append({

53 'sprite': sprite,

54 'desc': s,

55 })

56

57 for c in ch.fatetell:

58 rst.append({

59 'sprite': cast(str, c.ui_meta.tag),

60 'desc': cast(str, c.ui_meta.description),

61 })

62

63 return rst

64

65

66@ui_meta

67 def vitality(g, p, v):

68 current = PlayerTurn.get_current(g).target

69 if v <= 0 and current is p:

70 return 'thb-tag-attacked', '没有干劲了……'

71

72

73@ui_meta

74 def wine(g, p, v):

75 return v and ('thb-tag-wine', '喝醉了…')

76

77

78@ui_meta

79 def flan_cs(g, p, v):

80 current = PlayerTurn.get_current(g).target

81 if v >= p.tags['turn_count'] and current is p:

82 return 'thb-tag-flandrecs', '玩坏你哦！'

83

84

85@ui_meta

86 def lunadial(g, p, v):

87 current = PlayerTurn.get_current(g).target

88 if v and current is p:

89 return 'thb-tag-lunadial', '咲夜的时间！'

90

91

92@ui_meta

93 def riverside_target(g, p, v):

94 if v == g.turn_count:

95 return 'thb-tag-riverside', '被指定为彼岸的目标'

96

97

98@ui_meta

99 def ran_ei(g, p, v):

100 if v < p.tags['turn_count'] + 1:

101 return 'thb-tag-ran_ei', '还可以发动极智'

102

103

104@ui_meta

105 def aya_count(g, p, v):

106 current = PlayerTurn.get_current(g).target

107 if v >= 2 and p is current:

108 return 'thb-tag-aya_range_max', '使用卡牌时不受距离限制'

109

110

111@ui_meta

112 def exterminate(g, p, v):

113 return v and 'thb-tag-flandre_exterminate', '毁灭：无法使用人物技能'

114

115

116@ui_meta

117 def reisen_discarder(g, p, v):

118 return v and 'thb-tag-reisen_discarder', '丧心：下一个出牌阶段只能使用弹幕，且只能对最近的角色使用弹幕'

119

120

121@ui_meta

122 def shizuha_decay(g, p, v):

123 return v and 'thb-tag-shizuha_decay', '凋零：弃牌阶段需额外弃置一张手牌'

124

125

126@ui_meta

127 def scarlet_mist(g, p, v):

128 if v == 'buff':

129 return 'thb-tag-scarlet_mist', '红雾：增益效果'

130

131

132@ui_meta

133 def keine_devour(g, p, v):

134 current = PlayerTurn.get_current(g).target

135 if v and p is current:

136 return 'thb-tag-keine_devour', '这位玩家的历史将会被慧音吞噬'

137

138

139@ui_meta

140 def devoted(g, p, v):

141 return 'thb-tag-keine_devoted', '合格的CP当然要同富贵共患难！'

142

143# -----END TAGS UI META-----