balatrobot 0.7.4__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
balatrobot/models.py DELETED
@@ -1,402 +0,0 @@
1
- """Pydantic models for BalatroBot API matching Lua types structure."""
2
-
3
- from typing import Any, Literal
4
-
5
- from pydantic import BaseModel, ConfigDict, Field, field_validator
6
-
7
- from .enums import State
8
-
9
-
10
- class BalatroBaseModel(BaseModel):
11
- """Base model for all BalatroBot API models."""
12
-
13
- model_config = ConfigDict(
14
- extra="allow",
15
- str_strip_whitespace=True,
16
- validate_assignment=True,
17
- frozen=True,
18
- )
19
-
20
-
21
- # =============================================================================
22
- # Request Models (keep existing - they match Lua argument types)
23
- # =============================================================================
24
-
25
-
26
- class StartRunRequest(BalatroBaseModel):
27
- """Request model for starting a new run."""
28
-
29
- deck: str = Field(..., description="Name of the deck to use")
30
- stake: int = Field(1, ge=1, le=8, description="Stake level (1-8)")
31
- seed: str | None = Field(None, description="Optional seed for the run")
32
- challenge: str | None = Field(None, description="Optional challenge name")
33
-
34
-
35
- class BlindActionRequest(BalatroBaseModel):
36
- """Request model for skip or select blind actions."""
37
-
38
- action: Literal["skip", "select"] = Field(
39
- ..., description="Action to take with the blind"
40
- )
41
-
42
-
43
- class HandActionRequest(BalatroBaseModel):
44
- """Request model for playing hand or discarding cards."""
45
-
46
- action: Literal["play_hand", "discard"] = Field(
47
- ..., description="Action to take with the cards"
48
- )
49
- cards: list[int] = Field(
50
- ..., min_length=1, max_length=5, description="List of card indices (0-indexed)"
51
- )
52
-
53
-
54
- class ShopActionRequest(BalatroBaseModel):
55
- """Request model for shop actions."""
56
-
57
- action: Literal["next_round"] = Field(..., description="Shop action to perform")
58
-
59
-
60
- # =============================================================================
61
- # Game State Models (matching src/lua/types.lua)
62
- # =============================================================================
63
-
64
-
65
- class GGameTags(BalatroBaseModel):
66
- """Game tags model matching GGameTags in Lua types."""
67
-
68
- key: str = Field("", description="Tag ID (e.g., 'tag_foil')")
69
- name: str = Field("", description="Tag display name (e.g., 'Foil Tag')")
70
-
71
-
72
- class GGameLastBlind(BalatroBaseModel):
73
- """Last blind info matching GGameLastBlind in Lua types."""
74
-
75
- boss: bool = Field(False, description="Whether the last blind was a boss")
76
- name: str = Field("", description="Name of the last blind")
77
-
78
-
79
- class GGameCurrentRound(BalatroBaseModel):
80
- """Current round info matching GGameCurrentRound in Lua types."""
81
-
82
- discards_left: int = Field(0, description="Number of discards remaining")
83
- discards_used: int = Field(0, description="Number of discards used")
84
- hands_left: int = Field(0, description="Number of hands remaining")
85
- hands_played: int = Field(0, description="Number of hands played")
86
- voucher: dict[str, Any] = Field(
87
- default_factory=dict, description="Vouchers for this round"
88
- )
89
-
90
- @field_validator("voucher", mode="before")
91
- @classmethod
92
- def convert_empty_list_to_dict(cls, v):
93
- """Convert empty list to empty dict."""
94
- return {} if v == [] else v
95
-
96
-
97
- class GGameSelectedBack(BalatroBaseModel):
98
- """Selected deck info matching GGameSelectedBack in Lua types."""
99
-
100
- name: str = Field("", description="Name of the selected deck")
101
-
102
-
103
- class GGameShop(BalatroBaseModel):
104
- """Shop configuration matching GGameShop in Lua types."""
105
-
106
- joker_max: int = Field(0, description="Maximum jokers in shop")
107
-
108
-
109
- class GGameStartingParams(BalatroBaseModel):
110
- """Starting parameters matching GGameStartingParams in Lua types."""
111
-
112
- boosters_in_shop: int = Field(0, description="Number of boosters in shop")
113
- reroll_cost: int = Field(0, description="Cost to reroll shop")
114
- hand_size: int = Field(0, description="Starting hand size")
115
- hands: int = Field(0, description="Starting hands per round")
116
- ante_scaling: int = Field(0, description="Ante scaling factor")
117
- consumable_slots: int = Field(0, description="Number of consumable slots")
118
- dollars: int = Field(0, description="Starting money")
119
- discards: int = Field(0, description="Starting discards per round")
120
- joker_slots: int = Field(0, description="Number of joker slots")
121
- vouchers_in_shop: int = Field(0, description="Number of vouchers in shop")
122
-
123
-
124
- class GGamePreviousRound(BalatroBaseModel):
125
- """Previous round info matching GGamePreviousRound in Lua types."""
126
-
127
- dollars: int = Field(0, description="Dollars from previous round")
128
-
129
-
130
- class GGameProbabilities(BalatroBaseModel):
131
- """Game probabilities matching GGameProbabilities in Lua types."""
132
-
133
- normal: float = Field(1.0, description="Normal probability modifier")
134
-
135
-
136
- class GGamePseudorandom(BalatroBaseModel):
137
- """Pseudorandom data matching GGamePseudorandom in Lua types."""
138
-
139
- seed: str = Field("", description="Pseudorandom seed")
140
-
141
-
142
- class GGameRoundBonus(BalatroBaseModel):
143
- """Round bonus matching GGameRoundBonus in Lua types."""
144
-
145
- next_hands: int = Field(0, description="Bonus hands for next round")
146
- discards: int = Field(0, description="Bonus discards")
147
-
148
-
149
- class GGameRoundScores(BalatroBaseModel):
150
- """Round scores matching GGameRoundScores in Lua types."""
151
-
152
- cards_played: dict[str, Any] = Field(
153
- default_factory=dict, description="Cards played stats"
154
- )
155
- cards_discarded: dict[str, Any] = Field(
156
- default_factory=dict, description="Cards discarded stats"
157
- )
158
- furthest_round: dict[str, Any] = Field(
159
- default_factory=dict, description="Furthest round stats"
160
- )
161
- furthest_ante: dict[str, Any] = Field(
162
- default_factory=dict, description="Furthest ante stats"
163
- )
164
-
165
-
166
- class GGame(BalatroBaseModel):
167
- """Game state matching GGame in Lua types."""
168
-
169
- bankrupt_at: int = Field(0, description="Money threshold for bankruptcy")
170
- base_reroll_cost: int = Field(0, description="Base cost for rerolling shop")
171
- blind_on_deck: str = Field("", description="Current blind type")
172
- bosses_used: dict[str, int] = Field(
173
- default_factory=dict, description="Bosses used in run"
174
- )
175
- chips: int = Field(0, description="Current chip count")
176
- current_round: GGameCurrentRound | None = Field(
177
- None, description="Current round information"
178
- )
179
- discount_percent: int = Field(0, description="Shop discount percentage")
180
- dollars: int = Field(0, description="Current money amount")
181
- hands_played: int = Field(0, description="Total hands played in the run")
182
- inflation: int = Field(0, description="Current inflation rate")
183
- interest_amount: int = Field(0, description="Interest amount per dollar")
184
- interest_cap: int = Field(0, description="Maximum interest that can be earned")
185
- last_blind: GGameLastBlind | None = Field(
186
- None, description="Last blind information"
187
- )
188
- max_jokers: int = Field(0, description="Maximum number of jokers allowed")
189
- planet_rate: int = Field(0, description="Probability for planet cards in shop")
190
- playing_card_rate: int = Field(
191
- 0, description="Probability for playing cards in shop"
192
- )
193
- previous_round: GGamePreviousRound | None = Field(
194
- None, description="Previous round information"
195
- )
196
- probabilities: GGameProbabilities | None = Field(
197
- None, description="Various game probabilities"
198
- )
199
- pseudorandom: GGamePseudorandom | None = Field(
200
- None, description="Pseudorandom seed data"
201
- )
202
- round: int = Field(0, description="Current round number")
203
- round_bonus: GGameRoundBonus | None = Field(
204
- None, description="Round bonus information"
205
- )
206
- round_scores: GGameRoundScores | None = Field(
207
- None, description="Round scoring data"
208
- )
209
- seeded: bool = Field(False, description="Whether the run uses a seed")
210
- selected_back: GGameSelectedBack | None = Field(
211
- None, description="Selected deck information"
212
- )
213
- shop: GGameShop | None = Field(None, description="Shop configuration")
214
- skips: int = Field(0, description="Number of skips used")
215
- smods_version: str = Field("", description="SMODS version")
216
- stake: int = Field(0, description="Current stake level")
217
- starting_params: GGameStartingParams | None = Field(
218
- None, description="Starting parameters"
219
- )
220
- tags: list[GGameTags] = Field(default_factory=list, description="Array of tags")
221
- tarot_rate: int = Field(0, description="Probability for tarot cards in shop")
222
- uncommon_mod: int = Field(0, description="Modifier for uncommon joker probability")
223
- unused_discards: int = Field(0, description="Unused discards from previous round")
224
- used_vouchers: dict[str, bool] | list = Field(
225
- default_factory=dict, description="Vouchers used in run"
226
- )
227
- voucher_text: str = Field("", description="Voucher text display")
228
- win_ante: int = Field(0, description="Ante required to win")
229
- won: bool = Field(False, description="Whether the run is won")
230
-
231
- @field_validator("bosses_used", "used_vouchers", mode="before")
232
- @classmethod
233
- def convert_empty_list_to_dict(cls, v):
234
- """Convert empty list to empty dict."""
235
- return {} if v == [] else v
236
-
237
- @field_validator(
238
- "previous_round",
239
- "probabilities",
240
- "pseudorandom",
241
- "round_bonus",
242
- "round_scores",
243
- "shop",
244
- "starting_params",
245
- mode="before",
246
- )
247
- @classmethod
248
- def convert_empty_list_to_none(cls, v):
249
- """Convert empty list to None for optional nested objects."""
250
- return None if v == [] else v
251
-
252
-
253
- class GHandCardsBase(BalatroBaseModel):
254
- """Hand card base properties matching GHandCardsBase in Lua types."""
255
-
256
- id: Any = Field(None, description="Card ID")
257
- name: str = Field("", description="Base card name")
258
- nominal: str = Field("", description="Nominal value")
259
- original_value: str = Field("", description="Original card value")
260
- suit: str = Field("", description="Card suit")
261
- times_played: int = Field(0, description="Times this card has been played")
262
- value: str = Field("", description="Current card value")
263
-
264
- @field_validator("nominal", "original_value", "value", mode="before")
265
- @classmethod
266
- def convert_int_to_string(cls, v):
267
- """Convert integer values to strings."""
268
- return str(v) if isinstance(v, int) else v
269
-
270
-
271
- class GHandCardsConfigCard(BalatroBaseModel):
272
- """Hand card config card data matching GHandCardsConfigCard in Lua types."""
273
-
274
- name: str = Field("", description="Card name")
275
- suit: str = Field("", description="Card suit")
276
- value: str = Field("", description="Card value")
277
-
278
-
279
- class GHandCardsConfig(BalatroBaseModel):
280
- """Hand card configuration matching GHandCardsConfig in Lua types."""
281
-
282
- card_key: str = Field("", description="Unique card identifier")
283
- card: GHandCardsConfigCard | None = Field(None, description="Card-specific data")
284
-
285
-
286
- class GHandCards(BalatroBaseModel):
287
- """Hand card matching GHandCards in Lua types."""
288
-
289
- label: str = Field("", description="Display label of the card")
290
- base: GHandCardsBase | None = Field(None, description="Base card properties")
291
- config: GHandCardsConfig | None = Field(None, description="Card configuration")
292
- debuff: bool = Field(False, description="Whether card is debuffed")
293
- facing: str = Field("front", description="Card facing direction")
294
- highlighted: bool = Field(False, description="Whether card is highlighted")
295
-
296
-
297
- class GHandConfig(BalatroBaseModel):
298
- """Hand configuration matching GHandConfig in Lua types."""
299
-
300
- card_count: int = Field(0, description="Number of cards in hand")
301
- card_limit: int = Field(0, description="Maximum cards allowed in hand")
302
- highlighted_limit: int = Field(
303
- 0, description="Maximum cards that can be highlighted"
304
- )
305
-
306
-
307
- class GHand(BalatroBaseModel):
308
- """Hand structure matching GHand in Lua types."""
309
-
310
- cards: list[GHandCards] = Field(
311
- default_factory=list, description="Array of cards in hand"
312
- )
313
- config: GHandConfig | None = Field(None, description="Hand configuration")
314
-
315
-
316
- class GJokersCardsConfig(BalatroBaseModel):
317
- """Joker card configuration matching GJokersCardsConfig in Lua types."""
318
-
319
- center: dict[str, Any] = Field(
320
- default_factory=dict, description="Center configuration for joker"
321
- )
322
-
323
-
324
- class GJokersCards(BalatroBaseModel):
325
- """Joker card matching GJokersCards in Lua types."""
326
-
327
- label: str = Field("", description="Display label of the joker")
328
- config: GJokersCardsConfig | None = Field(None, description="Joker configuration")
329
-
330
-
331
- class G(BalatroBaseModel):
332
- """Root game state response matching G in Lua types."""
333
-
334
- state: Any = Field(None, description="Current game state enum value")
335
- game: GGame | None = Field(
336
- None, description="Game information (null if not in game)"
337
- )
338
- hand: GHand | None = Field(
339
- None, description="Hand information (null if not available)"
340
- )
341
- jokers: list[GJokersCards] | dict[str, Any] = Field(
342
- default_factory=list, description="Jokers structure (can be list or dict)"
343
- )
344
-
345
- @field_validator("hand", mode="before")
346
- @classmethod
347
- def convert_empty_list_to_none_for_hand(cls, v):
348
- """Convert empty list to None for hand field."""
349
- return None if v == [] else v
350
-
351
- @property
352
- def state_enum(self) -> State | None:
353
- """Get the state as an enum value."""
354
- return State(self.state) if self.state is not None else None
355
-
356
-
357
- class ErrorResponse(BalatroBaseModel):
358
- """Model for API error responses matching Lua ErrorResponse."""
359
-
360
- error: str = Field(..., description="Error message")
361
- error_code: str = Field(..., description="Standardized error code")
362
- state: Any = Field(..., description="Current game state when error occurred")
363
- context: dict[str, Any] | None = Field(None, description="Additional error context")
364
-
365
-
366
- # =============================================================================
367
- # API Message Models
368
- # =============================================================================
369
-
370
-
371
- class APIRequest(BalatroBaseModel):
372
- """Model for API requests sent to the game."""
373
-
374
- model_config = ConfigDict(extra="forbid")
375
-
376
- name: str = Field(..., description="Function name to call")
377
- arguments: dict[str, Any] | list = Field(
378
- ..., description="Arguments for the function"
379
- )
380
-
381
-
382
- class APIResponse(BalatroBaseModel):
383
- """Model for API responses from the game."""
384
-
385
- model_config = ConfigDict(extra="allow")
386
-
387
-
388
- class JSONLLogEntry(BalatroBaseModel):
389
- """Model for JSONL log entries that record game actions."""
390
-
391
- timestamp_ms: int = Field(
392
- ...,
393
- description="Unix timestamp in milliseconds when the action occurred",
394
- )
395
- function: APIRequest = Field(
396
- ...,
397
- description="The game function that was called",
398
- )
399
- game_state: G = Field(
400
- ...,
401
- description="Complete game state before the function execution",
402
- )
balatrobot/py.typed DELETED
File without changes
@@ -1,10 +0,0 @@
1
- balatrobot/__init__.py,sha256=sn-gdztWJAELq4WCWhtOQVIu3r4fguVwb9YP6JEn4TU,406
2
- balatrobot/client.py,sha256=pXPKmTh3hQpt0wMQG9wZSNFD47x-pwHbqspndjApAcE,18664
3
- balatrobot/enums.py,sha256=UzlrljX1x_UlbuqR87c-KrCQjS74DGpG8A0zH0G-h98,22463
4
- balatrobot/exceptions.py,sha256=fRupkYMw4PuMCJd8SFjfBDlla8wiKwhVzLj8AxmVL9I,4046
5
- balatrobot/models.py,sha256=me9-qN1LQtnWfReC8tF8DFR38d5hBBSJD1SfUF3d2b4,14996
6
- balatrobot/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- balatrobot-0.7.4.dist-info/METADATA,sha256=iFVGpa27v74dlCNe9ix5qEHTVq9WDjYCL-6GpFUp_EM,2801
8
- balatrobot-0.7.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- balatrobot-0.7.4.dist-info/licenses/LICENSE,sha256=71EXhU7CSe-Cihhj_VVxLtgVnSOaavHqVoixPKtE7Bk,1064
10
- balatrobot-0.7.4.dist-info/RECORD,,