Files
roll-room/pyground/sugar/TestSugarRushSameSymbol.py
2026-04-23 16:58:11 +08:00

52 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import unittest
from SugarRush1000 import SugarRush1000
def checkGrid(grid):
total_scotter_count = 0
for col in range(7):
scotter_count = 0
for row in range(7):
if grid[row][col] == "S":
scotter_count += 1
total_scotter_count += 1
if scotter_count > 1:
print(f"col{col} has {scotter_count} scotter")
return False
if total_scotter_count > 7:
print(f"total scotter count {total_scotter_count} > 7")
return False
return True
class TestSugarRushLogic(unittest.TestCase):
def test_same_symbol_clusters(self):
mock_grid = [
['A','E','E','A','B','A','F'],
['E','E','E','B','C','D','E'],
['E','E','S','C','A','A','A'],
['A','B','A','D','E','B','B'],
['B','E','E','A','E','E','A'],
['E','C','D','E','B','E','B'],
['A','F','E','A','A','E','A'],
]
game = SugarRush1000(balance=100000, bet=1, mock_grid=mock_grid)
# 1. 触发
import json
result = game.doSpin()
# print(json.dumps(result))
assert len(result['steps'][0]['symbol_links']) == 2
assert result['steps'][0]['symbol_links'][0]['symbol'] == 'E'
assert result['steps'][0]['symbol_links'][1]['symbol'] == 'E'
print("✅ 测试通过同个符号多个cluster消除正常")
if __name__ == "__main__":
unittest.main(argv=["first-arg-is-ignored"], exit=False)