Final Project Progress Report 3

Today I finished the basic coding of my game. Here is the code.

print '''ooooo   ooooo   .oooooo.   ooo        ooooo oooooooooooo  .oooooo..o ooooo   .oooooo.   oooo    oooo 
`888'   `888'  d8P'  `Y8b  `88.       .888' `888'     `8 d8P'    `Y8 `888'  d8P'  `Y8b  `888   .8P'  
 888     888  888      888  888b     d'888   888         Y88bo.       888  888           888  d8'    
 888ooooo888  888      888  8 Y88. .P  888   888oooo8     `"Y8888o.   888  888           88888[      
 888     888  888      888  8  `888'   888   888    "         `"Y88b  888  888           888`88b.    
 888     888  `88b    d88'  8    Y     888   888       o oo     .d8P  888  `88b    ooo   888  `88b.  
o888o   o888o  `Y8bood8P'  o8o        o888o o888ooooood8 8""88888P'  o888o  `Y8bood8P'  o888o  o888o'''
#Game start
game_status = 0
while game_status == 0:
    start_command = raw_input('\nPress enter to start')
    if start_command == '':
        game_status = 1
#Super secret values to use for later
hope = 5
keys = 0
completion = 0
#Intro
if game_status == 1:
    #Typewriter effect (Thanks Stackoverflow)
    import sys
    from time import sleep
    words = '\n. . .   '
    for char in words:
        sleep(0.3)
        sys.stdout.write(char)
        sys.stdout.flush()
    words2 = '\nWhere are you?    '
    for char in words2:
        sleep(0.2)
        sys.stdout.write(char)
        sys.stdout.flush()
    words3 = "\n. . . . .     \n"
    for char in words3:
        sleep(0.4)
        sys.stdout.write(char)
        sys.stdout.flush()
    print '\nYou woke up in a small, dark room. There is a ' + '\033[1m' + 'computer' + '\033[0m' + ', a '\
          + '\033[1m' + 'mirror' + '\033[0m' + ', and a ' + '\033[1m' + 'small cabinet.' + '\033[0m'
    game_status = 2
    while game_status == 2: #First interaction
        action = raw_input('What do you check in the room? ')
        if action.lower() == 'mirror':
            print '\nYou look into a mirror. There is a small note near the bottom. It reads: ' + '\033[1m' + \
                  'A1Z26' + '\033[0m' + '\n'
        elif action.lower() == 'small cabinet' or action.lower() == 'cabinet':
            print '\nThere are papers scattered on top of the cabinet. You shuffle through them until you find one \
with \'key\' written on it.\nThere is only one key: ' + '\033[1m' + '22-1-7-1-2-15-21-14-4\n' + '\033[0m'
        elif action.lower() == 'computer':
            print '\nYou turn on the computer.'
            password_guess = raw_input('Enter password: ')
            if password_guess.lower() == 'vagabound':
                game_status = 3
            else:
                print '\033[1m' + 'Incorrect password\n' + '\033[0m'
                hope -= 1
                if hope == 0:
                    game_status = 15
if game_status == 3: #Second interaction
    readme_status = bool
    keys_status = bool
    world_lock_status = bool
    vgnr_ky_status = bool
    print '\nYou gained access to the computer. There are four files on the desktop.\n'
    print '\033[0m' + '''readme
keys
safe_secret
vgnr_ky\n'''
    while game_status == 3:
        if readme_status == True and keys_status == True and world_lock_status == True and vgnr_ky_status == True:
            game_status = 4
        else:
            action2 = raw_input('Open a file: ')
            if action2.lower() == 'readme':
                print '''\nHello.
        
If you\'re reading this, it\'s already too late.
You\'ve been trapped here for very long.
When will you realize?
You\'ll never leave.
You can\'t.
Every mistake you make will cost you.
There is no way back home.\n'''
                readme_status = True
            elif action2.lower() == 'keys':
                print '''\n815135
3 18 22
LIMBO\n'''
                keys_status = True
            elif action2.lower() == 'safe_secret' and completion == 0:
                print '\n' + '' + '\033[1m' + 'Access denied.\n' + '\033[0m'
                world_lock_status = True
            elif action2.lower() == 'safe_secret' and completion == 2: #secret thing
                print '482543'
            elif action2.lower() == 'vgnr_ky':
                print '''
#(&%&>'@($%^6(!+h$*&%-_^!*
@*$(%@)>@#o$^:>@&#_#&^+_%@
)(86(@(`^*@&($+<_)_m(&$4@>
@*%#*3e+_~@":>%@y{@&"~|{:.\n'''
                vgnr_ky_status = True
#Third interaction
if game_status == 4:
    from time import sleep
    print 'So you finally made it.'
    sleep(2)
    print 'Now you are ready to begin your journey.'
    sleep(3)
    print '* * * * * * * *\nYou find yourself on an open field.\nYou see some ' + '\033[1m' + 'docks ' '\033[0m' \
    + 'and a ' + '\033[1m' + 'small village.' + '\033[0m'
    action3 = raw_input('Where do you go? ')
    while action3.lower() not in ('docks', 'small village', 'village'):
        action3 = raw_input('Where do you go? ')
    if action3.lower() == 'docks':
        game_status = 5
    if action3.lower() == 'village' or action3.lower() == 'small village':
        game_status = 6
if game_status == 6: #village
    print 'You head to the village and find nobody in it. Only two buildings light up the darkness, a \n'\
    + '\033[1m' + 'tower' + '\033[0m' + ', and a building that reads: ' + '\033[1m' + 'Memory Bank' + '\033[0m'
    action4 = raw_input('Which building do you visit? ')
    if action4.lower() == 'bank' or action4.lower() == 'memory bank':
        game_status = 7
    if action4.lower() == 'tower':
        game_status = 8
if game_status == 7: #Memory bank
    safe_status = True
    print '\nYou make your way into the bank and see a giant safe. There is a 6 digit code needed to unlock it'
    while safe_status == True:
        lock_code = raw_input('Enter code: ')
        if lock_code == '815135':
            print 'You opened the safe and found a key! You head back to the village.'
            keyloop_prevent = 0
            if keyloop_prevent == 0:
                keys += 1
                keyloop_prevent += 1
            action6 = raw_input('\nGo to the lighthouse or tower? ')
            if action6.lower() == 'lighthouse':
                game_status = 9
            if action6.lower() == 'tower':
                game_status = 8
        else:
            action5 = raw_input('The code didn\'t work. Go back to the village? ')
            if action5.lower == 'no' or action5.lower() == 'n':
                safe_status = True
            elif action5.lower() == 'yes' or action5.lower() == 'y':
                safe_status = False
                hope -= 1
                if hope == 0:
                    game_status = 15
                action6 = raw_input('Go to the lighthouse or tower? ')
                if action6.lower() == 'lighthouse':
                    game_status = 9
                if action6.lower() == 'tower':
                    game_status = 8
if game_status == 8: #tower
    print 'You enter the tower and start making your way up. A dimly lit computer is in the way.'
    action7 = raw_input('Read it? ')
    if action7.lower() == 'yes' or action7.lower() == 'y': #Computer
        print '*#*@(%&(*#@$#*'
        sleep(0.1)
        print '$*@(%&#@(%)#&@'
        sleep(0.1)
        print ')@(!*^&@^*#^$!'
        sleep(0.1)
        print '^@(*&@^%$@^&$#'
        sleep(1)
        password_guess2 = raw_input('En#t%Er pS$S@Awo)RD: ')
        if password_guess2 == 'LIMBO':
            print 'Game over'
        else:
            pass_attempts = 0
            pass_attempts +=1
            if pass_attempts == 5:
                print 'The computer shut down.'
                completion += 1
    if action7.lower() == 'no' or action7.lower() == 'n':
        print 'You end up on the top of the tower. There\'s nothing else in the room except for a small, shiny object.'
        print 'You got a key! You head down to the docks.'
        keyloop_prevent2 = 0
        if keyloop_prevent2 == 0:
            keys += 1
            keyloop_prevent2 += 1
        if keyloop_prevent2 == 1:
            game_status = 9
        game_status = 9
if game_status == 5: #docks
    print 'You\'re at the docks. There is a ' + '\033[1m' + 'shed' + '\033[0m' + 'and a ' + '\033[1m' + 'pier'
    action8 = raw_input('Which one do you go to? ')
    if action8.lower() == 'shed':
        game_status = 10
    if action8.lower() == 'pier':
        if boatengine == 1:
            game_status = 11
        else:
            print 'There\'s a broken boat here. Somebody else is also here.'
            sleep(2)
            print 'He turns around.'
            words4 = '\nHey! Please help me fix up my boat! I\'ll take you anywhere in return.'
            for char in words:
                sleep(0.1)
                sys.stdout.write(char)
                sys.stdout.flush()
            print 'You don\'t have anything to fix the boat. You enter the shed to search for something that might work.'
if game_status == 10: #shed
    locker_status = 0
    print 'Inside the shed, there is a small locker. '
    while locker_status == 0:
        password_guess3 = raw_input('Enter first number: ')
        if password_guess3 == '3':
            safe_status2 = 1
        else:
            hope -= 1
            if hope == 0:
                break
                game_status = 15
    while locker_status == 1:
        password_guess4 = raw_input('Enter second number: ')
        if password_guess4 == '18':
            safe_status2 = 2
        else:
            hope -=1
            if hope == 0:
                break
                game_status = 15
    while locker_status == 2:
        password_guess5 = raw_input('Enter final number: ')
        if password_guess5 == '22':
            print 'Inside the locker, there was a boat engine!'
            boatengine = 1
            print 'You head to the pier'
            game_status = 11
        else:
            hope -=1
            if hope == 0:
                break
                game_status = 15
if game_status == 11: #docks completed
        words5 = 'Oh! An engine! Thanks to you, I can use this boat! I can take you across the harbour, or name any other place you want to go!'
        for char in words:
            sleep(0.1)
            sys.stdout.write(char)
            sys.stdout.flush()
        destination = raw_input('Where to? (Across the harbour / ???) ')
        while destination.lower() not in ('domum', 'across the harbour'):
            destination_repeat = raw_input('Sorry, didn\'t catch that. Where to? (Across the harbour / ???)')
        if destination.lower() or destination_repeat.lower() == 'across the harbour':
            game_status = 12
if hope == 0:
    game_status = 15
if game_status == 12:
    print '''You crossed the harbour.
At the horizon was a huge a giant door with two keyholes.'''
    if keys == 0:
        print 'There was no way in. But you have done your part. The journey home begins.'
    elif keys == 1:
        print 'You were able to fit one key in, but there was nothing for the other keyhole. There was no way in. But you have done your part. The journey home begins.'
    elif keys == 2:
        print 'You placed both keys in. The door is unlocked.'
if game_status == 15:
    print '\033[1m' + 'GAME OVER' + '\033[0m'

Now that the framework is done, I plan on testing this game out with my friends and improving the coding. I also need to add in the secret stuff

Final Project Progress Report 2

Hello! Small update for my game. Today I tried to settle on what I wanted my final product to be. I made a very rough flowchart on which general direction I want this game to be.

It looks very rough right now, but it’s enough for me to develop the storyline. Obviously, there will be more text in the final product despite the flowchart lacking any actual text from the game. For tomorrow, I hope that I can work on the coding aspect and ask a few friends to try out my game. Thankfully a 15 hour plane ride should help me write a lot of code.

Final Project Progress Report 1

I didn’t get as much work done as I would’ve liked, but I still felt like I had a decent start for my text-based adventure game.

Here is the code I’m working with right now. (Cut into two pieces because it was too big)

This code was a result of experimenting with python on seeing what I could do. Right now, my game has two fully functioning interactions. The first one is a puzzle, and the second one relates to the story. I improved my use of booleans and variables in this code, so my code won’t just be a ton of if statements. I’m working on implementing some variables for some *secret* things to add. Overall, I’m happy with what I have so far, and I feel that I can come up with many ideas to use.

Mini Project 2

I had a little trouble at first, but I managed to create a hangman game in python! Here’s the code

This was challenging for me because of the use of lists and indexes. I still need to work on for loops but I think that I’m making good progress in python.

 

 

Weekend Mini Project

Flowchart

Before I wrote the code, I wanted to diagram what I wanted to create. The prompt I chose was: How to apply to HKIS (R1). I checked out the application procedure on the HKIS website and from my research, I created this flowchart to outline my code. Also, it turns out that the HKIS application procedure is actually really simple.

In this flowchart, it looks like all of the choices are yes or no questions without any inputs, so the whole procedure will be pretty straightforward.

Pseudocoding

This is my first time writing pseudocode, but I felt like I had a pretty good understanding of what to do when writing this

 

print 'Thank you for your interest in applying to HKIS!'
print 'Please follow these instructions for applying.'
print 'Answer 'yes' or 'no' to these questions'
application status = input of 'Have you completed the online application?'
if the answer is no
  print 'Sorry, you need to complete the onine application.' 
  print 'Visit [link] for more information.'
else if the answer is yes
  forms_status = input of 'Have you submitted all of the following forms?'
  if the answer is no
    print 'Sorry, you need to submit all of the forms. Visit the HKIS website to access them.
  else if the answer is yes
    interview_status = input of 'Has HKIS held an interview or assessment for your child yet?'
    if the answer is no
      print 'Please schedule an appointment with HKIS as soon as possible'
    else if the answer is yes
      print 'You're all set! Good luck!'

That’s my pseudocode. I planned on adding more info in the final code.

Interactive Flowchart – Python

Here is my final code. I added a bit more code that wasn’t in the pseudocode. It’s pretty simple.

Here’s a video.

I2P-Sean_Liang-Day6

Message Encryptor/Decryptor

I started off with a somewhat functioning message encryptor/decryptor in python, but there were many flaws to it. I decided to use a Caesar cipher to code messages, so that means I would need to find a way to shift the ASCII values of each letter using chr() and ord() functions.

I thought that this code will work without error, buuuuut:

At least it’s still functional right? Well, turns out that things get a little bit tricky when using ASCII values

Yeah. Still figuring this one out. I tried to first convert the input text to ASCII values first and use and if statement to test if the value is above 122 (the ASCII value for z), then subtracting 26 from the value. This should’ve worked, but I had trouble organizing my code to make that work.

This is an ASCII table. Thanks to this, my text encryptor/decryptor doesn’t work.

Oh well. This is technically still encryption though, just with ASCII values, so I guess I can say that I’ve managed to encrypt messages through an ASCII-based Caesar cipher.

Google Form Bidding

 

Today showed me that I still need to work on JavaScript.

I researched on sending e-mails through google scripts, but I wasn’t able to create an auction. Today’s challenge for JavaScript seemed to be out of my skill level right now. Hopefully as I learn more I will be able to code functions for google forms.

I2P-Sean_Liang-Day5

Random Number Generator – Python

I was able to create a random number generator guessing game pretty easily in python. I used a while loop and if/elif/else statements to make this. It’s pretty simple

Random Number Generator – Javascript

I had some trouble creating the same thing in javascript. Here is my code

It’s almost functioning, but everything messes up when I guess the number correctly. Despite my code, the status variable never seems to change, and the result is an endless loop of alerts. I’m starting off a bit slow with Javascript, but I’m still making some progress.

I2P-Sean_Liang-Day4

Calendar

This one was super hard. I honestly had no idea how to do this.

Here was what I was able to come up with

I got the while loop down, but I had trouble coding all the actions. The only functioning actions I have is to add and view events.  Both of these actions use the list called ‘calenderlist’. However, the code doesn’t take in the month, and the function will display all events regardless of which month is selected.

For the rest of the actions, I couldn’t successfully code the functions. For deleting events, I thought of using ‘del calenderlist[event]’ but I wasn’t able to make to code delete an existing event. For updating events, I considered writing ‘calenderlist[event] = [eventupdated]’. This also didn’t work

 

This challenge really had me. I wasn’t able to create a functioning event calendar. Hopefully, I can get back on track the further I get in Codecademy