Merge pull request '[chuni] Auto stock tickets at login' (#170) from daydensteve/artemis:chuni_ticket_stock into develop
Reviewed-on: #170
This commit is contained in:
commit
7ebd9bfb8a
@ -80,12 +80,14 @@ The importer for Chunithm will import: Events, Music, Charge Items and Avatar Ac
|
||||
|
||||
Config file is located in `config/chuni.yaml`.
|
||||
|
||||
| Option | Info |
|
||||
|------------------|----------------------------------------------------------------------------------------------------------------|
|
||||
| `news_msg` | If this is set, the news at the top of the main screen will be displayed (up to Chunithm Paradise Lost) |
|
||||
| `name` | If this is set, all players that are not on a team will use this one by default. |
|
||||
| `use_login_bonus`| This is used to enable the login bonuses |
|
||||
| `crypto` | This option is used to enable the TLS Encryption |
|
||||
| Option | Info |
|
||||
|------------------|---------------------------------------------------------------------------------------------------------------------|
|
||||
| `news_msg` | If this is set, the news at the top of the main screen will be displayed (up to Chunithm Paradise Lost) |
|
||||
| `name` | If this is set, all players that are not on a team will use this one by default. |
|
||||
| `use_login_bonus`| This is used to enable the login bonuses |
|
||||
| `stock_tickets` | If this is set, specifies tickets to auto-stock at login. Format is a comma-delimited list of IDs. Defaults to None |
|
||||
| `stock_count` | Ignored if stock_tickets is not specified. Number to stock of each ticket. Defaults to 99 |
|
||||
| `crypto` | This option is used to enable the TLS Encryption |
|
||||
|
||||
|
||||
If you would like to use network encryption, add the keys to the `keys` section under `crypto`, where the key
|
||||
|
@ -8,7 +8,11 @@ team:
|
||||
|
||||
mods:
|
||||
use_login_bonus: True
|
||||
|
||||
# stock_tickets allows specified ticket IDs to be auto-stocked at login. Format is a comma-delimited string of ticket IDs
|
||||
# note: quanity is not refreshed on "continue" after set - only on subsequent login
|
||||
stock_tickets:
|
||||
stock_count: 99
|
||||
|
||||
version:
|
||||
11:
|
||||
rom: 2.00.00
|
||||
|
@ -24,20 +24,35 @@ class ChuniBase:
|
||||
|
||||
async def handle_game_login_api_request(self, data: Dict) -> Dict:
|
||||
"""
|
||||
Handles the login bonus logic, required for the game because
|
||||
getUserLoginBonus gets called after getUserItem and therefore the
|
||||
Handles the login bonus and ticket stock logic, required for the game
|
||||
because getUserLoginBonus gets called after getUserItem; therefore the
|
||||
items needs to be inserted in the database before they get requested.
|
||||
|
||||
Adds a bonusCount after a user logged in after 24 hours, makes sure
|
||||
loginBonus 30 gets looped, only show the login banner every 24 hours,
|
||||
adds the bonus to items (itemKind 6)
|
||||
- Adds a stock for each specified ticket (itemKind 5)
|
||||
- Adds a bonusCount after a user logged in after 24 hours, makes sure
|
||||
loginBonus 30 gets looped, only show the login banner every 24 hours,
|
||||
adds the bonus to items (itemKind 6)
|
||||
"""
|
||||
|
||||
user_id = data["userId"]
|
||||
|
||||
# If we want to make certain tickets always available, stock them now
|
||||
if self.game_cfg.mods.stock_tickets:
|
||||
for ticket in self.game_cfg.mods.stock_tickets.split(","):
|
||||
await self.data.item.put_item(
|
||||
user_id,
|
||||
{
|
||||
"itemId": ticket.strip(),
|
||||
"itemKind": 5,
|
||||
"stock": self.game_cfg.mods.stock_count,
|
||||
"isValid": True,
|
||||
},
|
||||
)
|
||||
|
||||
# ignore the login bonus if disabled in config
|
||||
if not self.game_cfg.mods.use_login_bonus:
|
||||
return {"returnCode": 1}
|
||||
|
||||
user_id = data["userId"]
|
||||
login_bonus_presets = await self.data.static.get_login_bonus_presets(self.version)
|
||||
|
||||
for preset in login_bonus_presets:
|
||||
|
@ -53,6 +53,18 @@ class ChuniModsConfig:
|
||||
self.__config, "chuni", "mods", "use_login_bonus", default=True
|
||||
)
|
||||
|
||||
@property
|
||||
def stock_tickets(self) -> str:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "chuni", "mods", "stock_tickets", default=None
|
||||
)
|
||||
|
||||
@property
|
||||
def stock_count(self) -> int:
|
||||
return CoreConfig.get_config_field(
|
||||
self.__config, "chuni", "mods", "stock_count", default=99
|
||||
)
|
||||
|
||||
|
||||
class ChuniVersionConfig:
|
||||
def __init__(self, parent_config: "ChuniConfig") -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user