Esempio n. 1
0
    def OpeningScene(self, screen):
        while True:
            screen.blit(gameover, (290, 150))
            select_exit = Opening(ending_exit_1, ending_exit_2, (390, 500))
            self.render()
            select_exit.render()
#            screen.blit(pygame.image.load(transparent_image).convert_alpha(), (655, 655))
            screen.blit(dead_face, (665, 665))
            for event in pygame.event.get():
                if event.type == pygame.QUIT or (select_exit.isOver() and pygame.mouse.get_pressed()[0]):
                    pygame.quit()
                    exit()
                if self.isOver() and pygame.mouse.get_pressed()[0]:
                    stage_num = 0
                    return stage_num
            pygame.display.update()
Esempio n. 2
0
 def OpeningScene(self, screen):
 	screen.blit(menu, (0,0))
     select_exit = Opening(menu_exit_1, menu_exit_2, (380, 500))
     select_help = Opening(help1, help2, (380, 600))
 	self.render()
     select_exit.render()
 	for event in pygame.event.get():
         if event.type == pygame.QUIT or (select_exit.isOver() and pygame.mouse.get_pressed()[0]):
         	pygame.quit()
         	exit()
         if (self.isOver() and pygame.mouse.get_pressed()[0]) or pygame.key.get_pressed()[K_ESCAPE] :
         	stage_num = 11
             time.sleep(0.15)
             return stage_num
     pygame.display.update()
     return 3
Esempio n. 3
0
    def evaluate(self, moves):

        black_moves = []
        white_moves = []
        res = 0

        # On remplit les tableau de noirs et de blancs présents sur le plateau lors de l'appel de l'heuristique
        for move in moves:
            ufcoord = Goban.Board.name_to_coord(move)
            x = ufcoord[0]
            y = ufcoord[1]
            if self._board[Goban.Board.flatten((x, y))] == self._board._BLACK:
                black_moves.append(move)
        for move in moves:
            ufcoord = Goban.Board.name_to_coord(move)
            x = ufcoord[0]
            y = ufcoord[1]
            if self._board[Goban.Board.flatten((x, y))] == self._board._WHITE:
                white_moves.append(move)

        if self._count <= 4:  # Evaluation Fuseki (début de jeu) pour les premiers coups, on cherche à prendre le maximum de territoires
            opening = Opening.Opening(self._board, self._mycolor, black_moves,
                                      white_moves, self._black_goban,
                                      self._white_goban)
            res = opening.evaluate_opening()
            return res

        else:  # Appel de l'heuristique pour milieu et fin de jeu
            game = Game.Game(self._board, self._mycolor, self._count,
                             black_moves, white_moves, self._black_goban,
                             self._white_goban)
            res = game.evaluation()
            return res
        return res
Esempio n. 4
0
 def OpeningScene(self, screen):
     while True:
         screen.blit(gameover, (290, 150))
         select_exit = Opening(ending_exit_1, ending_exit_2, (390, 500))
         self.render()
         select_exit.render()
         #            screen.blit(pygame.image.load(transparent_image).convert_alpha(), (655, 655))
         screen.blit(dead_face, (665, 665))
         for event in pygame.event.get():
             if event.type == pygame.QUIT or (
                     select_exit.isOver()
                     and pygame.mouse.get_pressed()[0]):
                 pygame.quit()
                 exit()
             if self.isOver() and pygame.mouse.get_pressed()[0]:
                 stage_num = 0
                 return stage_num
         pygame.display.update()
Esempio n. 5
0
    def OpeningScene(self, screen):
        screen.blit(opening_bg, (0, 0))
        select_exit = Opening(exit_1, exit_2, (380, 500))
        load_game = Opening(load_game1, load_game2, (380, 350))
        self.render()
        select_exit.render()
        load_game.render()
        for event in pygame.event.get():
            if event.type == pygame.QUIT or (select_exit.isOver() and
                                             pygame.mouse.get_pressed()[0]):
                pygame.quit()
                exit()
            if self.isOver() and pygame.mouse.get_pressed()[0]:
                stage_num = 11
                return stage_num
            if load_game.isOver() and pygame.mouse.get_pressed()[0]:
                stage_num = pickle.load(open("./save/save_stage", "rb"))
                #GameReinitialization(stage_num)
                return stage_num

        pygame.display.update()
        return 1
Esempio n. 6
0
    def OpeningScene(self, screen):
    	screen.blit(opening_bg, (0,0))
        select_exit = Opening(exit_1, exit_2, (380, 500))
        load_game = Opening(load_game1, load_game2, (380, 350))
    	self.render()
        select_exit.render()
        load_game.render()
    	for event in pygame.event.get():
            if event.type == pygame.QUIT or (select_exit.isOver() and pygame.mouse.get_pressed()[0]):
            	pygame.quit()
            	exit()
            if self.isOver() and pygame.mouse.get_pressed()[0]:
            	stage_num = 11
                return stage_num
            if load_game.isOver() and pygame.mouse.get_pressed()[0]:
            	stage_num = pickle.load(open("./save/save_stage", "rb"))
                #GameReinitialization(stage_num)
                return stage_num

        pygame.display.update()
        return 1
Esempio n. 7
0
 def OpeningScene(self, screen):
     screen.blit(menu, (0, 0))
     select_exit = Opening(menu_exit_1, menu_exit_2, (380, 500))
     select_help = Opening(help1, help2, (380, 600))
     self.render()
     select_exit.render()
     for event in pygame.event.get():
         if event.type == pygame.QUIT or (select_exit.isOver() and
                                          pygame.mouse.get_pressed()[0]):
             pygame.quit()
             exit()
         if (self.isOver() and pygame.mouse.get_pressed()[0]
             ) or pygame.key.get_pressed()[K_ESCAPE]:
             stage_num = 11
             time.sleep(0.15)
             return stage_num
     pygame.display.update()
     return 3
Esempio n. 8
0
def Setup(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS):
    # global PLAYER  # The main character. player is an object instance of class character.
    # global ITEMS  # All the items. This a dictionary of objects of class equipment keyed by their lowcase equipment name (item.name). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global MAPS  # All the locations. A tuple of objects of class Map inxed by there x,y,z coordinate (MAPS[x][y][z])
    # global INTERACT  # All the interactables (stationary things that need something). This a dictionary of objects of class Interact keyed by their lowcase name (interact.name). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global QUESTS  # Quest statuses. This is a dictionary of flags (1 or 0) for the status of the quest keyed by quest name.
    # global ENEMIES  # All the npcs. This a dictionary of objects of class Enemy keyed by their lowcase equipment name (item.name.lower()). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global GAMEINFO  # Miscellaneous game info. Dictionary of all sorts of variables
    # global GAMESETTINGS  # The game settings that are saved in the game


    if GAMEINFO['loadgame']:  # If player loaded the game it returns out of the setup and goes to main
        GAMEINFO['timestart'] = time.time()  # reset local variable starttime to current time
        GAMEINFO['loadgame'] = 0  # sets the parameter to 0 just so it doesn't accidentally save
        return MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS

    if not(GAMESETTINGS['DisableOpening'] or GAMESETTINGS['SpeedRun'] or GAMEINFO['devmode']): Opening.Opening() #plays the opening if disable opening is set to False
    
    print(LINEBREAK)

    if GAMEINFO['devmode']: GAMEINFO['playername'] = "Doug Fallon"  # Skip name step and names your person Doug
    else:
        # - Name Selection -
        name = ""
        badchar = ["\\", "/", ":", "*", "?", "'", "<", ">", "|", '"']
        while not name:  # name selection can't be empty
            name = input("First, what is your name?\n")
            if name in [""," ", "  ", "   ", ".",",", "no"]:  # not accepted names
                printT(""+losecolour+"Please enter a valid name! "+textcolour+"")
                name = ""
            elif [True for e in badchar if e in name]:  # if the bad character is in there
                printT("" + losecolour + "You cannot use \ / : * ? ' < > | " + '" in your name!' + textcolour + "")
                name = ""
            else:
                GAMEINFO['playername'] = name


    
    PLAYER.name = GAMEINFO['playername']
    ENEMIES, MAPS = NameChange(PLAYER.name)  # changes the name of all name related things in the game


    x,y,z,dim = STARTLOCATION
    if GAMEINFO['devmode']: x,y,z,dim = BRENSTARTLOCATION
    PLAYER.location[0] = x
    PLAYER.location[1] = y
    PLAYER.location[2] = z
    PLAYER.location[3] = dim

    CurrentPlace = MAPS[x][y][z][dim]

    # This prints

    # searches and prints the information with spawn set to true to print "You wake up in"
    CurrentPlace.search(MAPS, DIMENSIONS,GAMESETTINGS,True)

    
    GAMEINFO['gamestart'] = time.time()  # Gives the local start date of the game in seconds since epoch of 1970
    save_game("basegame")  # Use this to get a base state newgame, keep it in each time so don't have to worry about updating
    # This tyler Kashak has to be after the basegame save or else it will always revert the base game to you spawning as Tyler
    # Enables this ULTRA character is name is Tyler Kashak or in DevMode
    if PLAYER.name == "Tyler Kashak" or GAMEINFO['devmode']: #He realizes he's the main character and can do anything he wants
        # AsciiArt.One()  # TODO Enable once Dynamic Ascii Art
        print("\nHe is beginning to believe.\n\nYOU are the One.\n")
        # TODO Change back to Tyler
        PLAYER.__dict__ = BREN007PIE.__dict__  # sets him to the initial Tyler character for strating inventory
        PLAYER.maxhealth = 999
        PLAYER.basestats = [420,420,420]
        PLAYER.updateStats()
    CurrentPlace.travelled = 0  # so that it says it's been travelled, I moved it down so that it wouldn't effect the basegame save
   
    GAMEINFO['timestart'] = GAMEINFO['gamestart']   # runtime counter of the start of each main loop session. Needs to be global. Is equal to gamestart at the session start but will change as the user saves, loads, restarts, or does a nested game
    if GAMESETTINGS['SpeedRun']: print("Your time starts now!")
                                                                        #this time.ctime(seconds) converts to a nice readable time to be output to the log
    GAMEINFO['log'] = [GAMEINFO['versionname'],  GAMEINFO['playername'], time.ctime(GAMEINFO['gamestart']), "--LOG START--"] #log list is a list that keeps track of player movements for game debugging. Each ellement of the list is written in a new line to the log file when the game ends or is saved.
    
    return MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS
Esempio n. 9
0
def End(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS):
    # # Anywhere where a loadgame happens you need all the global variables
    # global PLAYER  # The main character. player is an object instance of class character.
    # global ITEMS  # All the items. This a dictionary of objects of class equipment keyed by their lowcase equipment name (item.name). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global MAPS  # All the locations. A tuple of objects of class Map inxed by there x,y,z coordinate (MAPS[x][y][z])
    # global INTERACT  # All the interactables (stationary things that need something). This a dictionary of objects of class Interact keyed by their lowcase name (interact.name). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global QUESTS  # Quest statuses. This is a dictionary of flags (1 or 0) for the status of the quest keyed by quest name.
    # global ENEMIES  # All the npcs. This a dictionary of objects of class Enemy keyed by their lowcase equipment name (item.name.lower()). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global GAMEINFO  # Miscellaneous game info. Dictionary of all sorts of variables
    # global GAMESETTINGS  # The game settings that are saved in the game

    save_game(GAMEINFO['playername'])  # saves all data RIGHT away so they can't restart when they die

    GAMEINFO['runtime'] = GAMEINFO['runtime'] + (time.time()-GAMEINFO['timestart']) #calculates total time you've been playing by adding your loaded runtime to your instance runtime (end time - start time)
    GAMEINFO['log'] = GAMEINFO['log'] + ["--END OF LOG--", "Stepcount: "+str(GAMEINFO['stepcount']), "Command Count: " + str(GAMEINFO['commandcount']),
      "Run Time: " + str(GAMEINFO['runtime']), "--Character STATS--",str((PLAYER.location[0],PLAYER.location[1],PLAYER.location[2], PLAYER.location[3])),
      str((PLAYER.stats[0],PLAYER.stats[1],PLAYER.stats[2])),str(PLAYER.health),"HEAD: " + str(PLAYER.inv["head"].name),
      "BODY: " + str(PLAYER.inv["body"].name), "HAND: " + str(PLAYER.inv["hand"].name), "OFF-HAND: " + str(PLAYER.inv["off-hand"].name)
        ] #adds the final info to the log leger

    if GAMEINFO['winner']== 0:  # player died and that's how they're out of the loop
        print(LINEBREAK)
        if GAMESETTINGS['SpeedRun']: DisplayTime(GAMEINFO['runtime'])  # displays the runtime for speed running
        if GAMESETTINGS['SpeedRun']: printT("Total Step Count: "+ str(GAMEINFO['stepcount']) + " (\S)Total Command Count: " + str(GAMEINFO['commandcount']))
        logGame(GAMEINFO['log']) # writes the log file
        printT("Thanks for playing!! Better luck next time! (\S)")#lets the player restart the game
    else:
        input("You've " +wincolour+"won"+textcolour+"! Type anything to continue\n").lower()  # If they beat either of the storylines
        GAMEINFO['log'].append("---THEY WON---") #appends they won at the end of the log file to make it easier find
        if GAMEINFO['winner'] == 1: #The bad storyline ending
            printT("After performing the purge of the faculty you join Dr.Cassidy in shaping the New Order.\nAs Dr.Cassidy's apprentice, you reign over McMaster University with an iron fist.\nEngineering Physics is established as the premium field of study and all funding is directed to you.\nYou unlock secrets of untold power which allow you to reinforce your overwhelming grasp on the university.\nYour deeds have given you complete power and you reign supreme for eternity.\nTHE END  (\S)")
            GAMEINFO['winner'] = 1
        elif GAMEINFO['winner'] == 2: #The good storyline ending.
            printT("Having defeated Dr. Cassidy you proved yourself to be a truly honourable engineer.\nWith the forces of evil defeated, McMaster University will continue to operate in peace.\nAll faculties exist in harmony and the integrity of the institution has been preserved.\nYou go on to lead a successful life as an engineer satisfied that you chose what was right.\nTHE END. (\S)")
            GAMEINFO['winner'] = 2
        elif GAMEINFO['winner'] == 3: #The good storyline ending.
            printT("After defeating both Dr. Cassidy and Sir William McMaster you take a moment to think while the deed to McMaster University lies at your feet fluttering slowly in a gentle breeze. You think about what you were told. Does that piece of paper really give you immense power and control over the school? After a quick smirk and a laugh, you pick up the deed and begin to rip it up. The parchment resists for a moment before giving way in a spectacular display of sparks and disappearing into the wind. You go on knowing that the fate of the University now resides in the hands of no one... it resides in everyone's hands. (\S)THE END  (\S)")
            QUESTS['neutral balance'] = 0
            GAMEINFO['winner'] = 3
        if GAMESETTINGS['SpeedRun']: DisplayTime(GAMEINFO['runtime']) #displays the runtime then all other status
        if GAMESETTINGS['SpeedRun']:printT("Total Step Count: "+ str(GAMEINFO['stepcount']) + " (\S)Total Command Count: " + str(GAMEINFO['commandcount']))
        logGame(GAMEINFO['log']) #logs the data to be submitted
        save_game(GAMEINFO['playername'] + " Winner") #saves all data to later be submited, different from the main save file
        Opening.Closing()  # plays the closing
        printT("Thanks for playing!!! (\S)")
    endchoice = ""
    while not endchoice:  # death or ending selection screen
        printT(" (\S)Continue Playing[C]   Restart Game[R]  Exit[E]")
        #printT(" (\S)Continue Playing[C]   Restart Game[R]  Main Menu Return[M]  Exit[E]")
        endchoice = input("Choose what you want to do: ").lower().strip() #this input is to hold the screen until the player decides what to do
        if (GAMEINFO['winner'] == 0) and (endchoice in ["c","continue playing","continue","play"]):
            printT("You can't continue because you're dead!")
            endchoice = ""
        #elif endchoice not in ["c", "r", "m", "e", "continue playing", "continue", "play", "restart game", "restart","main menu return", "main menu", "menu return", "main", "menu", "return", "exit"]:
        elif endchoice not in ["c","r","m","e","continue playing","continue","play","restart game","restart","exit"]:
            printT(""+losecolour+"Please choice a valid option!"+textcolour+"")
            endchoice = ""
    if endchoice in ["c","continue playing","continue","play"]:
        PLAYER.alive = True
        print(LINEBREAK)
        QUESTS['restored order'] = 0  # turn this off so you can continue playing the game without the quest redoing
        QUESTS['create chaos'] = 0
        Main(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS)  # returns to the main (hopefully in the same state)
    elif endchoice in ["r","restart game","restart"]:
        MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS = load_game("basegame") #loads in the savefile global variables
        GAMEINFO['timestart'] = time.time() #reset local variable starttime to current time
        Main(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS) #re-enters the main loop
    # No return to main menu implemented due to bad looping structure
    # elif endchoice in ["m","main menu return","main menu","menu return","main","menu","return"]:
    #     Opening.StartScreen()  # Startscreen loop where you can play new game, loadgame, choose settings, or exit
    #     Setup()
    #     Main()
    elif endchoice in ["e","exit"]:
        if input("\n\nAre you sure you want to " +losecolour+ "quit" +textcolour+ " the game?\nType Y if you wish to save and leave,\nanythine else to continue: \n").lower() in ["y", 'yes', 'yeah']:
            GAMEINFO['runtime'] += (time.time() - GAMEINFO['timestart'])  # adds the runtime (initilized to zero) to the session runtime to make the total runtime
            GAMEINFO['timestart'] = time.time()  # resets timestart so it's not doubly added at the end
            logGame(GAMEINFO['log'])  # logs the game when you save it
            save_game(GAMEINFO['playername'])  # saves all data
            # print "Your game has been saved! " + GAMEINFO['playername']  # Don't indicate the save file has save file in the name
            AsciiArt.ThanksForPlaying()
            input("" +indicatecolour+ "We're sad to see you go :(" +textcolour+ " \nI hope whatever you're doing is more fun.\nPress anything to leave")
            exit()
    return MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS
Esempio n. 10
0
    f.close()
    if data[0] == "LOL NO U":  # contents of the dev file needs to be
        # quickly asks you want to not be in dev mode in obfuscated way
        if not input("What would you like? Type in n: ") == "n":
            GAMEINFO['devmode'] = 1
            print(CLEARSCREEN)  # clears the screen

except:  # does nothing if no dev file there
    pass
    #raw_input("HI I'M NOT A DEV!")




# Start Screen is after reading in settings so it can skip start screen if enabled
MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS = Opening.StartScreen()  # Startscreen loop where you can play new game, loadgame, choose settings, or exit

#TODO Comment out before release, used to debug loading
#GAMEINFO['devmode'] = 1

# The Actual Start of the game when you hit Play, depending on if in Dev Mode or not
if GAMEINFO['devmode']:  # If Dev mode enabled no error catching
    MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS = Setup(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS)
    Main(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS)
else:  # Dev mode not enabled so error catching
    try:  # runs the main functions (the whole game bassically)
        MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS = Setup(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS)
        Main(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS)
    # end function is run at the end of main loop so you can restart the game
    except (KeyboardInterrupt, SystemExit):  # if keyboard pressed or x out of the game, this is so it doesn't save null data when you press teh keyboard
        raise
Esempio n. 11
0
def events(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO,
           GAMESETTINGS):
    # # These are all the global dictionaries/objects in the game. Anywhere where a loadgame happens you need all the global variables
    # global PLAYER  # The main character. player is an object instance of class character.
    # global ITEMS  # All the items. This a dictionary of objects of class equipment keyed by their lowcase equipment name (item.name). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global MAPS  # All the locations. A tuple of objects of class Map inxed by there x,y,z coordinate (MAPS[x][y][z])
    # global INTERACT  # All the interactables (stationary things that need something). This a dictionary of objects of class Interact keyed by their lowcase name (interact.name). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global QUESTS  # Quest statuses. This is a dictionary of flags (1 or 0) for the status of the quest keyed by quest name.
    # global ENEMIES  # All the npcs. This a dictionary of objects of class Enemy keyed by their lowcase equipment name (item.name.lower()). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global GAMEINFO  # Miscellaneous game info. Dictionary of all sorts of variables
    # global GAMESETTINGS  # The game settings that are saved in the game
    # # global keyword makes the variables inside the function reference the correct global scope variable when assigned in the function.
    # # If not assignment within the function  may lead to changes only in the local scope

    # Killcount counter in player will trigger the police eventually

    # --- Portals ---
    # TODO Build in this portal fucntionality into INTERACTS or maybe just places with doors

    # # To Green Lake
    # if INTERACT["lake painting"].quest:
    #     PLAYER.location = [0,0,0,2]  # WHEN YOU TELIPORT IT HAS TO BE A LIST BECAUSE PLAYER LOCATION IS A LIST
    #     CurrentPlace = MAPS[0][0][0][2]
    #     CurrentPlace.search(MAPS, DIMENSIONS,GAMESETTINGS, True)
    #     INTERACT["lake painting"].need = None
    #     printT("(\S)You no longer need the keys to get into this place.")
    #     INTERACT["lake painting"].quest = False
    #
    # # Back to Art Museum
    # if INTERACT["portkey"].quest:
    #     PLAYER.location = [3,0,1,0]  # WHEN YOU TELIPORT IT HAS TO BE A LIST BECAUSE PLAYER LOCATION IS A LIST
    #     CurrentPlace = MAPS[3][0][1][0]
    #     CurrentPlace.search(MAPS, DIMENSIONS,GAMESETTINGS, True)
    #     INTERACT["portkey"].quest = False

    # -- EBTA All the way Down --
    # when you put the pen in the laptop it opens the thing
    if INTERACT["lenovo laptop"].quest and QUESTS['EPTA all the way down']:
        # TODO as homework see if there's a way to do this with recursion instead of simulating it
        # Would put drums if there was sound effect
        playgame = input(
            '========================================================================\nWould you like to play? \n'
        ).lower()
        if playgame == "yes" or playgame == "y":
            printT(
                "You click on the game and it begins in the terminal. The " +
                red + "drumming intensifies" + textcolour +
                ". You're not sure if you made the right choice.")
            printT(
                "======================================================================== (\S) (\S)"
            )
            import CreativeMode  # this is imported here not at the top to avoid recursive import errors (show up as global names not being defined in the compiler)
            QUESTS[
                'EPTA all the way down'] = 0  # Truns off the quest, has to be before the game saves so the quest is ended when you come back
            save_game(
                str(GAMEINFO['layersdeep'])
            )  # saving game to be reloaded after death or won the game
            log = GAMEINFO[
                'log']  # keeps the log as a temporary variable to keep a running log in the nested game
            Opening.Opening()
            newplayername = input("First, what is your name?\n")
            layers = GAMEINFO[
                'layersdeep']  # saves layersdeep to a temporary variable for after the load
            MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS = load_game(
                "basegame")  # should display the exact start
            GAMEINFO[
                'layersdeep'] = layers + 1  # increments the global layers deep because you're now in a lower level, using the memory of the local variable

            GAMEINFO[
                'playername'] = PLAYER.name = newplayername  # this is done for the log
            GAMEINFO['gamestart'] = time.time(
            )  # Settign the game and timestart for for this layer
            GAMEINFO['timestart'] = GAMEINFO['gamestart']
            # Passes the log and adds onto it to keep a HUGE running log (TODO Make this more effecient with log appending)
            GAMEINFO['log'] = log + [
                str(playgame), "--NESTED GAME--", GAMEINFO['layersdeep'],
                GAMEINFO['versionname'], GAMEINFO['playername'],
                time.ctime(GAMEINFO['timestart']), "--LOG START--"
            ]  # log list is a list that keeps track of player movements for game debugging. Each ellement of the list is written in a new line to the log file when the game ends or is saved.
        elif playgame == "no" or playgame == "n":
            printT(
                "You " + indicatecolour + "decide against it" + textcolour +
                ", fearing the worst. You safely edject the pen, drop it on the floor, and "
                + red + "smash" + textcolour +
                " it to pieces. Better safe than sorry. (\S)" + lightblue +
                "The drumming stops" + textcolour + ".)")
            printT(
                "========================================================================"
            )
            QUESTS['EPTA all the way down'] = 0
            GAMEINFO['log'] += [str(playgame)]  # adds your command to the log
        else:
            printT("" + losecolour + "It was a yes or no question" +
                   textcolour + ". When you look back the files are " +
                   losecolour + "gone" + textcolour +
                   ". (\S)Even the FlexPDE code. Good riddance.")
            printT(
                "========================================================================"
            )
            QUESTS['EPTA all the way down'] = 0
            GAMEINFO['log'] += [str(playgame)]  # adds your command to the log

    return MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS
Esempio n. 12
0
def sidequests(MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO,
               GAMESETTINGS):
    # # These are all the global dictionaries/objects in the game. Anywhere where a loadgame happens you need all the global variables
    # global PLAYER  # The main character. player is an object instance of class character.
    # global ITEMS  # All the items. This a dictionary of objects of class equipment keyed by their lowcase equipment name (item.name). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global MAPS  # All the locations. A tuple of objects of class Map inxed by there x,y,z coordinate (MAPS[x][y][z])
    # global INTERACT  # All the interactables (stationary things that need something). This a dictionary of objects of class Interact keyed by their lowcase name (interact.name). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global QUESTS  # Quest statuses. This is a dictionary of flags (1 or 0) for the status of the quest keyed by quest name.
    # global ENEMIES  # All the npcs. This a dictionary of objects of class Enemy keyed by their lowcase equipment name (item.name.lower()). Remember the lowercase, may trip you up if referencing upercase version in the file.
    # global GAMEINFO  # Miscellaneous game info. Dictionary of all sorts of variables
    # global GAMESETTINGS  # The game settings that are saved in the game
    # # global keyword makes the variables inside the function reference the correct global scope variable when assigned in the function.
    # # If not assignment within the function  may lead to changes only in the local scope

    # --- Side Quests ---
    # -- Secret Spaces --
    if INTERACT['coat of arms'].quest and QUESTS[
            "secret spaces"]:  # Unlocks the secret space once you get the scroll
        MAPS[0][2][1][0].removeWall(
            "d"
        )  # DON'T FORGET to make wall a list instead of a tuple in the object!
        QUESTS["secret spaces"] = 0

    # -- Rules Sign --
    if INTERACT["rules sign"].quest and QUESTS[
            'rules sign']:  # Once the sign is read
        MAPS[2][3][1][0].removeInteract(INTERACT["rules sign"])
        INTERACT["rules sign"].location = (None, None, None, None)
        printT("The sign " + indicatecolour + "disappears" + textcolour +
               " in a flash of " + indicatecolour + "smoke" + textcolour +
               ". You look around. Are you still dreaming?")
        QUESTS["rules sign"] = 0

    # -- EBTA All the way Down --
    # when you put the pen in the laptop it opens the thing
    if INTERACT["lenovo laptop"].quest and QUESTS['EPTA all the way down']:
        # TODO as homework see if there's a way to do this with recursion instead of simulating it
        # Would put drums if there was sound effect
        playgame = input(
            '========================================================================\nWould you like to play? \n'
        ).lower()
        if playgame == "yes" or playgame == "y":
            printT(
                "You click on the game and it begins in the terminal. The " +
                red + "drumming intensifies" + textcolour +
                ". You're not sure if you made the right choice.")
            printT(
                "======================================================================== (\S) (\S)"
            )
            import CreativeMode  # this is imported here not at the top to avoid recursive import errors (show up as global names not being defined in the compiler)
            QUESTS[
                'EPTA all the way down'] = 0  # Truns off the quest, has to be before the game saves so the quest is ended when you come back
            save_game(
                str(GAMEINFO['layersdeep'])
            )  # saving game to be reloaded after death or won the game
            log = GAMEINFO[
                'log']  # keeps the log as a temporary variable to keep a running log in the nested game
            Opening.Opening()
            newplayername = input("First, what is your name?\n")
            layers = GAMEINFO[
                'layersdeep']  # saves layersdeep to a temporary variable for after the load
            MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS = load_game(
                "basegame")  # should display the exact start
            GAMEINFO[
                'layersdeep'] = layers + 1  # increments the global layers deep because you're now in a lower level, using the memory of the local variable

            GAMEINFO[
                'playername'] = PLAYER.name = newplayername  # this is done for the log
            GAMEINFO['gamestart'] = time.time(
            )  # Settign the game and timestart for for this layer
            GAMEINFO['timestart'] = GAMEINFO['gamestart']
            # Passes the log and adds onto it to keep a HUGE running log (TODO Make this more effecient with log appending)
            GAMEINFO['log'] = log + [
                str(playgame), "--NESTED GAME--", GAMEINFO['layersdeep'],
                GAMEINFO['versionname'], GAMEINFO['playername'],
                time.ctime(GAMEINFO['timestart']), "--LOG START--"
            ]  # log list is a list that keeps track of player movements for game debugging. Each ellement of the list is written in a new line to the log file when the game ends or is saved.
        elif playgame == "no" or playgame == "n":
            printT(
                "You " + indicatecolour + "decide against it" + textcolour +
                ", fearing the worst. You safely edject the pen, drop it on the floor, and "
                + red + "smash" + textcolour +
                " it to pieces. Better safe than sorry. (\S)" + lightblue +
                "The drumming stops" + textcolour + ".)")
            printT(
                "========================================================================"
            )
            QUESTS['EPTA all the way down'] = 0
            GAMEINFO['log'] += [str(playgame)]  # adds your command to the log
        else:
            printT("" + losecolour + "It was a yes or no question" +
                   textcolour + ". When you look back the files are " +
                   losecolour + "gone" + textcolour +
                   ". (\S)Even the FlexPDE code. Good riddance.")
            printT(
                "========================================================================"
            )
            QUESTS['EPTA all the way down'] = 0
            GAMEINFO['log'] += [str(playgame)]  # adds your command to the log

    #National Treasure
    if INTERACT["tri-coloured glasses"].quest and QUESTS[
            'national treasure']:  # Once the sign is read
        MAPS[1][0][1][0].removeWall(
            "u"
        )  # DON'T FORGET to make wall a list instead of a tuple in the object!
        QUESTS["national treasure"] = 0

    if INTERACT["red book"].quest and QUESTS[
            'open the trees']:  # Once the sign is read
        printT("You feel like you've " + indicatecolour + "gained" +
               textcolour + " some knowledge!")
        MAPS[3][7][1][0].removeInteract(INTERACT['gap in the trees'])
        INTERACT['gap in the trees'].location = (None, None, None, None)
        INTERACT['gap in the trees'].location = None
        MAPS[3][7][1][0].placeInteract(INTERACT['opening in the trees'])
        INTERACT['opening in the trees'].location = (3, 7, 1, 0)
        QUESTS['open the trees'] = 0
        #return INTERACT,MAPS  # don't need to return this scope because reasons?

    if INTERACT["lit firepit"].quest and QUESTS['open the cabin']:
        MAPS[8][9][0][4].removeWall(
            "r"
        )  # DON'T FORGET to make wall a list instead of a tuple in the object!
        QUESTS['open the cabin'] = 0

    if INTERACT['gate of the forest'].quest and QUESTS['open the forest']:
        MAPS[0][7][0][4].removeWall(
            "b"
        )  # DON'T FORGET to make wall a list instead of a tuple in the object!
        QUESTS['open the forest'] = 0

    if INTERACT['stone pedestal'].quest and QUESTS['power of the forest']:
        PLAYER.maxhealth = 200
        PLAYER.health = 200
        PLAYER.basestats = [100, 100, 100]
        PLAYER.updateStats()
        printT(" (\S) (\S)You see a " + indicatecolour + "flash of light" +
               textcolour + " and " + wincolour + "feel stronger" +
               textcolour + ".")
        AsciiArt.HauntedForest()
        QUESTS['power of the forest'] = 0

    return MAPS, PLAYER, ITEMS, INTERACT, QUESTS, ENEMIES, GAMEINFO, GAMESETTINGS
Esempio n. 13
0
    if p.CheckAlive() == False and stage_num >= 11:
        GameReinitialization(stage_num)
        lose_sound.play()
        if not isBoss:
            background_music.fadeout(1500)
        else:
            boss_sound.fadeout(1500)
        stage_num = ending.OpeningScene(screen)
        isArcher = False
        isMage = False
        isBoss = False
        p.SetAlive(True)
## reinitialize the game

    opening = Opening(upimage, downimage, (380, 400))
    mode_select = SelectMode(new_game1, new_game2, (380, 200))
    menu = Menu(back1, back2, (70, 30))
    if stage_num == 0:
        stage_num = opening.OpeningScene(screen)
        clock.tick()
    elif stage_num == 1:
        stage_num = mode_select.OpeningScene(screen)
        if stage_num != 1:
            background_music.play(-1)
            GameReinitialization(stage_num)
        clock.tick()
    #print stage_num
    elif stage_num == 3:
        stage_num = menu.OpeningScene(screen)
        clock.tick()