graph-games-proto 0.3.1788__py3-none-any.whl → 0.3.1790__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.
graph_games_proto/fns.py CHANGED
@@ -15,7 +15,7 @@ from functools import cmp_to_key
15
15
  from itertools import combinations as itertools_combinations, chain
16
16
  from collections import deque
17
17
 
18
- DEFAULT_ALLOTTED_SECONDS = 30 #60
18
+ DEFAULT_ALLOTTED_SECONDS = 10 #60
19
19
  INITIAL_ALLOTTED_SECONDS = 20 #120
20
20
 
21
21
  class NoAction(PClass):
@@ -3233,6 +3233,50 @@ def default_after_accept_action(game, action):
3233
3233
  )
3234
3234
 
3235
3235
 
3236
+ def recycle_decks_if_needed(game):
3237
+ for deck_idx in range(len(game.decks)):
3238
+ game = recycle_if_needed(game, deck_idx)
3239
+ return game
3240
+
3241
+
3242
+ def replenish_faceup_spot_if_needed(game, deck_idx, spot_idx):
3243
+ deck = game.decks[deck_idx]
3244
+
3245
+ if deck.faceup_spots[spot_idx] is not None:
3246
+ return game
3247
+
3248
+ if len(deck.facedown_stack) == 0:
3249
+ return game
3250
+
3251
+ deck.faceup_spots[spot_idx] = deck.facedown_stack.pop()
3252
+
3253
+ game = ensure_faceup_spots_valid(game)
3254
+
3255
+ return game.set(
3256
+ decks=game.decks,
3257
+ )
3258
+
3259
+
3260
+ def replenish_faceup_if_needed(game, deck_idx):
3261
+ deck = game.decks[deck_idx]
3262
+ for spot_idx in range(len(deck.faceup_spots)):
3263
+ game = replenish_faceup_spot_if_needed(game, deck_idx, spot_idx)
3264
+ return game
3265
+
3266
+
3267
+ def recycle_if_needed(game, deck_idx):
3268
+ deck = game.decks[deck_idx]
3269
+ if len(deck.facedown_stack) == 0:
3270
+ shuffled_discards = list(deck.discard)
3271
+ game.rng.shuffle(shuffled_discards)
3272
+ deck = deck.set(
3273
+ facedown_stack = shuffled_discards,
3274
+ discard = []
3275
+ )
3276
+ game = set_deck(game, deck.idx, deck)
3277
+ return game
3278
+
3279
+
3236
3280
  def handle_draw_action(game, action):
3237
3281
  if not game or not action or not action.legal_action or not action.legal_action.draw:
3238
3282
  return game
@@ -3247,14 +3291,7 @@ def handle_draw_action(game, action):
3247
3291
  for _ in range(draw.quantity):
3248
3292
  drawn_card = deck.facedown_stack.pop()
3249
3293
  player.cards.append(drawn_card)
3250
- if len(deck.facedown_stack) == 0:
3251
- shuffled_discards = list(deck.discard)
3252
- game.rng.shuffle(shuffled_discards)
3253
- deck = deck.set(
3254
- facedown_stack = shuffled_discards,
3255
- discard = []
3256
- )
3257
- game = set_deck(game, deck.idx, deck)
3294
+ game = recycle_if_needed(game, draw.deck_idx)
3258
3295
 
3259
3296
  game = game.set(
3260
3297
  players=game.players,
@@ -3394,12 +3431,9 @@ def handle_faceup_draw_action(game, action):
3394
3431
  drawn_card = deck.faceup_spots[spot_idx] if spot_idx is not None else None
3395
3432
  player.cards.append(drawn_card)
3396
3433
 
3397
- if len(deck.facedown_stack) > 0:
3398
- deck.faceup_spots[spot_idx] = deck.facedown_stack.pop()
3399
- else:
3400
- deck.faceup_spots[spot_idx] = None
3401
-
3402
- game = ensure_faceup_spots_valid(game)
3434
+ deck.faceup_spots[spot_idx] = None
3435
+ game = game.set(decks=game.decks)
3436
+ game = replenish_faceup_spot_if_needed(game, faceup_draw.deck_idx, spot_idx)
3403
3437
 
3404
3438
  # Prevent an extra draw if last draw was a face-wild-draw
3405
3439
  if not game.carduuid2card[drawn_card].is_wild:
@@ -3408,7 +3442,6 @@ def handle_faceup_draw_action(game, action):
3408
3442
 
3409
3443
  return game.set(
3410
3444
  players=game.players,
3411
- decks=game.decks,
3412
3445
  )
3413
3446
 
3414
3447
 
@@ -3595,6 +3628,8 @@ def handle_move_pieces_to_path_action(game, action):
3595
3628
  # add to discard
3596
3629
  game.decks[game.carduuid2card[card_uuid].deck_idx].discard.append(card_uuid)
3597
3630
 
3631
+ game = recycle_decks_if_needed(game)
3632
+ game = replenish_faceup_if_needed(game)
3598
3633
  game = game.set(players=game.players)
3599
3634
  game = game.set(idx2path=game.idx2path)
3600
3635
  game = game.set(player_graphs=calc_player_graphs(game)) #
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graph_games_proto
3
- Version: 0.3.1788
3
+ Version: 0.3.1790
4
4
  Requires-Dist: multipledispatch==1.0.0
5
5
  Requires-Dist: pyrsistent==0.20.0
6
6
  Requires-Dist: numpy==2.2.4
@@ -1,9 +1,9 @@
1
1
  graph_games_proto/__init__.py,sha256=O5XjRfe3DlxbJn4zezDvvy7cXvL4IzIRPZCL3Y-n7s8,776
2
2
  graph_games_proto/all_types.py,sha256=IpbwftEcHS5Ewz-saFNk0lO9FvcbuHG36odRTayCXUk,54911
3
- graph_games_proto/fns.py,sha256=dxCpZO1Pw6KTrnh2qqy-HLV1pv0irMWbbLxLEh1JFyQ,240942
3
+ graph_games_proto/fns.py,sha256=3kNaljeFJgh2FJrUfo8B8fUlIyT8D9jA0t36c7Z1_2Y,241832
4
4
  graph_games_proto/main.py,sha256=fj2U7KcwrpZtuUhjOX5yVxY18LZvvsxDFYZ_S5mxe04,145
5
5
  graph_games_proto/state.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- graph_games_proto-0.3.1788.dist-info/METADATA,sha256=ToNnoSa7Ukg_CNhHXs4VTfuHsPxZvDiETsM9zBKx6ug,188
7
- graph_games_proto-0.3.1788.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
- graph_games_proto-0.3.1788.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
- graph_games_proto-0.3.1788.dist-info/RECORD,,
6
+ graph_games_proto-0.3.1790.dist-info/METADATA,sha256=PR9TvSxR9-K7FpaGHcRGxlL3yh7w_MM71k7QdHKVKCc,188
7
+ graph_games_proto-0.3.1790.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
8
+ graph_games_proto-0.3.1790.dist-info/top_level.txt,sha256=-4QSrBMf_MM4BGsr2QXBpqDx8c8k_OPnzGyFjqjakes,18
9
+ graph_games_proto-0.3.1790.dist-info/RECORD,,