52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
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)
|