47 lines
1.3 KiB
Python
47 lines
1.3 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_scotter_rule(self):
|
|
game = SugarRush1000(balance=100000, bet=1)
|
|
|
|
# 1. 触发
|
|
for _ in range(10000):
|
|
result = game.doSpin()
|
|
assert checkGrid(result['grid'])
|
|
|
|
|
|
print("✅ 测试通过:生成scotter规则正常")
|
|
|
|
def test_free_spin_scotter_rule(self):
|
|
game = SugarRush1000(balance=100000, bet=1)
|
|
for _ in range(10000):
|
|
game.buy_free_spins('standard')
|
|
result = game.doSpin()
|
|
assert checkGrid(result['grid'])
|
|
print("✅ 测试通过:免费旋转scotter规则正常")
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=["first-arg-is-ignored"], exit=False)
|