aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/COC7/__init__.py
blob: 01efe572b202ad1cef640a9d540d874429f1e630 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import math

from hrc import Core, player_card

core = Core()


@core.event_post_processor_hook
async def auto_card(_event="T_Event"):
    g = core.session
    pc = player_card
    if g and core.session.gid and g.ac:
        if hasattr(pc.trans, "生命") or hasattr(pc.trans, "理智"):
            core.session.call(
                "set_group_card", pc.gid, f"card#{pc.uid}", await overview_card(pc.char)
            )


async def overview_card(pc: player_card):
    max_hp = math.floor((pc.get("CON", 0) + pc.get("SIZ", 0) / 10))
    max_san = math.floor(99 - pc.get("CM", 0))
    mp = pc.get("MP", 0)
    mp_show = (
        " mp" + str(mp) + "/" + str(math.floor(pc.get("POW", 0) / 5))
        if mp and mp != math.floor(pc.get("POW", 0) / 5)
        else ""
    )
    return (
        pc.get("__Name", "")
        + " hp"
        + str(pc.get("HP", max_hp))
        + "/"
        + str(max_hp)
        + " san"
        + str(pc.get("SAN", "?"))
        + "/"
        + str(max_san)
        + mp_show
        + " DEX"
        + str(pc.get("DEX", "?"))
    )