Coverage for thb/meta/tags.py : 28%
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
4# -- stdlib --
5from typing import List, TYPE_CHECKING, cast
6import itertools
8# -- third party --
9from typing_extensions import TypedDict
11# -- own --
12from thb.actions import PlayerTurn
13from thb.mode import THBattle
15# -- typing --
16if TYPE_CHECKING:
17 from thb.characters.base import Character # noqa: F401
20# -- code --
21tags = {}
24def ui_meta(f):
25 tags[f.__name__] = f
26 return f
29class TagAnimation(TypedDict):
30 sprite: str
31 desc: str
34def get_display_tags(g: THBattle, ch: Character) -> List[TagAnimation]:
35 from thb.actions import ttags
37 rst: List[TagAnimation] = []
39 for t, v in itertools.chain(ch.tags.items(), ttags(ch).items()):
40 meta = tags.get(t)
41 if not meta:
42 continue
44 desc = meta(g, ch, v)
45 if not desc:
46 continue
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 })
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 })
63 return rst
66@ui_meta
67def vitality(g, p, v):
68 current = PlayerTurn.get_current(g).target
69 if v <= 0 and current is p:
70 return 'thb-tag-attacked', '没有干劲了……'
73@ui_meta
74def wine(g, p, v):
75 return v and ('thb-tag-wine', '喝醉了…')
78@ui_meta
79def 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', '玩坏你哦!'
85@ui_meta
86def lunadial(g, p, v):
87 current = PlayerTurn.get_current(g).target
88 if v and current is p:
89 return 'thb-tag-lunadial', '咲夜的时间!'
92@ui_meta
93def riverside_target(g, p, v):
94 if v == g.turn_count:
95 return 'thb-tag-riverside', '被指定为彼岸的目标'
98@ui_meta
99def ran_ei(g, p, v):
100 if v < p.tags['turn_count'] + 1:
101 return 'thb-tag-ran_ei', '还可以发动极智'
104@ui_meta
105def 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', '使用卡牌时不受距离限制'
111@ui_meta
112def exterminate(g, p, v):
113 return v and 'thb-tag-flandre_exterminate', '毁灭:无法使用人物技能'
116@ui_meta
117def reisen_discarder(g, p, v):
118 return v and 'thb-tag-reisen_discarder', '丧心:下一个出牌阶段只能使用弹幕,且只能对最近的角色使用弹幕'
121@ui_meta
122def shizuha_decay(g, p, v):
123 return v and 'thb-tag-shizuha_decay', '凋零:弃牌阶段需额外弃置一张手牌'
126@ui_meta
127def scarlet_mist(g, p, v):
128 if v == 'buff':
129 return 'thb-tag-scarlet_mist', '红雾:增益效果'
132@ui_meta
133def 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', '这位玩家的历史将会被慧音吞噬'
139@ui_meta
140def devoted(g, p, v):
141 return 'thb-tag-keine_devoted', '合格的CP当然要同富贵共患难!'
143# -----END TAGS UI META-----