shapeGen.py 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. import random
  2. import game.const.game as G
  3. import game.const.rouge as R
  4. import game.const.rouge_theme as T
  5. def randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=False):
  6. # 其中n为该区难度
  7. # alpha为第二只及以上的重复怪物的权重系数,取值范围(0,1),通常为0.5
  8. # beta为怪的随机变难因子(容忍最后加的这只怪最终超出地图难度多少) ( max{单怪难度+剩余可分配难度}=beta ),通常为8
  9. # minDiff为进行随机抽取的最低剩余可分配难度,当剩余难度比此值低时则强制选取1只怪,通常为3
  10. # minName为字符串:"**",即强制选取的怪物名称
  11. break_time = 0
  12. district=[]
  13. diffList=[]
  14. # 初始化三个空的列表,用于存储不同类型的主键
  15. normal_keys = []
  16. elite_keys = []
  17. boss_keys = []
  18. normal_elite_keys = []
  19. elite_boss_keys = []
  20. all_keys = []
  21. has_boss = False
  22. # 遍历原始字典,根据"type"字段分类主键
  23. for key, value in mon_dic.items():
  24. if value['type'] == 'normal':
  25. normal_keys.append(key)
  26. normal_elite_keys.append(key)
  27. all_keys.append(key)
  28. elif value['type'] == 'elite':
  29. elite_keys.append(key)
  30. normal_elite_keys.append(key)
  31. elite_boss_keys.append(key)
  32. all_keys.append(key)
  33. elif value['type'] == 'boss':
  34. boss_keys.append(key)
  35. elite_boss_keys.append(key)
  36. all_keys.append(key)
  37. if cell_type == "single_boss" or cell_type == "mix_boss":
  38. n = int(n*1.2)
  39. if R.difficulty == "Easy":
  40. rd = random.randint(0,1)
  41. elif R.difficulty == "Normal":
  42. rd = random.randint(-1,1)
  43. else:
  44. rd = random.randint(-2,1)
  45. while sum(diffList) < n:
  46. name = None
  47. break_time += 1
  48. if len(district) > 5-random.randint(0,1):
  49. break
  50. else:
  51. if R.difficulty == "Easy" and len(district) > 4-random.randint(0,1):
  52. break
  53. if cell_type == "elite":
  54. if len(district) > R.diff_elite_num[R.difficulty]-rd:
  55. break
  56. if cell_type == "elite_normal":
  57. if len(district) > R.diff_elite_normal_num[R.difficulty]-rd:
  58. break
  59. if break_time >= 10000:
  60. if cell_type == "single_boss" or "mix_boss":
  61. name = random.choice(normal_elite_keys)
  62. district.append(name)
  63. diffList.append(mon_dic[name]["diff"])
  64. else:
  65. district.append(minName)
  66. diffList.append(minDiff)
  67. break
  68. # 开始分怪
  69. if cell_type == "normal":
  70. name = random.choice(normal_keys)
  71. if cell_type == "normal_elite":
  72. name = random.choice(normal_elite_keys)
  73. if cell_type == "elite":
  74. name = random.choice(elite_keys)
  75. if cell_type == "single_boss":
  76. name = random.choice(boss_keys)
  77. if cell_type == "mix_boss":
  78. if not has_boss:
  79. has_boss = True
  80. name = random.choice(boss_keys)
  81. else:
  82. name = random.choice(elite_boss_keys)
  83. if break_time >= 1000:
  84. if cell_type == "single_boss" or "mix_boss":
  85. name = random.choice(normal_elite_keys)
  86. difficulty = mon_dic[name]["diff"]
  87. if district.count(name) >= mon_dic[name]["max"] or (symmetric and mon_dic[name]["max"]<=2):
  88. continue
  89. if district.count(name) >= 1:
  90. difficulty = round(difficulty * (alpha + (1.5*(1-alpha))/district.count(name)),1)
  91. if n-sum(diffList)<=minDiff:
  92. district.append(minName)
  93. diffList.append(minDiff+1)
  94. continue
  95. else:
  96. if difficulty > n-sum(diffList)+beta:
  97. continue
  98. else:
  99. if district.count(name) == 0:
  100. difficulty = max(difficulty*1.4, difficulty+6)
  101. district.append(name)
  102. diffList.append(difficulty)
  103. # print(diffList,",难度系数=", sum(diffList))
  104. return district, diffList
  105. def setable(list):
  106. return [tuple(item) for item in list]
  107. hole_type_map = {
  108. 1: [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]],
  109. 2: [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]],
  110. 3: [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]],
  111. 4: [[7,8],[8,7],[8,8],[8,9],[9,8], [4,4],[4,5],[5,4],[5,5], [11,11],[11,12],[12,11],[12,12], [11,4],[11,5],[12,4],[12,5], [4,11],[4,12],[5,11],[5,12]],
  112. 5: [[2,8],[3,8],[4,8],[5,8],[6,8],[7,9],[8,10],[8,13],[8,14],[8,2],[8,3],[8,6],[9,7],[10,8],[11,8],[12,8],[13,8],[14,8]], # 四宫格
  113. 6: [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]],
  114. 7: [(7, 7), (7, 9), (9, 9), (9, 7), (11, 8), (8, 5), (5, 8), (8, 11), (7, 13), (9, 13), (11, 13), (13, 12), (5, 13), (3, 12), (3, 10), (13, 10), (7, 3), (9, 3), (11, 3), (5, 3), (3, 4), (3, 6), (13, 6), (13, 4), (3, 8), (13, 8)], # 散点地形
  115. 8: [(3, 11), (5, 11), (6, 9), (6, 8), (6, 7), (7, 4), (8, 4), (9, 4), (10, 4), (11, 4), (12, 4), (8, 8), (8, 9), (8, 10), (8, 11), (6, 6), (8, 7), (8, 6), (10, 6), (11, 6), (12, 7), (12, 8), (11, 9), (10, 9), (12, 10), (12, 11), (11, 12), (10, 12), (8, 12), (6, 10), (5, 12), (4, 10), (3, 12)], # sqrt13
  116. 9: [(4, 10), (4, 9), (4, 8), (7, 12), (9, 12), (5, 11), (6, 11), (10, 11), (11, 11), (12, 10), (12, 9), (12, 8), (12, 7), (4, 7), (5, 6), (11, 6), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (10, 5), (6, 5), (8, 12)], # 关机图标
  117. 10: [(5, 4), (6, 4), (10, 4), (11, 4), (12, 5), (12, 6), (9, 10), (9, 11), (5, 9), (6, 9), (4, 10), (4, 11), (5, 12), (6, 12), (12, 10), (12, 11), (11, 12), (10, 12), (10, 7), (11, 7), (7, 6), (7, 5), (4, 5), (4, 6), (10, 9), (7, 10), (6, 7), (9, 6)], # 4个C
  118. 11: [(8, 7), (7, 6), (6, 6), (5, 7), (6, 8), (5, 8), (6, 9), (7, 10), (8, 11), (9, 10), (10, 9), (11, 8), (11, 7), (10, 6), (9, 6), (10, 8), (10, 7), (9, 7), (9, 8), (9, 9), (8, 8), (8, 10), (8, 9), (7, 7), (6, 7), (7, 8), (7, 9)], # Love
  119. 12: [(5, 4), (5, 6), (5, 7), (9, 4), (10, 5), (11, 4), (11, 5), (11, 6), (10, 6), (9, 6), (10, 7), (4, 11), (6, 11), (5, 10), (7, 13), (9, 10), (10, 10), (11, 10), (10, 11), (10, 12), (4, 12), (10, 13), (9, 5), (8, 5), (12, 5), (5, 5), (5, 13), (6, 13)], # I LOVE QT
  120. 13: [(4,6), (4,7), (4,8), (4,9), (4,10), (6,7), (6,8), (6,9), (7,6), (7,10), (8,6), (8,10), (10,6), (10,7), (10,8), (10,9), (10,10), (11,6), (11,8), (11,10), (12,6), (12,8), (12,10)], # ICE
  121. 14: [[7,8],[8,7],[8,8],[8,9],[9,8]], # 短十字架
  122. 15: [(6,6),(6,7),(6,9),(6,10),(7,6),(7,10),(9,6),(9,10),(10,6),(10,7),(10,9),(10,10)], # 小正方形框漏四个口
  123. 16: [(3,3),(3,13),(4,4),(4,12),(6,6),(6,10),(7,7),(7,9),(8,8),(9,7),(9,9),(10,6),(10,10),(12,4),(12,12),(13,3),(13,13)], # 斜交叉四宫格
  124. 17: [(4,5),(4,6),(4,10),(4,11),(5,4),(5,12),(6,4),(6,6),(6,10),(6,12),(7,7),(7,9),(12,5),(12,6),(12,10),(12,11),(11,4),(11,12),(10,4),(10,6),(10,10),(10,12),(9,7),(9,9)], # 四个锚
  125. 18: [(3,10),(4,9),(4,10),(5,8),(6,7),(6,10),(7,6),(7,10),(8,5),(8,10),(9,6),(9,10),(10,7),(10,10),(11,8),(12,9),(12,10),(13,10)], # △
  126. 19: [(3,7),(3,8),(3,9),(4,6),(4,10),(5,6),(6,6),(6,10),(7,7),(7,9),(8,8),(9,7),(9,9),(10,6),(10,10),(11,10),(12,6),(12,10),(13,7),(13,8),(13,9)], # ∞
  127. 20: [(5,5),(6,5),(7,5),(8,5),(9,5),(10,5),(11,5),(8,6),(8,7),(6,8),(7,8),(8,8),(9,8),(10,8),(8,9),(8,10),(5,11),(6,11),(7,11),(8,11),(9,11),(10,11),(11,11)], # 王
  128. 21: [(3,3),(4,4),(5,5),(5,6),(5,7),(6,4),(7,3),(7,6),(7,7),(7,8),(7,9),(7,10),(8,6),(8,8),(8,10),(9,6),(9,8),(9,10),(11,8),(11,9),(11,10),(11,12),(12,8),(12,10),(12,12),(13,8),(13,10),(13,11),(13,12)] # YES
  129. }
  130. def generalDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum):
  131. # 前几个参数和分区函数相同
  132. # besiege表示每个怪物被墙围住的概率%(0-100)
  133. # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15<cubeNum<64)
  134. # wall为不可摧毁墙;
  135. monsters = []
  136. if random.randint(1, 100) >= 84:
  137. hole_type = random.randint(1, 21)
  138. coordinates = hole_type_map[hole_type].copy()
  139. obstacles = hole_type_map[hole_type].copy()
  140. wall = hole_type_map[hole_type].copy()
  141. wallNum = 0
  142. wall = setable(wall)
  143. coordinates = setable(coordinates)
  144. else:
  145. obstacles = []
  146. wall = []
  147. coordinates = []
  148. cube=[]
  149. Monsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type)[0]
  150. if mon_dic == T.theme3_C_mon_dic: # 实验所特殊设置
  151. if "RogueLabAFireArtillery" not in Monsters and cell_type in ["elite","elite_normal"]:
  152. if len(Monsters) >= 4:
  153. Monsters.append("RogueLabAFireArtillery")
  154. elif mon_dic == T.theme_destiny_mon_dic: # 实验所特殊设置
  155. if len(Monsters) >= 4 and random.randint(1,100) >= 20:
  156. Monsters.append("RogueDestinyATimeStabilizer")
  157. if random.randint(1,100) >= 80:
  158. Monsters.append("RogueDestinyATimeStabilizer")
  159. if R.print_mode:
  160. print(Monsters)
  161. district=[]
  162. for i in range(len(Monsters)):
  163. x = random.randint(3, 13)
  164. y = random.randint(3, 13)
  165. if coordinates.count((x,y)) == 0:
  166. coordinates.append((x,y))
  167. monsters.append([x,y])
  168. district.append({"name": Monsters[i],"y": y,"x": x})
  169. else:
  170. a=x
  171. b=y
  172. while coordinates.count((a,b)) != 0:
  173. a = random.randint(3, 13)
  174. b = random.randint(3, 13)
  175. if coordinates.count((a,b)) == 0:
  176. coordinates.append((a,b))
  177. monsters.append([x,y])
  178. district.append({"name": Monsters[i],"y": b,"x": a})
  179. break
  180. for i in range(len(monsters)):
  181. isStop = random.randint(0, 100)
  182. x = monsters[i][0]
  183. y = monsters[i][1]
  184. if isStop >=100-besiege:
  185. if coordinates.count((x+1,y)) == 0:
  186. if obstacles.count([x+1,y]) == 0:
  187. obstacles.append([x+1,y])
  188. cube.append((x+1, y))
  189. coordinates.append((x+1,y))
  190. if coordinates.count((x-1,y)) == 0:
  191. if obstacles.count([x-1,y]) == 0:
  192. obstacles.append([x-1,y])
  193. cube.append((x-1, y))
  194. coordinates.append((x-1,y))
  195. if coordinates.count((x,y+1)) == 0:
  196. if obstacles.count([x,y+1]) == 0:
  197. obstacles.append([x,y+1])
  198. cube.append((x, y+1))
  199. coordinates.append((x,y+1))
  200. if coordinates.count((x,y-1)) == 0:
  201. if obstacles.count([x,y-1]) == 0:
  202. obstacles.append([x,y-1])
  203. cube.append((x, y-1))
  204. coordinates.append((x,y-1))
  205. while len(wall)<wallNum:
  206. x = random.randint(3, 13)
  207. y = random.randint(3, 13)
  208. if coordinates.count((x,y)) == 0:
  209. if obstacles.count([x,y]) == 0:
  210. obstacles.append((x,y))
  211. wall.append((x, y))
  212. coordinates.append((x,y))
  213. while len(cube)<cubeNum:
  214. x = random.randint(3, 13)
  215. y = random.randint(3, 13)
  216. if coordinates.count((x,y)) == 0:
  217. if obstacles.count([x,y]) == 0:
  218. obstacles.append([x,y])
  219. cube.append((x, y))
  220. coordinates.append((x,y))
  221. # print(wall, cube)
  222. # if len(set(wall).intersection(set(cube))) > 0:
  223. # print("有重复!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:", set(wall).intersection(set(cube)))
  224. # import sys
  225. # sys.exit() # 中断代码执行
  226. return wall, cube, district
  227. # 子房到实际坐标xy映射
  228. def sub_cell_map(point_list, cell):
  229. if type(point_list) == list:
  230. result = []
  231. for point in point_list:
  232. result.append((point[0]+15*cell[0], point[1]+15*cell[1]))
  233. else:
  234. result = (point_list[0]+15*cell[0], point_list[1]+15*cell[1])
  235. return result
  236. # 实际坐标xy到子房映射
  237. def sub_cell_map_reverse(xy):
  238. return (int((xy[0]-2)/15), int((xy[1]-2)/15))
  239. def dynamic_cube_num(diff):
  240. return int(min(max(20, 0.6*diff), 45))
  241. def random_cell_generate(diff, monster_dic, cell_type, cell):
  242. diff = int(diff * min(1.6, max(0.7, random.normalvariate(1,1))))
  243. wall, cube, district = generalDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff))
  244. for mon in district:
  245. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  246. mon["x"] = new_xy[0]
  247. mon["y"] = new_xy[1]
  248. final_wall = sub_cell_map(wall, cell)
  249. final_cube = sub_cell_map(cube, cell)
  250. return final_wall, final_cube, district
  251. def generate_xy_symmetric_points(points):
  252. new_points = set() # 使用集合来自动去除重复的点
  253. max_coordinate = 16 # 假设最大坐标为16
  254. for x, y in points:
  255. # 计算x轴和y轴的对称点
  256. symmetric_point_x = (max_coordinate - x, y)
  257. symmetric_point_y = (x, max_coordinate - y)
  258. # 添加原始点和对称点到新集合中,集合自动处理重复值
  259. new_points.add((x, y))
  260. new_points.add(symmetric_point_x)
  261. new_points.add(symmetric_point_y)
  262. # 计算所有点的双轴对称点
  263. for x, y in list(new_points):
  264. symmetric_point_xy = (max_coordinate - x, max_coordinate - y)
  265. new_points.add(symmetric_point_xy)
  266. return list(new_points) # 将集合转换回列表
  267. # xy对称性区域
  268. def xy_SymmetricDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum, level_num):
  269. # 前几个参数和分区函数相同
  270. # besiege表示每个怪物被墙围住的概率%(0-100)
  271. # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15<cubeNum<64)
  272. # wall为不可摧毁墙;
  273. monsters = []
  274. small_monsters = []
  275. obstacles=[]
  276. wall=[]
  277. coordinates=[]
  278. cube=[]
  279. district=[]
  280. if R.difficulty == "Easy":
  281. l_bound = 3
  282. elif R.difficulty == "Normal":
  283. l_bound = 2
  284. else:
  285. l_bound = 1
  286. sym_type = "corner"
  287. if random.randint(1,100)>=30:
  288. if random.randint(1,100)>=50:
  289. sym_type = "axis"
  290. else:
  291. sym_type = "centre"
  292. if sym_type == "corner":
  293. if R.difficulty == "Easy" and cell_type == "elite":
  294. cell_type = "normal_elite"
  295. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  296. cell_type = "normal"
  297. Monsters = []
  298. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0]
  299. smallMonsters = smallMonsters[1:max(2,min(3,len(smallMonsters)+1))]
  300. elif sym_type == "axis":
  301. Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])]
  302. if (level_num - 1) % 5 + 1 <= l_bound:
  303. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0]
  304. else:
  305. if R.difficulty == "Easy" and cell_type == "elite":
  306. cell_type = "normal_elite"
  307. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  308. cell_type = "normal"
  309. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0]
  310. if cell_type == "normal":
  311. smallMonsters = smallMonsters[1:max(2,min(3,len(smallMonsters)+1))]
  312. else:
  313. smallMonsters = [smallMonsters[0]]
  314. (x,y) = random.choice([(5,8),(6,8),(7,8),(7,8),(8,7),(8,7),(8,6),(8,5)])
  315. sym_points = generate_xy_symmetric_points([(x,y)])
  316. for point in sym_points:
  317. coordinates.append((point[0],point[1]))
  318. monsters.append([point[0],point[1]])
  319. district.append({"name": Monsters[0],"y": point[1],"x": point[0]})
  320. if coordinates.count((point[0]+1,point[1])) == 0:
  321. if obstacles.count([point[0]+1,point[1]]) == 0:
  322. obstacles.append([point[0]+1,point[1]])
  323. cube.append((point[0]+1,point[1]))
  324. coordinates.append((point[0]+1,point[1]))
  325. if coordinates.count((point[0]-1,point[1])) == 0:
  326. if obstacles.count([point[0]-1,point[1]]) == 0:
  327. obstacles.append([point[0]-1,point[1]])
  328. cube.append((point[0]-1,point[1]))
  329. coordinates.append((point[0]-1,point[1]))
  330. if coordinates.count((point[0],point[1]+1)) == 0:
  331. if obstacles.count([point[0],point[1]+1]) == 0:
  332. obstacles.append([point[0],point[1]+1])
  333. cube.append((point[0],point[1]+1))
  334. coordinates.append((point[0],point[1]+1))
  335. if coordinates.count((point[0],point[1]-1)) == 0:
  336. if obstacles.count([point[0],point[1]-1]) == 0:
  337. obstacles.append([point[0],point[1]-1])
  338. cube.append((point[0],point[1]-1))
  339. coordinates.append((point[0],point[1]-1))
  340. else:
  341. Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])]
  342. if mon_dic == T.theme3_C_mon_dic: # 实验所特殊设置
  343. if "RogueLabAFireArtillery" not in Monsters and cell_type in ["elite","elite_normal"]:
  344. Monsters = ["RogueLabAFireArtillery"]
  345. if (level_num - 1) % 5 + 1 <= l_bound:
  346. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0]
  347. else:
  348. if R.difficulty == "Easy" and cell_type == "elite":
  349. cell_type = "normal_elite"
  350. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  351. cell_type = "normal"
  352. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0]
  353. if cell_type == "normal":
  354. smallMonsters = smallMonsters[0:max(2,min(3,len(smallMonsters)+1))-1]
  355. if R.difficulty == "Easy" and len(smallMonsters) > 0:
  356. smallMonsters = [smallMonsters[0]]
  357. else:
  358. smallMonsters = [smallMonsters[0]]
  359. coordinates.append((8,8))
  360. monsters.append([8,8])
  361. district.append({"name": Monsters[0],"y": 8,"x": 8})
  362. # print(sym_type, Monsters, smallMonsters)
  363. # print(cell_type, (level_num - 1) % 5 + 1, l_bound)
  364. for i in range(len(smallMonsters)):
  365. x = random.choice([5,6,6,7,7,7])
  366. y = random.choice([5,6,6,7,7,7])
  367. if coordinates.count((x,y)) == 0:
  368. coordinates.append((x,y))
  369. monsters.append([x,y])
  370. small_monsters.append([x,y])
  371. district.append({"name": smallMonsters[i],"y": y,"x": x})
  372. else:
  373. a=x
  374. b=y
  375. t = 0
  376. while coordinates.count((a,b)) != 0:
  377. t += 1
  378. if t >= 10000:
  379. break
  380. a = random.choice([5,6,6,7,7,7])
  381. b = random.choice([5,6,6,7,7,7])
  382. if coordinates.count((a,b)) == 0:
  383. coordinates.append((a,b))
  384. monsters.append([a,b])
  385. small_monsters.append([a,b])
  386. district.append({"name": smallMonsters[i],"y": b,"x": a})
  387. break
  388. for i in range(len(monsters)):
  389. isStop = random.randint(0, 100)
  390. x = monsters[i][0]
  391. y = monsters[i][1]
  392. if isStop >= 0:
  393. if coordinates.count((x+1,y)) == 0:
  394. if obstacles.count([x+1,y]) == 0:
  395. obstacles.append([x+1,y])
  396. cube.append((x+1, y))
  397. coordinates.append((x+1,y))
  398. if coordinates.count((x-1,y)) == 0:
  399. if obstacles.count([x-1,y]) == 0:
  400. obstacles.append([x-1,y])
  401. cube.append((x-1, y))
  402. coordinates.append((x-1,y))
  403. if coordinates.count((x,y+1)) == 0:
  404. if obstacles.count([x,y+1]) == 0:
  405. obstacles.append([x,y+1])
  406. cube.append((x, y+1))
  407. coordinates.append((x,y+1))
  408. if coordinates.count((x,y-1)) == 0:
  409. if obstacles.count([x,y-1]) == 0:
  410. obstacles.append([x,y-1])
  411. cube.append((x, y-1))
  412. coordinates.append((x,y-1))
  413. while len(wall)<int(wallNum/3):
  414. x = random.randint(3, 8)
  415. y = random.randint(3, 8)
  416. if coordinates.count((x,y)) == 0:
  417. if obstacles.count([x,y]) == 0:
  418. obstacles.append([x,y])
  419. wall.append((x, y))
  420. coordinates.append((x,y))
  421. while len(cube)<int(cubeNum/3):
  422. x = random.randint(3, 8)
  423. y = random.randint(3, 8)
  424. if coordinates.count((x,y)) == 0:
  425. if obstacles.count([x,y]) == 0:
  426. obstacles.append([x,y])
  427. cube.append((x, y))
  428. coordinates.append((x,y))
  429. res_cube = generate_xy_symmetric_points(cube)
  430. res_wall = generate_xy_symmetric_points(wall)
  431. for monster in district:
  432. for p in generate_xy_symmetric_points([(monster["x"],monster["y"])]):
  433. if {"name": monster["name"],"y": p[1],"x": p[0]} not in district and (p[0],p[1]) not in coordinates:
  434. coordinates.append((p[0],p[1]))
  435. district.append({"name": monster["name"],"y": p[1],"x": p[0]})
  436. return res_wall, res_cube, district
  437. def xy_symmetric_cell_generate(diff, monster_dic, cell_type, cell, level_num):
  438. diff = int(diff * min([2, max(0.7, random.normalvariate(1,1))]))
  439. wall, cube, district = xy_SymmetricDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff), level_num)
  440. for mon in district:
  441. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  442. mon["x"] = new_xy[0]
  443. mon["y"] = new_xy[1]
  444. final_wall = sub_cell_map(wall, cell)
  445. final_cube = sub_cell_map(cube, cell)
  446. return final_wall, final_cube, district
  447. def generate_rotated_points(points):
  448. new_points = set() # 使用集合来自动去除重复的点
  449. cx, cy = 8, 8 # 旋转中心
  450. for x, y in points:
  451. # 原始点
  452. new_points.add((x, y))
  453. # 90度旋转
  454. x_90 = cy - (y - cy)
  455. y_90 = (x - cx) + cy
  456. new_points.add((x_90, y_90))
  457. # 180度旋转
  458. x_180 = cx - (x - cx)
  459. y_180 = cy - (y - cy)
  460. new_points.add((x_180, y_180))
  461. # 270度旋转
  462. x_270 = (y - cy) + cx
  463. y_270 = cy - (x - cx)
  464. new_points.add((x_270, y_270))
  465. return list(new_points) # 将集合转换回列表
  466. # 旋转对称区域
  467. def rotationalSymmetricDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum, level_num):
  468. # 前几个参数和分区函数相同
  469. # besiege表示每个怪物被墙围住的概率%(0-100)
  470. # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15<cubeNum<64)
  471. # wall为不可摧毁墙;
  472. monsters = []
  473. small_monsters = []
  474. obstacles=[]
  475. wall=[]
  476. coordinates=[]
  477. cube=[]
  478. district=[]
  479. if R.difficulty == "Easy":
  480. l_bound = 3
  481. elif R.difficulty == "Normal":
  482. l_bound = 2
  483. else:
  484. l_bound = 1
  485. sym_type = "corner"
  486. if random.randint(1,100)>=50:
  487. sym_type = "centre"
  488. if sym_type == "corner":
  489. if R.difficulty == "Easy" and cell_type == "elite":
  490. cell_type = "normal_elite"
  491. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  492. cell_type = "normal"
  493. Monsters = []
  494. smallMonsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0])] + [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, "normal", symmetric=True)[0])]
  495. else:
  496. Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])]
  497. if (level_num - 1) % 5 + 1 <= l_bound:
  498. smallMonsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0])] + random.randint(0,1) * [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0])]
  499. else:
  500. if R.difficulty == "Easy" and cell_type == "elite":
  501. cell_type = "normal_elite"
  502. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  503. cell_type = "normal"
  504. smallMonsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type=cell_type, symmetric=True)[0])] + random.randint(0,1) * [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0])]
  505. coordinates.append((8,8))
  506. monsters.append([8,8])
  507. district.append({"name": Monsters[0],"y": 8,"x": 8})
  508. if R.print_mode:
  509. print(sym_type, Monsters, smallMonsters)
  510. print(cell_type, (level_num - 1) % 5 + 1, l_bound)
  511. for i in range(len(smallMonsters)):
  512. x = random.choice([5,6,6,7,7,7])
  513. y = random.choice([5,6,6,7,7,7])
  514. if coordinates.count((x,y)) == 0:
  515. coordinates.append((x,y))
  516. monsters.append([x,y])
  517. small_monsters.append([x,y])
  518. district.append({"name": smallMonsters[i],"y": y,"x": x})
  519. else:
  520. a=x
  521. b=y
  522. t = 0
  523. while coordinates.count((a,b)) != 0:
  524. t += 1
  525. if t >= 10000:
  526. break
  527. a = random.choice([5,6,6,7,7,7])
  528. b = random.choice([5,6,6,7,7,7])
  529. if coordinates.count((a,b)) == 0:
  530. coordinates.append((a,b))
  531. monsters.append([a,b])
  532. small_monsters.append([a,b])
  533. district.append({"name": smallMonsters[i],"y": b,"x": a})
  534. break
  535. for i in range(len(monsters)):
  536. isStop = random.randint(0, 100)
  537. x = monsters[i][0]
  538. y = monsters[i][1]
  539. if isStop >= 0:
  540. if coordinates.count((x+1,y)) == 0:
  541. if obstacles.count([x+1,y]) == 0:
  542. obstacles.append([x+1,y])
  543. cube.append((x+1, y))
  544. coordinates.append((x+1,y))
  545. if coordinates.count((x-1,y)) == 0:
  546. if obstacles.count([x-1,y]) == 0:
  547. obstacles.append([x-1,y])
  548. cube.append((x-1, y))
  549. coordinates.append((x-1,y))
  550. if coordinates.count((x,y+1)) == 0:
  551. if obstacles.count([x,y+1]) == 0:
  552. obstacles.append([x,y+1])
  553. cube.append((x, y+1))
  554. coordinates.append((x,y+1))
  555. if coordinates.count((x,y-1)) == 0:
  556. if obstacles.count([x,y-1]) == 0:
  557. obstacles.append([x,y-1])
  558. cube.append((x, y-1))
  559. coordinates.append((x,y-1))
  560. while len(wall)<int(wallNum/3):
  561. x = random.randint(3, 8)
  562. y = random.randint(3, 8)
  563. if coordinates.count((x,y)) == 0:
  564. if obstacles.count([x,y]) == 0:
  565. obstacles.append([x,y])
  566. wall.append((x, y))
  567. coordinates.append((x,y))
  568. while len(cube)<int(cubeNum/3):
  569. x = random.randint(3, 8)
  570. y = random.randint(3, 8)
  571. if coordinates.count((x,y)) == 0:
  572. if obstacles.count([x,y]) == 0:
  573. obstacles.append([x,y])
  574. cube.append((x, y))
  575. coordinates.append((x,y))
  576. res_cube = generate_rotated_points(cube)
  577. res_wall = generate_rotated_points(wall)
  578. res_wall = list(set(res_wall) - set(res_cube))
  579. for monster in district:
  580. for p in generate_rotated_points([(monster["x"],monster["y"])]):
  581. if {"name": monster["name"],"y": p[1],"x": p[0]} not in district and (p[0],p[1]) not in coordinates:
  582. coordinates.append((p[0],p[1]))
  583. district.append({"name": monster["name"],"y": p[1],"x": p[0]})
  584. return res_wall, res_cube, district
  585. def rotationalSymmetric_cell_generate(diff, monster_dic, cell_type, cell, level_num):
  586. diff = int(diff * min([2, max(0.7, random.normalvariate(1,1))]))
  587. wall, cube, district = rotationalSymmetricDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff), level_num)
  588. for mon in district:
  589. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  590. mon["x"] = new_xy[0]
  591. mon["y"] = new_xy[1]
  592. final_wall = sub_cell_map(wall, cell)
  593. final_cube = sub_cell_map(cube, cell)
  594. return final_wall, final_cube, district
  595. def bossDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum):
  596. # 前几个参数和分区函数相同
  597. # besiege表示每个怪物被墙围住的概率%(0-100)
  598. # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15<cubeNum<64)
  599. # wall为不可摧毁墙;
  600. monsters = []
  601. cell_type = random.choice(["single_boss","mix_boss"])
  602. if random.randint(1, 100) >= 95:
  603. hole_type = random.randint(1,5)
  604. if hole_type == 1:
  605. coordinates = [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  606. obstacles=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  607. wall=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  608. wallNum = 0
  609. elif hole_type == 2:
  610. coordinates = [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  611. obstacles=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  612. wall=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  613. wallNum = 0
  614. elif hole_type == 3:
  615. coordinates = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  616. obstacles = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  617. wall = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  618. wallNum = 0
  619. elif hole_type == 4:
  620. coordinates = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  621. obstacles = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  622. wall = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  623. wallNum = 0
  624. else:
  625. coordinates = [[7,8],[8,7],[8,8],[8,9],[9,8]]
  626. obstacles=[[7,8],[8,7],[8,8],[8,9],[9,8]]
  627. wall=[[7,8],[8,7],[8,8],[8,9],[9,8]]
  628. wallNum = 0
  629. coordinates = setable(coordinates)
  630. else:
  631. obstacles=[]
  632. wall=[]
  633. coordinates=[]
  634. cube=[]
  635. Monsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type)[0]
  636. boss_num = 0
  637. for m in Monsters:
  638. if m in T.boss_list:
  639. boss_num += 1
  640. if boss_num >= 3:
  641. Monsters.remove(m)
  642. if R.print_mode:
  643. print(Monsters)
  644. district=[]
  645. for i in range(len(Monsters)):
  646. x = random.randint(3, 13)
  647. y = random.randint(3, 13)
  648. if coordinates.count((x,y)) == 0:
  649. coordinates.append((x,y))
  650. monsters.append([x,y])
  651. district.append({"name": Monsters[i],"y": y,"x": x})
  652. else:
  653. a=x
  654. b=y
  655. while coordinates.count((a,b)) != 0:
  656. a = random.randint(3, 13)
  657. b = random.randint(3, 13)
  658. if coordinates.count((a,b)) == 0:
  659. coordinates.append((a,b))
  660. monsters.append([x,y])
  661. district.append({"name": Monsters[i],"y": b,"x": a})
  662. break
  663. for i in range(len(monsters)):
  664. isStop = random.randint(0, 100)
  665. x = monsters[i][0]
  666. y = monsters[i][1]
  667. if isStop >=100-besiege:
  668. if coordinates.count((x+1,y)) == 0:
  669. if obstacles.count((x+1,y)) == 0:
  670. obstacles.append([x+1,y])
  671. cube.append((x+1, y))
  672. coordinates.append((x+1,y))
  673. if coordinates.count((x-1,y)) == 0:
  674. if obstacles.count([x-1,y]) == 0:
  675. obstacles.append([x-1,y])
  676. cube.append((x-1, y))
  677. coordinates.append((x-1,y))
  678. if coordinates.count((x,y+1)) == 0:
  679. if obstacles.count([x,y+1]) == 0:
  680. obstacles.append([x,y+1])
  681. cube.append((x, y+1))
  682. coordinates.append((x,y+1))
  683. if coordinates.count((x,y-1)) == 0:
  684. if obstacles.count([x,y-1]) == 0:
  685. obstacles.append([x,y-1])
  686. cube.append((x, y-1))
  687. coordinates.append((x,y-1))
  688. while len(wall)<wallNum:
  689. x = random.randint(3, 13)
  690. y = random.randint(3, 13)
  691. if coordinates.count((x,y)) == 0:
  692. if obstacles.count([x,y]) == 0:
  693. obstacles.append([x,y])
  694. wall.append((x, y))
  695. coordinates.append((x,y))
  696. while len(cube)<cubeNum:
  697. x = random.randint(3, 13)
  698. y = random.randint(3, 13)
  699. if coordinates.count((x,y)) == 0:
  700. if obstacles.count([x,y]) == 0:
  701. obstacles.append([x,y])
  702. cube.append((x, y))
  703. coordinates.append((x,y))
  704. return wall, cube, district
  705. def boss_cell_generate(diff, monster_dic, cell_type, cell):
  706. diff = int(diff * min(1.6, max(0.8, random.normalvariate(1,1))))
  707. wall, cube, district = bossDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff))
  708. for mon in district:
  709. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  710. mon["x"] = new_xy[0]
  711. mon["y"] = new_xy[1]
  712. final_wall = sub_cell_map(wall, cell)
  713. final_cube = sub_cell_map(cube, cell)
  714. return final_wall, final_cube, district
  715. # 修行区
  716. def exercise_cell_generate(cell):
  717. wall = [(3,3),(3,4),(3,12),(3,13),(4,3),(4,6),(4,7),(4,9),(4,10),(4,13),(5,7),(5,8),(5,9),(6,4),(6,12),(7,4),(7,5),(7,7),(7,9),(7,11),(7,12),(9,4),(9,5),(9,7),(9,9),(9,11),(9,12),(10,4),(10,12),(11,7),(11,8),(11,9),(12,3),(12,6),(12,7),(12,9),(12,10),(12,13),(13,3),(13,4),(13,12),(13,13)]
  718. cube = [(7,6),(7,10),(8,5),(8,7),(8,9),(8,11),(9,6),(9,10)]
  719. district = [{"name": "RougeExerciseController","y": 8,"x": 8}]
  720. for mon in district:
  721. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  722. mon["x"] = new_xy[0]
  723. mon["y"] = new_xy[1]
  724. final_wall = sub_cell_map(wall, cell)
  725. final_cube = sub_cell_map(cube, cell)
  726. return final_wall, final_cube, district
  727. # 商店区
  728. def shop_cell_generate(cell, shop_level=1, level_num=1):
  729. # wall = [(5,5),(4,5),(3,5),(3,6),(3,7),(3,8),(3,9), (4,9), (5,6),(5,7),(5,9),(5,11),(5,12),(5,13), (6,5),(6,6),(6,7),(6,13), (7,5),(7,9),(7,10),(7,11),(7,13), (8,4),(8,5),(8,6),(8,7),(8,9),(8,13), (9,4),(9,9),(9,10),(9,11),(9,13), (10,4),(10,5),(10,6),(10,7),(10,13), (11,5),(11,9),(11,11),(11,12),(11,13), (12,5),(12,6),(12,7),(12,8),(12,9)]
  730. # sell_coordinate = [(5,5),(11,5),(5,11),(11,11)]
  731. # district = [{"name": "RougeShopQuit","y": 10,"x": 8}]
  732. wall = [(12, 5), (12, 6), (4, 5), (4, 10), (4, 11), (6, 12), (7, 12), (10, 12), (11, 12), (12, 12), (12, 11), (12, 10), (12, 9), (12, 4), (11, 4), (4, 6), (4, 7), (10, 4), (4, 12), (5, 12), (6, 5), (5, 10), (10, 11), (6, 7), (6, 6), (10, 6), (10, 10), (8, 4), (8, 5), (10, 7), (8, 7), (6, 8), (4, 8), (10, 5), (12, 7), (7, 10), (6, 10), (10, 9), (8, 12), (8, 6), (5, 5), (7, 4), (6, 4), (8, 10), (8, 8), (4, 4), (5, 4)]
  733. sell_coordinate = [(5,6),(11,5),(5,11),(11,11)]
  734. district = [{"name": "RougeShopQuit","y": 5,"x": 7}]
  735. seller_1 = ["RougeShopHP100", "RougeShopDMG100", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotion", "RougeShopMonsterDefenseN200", "RougeShopMonsterHPN4", "RougeShopHPReviveCard", "RougeShopFlameSelfDMGN20"]
  736. seller_2 = ["RougeShopHP100", "RougeShopHP200", "RougeShopDMG100", "RougeShopDMG200", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotionMiddle", "RougeSmallHPRecoveryPotionMiddle", "RougeShopMonsterDefenseN200", "RougeShopMonsterDefenseN400", "RougeShopMonsterHPN4", "RougeShopMonsterHPN8", "RougeShopHPReviveCard", "RougeShopHPReviveCard", "RougeShopFlameSelfDMGN20", "RougeShopFlameSelfDMGN40", "RougeShopSwitchHPDMG", "RougeShopSlowImmune", "RougeShopReverseImmune", "RougeShopRootImmune", "RougeShopStunImmune", "RougeShopDestination"]
  737. seller_3 = ["RougeShopHP100", "RougeShopHP200", "RougeShopHP300", "RougeShopDMG100", "RougeShopDMG200", "RougeShopDMG300", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotionMiddle", "RougeSmallHPRecoveryPotionMiddle", "RougeSmallHPRecoveryPotionBig", "RougeSmallHPRecoveryPotionBig", "RougeSmallHPRecoveryPotionBig", "RougeShopMonsterDefenseN200", "RougeShopMonsterDefenseN400", "RougeShopMonsterDefenseN800", "RougeShopMonsterHPN4", "RougeShopMonsterHPN8", "RougeShopMonsterHPN16", "RougeShopHPReviveCard", "RougeShopHPReviveCard", "RougeShopHPReviveCard", "RougeShopFlameSelfDMGN20", "RougeShopFlameSelfDMGN40", "RougeShopFlameSelfDMGN60", "RougeShopSwitchHPDMG", "RougeShopSlowImmune", "RougeShopReverseImmune", "RougeShopRootImmune", "RougeShopStunImmune"] + \
  738. ["RougeShopDestination"]
  739. seller_4 = ["RougeShopHP300", "RougeShopDMG300", "RougeSmallHPRecoveryPotionBig", "RougeShopMonsterHPN16", "RougeShopHPReviveCard", "RougeShopFlameSelfDMGN60", "RougeShopSwitchHPDMG", "RougeShopSlowImmune", "RougeShopReverseImmune", "RougeShopRootImmune", "RougeShopStunImmune", "RougeShopDestination"]
  740. seller_5 = seller_4 # 巫术商店(用血量来买伤害/道具/金币)
  741. sell_num = random.randint(3,4)
  742. if shop_level==3:
  743. if random.randint(1,100)>=90:
  744. shop_level = 4
  745. sell_num = random.randint(3,4)
  746. if shop_level<=3:
  747. if random.randint(1,100)>=95:
  748. shop_level = 5
  749. sell_num = 4
  750. for i in range(sell_num):
  751. if shop_level==1:
  752. s = random.choice(seller_1)
  753. elif shop_level==2:
  754. s = random.choice(seller_2)
  755. elif shop_level==3:
  756. s = random.choice(seller_3)
  757. elif shop_level==4:
  758. s = random.choice(seller_4)
  759. else:
  760. s = random.choice(seller_5)
  761. if i == 0 and not R.has_ocean_shop:
  762. if R.pass_status[R.difficulty] >= 1 and level_num >= 8 and not R.story_ocean:
  763. R.has_ocean_shop = True
  764. s = "RougeStoryOcean"
  765. if R.print_mode:
  766. print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  767. print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  768. print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  769. print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  770. print("yes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", level_num)
  771. # Test
  772. # s = "RougeShopReverseImmune"
  773. xy = sell_coordinate[i]
  774. district.append({"name": s, "y": xy[1], "x": xy[0]})
  775. for mon in district:
  776. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  777. mon["x"] = new_xy[0]
  778. mon["y"] = new_xy[1]
  779. final_wall = sub_cell_map(wall, cell)
  780. return final_wall, district
  781. # 祈运区
  782. def treasure_cell_generate(cell, shop_level=1):
  783. wall1 = [(5,5),(5,6),(6,5),(6,8),(6,9),(7,9),(7,10),(8,6),(8,10),(9,6),(9,7),(10,7),(10,8),(10,11),(11,10),(11,11)]
  784. wall2 = [(10, 7), (10, 9), (6, 9), (6, 7), (7, 6), (9, 6), (9, 10), (7, 10), (9, 5), (8, 4), (7, 11), (8, 12), (11, 9), (12, 8), (5, 7), (4, 8), (9, 12), (4, 9), (12, 7), (7, 4)]
  785. wall3 = [(5, 6), (6, 5), (10, 11), (2, 6), (6, 2), (11, 10), (14, 10), (10, 14), (6, 9), (7, 10), (7, 11), (5, 9), (7, 9), (9, 5), (9, 6), (9, 7), (10, 7), (11, 7), (3, 12), (3, 13), (4, 13), (12, 3), (13, 3), (13, 4), (10, 12), (12, 10), (4, 6), (6, 4), (10, 10), (6, 6), (7, 7), (9, 9), (9, 10), (7, 6), (8, 12), (7, 12), (9, 4), (8, 4), (12, 7), (12, 8), (4, 8), (4, 9)]
  786. wall = random.choice([wall1, wall2, wall3])
  787. cube = [(4,10),(4,11),(4,12),(5,10),(5,12),(6,10),(6,11),(6,12), (10,4),(10,5),(10,6),(11,4),(11,6),(12,4),(12,5),(12,6)]
  788. district = [{"name": "RougeTreasureController","y": 8,"x": 8}]
  789. for mon in district:
  790. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  791. mon["x"] = new_xy[0]
  792. mon["y"] = new_xy[1]
  793. final_wall = sub_cell_map(wall, cell)
  794. final_cube = sub_cell_map(cube, cell)
  795. return final_wall, final_cube, district
  796. # 擂台区
  797. def combat_decision(cell, level_num):
  798. wall = [(4,12),(12,4), (10, 4), (11, 4), (12, 5), (12, 6), (5, 9), (4, 10), (4, 11), (5, 12), (6, 12), (11, 7), (9, 5), (7, 11), (8, 7), (8, 9), (7, 10), (9, 6), (5, 3), (3, 5), (4, 4), (5, 5), (11, 13), (13, 11), (11, 11), (12, 12)]
  799. cube = [(4, 3), (3, 4), (6, 4), (6, 5), (5, 6), (4, 6), (8, 8), (12, 10), (11, 10), (10, 11), (10, 12), (12, 13), (13, 12)]
  800. district = [{"name": "RougeCombatAccept","y": 5,"x": 11},{"name": "RougeCombatRun","y": 11,"x": 5}]
  801. # print(R.pass_status[R.difficulty], level_num, R.story_eden, R.story_destiny)
  802. if R.pass_status[R.difficulty] >= 1 and level_num == 10 and not R.story_eden and not R.story_destiny:
  803. # print("comem on!")
  804. R.story_eden = True
  805. district = [{"name": "RougeStoryEden","y": 5,"x": 11},{"name": "RougeStoryRun","y": 11,"x": 5}]
  806. # 坐标映射
  807. for mon in district:
  808. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  809. mon["x"] = new_xy[0]
  810. mon["y"] = new_xy[1]
  811. final_wall = sub_cell_map(wall, cell)
  812. final_cube = sub_cell_map(cube, cell)
  813. return final_wall, final_cube, district
  814. # 赌场
  815. def casino(cell):
  816. wall = [(4, 4), (5, 4), (4, 5), (4, 6), (4, 7), (6, 7), (6, 6), (7, 6), (11, 4), (12, 4), (12, 5), (12, 6), (12, 7), (9, 6), (10, 6), (10, 7), (12, 9), (12, 10), (12, 11), (12, 12), (11, 12), (10, 12), (9, 12), (10, 9), (10, 10), (9, 10), (6, 9), (6, 10), (7, 10), (4, 9), (4, 10), (4, 11), (4, 12), (5, 12), (6, 12), (7, 12), (6, 4), (10, 4), (9, 4), (7, 4), (7, 7), (7, 9), (9, 7), (9, 9)]
  817. cube = [(8, 7), (7, 8), (9, 8), (8, 9)]
  818. district = [{"name": "RougeCasinoGamble20P","y": 5,"x": 11},{"name": "RougeCasinoRun","y": 8,"x": 8}]
  819. # 坐标映射
  820. for mon in district:
  821. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  822. mon["x"] = new_xy[0]
  823. mon["y"] = new_xy[1]
  824. final_wall = sub_cell_map(wall, cell)
  825. final_cube = sub_cell_map(cube, cell)
  826. return final_wall, final_cube, district