123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- class MetroidState:
- def __init__(self):
- self.itemsCollected = {
- "Maru Mari": False,
- "Bombs": False,
- "Long Beam": False,
- "Ice Beam": False,
- "Wave Beam": False,
- "High Jump Boots": False,
- "Varia": False,
- "Screw Attack": False
- }
- self.samusHas = {
- "Maru Mari": False,
- "Bombs": False,
- "Long Beam": False,
- "Ice Beam": False,
- "Wave Beam": False,
- "High Jump Boots": False,
- "Varia": False,
- "Screw Attack": False
- }
- self.missileTanks = {
- 1: False,
- 2: False,
- 3: False,
- 4: False,
- 5: False,
- 6: False,
- 7: False,
- 8: False,
- 9: False,
- 10: False,
- 11: False,
- 12: False,
- 13: False,
- 14: False,
- 15: False,
- 16: False,
- 17: False,
- 18: False,
- 19: False,
- 20: False,
- 21: False
- }
- self.energyTanks = {
- 1: False,
- 2: False,
- 3: False,
- 4: False,
- 5: False,
- 6: False,
- 7: False,
- 8: False
- }
- self.zebetitesDestroyed = {
- 1: False,
- 2: False,
- 3: False,
- 4: False,
- 5: False
- }
- self.doors = {
- "Brinstar": {
- 1: False,
- 2: False,
- 3: False,
- 4: False,
- 5: False
- }, "Norfair": {
- 1: False,
- 2: False,
- 3: False,
- 4: False
- }, "Kraid": {
- 1: False,
- 2: False,
- 3: False,
- 4: False,
- 5: False
- }, "Ridley": {
- 1: False,
- 2: False
- }, "Tourian": {
- 1: False,
- 2: False,
- 3: False
- }
- }
- self.kraidKilled = False
- self.ridleyKilled = False
- self.motherBrainKilled = False
- self.kraidStatue = False
- self.ridleyStatue = False
- self.swimsuit = False
- self.missileCount = 0
- self.gameAge = 0
- self.locations = ["Brinstar", "Norfair", "Kraid's Lair", "Ridley's Lair", "Tourian"]
- self.startLocation = 0
-
- def toggleItem(self, itm):
- if itm in self.itemsCollected.keys():
- self.itemsCollected[itm] = not self.itemsCollected[itm]
- self.samusHas[itm] = not self.samusHas[itm]
- else:
- print("Couldn't find item: {}".format(str(itm)))
-
- def toggleMissileTank(self, num):
- try:
- num = int(num)
- except:
- print("{} is not a number".format(num))
- return
- if num in self.missileTanks.keys():
- self.missileTanks[num] = not self.missileTanks[num]
- else:
- print("Couldn't find missile tank: {}".format(num))
-
- def toggleEnergyTank(self, num):
- try:
- num = int(num)
- except:
- print("{} is not a number".format(num))
- return
- if num in self.energyTanks.keys():
- self.energyTanks[num] = not self.energyTanks[num]
- else:
- print("Couldn't find energy tank: {}".format(num))
-
- def toggleZebetite(self, num):
- try:
- num = int(num)
- except:
- print("{} is not a number".format(num))
- return
- if num in self.zebetitesDestroyed.keys():
- self.zebetitesDestroyed[num] = not self.zebetitesDestroyed[num]
- else:
- print("Couldn't find Zebetite: {}".format(num))
-
- def toggleKraid(self):
- self.kraidKilled = not self.kraidKilled
- self.kraidStatue = self.kraidKilled
-
- def toggleKraidStatue(self):
- self.kraidStatue = not self.kraidStatue
- if self.kraidKilled and not self.kraidStatue:
- print("WARNING: Kraid has been killed but his statue has not been raised.")
-
- def toggleRidley(self):
- self.ridleyKilled = not self.ridleyKilled
- self.ridleyStatue = self.ridleyKilled
-
- def toggleRidleyStatue(self):
- self.ridleyStatue = not self.ridleyStatue
- if self.ridleyKilled and not self.ridleyStatue:
- print("WARNING: Ridley has been killed but his statue has not been raised.")
-
- def toggleMotherBrain(self):
- self.motherBrainKilled = not self.motherBrainKilled
-
- def toggleDoor(self, area, door):
- try:
- area = str(area)
- door = int(door)
- except:
- print("Area must be string, door must be a positive integer")
- return
- if area in self.doors.keys() and int(door) in self.doors[area].keys():
- self.doors[area][door] = not self.doors[area][door]
- else:
- print("Couldn't find door {} in area {}".format(door, area))
-
- def toggleSwimsuit(self):
- self.swimsuit = not self.swimsuit
-
- def newLocation(self, loc):
- try:
- loc = str(loc)
- except:
- print("Location must be a string")
- return
- if loc in self.locations:
- self.startLocation = self.locations.index(loc)
- else:
- print("Couldn't find location: {}".format(loc))
-
- def collectedItems(self):
- o = []
- for k,v in self.itemsCollected.items():
- if v == True:
- o.append(k)
- if len(o) == 0:
- return "None"
- else:
- return ", ".join(o)
-
- def collectedMissiles(self):
- o = []
- for k, v in self.missileTanks.items():
- if v == True:
- o.append(k)
- if len(o) == 0:
- return "None"
- else:
- return ", ".join([str(b) for b in o])
-
- def collectedEtanks(self):
- o = []
- for k, v in self.energyTanks.items():
- if v == True:
- o.append(k)
- if len(o) == 0:
- return "None"
- else:
- return ", ".join([str(b) for b in o])
-
- def killedZebetites(self):
- o = []
- for k, v in self.zebetitesDestroyed.items():
- if v == True:
- o.append(k)
- if len(o) == 0:
- return "None"
- else:
- return ", ".join([str(b) for b in o])
-
- def killedBosses(self):
- o = []
- if self.kraidKilled:
- o.append("Kraid")
- if self.ridleyKilled:
- o.append("Ridley")
- if self.motherBrainKilled:
- o.append("Mother Brain")
- if len(o) == 0:
- return "None"
- else:
- return ", ".join(o)
-
- def raisedStatues(self):
- o = []
- if self.kraidStatue:
- o.append("Kraid")
- if self.ridleyStatue:
- o.append("Ridley")
- if len(o) == 0:
- return "None"
- else:
- return ", ".join(o)
-
- def inBailey(self):
- if self.swimsuit:
- return "Yes"
- else:
- return "No"
-
- def toString(self):
- ic = "Items Collected: {}".format(self.collectedItems())
- mt = "Missile Tanks Collected: {}".format(self.collectedMissiles())
- et = "Energy Tanks Collected: {}".format(self.collectedEtanks())
- zb = "Zebetites Killed: {}".format(self.killedZebetites())
- kb = "Bosses Killed: {}".format(self.killedBosses())
- rs = "Statues Raised: {}".format(self.raisedStatues())
- sw = "Swimsuit?: {}".format(self.inBailey())
- dr = ""
- return "\n".join([ic, mt, et, zb, kb, rs, sw, dr])
-
- def main():
- gs = MetroidState()
- gs.kraidKilled = True
- print(gs.toString())
-
- if __name__ == "__main__":
- main()
|