2022-10-15 08:14:32 +00:00
|
|
|
from enum import Enum
|
|
|
|
from typing import List, Tuple
|
|
|
|
|
2022-10-15 15:15:22 +00:00
|
|
|
from pydantic import BaseModel
|
|
|
|
|
2023-12-06 14:17:14 +00:00
|
|
|
from modules.wish.error import GachaIllegalArgument
|
|
|
|
from modules.wish.utils import lerp
|
2022-10-15 08:14:32 +00:00
|
|
|
|
|
|
|
|
2023-06-14 10:59:04 +00:00
|
|
|
class GenshinBannerType(Enum):
|
2022-10-15 08:14:32 +00:00
|
|
|
STANDARD = 0
|
|
|
|
EVENT = 1
|
|
|
|
WEAPON = 2
|
|
|
|
|
|
|
|
|
2022-10-15 15:15:22 +00:00
|
|
|
class GachaBanner(BaseModel):
|
2024-11-30 14:32:07 +00:00
|
|
|
weight4: tuple[tuple[int, int]] = ((1, 510), (8, 510), (10, 10000))
|
|
|
|
weight5: tuple[tuple[int, int]] = ((1, 60), (73, 60), (90, 10000))
|
2022-10-15 08:14:32 +00:00
|
|
|
fallback_items3: List[int] = [
|
|
|
|
11301,
|
|
|
|
11302,
|
|
|
|
11306,
|
|
|
|
12301,
|
|
|
|
12302,
|
|
|
|
12305,
|
|
|
|
13303,
|
|
|
|
14301,
|
|
|
|
14302,
|
|
|
|
14304,
|
|
|
|
15301,
|
|
|
|
15302,
|
|
|
|
15304,
|
|
|
|
]
|
|
|
|
# 硬编码三星武器
|
2022-10-15 13:06:42 +00:00
|
|
|
title: str = ""
|
|
|
|
html_title: str = ""
|
|
|
|
banner_id: str = ""
|
2023-06-14 10:59:04 +00:00
|
|
|
banner_type: GenshinBannerType = GenshinBannerType.STANDARD
|
2022-10-15 08:14:32 +00:00
|
|
|
wish_max_progress: int = 0
|
|
|
|
pool_balance_weights4: Tuple[int] = ((1, 255), (17, 255), (21, 10455))
|
|
|
|
pool_balance_weights5: Tuple[int] = ((1, 30), (147, 150), (181, 10230))
|
|
|
|
event_chance5: int = 50
|
|
|
|
event_chance4: int = 50
|
|
|
|
event_chance: int = -1
|
|
|
|
rate_up_items5: List[int] = [] # UP五星
|
|
|
|
fallback_items5_pool1: List[int] = [] # 基础五星角色
|
|
|
|
fallback_items5_pool2: List[int] = [] # 基础五星武器
|
|
|
|
rate_up_items4: List[int] = [] # UP四星
|
|
|
|
fallback_items4_pool1: List[int] = [] # 基础四星角色
|
|
|
|
fallback_items4_pool2: List[int] = [] # 基础四星武器
|
|
|
|
auto_strip_rate_up_from_fallback: bool = True
|
|
|
|
|
|
|
|
def get_weight(self, rarity: int, pity: int) -> int:
|
|
|
|
if rarity == 4:
|
|
|
|
return lerp(pity, self.weight4)
|
2023-03-14 01:27:22 +00:00
|
|
|
if rarity == 5:
|
2022-10-15 08:14:32 +00:00
|
|
|
return lerp(pity, self.weight5)
|
2023-03-14 01:27:22 +00:00
|
|
|
raise GachaIllegalArgument
|
2022-10-15 08:14:32 +00:00
|
|
|
|
|
|
|
def has_epitomized(self):
|
2023-06-14 10:59:04 +00:00
|
|
|
return self.banner_type == GenshinBannerType.WEAPON
|
2022-10-15 08:14:32 +00:00
|
|
|
|
|
|
|
def get_event_chance(self, rarity: int) -> int:
|
|
|
|
if rarity == 4:
|
|
|
|
return self.event_chance4
|
2023-03-14 01:27:22 +00:00
|
|
|
if rarity == 5:
|
2022-10-15 08:14:32 +00:00
|
|
|
return self.event_chance5
|
2023-03-14 01:27:22 +00:00
|
|
|
if self.event_chance >= -1:
|
2022-10-15 08:14:32 +00:00
|
|
|
return self.event_chance
|
2023-03-14 01:27:22 +00:00
|
|
|
raise GachaIllegalArgument
|
2022-10-15 08:14:32 +00:00
|
|
|
|
|
|
|
def get_pool_balance_weight(self, rarity: int, pity: int) -> int:
|
|
|
|
if rarity == 4:
|
|
|
|
return lerp(pity, self.pool_balance_weights4)
|
2023-03-14 01:27:22 +00:00
|
|
|
if rarity == 5:
|
2022-10-15 08:14:32 +00:00
|
|
|
return lerp(pity, self.pool_balance_weights5)
|
2023-03-14 01:27:22 +00:00
|
|
|
raise GachaIllegalArgument
|