A save state/password generator for the original Metroid.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

metroidgen.py 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. class MetroidState:
  2. def __init__(self):
  3. self.itemsCollected = {
  4. "Maru Mari": False,
  5. "Bombs": False,
  6. "Long Beam": False,
  7. "Ice Beam": False,
  8. "Wave Beam": False,
  9. "High Jump Boots": False,
  10. "Varia": False,
  11. "Screw Attack": False
  12. }
  13. self.samusHas = {
  14. "Maru Mari": False,
  15. "Bombs": False,
  16. "Long Beam": False,
  17. "Ice Beam": False,
  18. "Wave Beam": False,
  19. "High Jump Boots": False,
  20. "Varia": False,
  21. "Screw Attack": False
  22. }
  23. self.missileTanks = {
  24. 1: False,
  25. 2: False,
  26. 3: False,
  27. 4: False,
  28. 5: False,
  29. 6: False,
  30. 7: False,
  31. 8: False,
  32. 9: False,
  33. 10: False,
  34. 11: False,
  35. 12: False,
  36. 13: False,
  37. 14: False,
  38. 15: False,
  39. 16: False,
  40. 17: False,
  41. 18: False,
  42. 19: False,
  43. 20: False,
  44. 21: False
  45. }
  46. self.energyTanks = {
  47. 1: False,
  48. 2: False,
  49. 3: False,
  50. 4: False,
  51. 5: False,
  52. 6: False,
  53. 7: False,
  54. 8: False
  55. }
  56. self.zebetitesDestroyed = {
  57. 1: False,
  58. 2: False,
  59. 3: False,
  60. 4: False,
  61. 5: False
  62. }
  63. self.doors = {
  64. "Brinstar": {
  65. 1: False,
  66. 2: False,
  67. 3: False,
  68. 4: False,
  69. 5: False
  70. }, "Norfair": {
  71. 1: False,
  72. 2: False,
  73. 3: False,
  74. 4: False
  75. }, "Kraid": {
  76. 1: False,
  77. 2: False,
  78. 3: False,
  79. 4: False,
  80. 5: False
  81. }, "Ridley": {
  82. 1: False,
  83. 2: False
  84. }, "Tourian": {
  85. 1: False,
  86. 2: False,
  87. 3: False
  88. }
  89. }
  90. self.kraidKilled = False
  91. self.ridleyKilled = False
  92. self.motherBrainKilled = False
  93. self.kraidStatue = False
  94. self.ridleyStatue = False
  95. self.swimsuit = False
  96. self.missileCount = 0
  97. self.gameAge = 0
  98. self.locations = ["Brinstar", "Norfair", "Kraid's Lair", "Ridley's Lair", "Tourian"]
  99. self.startLocation = 0
  100. def toggleItem(self, itm):
  101. if itm in self.itemsCollected.keys():
  102. self.itemsCollected[itm] = not self.itemsCollected[itm]
  103. self.samusHas[itm] = not self.samusHas[itm]
  104. else:
  105. print("Couldn't find item: {}".format(str(itm)))
  106. def toggleMissileTank(self, num):
  107. try:
  108. num = int(num)
  109. except:
  110. print("{} is not a number".format(num))
  111. return
  112. if num in self.missileTanks.keys():
  113. self.missileTanks[num] = not self.missileTanks[num]
  114. else:
  115. print("Couldn't find missile tank: {}".format(num))
  116. def toggleEnergyTank(self, num):
  117. try:
  118. num = int(num)
  119. except:
  120. print("{} is not a number".format(num))
  121. return
  122. if num in self.energyTanks.keys():
  123. self.energyTanks[num] = not self.energyTanks[num]
  124. else:
  125. print("Couldn't find energy tank: {}".format(num))
  126. def toggleZebetite(self, num):
  127. try:
  128. num = int(num)
  129. except:
  130. print("{} is not a number".format(num))
  131. return
  132. if num in self.zebetitesDestroyed.keys():
  133. self.zebetitesDestroyed[num] = not self.zebetitesDestroyed[num]
  134. else:
  135. print("Couldn't find Zebetite: {}".format(num))
  136. def toggleKraid(self):
  137. self.kraidKilled = not self.kraidKilled
  138. self.kraidStatue = self.kraidKilled
  139. def toggleKraidStatue(self):
  140. self.kraidStatue = not self.kraidStatue
  141. if self.kraidKilled and not self.kraidStatue:
  142. print("WARNING: Kraid has been killed but his statue has not been raised.")
  143. def toggleRidley(self):
  144. self.ridleyKilled = not self.ridleyKilled
  145. self.ridleyStatue = self.ridleyKilled
  146. def toggleRidleyStatue(self):
  147. self.ridleyStatue = not self.ridleyStatue
  148. if self.ridleyKilled and not self.ridleyStatue:
  149. print("WARNING: Ridley has been killed but his statue has not been raised.")
  150. def toggleMotherBrain(self):
  151. self.motherBrainKilled = not self.motherBrainKilled
  152. def toggleDoor(self, area, door):
  153. try:
  154. area = str(area)
  155. door = int(door)
  156. except:
  157. print("Area must be string, door must be a positive integer")
  158. return
  159. if area in self.doors.keys() and int(door) in self.doors[area].keys():
  160. self.doors[area][door] = not self.doors[area][door]
  161. else:
  162. print("Couldn't find door {} in area {}".format(door, area))
  163. def toggleSwimsuit(self):
  164. self.swimsuit = not self.swimsuit
  165. def newLocation(self, loc):
  166. try:
  167. loc = str(loc)
  168. except:
  169. print("Location must be a string")
  170. return
  171. if loc in self.locations:
  172. self.startLocation = self.locations.index(loc)
  173. else:
  174. print("Couldn't find location: {}".format(loc))
  175. def collectedItems(self):
  176. o = []
  177. for k,v in self.itemsCollected.items():
  178. if v == True:
  179. o.append(k)
  180. if len(o) == 0:
  181. return "None"
  182. else:
  183. return ", ".join(o)
  184. def collectedMissiles(self):
  185. o = []
  186. for k, v in self.missileTanks.items():
  187. if v == True:
  188. o.append(k)
  189. if len(o) == 0:
  190. return "None"
  191. else:
  192. return ", ".join([str(b) for b in o])
  193. def collectedEtanks(self):
  194. o = []
  195. for k, v in self.energyTanks.items():
  196. if v == True:
  197. o.append(k)
  198. if len(o) == 0:
  199. return "None"
  200. else:
  201. return ", ".join([str(b) for b in o])
  202. def killedZebetites(self):
  203. o = []
  204. for k, v in self.zebetitesDestroyed.items():
  205. if v == True:
  206. o.append(k)
  207. if len(o) == 0:
  208. return "None"
  209. else:
  210. return ", ".join([str(b) for b in o])
  211. def killedBosses(self):
  212. o = []
  213. if self.kraidKilled:
  214. o.append("Kraid")
  215. if self.ridleyKilled:
  216. o.append("Ridley")
  217. if self.motherBrainKilled:
  218. o.append("Mother Brain")
  219. if len(o) == 0:
  220. return "None"
  221. else:
  222. return ", ".join(o)
  223. def raisedStatues(self):
  224. o = []
  225. if self.kraidStatue:
  226. o.append("Kraid")
  227. if self.ridleyStatue:
  228. o.append("Ridley")
  229. if len(o) == 0:
  230. return "None"
  231. else:
  232. return ", ".join(o)
  233. def inBailey(self):
  234. if self.swimsuit:
  235. return "Yes"
  236. else:
  237. return "No"
  238. def toString(self):
  239. ic = "Items Collected: {}".format(self.collectedItems())
  240. mt = "Missile Tanks Collected: {}".format(self.collectedMissiles())
  241. et = "Energy Tanks Collected: {}".format(self.collectedEtanks())
  242. zb = "Zebetites Killed: {}".format(self.killedZebetites())
  243. kb = "Bosses Killed: {}".format(self.killedBosses())
  244. rs = "Statues Raised: {}".format(self.raisedStatues())
  245. sw = "Swimsuit?: {}".format(self.inBailey())
  246. dr = ""
  247. return "\n".join([ic, mt, et, zb, kb, rs, sw, dr])
  248. def main():
  249. gs = MetroidState()
  250. gs.kraidKilled = True
  251. print(gs.toString())
  252. if __name__ == "__main__":
  253. main()