diff --git a/docs/game_specific_info.md b/docs/game_specific_info.md index 33d5710..37561fc 100644 --- a/docs/game_specific_info.md +++ b/docs/game_specific_info.md @@ -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 diff --git a/example_config/chuni.yaml b/example_config/chuni.yaml index 4855fa1..ca27fad 100644 --- a/example_config/chuni.yaml +++ b/example_config/chuni.yaml @@ -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 diff --git a/titles/chuni/base.py b/titles/chuni/base.py index 9be4bf7..0e0adac 100644 --- a/titles/chuni/base.py +++ b/titles/chuni/base.py @@ -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: diff --git a/titles/chuni/config.py b/titles/chuni/config.py index 72329ec..dcdfce4 100644 --- a/titles/chuni/config.py +++ b/titles/chuni/config.py @@ -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: