+31
-14
@@ -32,10 +32,14 @@ from jwebot_official_extensions.player_games import ( # noqa: E402
|
||||
|
||||
|
||||
COMPENSATION_AMOUNT = 200
|
||||
MORA_COMPENSATION_RELEASES = {
|
||||
"beta 2.0.0.1021": 400,
|
||||
}
|
||||
PRIMOGEM_COMPENSATION_RELEASES = {
|
||||
"beta 1.0.5.1016": 1,
|
||||
"beta 1.1.0.1016": 1,
|
||||
"beta 1.2.0.1019": 1,
|
||||
"beta 2.0.0.1021": 2,
|
||||
}
|
||||
MAX_BALANCE = 1_000_000_000
|
||||
MAX_SUMMARY_CHARS = 300
|
||||
@@ -127,13 +131,14 @@ def read_changelog_summary(path: Path, release: str) -> str:
|
||||
|
||||
|
||||
def build_announcement(release: str, summary: str) -> str:
|
||||
mora = mora_compensation_amount(release)
|
||||
primogems = primogem_compensation_amount(release)
|
||||
extra = f",原石 x{primogems}" if primogems else ""
|
||||
announcement = (
|
||||
"亲爱的群友:\n"
|
||||
f"{release} 更新现已完成。\n"
|
||||
f"更新内容:{summary}\n"
|
||||
f"更新补偿:摩拉 x{COMPENSATION_AMOUNT}{extra}\n"
|
||||
f"更新补偿:摩拉 x{mora}{extra}\n"
|
||||
"补偿范围:截至本公告发布前已创建摩拉账户的玩家\n"
|
||||
"发放方式:补偿已直接到账,无需领取\n"
|
||||
"感谢大家对 Taffy 的支持与理解,祝大家游戏愉快!"
|
||||
@@ -145,10 +150,16 @@ def build_announcement(release: str, summary: str) -> str:
|
||||
|
||||
def build_lifecycle_message(release: str, stage: str) -> str:
|
||||
if stage == "shutdown":
|
||||
message = (
|
||||
f"Taffy 准备停机更新到 {release},会短暂离线一下;"
|
||||
"别慌,我很快回来喵"
|
||||
)
|
||||
if release == "beta 2.0.0.1021":
|
||||
message = (
|
||||
"Taffy 准备停机更新,本次更新是架构级大版本更新,"
|
||||
f"预期版本{release},离线的时候保持耐心迎接Taffy的归来哦~"
|
||||
)
|
||||
else:
|
||||
message = (
|
||||
f"Taffy 准备停机更新到 {release},会短暂离线一下;"
|
||||
"别慌,我很快回来喵"
|
||||
)
|
||||
elif stage == "startup":
|
||||
message = (
|
||||
f"Taffy 刚上线,正在做 {release} 的最后自检;"
|
||||
@@ -165,6 +176,10 @@ def compensation_key(release: str) -> str:
|
||||
return f"release_compensation:{release}"
|
||||
|
||||
|
||||
def mora_compensation_amount(release: str) -> int:
|
||||
return int(MORA_COMPENSATION_RELEASES.get(release, COMPENSATION_AMOUNT))
|
||||
|
||||
|
||||
def primogem_compensation_amount(release: str) -> int:
|
||||
return int(PRIMOGEM_COMPENSATION_RELEASES.get(release, 0))
|
||||
|
||||
@@ -196,6 +211,7 @@ def release_groups(database_path: Path) -> list[str]:
|
||||
|
||||
|
||||
def checked_marker(raw: str, release: str) -> dict[str, Any]:
|
||||
expected_mora = mora_compensation_amount(release)
|
||||
expected_primogems = primogem_compensation_amount(release)
|
||||
try:
|
||||
marker = json.loads(raw)
|
||||
@@ -204,8 +220,8 @@ def checked_marker(raw: str, release: str) -> dict[str, Any]:
|
||||
if (
|
||||
not isinstance(marker, dict)
|
||||
or marker.get("release") != release
|
||||
or marker.get("amount") != COMPENSATION_AMOUNT
|
||||
or marker.get("mora_amount") not in {None, COMPENSATION_AMOUNT}
|
||||
or marker.get("amount") != expected_mora
|
||||
or marker.get("mora_amount") not in {None, expected_mora}
|
||||
or marker.get("primogem_amount") not in {None, expected_primogems}
|
||||
or not isinstance(marker.get("group_fingerprints"), list)
|
||||
):
|
||||
@@ -287,6 +303,7 @@ def apply_compensation(
|
||||
groups = sorted({str(row["group_fingerprint"]) for row in rows})
|
||||
old_balance_sum = 0
|
||||
old_primogem_sum = 0
|
||||
mora_amount = mora_compensation_amount(release)
|
||||
primogem_amount = primogem_compensation_amount(release)
|
||||
timestamp = isoformat_utc(applied_at)
|
||||
event_reason = f"{release} 版本更新补偿"
|
||||
@@ -302,14 +319,14 @@ def apply_compensation(
|
||||
balance = state.get("balance")
|
||||
if (
|
||||
type(balance) is not int
|
||||
or not 0 <= balance <= MAX_BALANCE - COMPENSATION_AMOUNT
|
||||
or not 0 <= balance <= MAX_BALANCE - mora_amount
|
||||
):
|
||||
raise ReleaseUpdateError("Mora account balance is invalid")
|
||||
old_balance_sum += balance
|
||||
old_primogem_sum += int(state["primogems"])
|
||||
state["balance"] = balance + COMPENSATION_AMOUNT
|
||||
state["balance"] = balance + mora_amount
|
||||
state["primogems"] += primogem_amount
|
||||
append_coin_event(state, COMPENSATION_AMOUNT, event_reason)
|
||||
append_coin_event(state, mora_amount, event_reason)
|
||||
state["coin_events"][-1]["created_at"] = applied_at.timestamp()
|
||||
if primogem_amount:
|
||||
append_primogem_event(
|
||||
@@ -335,14 +352,14 @@ def apply_compensation(
|
||||
)
|
||||
marker = {
|
||||
"release": release,
|
||||
"amount": COMPENSATION_AMOUNT,
|
||||
"mora_amount": COMPENSATION_AMOUNT,
|
||||
"amount": mora_amount,
|
||||
"mora_amount": mora_amount,
|
||||
"primogem_amount": primogem_amount,
|
||||
"accounts": len(rows),
|
||||
"group_fingerprints": groups,
|
||||
"old_balance_sum": old_balance_sum,
|
||||
"new_balance_sum": (
|
||||
old_balance_sum + COMPENSATION_AMOUNT * len(rows)
|
||||
old_balance_sum + mora_amount * len(rows)
|
||||
),
|
||||
"old_primogem_sum": old_primogem_sum,
|
||||
"new_primogem_sum": (
|
||||
@@ -594,7 +611,7 @@ def run_release_update(
|
||||
"status": "ok",
|
||||
"release": release,
|
||||
"compensation": compensation_state,
|
||||
"amount_each": COMPENSATION_AMOUNT,
|
||||
"amount_each": mora_compensation_amount(release),
|
||||
"primogems_each": primogem_compensation_amount(release),
|
||||
"accounts": int(marker["accounts"]),
|
||||
"groups": len(groups),
|
||||
|
||||
Reference in New Issue
Block a user