Пример #1
0
    def main(self):
        """ Runs the main loop. """
        start = time.time()
        cps = 8  # Cycles per second to run simulation. Set to None for no limit.
        cycle = 0

        starting_players = self.players[::-1]

        while len(self.players) > 0:

            # Check keyboard inputs and window closing
            events = pygame.event.get()
            self.check_globals(events)

            dead_players = set()

            # Update players
            for player in self.players[::-1]:
                player.update(events)
                if player in self.players:
                    dead_players |= player.move()
                    self.last_active_player = player
                if Game.pickle_best_agent:
                    try:
                        player.controller.agent.pop.pickle_best_agent = Game.pickle_best_agent
                    except AttributeError as a:
                        pass

            for player in dead_players:
                player.die()

            if Game.simulate and self.render_enable:
                self.display.update(Game.vis_mode)
                self.render_settings()
                pygame.display.flip()

            # Run at a fixed number of cycles per second
            if Game.simulate:
                while time.time() < start + 1 / cps:
                    pass
                start += 1 / cps
            else:
                start = time.time()

            cycle += 1

        if Game.render_enable:
            self.display.update(Game.vis_mode)
            self.render_settings()
            pygame.display.flip()

        if len(starting_players):
            winner = max(starting_players, key=lambda p: p.age)
            false_winner = False
            for item in starting_players:
                if item.age >= winner.age and item is not winner:
                    false_winner = True
            if not false_winner:
                winner.age *= 2
        return [bot.age * SURVIVAL_SCORE for bot in self.bot_list]
def journey(player):
	
	next = input("Press enter to continue on your journey.")
	print("You continue on your journey.")
	
	if player.journeyDays < 1:
		print("You are travelling across Burgandy. It's pretty scenic.")
		
	if player.journeyDays == 1:
		print("You are walking across the alps. It's a little bit rocky.")
		
	if player.journeyDays == 2:
		print("You are in Italy.")
		
	if player.journeyDays == 3:
		print("You arrive in Rome and deliver the message to the Pope.")
		print("After staying for a while in Rome, you decide it's time to go back.")
		
		
	rand = randint(0,100)
	
	if rand < 10:
		print("Oh no! You've been captured by brigands! What do you do?")
		print("1: Fight them.")
		print("2: Pray")
		
		while True:
			action = input("> ").lower()
			
			if action == "fight them" or action == "1":
				rand = randint(0,1)
				if rand == 1:
					print("You fight against the bandits, but all they do is beat you up more. They leave you on the side of the road, nearly dead.")
				elif rand == 0:
					print("You fight the bandits, but they're too strong! They kill you. You are dead.")
					player.die()
					player.journey = False
				break
				
			elif action == "pray" or action == "2":
				print("You don't fight back against the bandits, and instead remain silent and pray to God. Miraculously, when the bandits try to attack you, they are repelled by a mysterious force. They are so in awe that they all decide to become monks. They let you go unharmed.")
				player.decreasePenance(2)
				break
			else: 
				print("I don't understand that!")
				
	elif rand < 20:
		print("You stop at a monastary on the road. They offer you some delicious looking chicken for dinner. Should you eat it?")
		
		while True:
			action = input("> ").lower()
			
			if action == "yes":
				rand = randint(0,1)
				if rand == 1:
					print("You eat the meat. Tastes good!")
					player.increaseSins("laxity")
				elif rand == 0:
					print("As you are eating the chicken, a bone gets caught in your throat and you choke and die. Uh oh! You are dead!")
					player.die()
					player.journey = False
				break
			elif action == "no":
				print("You don't eat the meat! Good call!")
				player.decreasePenance(1)
				break
			else: 
				print("Please answer either yes or no!")
				
	elif rand < 30:
		print("You stop in an inn on the way to rest. While there, you notice a beautiful women looking at you. She approaches you.")
		print('"Hey there, handsome," she says, "Wanna have a good time?" She waggles her eyebrows at you.')
		print("You....")
		print("1. Have a good time.")
		print("2. Don't have a good time.")
		
		while True:
			action = input("> ").lower()
			
			if action == "1" or action == "have a good time":
				print("You have a good time.")
				player.increaseSins("kissing")
				break
			if action == "2" or action == "don't have a good time":
				print('"Get behind me Satan!", you cry. The woman looks insulted and walks away. Phew. You narrowly got out of that one.')
				break
			else:
				print("I don't understand that.")
		
	if player.journeyDays == 7:
		print("After a long and arduous trek, finally the great walls of Cluny come into sight once more! You did it!")
		player.journey = False
	
	player.journeyDays += 1
def sick_day(player):
	
	turns = 0
	
	validActions = ['rest','sleep','relax']
	
	
	while player.getSickliness() > 0:
		print("You are in the infirmirary. You are still feeling a bit sick. You should rest.")
	
		while True:
			action = input("> ")
			
			if action in validActions:
				print("You close your eyes and rest. You can feel yourself getting healthier already.")
				player.decreaseHealth(-3)
				break
			else:
				print("Now's not the time for that! You need to rest!")
				
		print("You wake up feeling refreshed. Someone brings you some food to eat. Wow, it's meat! Should you eat it?")
		
		while True:
			action = input("> ")
			if action == 'yes':
				print("You eat the meat. Delicious! You feel healthier already.")
				player.decreaseHealth(-1)
				break
			elif action == 'no':
				print("You don't eat the meat. That's very holy of you.")
				player.decreasePenance(1)
				break
			else:
				print("Answer either yes or no!")
			

		if len(player.getSinsList() > 0):
			print("A monk comes by to see if you have any sins to confess.")
			while len(player.getSinsList()) > 0:
				print("Type exit to exit and hint for a hint if you can't remember what sins you've done.")
				sin = input("What sins do you have to confess? \n > ")
				self.confessSin(sin)
		
		print("You sleep for the rest of the day.")
		
		#random chance of dying...
		rand = randint(0,100)
		print("Chance of dying is:", rand)
		if player.getSins() > 10:
			#more likely to die if you are a sinner....
			if rand < player.getSickliness() + 20:
				print("Unfortunately, however, your illness gets worse and you die. :(")
				player.die()
					
		else:
			if rand < player.getSickliness() + 10:
				print("Unfortunately, however, your illness gets worse and you die. :(")
				player.die()
				
			
		
		
	if player.alive == True:
		player.changeHealth(False)
		print("You are feeling a lot better! Tomorrow you can leave the infirmary and resume the regular hours.")