rogue_control.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. import json
  2. import os
  3. import sys
  4. import gc
  5. import pygame
  6. import time
  7. import concurrent.futures
  8. from functools import partial
  9. from datetime import datetime
  10. from json import JSONDecodeError
  11. from game.algo import rougeGen as RG
  12. from game.const import window as W, color as C, game as G
  13. from game.const import rouge as R
  14. from game.algo import utils as util
  15. from game.effect import effect
  16. from game.frame import character, flame
  17. from game.level.level import Level
  18. from game.sprite.hero import Hero
  19. from game.file_loader.fileLoader import load_json
  20. def garbage_collect(last_time):
  21. if time.time() - last_time[0] >= 10:
  22. collected = gc.collect()
  23. # print(f"Garbage collector: collected {collected} objects.")
  24. last_time[0] = time.time()
  25. def rouge_reset():
  26. R.has_ocean_shop = False
  27. R.has_eden_combat = False
  28. R.show_cursor = False
  29. R.coin_borrow = 0
  30. R.has_loan = False
  31. R.coin = 8
  32. R.current_standard_defense = 0
  33. R.monster_defense_delta = 0
  34. R.monster_HP_rate = 1 # 100%
  35. R.player_bomb_self_damage_reduce_rate = 1 # 100%
  36. R.slow_immune = 0
  37. R.reverse_immune = 0
  38. R.root_immune = 0
  39. R.stun_immune = 0
  40. R.random_dmg = False
  41. R.rouge_destiny["RougeTreasureDestiny"] = R.rouge_destiny["RougeTreasureDestinyWizard"] = R.rouge_destiny["RougeTreasureDestinyMachine"] = 0
  42. R.story_eden, R.story_destiny, R.story_ocean, R.story_skyland = False, False, False, False
  43. def _preload_flame(orientation):
  44. try:
  45. flame.get_flame(orientation)
  46. except Exception as e:
  47. if R.print_mode:
  48. print(f"Error processing flame {orientation}: {e}")
  49. def _preload_effect(e):
  50. try:
  51. name = e.split('.')[0]
  52. effect.get_effect(name)
  53. except Exception as e:
  54. if R.print_mode:
  55. print(f"Error processing effect {e}: {e}")
  56. def _preload_character(f):
  57. try:
  58. jf = load_json(G.GAME_PATH + "\\" + "game/frame/character/" + f)
  59. character.get_character(jf, C.CHARACTER_WHITE, dict())
  60. except Exception as e:
  61. if R.print_mode:
  62. print(f"Error processing character {f}: {e}")
  63. class Control:
  64. def __init__(self, screen, is_continue=False):
  65. self.map_json = None
  66. self.map_file = None
  67. self.map_name_json = None
  68. self.is_continue = is_continue
  69. self.cfg_json = None
  70. self.your_name = None # 玩家名称
  71. self.map_set_json = None
  72. self.map_set_at = None # 当前在map_set的第几关 从0开始
  73. self.mapmax_x = None # 当前关宽度
  74. self.mapmax_y = None # 当前关高度
  75. self.music_volume = None # 游戏音乐音量大小
  76. self.sound_volume = None # 游戏音效音量大小
  77. self.frame_rate = None # 游戏帧速率
  78. self.display_frame_rate = None # 显示帧率
  79. self.grid_damage_duration = None # 网格伤害持续时间
  80. self.display_flags = 0 # 画面显示特征
  81. self.screen = screen
  82. # 游戏值
  83. self.me = None # 玩家Hero对象
  84. self.current_level = None # 当前关卡Level对象
  85. self.orientations = dict() # 方向键与字符串的映射
  86. self.walking_stack = [] # 方向键栈
  87. self.bomb_old = 0 # 连按空格键标志
  88. self.f6_old = False # 连按F6键标志(名字牌显示开关)
  89. self.f7_old = False # 连按F7键标志(名字血量切换)
  90. self.pause_old = False
  91. self.reset_old = False # 连按reset键标志
  92. self.skills_old = [False, False, False, False, False, False, False] # 连按技能键标志
  93. self.message_old = [False, False, False, False]
  94. self.key2idx = dict() # 数字键与技能下标的映射
  95. self.key2message = dict()
  96. self.cfg_space = None # 用户自定义空格
  97. self.cfg_f6 = None # 用户自定义f6
  98. self.cfg_f7 = None # 用户自定义f7
  99. self.cfg_pause = None
  100. self.cfg_reset = None # 用户自定义重启0
  101. self.text_font = None
  102. self.description_shown = False
  103. self.wall_walking = True
  104. # 初始化pygame
  105. W.PAGE = W.Page.GAME
  106. G.CONTROL = self
  107. self.init_game()
  108. # self.preload()
  109. self.proceed_game()
  110. # self.update()
  111. def init_game(self):
  112. # 游戏初始化 读取配置文件
  113. try:
  114. with open("config.json", encoding="utf-8") as f:
  115. self.cfg_json = json.load(f)
  116. except JSONDecodeError:
  117. with open("config.json", encoding="utf-8_sig") as f:
  118. self.cfg_json = json.load(f)
  119. self.map_set_at = -1
  120. G.DISPLAY_NPC_NAME_CARD = True
  121. G.DISPLAY_NPC_BLOOD = self.cfg_json["display_npc_blood"]
  122. self.music_volume = self.cfg_json["music_volume"]
  123. self.frame_rate = int(self.cfg_json["frame_rate"])
  124. G.SOUND_VOLUME = self.cfg_json["sound_volume"]
  125. G.DISPLAY_FRAME_RATE = self.cfg_json["display_frame_rate"]
  126. G.FIRST_FRAME_SHORTEN_RATE = float(self.cfg_json["first_frame_shorten_rate"])
  127. G.LOW_CONFIG_MODE = bool(self.cfg_json["low_config_mode"])
  128. self.grid_damage_duration = G.GRID_DMG_DURATION
  129. self.your_name = self.cfg_json['your_name']
  130. if G.IS_ONLINE:
  131. self.your_name = G.USERNAME
  132. self.init_keys(self.cfg_json["keys"])
  133. self.text_font = pygame.font.Font("res/font/simsun.ttc", 16)
  134. G.DROP_ITEM = False
  135. G.LAST_MAP_TIME = G.LAST_LEVEL_TIME = pygame.time.get_ticks() // 1000
  136. if not self.is_continue:
  137. self.map_set_json = {
  138. "maps": [
  139. "rogueMap1", "rogueAttMap1", "rogueMap2", "rogueAttMap2", "rogueMap3", "rogueAttMap3",
  140. "rogueMap4", "rogueAttMap4", "rogueMap5", "rogueAttMap5", "rogueMap6", "rogueAttMap6",
  141. "rogueMap7", "rogueAttMap7", "rogueMap8", "rogueAttMap8", "rogueMap9", "rogueAttMap9",
  142. "rogueMap10", "rogueAttMap10", "rogueMap11", "rogueAttMap11", "rogueMap12", "rogueAttMap12",
  143. "rogueMap13", "rogueAttMap13", "rogueMap14", "rogueAttMap14", "rogueMap15", "rogueAttMap15"
  144. ]
  145. }
  146. else:
  147. self.map_set_at = G.CURRENT_LEVEL - 1
  148. self.map_set_json = R.central_mapset
  149. G.TOTAL_LEVEL = len(self.map_set_json["maps"])
  150. G.MAP_SET_NAME = self.cfg_json["map_set"]
  151. G.SHOW_STAT = True
  152. G.MONSTER_RECORD = False
  153. try:
  154. G.SHOW_TIME = bool(self.cfg_json["show_time"])
  155. except Exception as e:
  156. print(e)
  157. # G.LAST_MAP_TIME = G.TIME+3
  158. # G.LAST_LEVEL_TIME = G.TIME+3
  159. # logging.info(control准备判断是否有特殊地图参数, t={datetime.now().strftime("%Y-%m-%d %H:%M:%S")}')
  160. if not self.is_continue:
  161. self.map_file = {
  162. "maps": [
  163. "rogueMap1", "rogueAttMap1", "rogueMap2", "rogueAttMap2", "rogueMap3", "rogueAttMap3",
  164. "rogueMap4", "rogueAttMap4", "rogueMap5", "rogueAttMap5", "rogueMap6", "rogueAttMap6",
  165. "rogueMap7", "rogueAttMap7", "rogueMap8", "rogueAttMap8", "rogueMap9", "rogueAttMap9",
  166. "rogueMap10", "rogueAttMap10", "rogueMap11", "rogueAttMap11", "rogueMap12", "rogueAttMap12",
  167. "rogueMap13", "rogueAttMap13", "rogueMap14", "rogueAttMap14", "rogueMap15", "rogueAttMap15"
  168. ]
  169. }
  170. self.map_json = R.map_json_dic["rogueMap1"]
  171. else:
  172. self.map_file = R.central_mapset
  173. self.map_json = R.map_json_dic[R.central_mapset["maps"][G.CURRENT_LEVEL-1]]
  174. if "special" in self.map_json["basic"].keys():
  175. if "defense" in self.map_json["basic"]["special"].keys():
  176. G.SPECIAL_DEFENSE = self.map_json["basic"]["special"]["defense"]
  177. else:
  178. G.SPECIAL_DEFENSE = 0
  179. if "damage" in self.map_json["basic"]["special"].keys():
  180. G.SPECIAL_DAMAGE = self.map_json["basic"]["special"]["damage"]
  181. else:
  182. G.SPECIAL_DAMAGE = 0
  183. if "speed" in self.map_json["basic"]["special"].keys():
  184. G.SPECIAL_SPEED = self.map_json["basic"]["special"]["speed"]
  185. else:
  186. G.SPECIAL_SPEED = 0
  187. if "power" in self.map_json["basic"]["special"].keys():
  188. G.SPECIAL_POWER = self.map_json["basic"]["special"]["power"]
  189. else:
  190. G.SPECIAL_POWER = 0
  191. if "bomb" in self.map_json["basic"]["special"].keys():
  192. G.SPECIAL_BOMB = self.map_json["basic"]["special"]["bomb"]
  193. else:
  194. G.SPECIAL_BOMB = 0
  195. else:
  196. G.SPECIAL_DAMAGE = 0
  197. G.SPECIAL_DEFENSE = 0
  198. G.SPECIAL_SPEED = 1
  199. G.SPECIAL_POWER = 0
  200. G.SPECIAL_BOMB = 0
  201. def init_keys(self, keys_root):
  202. # 加载自定义按键
  203. self.orientations[keys_root["RIGHT"]] = "R"
  204. self.orientations[keys_root["UP"]] = "U"
  205. self.orientations[keys_root["LEFT"]] = "L"
  206. self.orientations[keys_root["DOWN"]] = "D"
  207. self.key2idx[keys_root["1"]] = 0
  208. self.key2idx[keys_root["2"]] = 1
  209. self.key2idx[keys_root["3"]] = 2
  210. self.key2idx[keys_root["4"]] = 3
  211. self.key2idx[keys_root["5"]] = 4
  212. self.key2idx[keys_root["6"]] = 5
  213. self.key2idx[keys_root["7"]] = 6
  214. self.key2message[keys_root["R"]] = 0
  215. self.key2message[keys_root["T"]] = 1
  216. self.key2message[keys_root["Y"]] = 2
  217. self.key2message[keys_root["U"]] = 3
  218. self.cfg_space = keys_root["SPACE"]
  219. self.cfg_f6 = keys_root["F6"]
  220. self.cfg_f7 = keys_root["F7"]
  221. self.cfg_reset = keys_root["RESET"]
  222. try:
  223. self.cfg_pause = keys_root["P"]
  224. except Exception as e:
  225. print(e)
  226. # self.cfg_pause = 112
  227. @classmethod
  228. def preload(cls):
  229. try:
  230. with open("config.json", encoding="utf-8") as f:
  231. cfg_json = json.load(f)
  232. except JSONDecodeError:
  233. with open("config.json", encoding="utf-8_sig") as f:
  234. cfg_json = json.load(f)
  235. if not cfg_json["allow_preload"]:
  236. return
  237. # 使用 ThreadPoolExecutor 来并行化 I/O 操作
  238. with concurrent.futures.ThreadPoolExecutor() as executor:
  239. futures = []
  240. ch_root = "game/frame/character/"
  241. # 对所有文件进行异步处理
  242. for f in os.listdir(ch_root):
  243. futures.append(executor.submit(_preload_character, f))
  244. eff_root = "game/effect/effect"
  245. for e in os.listdir(eff_root):
  246. futures.append(executor.submit(_preload_effect, e))
  247. for orientation in flame.ORIENTATIONS:
  248. futures.append(executor.submit(_preload_flame, orientation))
  249. # 等待所有任务完成
  250. for future in concurrent.futures.as_completed(futures):
  251. try:
  252. future.result()
  253. except Exception as e:
  254. print(f"Error during preload: {e}")
  255. def proceed_game(self, is_reset=False):
  256. # 进入下一个关卡
  257. if self.map_set_at + 1 < len(self.map_set_json["maps"]):
  258. self.map_set_at += 1
  259. map_name = self.map_set_json["maps"][self.map_set_at]
  260. hero_name = self.cfg_json["your_hero"]
  261. character_color = self.cfg_json["your_character_color"]
  262. print(map_name, self.map_set_at)
  263. self.set_level(self.your_name, map_name, hero_name, character_color, is_reset)
  264. else:
  265. # 正常刷新
  266. if not self.description_shown:
  267. self.current_level.update(self.screen)
  268. def proceed_custom_game(self, custom_map):
  269. # 进入指定关卡
  270. self.map_set_at = 0
  271. map_name = custom_map
  272. hero_name = self.cfg_json["your_hero"]
  273. character_color = self.cfg_json["your_character_color"]
  274. G.TOTAL_LEVEL = G.CURRENT_LEVEL + 1
  275. self.set_level(self.your_name, map_name, hero_name, character_color)
  276. G.HAS_RECORD = False
  277. def set_level(self, your_name, map_name, hero_name, character_color, is_reset=False):
  278. # 改变当前关卡
  279. character_colors = {
  280. "Red": C.CHARACTER_RED, "Blue": C.CHARACTER_BLUE, "SkyBlue": C.CHARACTER_SKYBLUE, "Yellow": C.CHARACTER_YELLOW, "Green": C.CHARACTER_GREEN,
  281. "Orange": C.CHARACTER_ORANGE, "Pink": C.CHARACTER_PINK, "SakuraPink": C.CHARACTER_SAKURAPINK, "Purple": C.CHARACTER_PURPLE,
  282. "Black": C.CHARACTER_BLACK, "White": C.CHARACTER_WHITE, "ForestGreen": C.CHARACTER_FORESTGREEN, "GrassGreen": C.CHARACTER_GRASSGREEN,
  283. "Withered": C.CHARACTER_WITHERED
  284. }
  285. character_color = character_colors[character_color]
  286. # 保留我的技能剩余数
  287. print(f">>>>>>>>>>>>>>> {hero_name}")
  288. me = Hero(hero_name, (0, 0), character_color)
  289. if self.me is not None and not is_reset:
  290. me.skill_remains = self.me.skill_remains
  291. self.me = me
  292. # 设置新关卡
  293. self.current_level = Level(your_name, map_name, self.me, self.music_volume, self.grid_damage_duration, self)
  294. def update(self):
  295. last_time = [time.time()]
  296. start = time.time()
  297. while W.PAGE == W.Page.GAME:
  298. for event in pygame.event.get():
  299. if event.type == pygame.QUIT:
  300. pygame.display.quit()
  301. pygame.quit()
  302. sys.exit()
  303. if self.current_level is not None:
  304. if self.current_level.finish_flag:
  305. # 如果过关
  306. self.proceed_game()
  307. elif self.current_level.custom_finish_flag:
  308. # 如果过关
  309. self.proceed_custom_game(self.current_level.custom_next_map)
  310. else:
  311. # 正常刷新
  312. if not self.description_shown:
  313. self.current_level.update(self.screen)
  314. self.key_pressed()
  315. pygame.display.flip()
  316. pygame.time.Clock().tick(min(self.frame_rate, 2400))
  317. garbage_collect(last_time)
  318. def key_pressed(self):
  319. # 键盘事件检测
  320. keys = pygame.key.get_pressed()
  321. self.player_bomb(keys)
  322. self.player_move(keys)
  323. self.player_f6(keys)
  324. self.player_f7(keys)
  325. # self.player_pause(keys)
  326. self.player_reset(keys)
  327. self.player_skill(keys)
  328. self.player_message(keys)
  329. def player_move(self, keys):
  330. # 玩家移动
  331. for enum in self.orientations.keys():
  332. if keys[enum]:
  333. if enum not in self.walking_stack:
  334. self.walking_stack.insert(0, enum)
  335. else:
  336. if enum in self.walking_stack:
  337. self.walking_stack.remove(enum)
  338. # 取栈顶元素first
  339. first = 0
  340. if len(self.walking_stack) > 0:
  341. first = self.walking_stack[0]
  342. # 判断first是哪个方向
  343. if first == 0:
  344. self.me.set_motion()
  345. else:
  346. self.me.set_motion(self.orientations[first])
  347. if G.IN_BUBBLE:
  348. if self.orientations[first] != G.LAST_KEY:
  349. G.LAST_KEY = self.orientations[first]
  350. G.KEY_QUEUE.append(self.orientations[first])
  351. def player_bomb(self, keys):
  352. if keys[self.cfg_space]:
  353. if self.bomb_old == 0:
  354. self.me.set_bomb()
  355. self.bomb_old += 1
  356. else:
  357. self.bomb_old = 0
  358. def player_f6(self, keys):
  359. if keys[self.cfg_f6]:
  360. if self.f6_old is True:
  361. return
  362. # 按下F6键
  363. G.DISPLAY_NPC_NAME_CARD = not G.DISPLAY_NPC_NAME_CARD
  364. self.f6_old = True
  365. else:
  366. self.f6_old = False
  367. def player_f7(self, keys):
  368. if keys[self.cfg_f7]:
  369. if self.f7_old is True:
  370. return
  371. # 按下F7键
  372. G.DISPLAY_NPC_NAME_CARD = True
  373. G.DISPLAY_NPC_BLOOD = not G.DISPLAY_NPC_BLOOD
  374. self.f7_old = True
  375. else:
  376. self.f7_old = False
  377. def player_pause(self, keys):
  378. if keys[self.cfg_pause]:
  379. if self.pause_old is True:
  380. return
  381. # 按下键
  382. G.PAUSE = not G.PAUSE
  383. self.pause_old = True
  384. else:
  385. self.pause_old = False
  386. def player_reset(self, keys):
  387. if keys[self.cfg_reset]:
  388. if self.reset_old is True:
  389. return
  390. self.do_reset(generate_new=True)
  391. else:
  392. self.reset_old = False
  393. def do_reset(self, generate_new=True):
  394. R.battle_district = []
  395. R.se_district = []
  396. R.story_eden, R.story_destiny, R.story_ocean, R.story_skyland = False, False, False, False
  397. R.continuing_game = False
  398. R.last_item = None
  399. R.extra_lv = 0
  400. user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
  401. qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
  402. os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
  403. last_game_file_path = os.path.join(qqtpve_folder, "rougeOBLastGame.rougedata") # 构建文件路径
  404. if generate_new:
  405. if os.path.exists(last_game_file_path):
  406. os.remove(last_game_file_path)
  407. print("清除旧数据")
  408. rouge_reset()
  409. G.CURRENT_LEVEL = 0
  410. if generate_new:
  411. RG.main_func()
  412. self.init_game()
  413. self.proceed_game(is_reset=True)
  414. self.reset_old = True
  415. G.CHEAT = False
  416. G.HAS_RECORD = False
  417. G.LAST_MAP_TIME = G.TIME
  418. G.LAST_LEVEL_TIME = G.TIME
  419. G.ALL_CLEAR = True
  420. R.coin_borrow = 0
  421. R.has_loan = False
  422. G.ITEM = 0
  423. G.MONSTER_RECORD_LIST = []
  424. G.HAS_RECORD_FULL = False
  425. G.HAS_GOLDEN = False
  426. self.cfg_json = load_json("config.json")
  427. self.map_set_json = {
  428. "maps": [
  429. "rogueMap1", "rogueAttMap1", "rogueMap2", "rogueAttMap2", "rogueMap3", "rogueAttMap3",
  430. "rogueMap4", "rogueAttMap4", "rogueMap5", "rogueAttMap5", "rogueMap6", "rogueAttMap6",
  431. "rogueMap7", "rogueAttMap7", "rogueMap8", "rogueAttMap8", "rogueMap9", "rogueAttMap9",
  432. "rogueMap10", "rogueAttMap10", "rogueMap11", "rogueAttMap11", "rogueMap12", "rogueAttMap12",
  433. "rogueMap13", "rogueAttMap13", "rogueMap14", "rogueAttMap14", "rogueMap15", "rogueAttMap15"
  434. ]
  435. }
  436. G.TOTAL_LEVEL = len(self.map_set_json["maps"])
  437. self.map_name_json = R.map_json_dic["rogueMap1"]
  438. if "environment_effect" in self.map_name_json["basic"].keys():
  439. G.ENVIRONMENT_EFFECT = self.map_name_json["basic"]["environment_effect"]
  440. else:
  441. G.ENVIRONMENT_EFFECT = []
  442. if "player_light" in self.map_name_json["basic"].keys():
  443. self.me.light = self.map_name_json["basic"]["player_light"]
  444. def player_skill(self, keys):
  445. for k in self.key2idx.keys():
  446. idx = self.key2idx[k] # 常量转索引
  447. if keys[k]:
  448. if self.skills_old[idx]:
  449. return
  450. self.me.use_skill(idx)
  451. self.skills_old[idx] = True
  452. else:
  453. self.skills_old[idx] = False
  454. def player_message(self, keys):
  455. for k in self.key2message.keys():
  456. idx = self.key2message[k] # 常量转索引
  457. if keys[k]:
  458. if self.message_old[idx]:
  459. return
  460. if R.debug_mode:
  461. G.LAST_LEVEL_TIME = self.current_level.times_num
  462. # print(R.current_standard_damage, G.SPECIAL_DAMAGE)
  463. R.current_standard_damage -= G.SPECIAL_DAMAGE
  464. R.current_standard_defense -= G.SPECIAL_DEFENSE
  465. self.proceed_game()
  466. self.me.use_message(idx)
  467. self.message_old[idx] = True
  468. else:
  469. self.message_old[idx] = False
  470. def reset(self, map_set):
  471. """
  472. with open("config.json", "r", encoding="utf-8") as json_file:
  473. mapsetdata = json.load(json_file)
  474. mapsetdata["map_set"] = map_set
  475. with open("config.json", "w", encoding="utf-8") as json_file:
  476. json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
  477. self.init_game()
  478. """
  479. self.map_set_json = {
  480. "maps": [
  481. "rogueMap1", "rogueAttMap1", "rogueMap2", "rogueAttMap2", "rogueMap3", "rogueAttMap3",
  482. "rogueMap4", "rogueAttMap4", "rogueMap5", "rogueAttMap5", "rogueMap6", "rogueAttMap6",
  483. "rogueMap7", "rogueAttMap7", "rogueMap8", "rogueAttMap8", "rogueMap9", "rogueAttMap9",
  484. "rogueMap10", "rogueAttMap10", "rogueMap11", "rogueAttMap11", "rogueMap12", "rogueAttMap12",
  485. "rogueMap13", "rogueAttMap13", "rogueMap14", "rogueAttMap14", "rogueMap15", "rogueAttMap15"
  486. ]
  487. }
  488. self.map_set_at = 0
  489. map_name = self.map_set_json["maps"][self.map_set_at]
  490. hero_name = self.cfg_json["your_hero"]
  491. character_color = self.cfg_json["your_character_color"]
  492. self.set_level(self.your_name, map_name, hero_name, character_color, is_reset=True)
  493. R.game_exp = 0
  494. R.extra_lv = 0
  495. # R.coin = 8
  496. self.reset_old = True
  497. G.CHEAT = False
  498. G.HAS_RECORD = False
  499. G.CURRENT_LEVEL = 1
  500. G.LAST_MAP_TIME = G.TIME
  501. G.LAST_LEVEL_TIME = G.TIME
  502. G.ALL_CLEAR = True
  503. R.coin_borrow = 0
  504. R.has_loan = False
  505. G.ITEM = 0
  506. # G.MONSTER_RECORD_LIST = []
  507. G.HAS_RECORD_FULL = False
  508. G.HAS_GOLDEN = False
  509. self.map_set_json = {
  510. "maps": [
  511. "rogueMap1", "rogueAttMap1", "rogueMap2", "rogueAttMap2", "rogueMap3", "rogueAttMap3",
  512. "rogueMap4", "rogueAttMap4", "rogueMap5", "rogueAttMap5", "rogueMap6", "rogueAttMap6",
  513. "rogueMap7", "rogueAttMap7", "rogueMap8", "rogueAttMap8", "rogueMap9", "rogueAttMap9",
  514. "rogueMap10", "rogueAttMap10", "rogueMap11", "rogueAttMap11", "rogueMap12", "rogueAttMap12",
  515. "rogueMap13", "rogueAttMap13", "rogueMap14", "rogueAttMap14", "rogueMap15", "rogueAttMap15"
  516. ]
  517. }
  518. G.TOTAL_LEVEL = len(self.map_set_json["maps"])
  519. self.map_name_json = R.map_json_dic["rogueMap1"]
  520. if "environment_effect" in self.map_name_json["basic"].keys():
  521. G.ENVIRONMENT_EFFECT = self.map_name_json["basic"]["environment_effect"]
  522. else:
  523. G.ENVIRONMENT_EFFECT = []
  524. if "player_light" in self.map_name_json["basic"].keys():
  525. self.me.light = self.map_name_json["basic"]["player_light"]
  526. now = datetime.now()
  527. # 格式化年月日
  528. year = now.strftime("%Y")
  529. month = now.strftime("%m")
  530. day = now.strftime("%d")
  531. # 移除月份和日期的前导零(如果有)
  532. month = month.lstrip("0")
  533. day = day.lstrip("0")
  534. R.today_datetime["year"] = int(year)
  535. R.today_datetime["month"] = int(month)
  536. R.today_datetime["day"] = int(day)