rogue_control.py 23 KB

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