def main(): textcom.globals_hack_init() print("Bradford: Welcome Commander. We've discovered an Alien Base, and " "it's your job to send someone out to deal with it.") print('Bradford: Choose a soldier from the 3 below to go on the mission.') barracks = [] #generates soldiers for i in range(3): x = create_soldier(i) barracks.append(x) #displays a list of the soldiers for i in range(len(barracks)): print(str(i + 1) + ': ') barracks[i].print_summary() print() #forces you to pick only one soldier soldier = barracks[get_int_input('# ', 1, 3) - 1] if soldier.lastname == "Bradford": soldier.say("What? There must have been a mistake on the sheet, " "Commander! You can't send --") elif soldier.lastname == "Van Doorn": soldier.say("I'm the Ops team?") else: soldier.say('Ready for duty, Commander!') scripted_levels = { 1: [create_alien(1, 1, 'Sectoid', nrank=0)], 2: [ create_alien(1, 2, 'Sectoid', nrank=0), create_alien(1, 2, 'Sectoid', nrank=0) ], 3: [ create_alien(1, 3, 'Sectoid', nrank=0), create_alien(1, 3, 'Sectoid', nrank=1) ], 5: ["Drop Zone"], 10: ["Drop Zone"], 15: ["Drop Zone"], 20: ["Drop Zone"], 30: [create_alien(1, 1, 'Muton', nrank=8, hp=50)] } game_map = create_map(NUMBER_OF_ROOMS, soldier, scripted_levels) # dump_map(game_map) # Yeah, I feel pretty bad about this, but currently I have no idea how to # make the current room index available for the death handler score # .calculation. Maybe everything works out fine if components are # introduced. I hope so. soldier.game_map = game_map #game loop, runs until your soldier is killed while soldier.alive == True: try: old_room = game_map.get_current_room() playerTurn(game_map) status(str(soldier) + ' is out of AP!') current_room = game_map.get_current_room() # Aliens are not allowed to act after the room was changed, # because they already scattered when the player entered the new # room. Also, there is no need for an alien turn if there are # no more aliens in the room. if soldier.alive == True and old_room == current_room \ and len(current_room) > 0: print() print("--------------Alien Activity!--------------") print() time.sleep(1) alienTurn(game_map) print() print("--------------XCOM Turn--------------") print() except ( ValueError or IndexError ): pass if game_map.current_room == len(game_map.rooms): print("You have won the game!") break
def setup_map(): soldier = Soldier(0, 'f', 5, 70, 10, 0, 'Jane', 'Doe', '', None, [], []) soldier.ap = soldier.mobility test_map = create_map(1, soldier) return test_map