Example #1
0
def checkDirect(userIn):
    global position
    blockFlag = False
    if userIn == "n":
        if room(position[0],position[1]+1,userIn):
            position[1] += 1
        else:
            blockFlag = True
    elif userIn =="s":
        if room(position[0],position[1]-1,userIn):
            position[1] -= 1
        else:
            blockFlag = True
    elif userIn =="e":
        if room(position[0]+1,position[1],userIn):
            position[0] += 1
        else:
            blockFlag = True
    elif userIn =="w":
        if room(position[0]-1,position[1],userIn):
            position[0] -= 1
        else:
            blockFlag = True
    else:
        print("That is not a direction!")
    if blockFlag == True:
        print("You can't go that way!")
    else:
        if randint(1,3) == 1 and position != [2,0] and position!= [1,4] and position != [4,6] and position !=[2,4]:
            combat([Globals.player, Gnoblin(min(randint(15,25),max(1, randint(Globals.player.level - 5, Globals.player.level + 5)))+Globals.levelInit )])
Example #2
0
def room(x,y,direc):
    global flag
    position = [x,y]
    if position == [2,0]:
        #Exit
        print("You exit the cave")
        #Globals.gameState = "Running"
        Globals.quitGame = True
        flag = True
        return True
    elif position == [2,1]:
        return True
    elif position == [3,0]:
        return True
    elif position == [0,1]:
        return True
    elif position == [1,1]:
        return True
    elif position == [3,1]:
        return True
    elif position == [4,1]:
        return True
    elif position == [5,1]:
        return True
    elif position == [1,2]:
        return True
    elif position == [2,2]:
        return True
    elif position == [4,2]:
        return True
    elif position == [0,3]:
        if direc !="w":
            return False
        else:
            return True
    elif position == [1,3]:
        if direc == "w":
            return False
        else:
            if Globals.whaleTrap == False:
                Globals.whaleTrap = True
                if randint(1,20)+Globals.player.DEX >= 20:
                    print("\nYou narrowly dodge a large form falling from the ceiling.\nA whale has fallen to the ground, covering the walls with bits of Baleen.")
                else:
                    tempDamage = randint(1,200)+50+randint(1,Globals.player.HP[1] - 1)
                    print("\nYou are hit by a whale falling from the ceiling for",tempDamage,"damage.")
                    Globals.player.HP[0] -=tempDamage
                    if Globals.player.dead():
                        print("Game Over...")
                        Globals.quitGame = True
            return True
    elif position == [2,3]:
        if direc == "e":
            return False
        else:
            return True
    elif position == [3,3]:
        if direc == "w":
            return False
        else:
            return True
    elif position == [4,3]:
        if direc == "e":
            return False
        else:
            return True
    elif position ==[0,4]:
        if Globals.getKey == False:
            print("There is a key here.")
        if direc == "n":
            return False
        else:
            return True
    elif position == [1,4]:
        if direc == "w":
            return False
        else:
            if Globals.miniBoss == False:
                combat([Globals.player, Gnoblin(Globals.levelInit+25)])
                Globals.miniBoss = True
            return True
    elif position == [2,4]:
        print("This is the resting room")
        if direc == "n":
            return True
        else:
            return False
    elif position == [3,4]:
        if direc == "e" or dir == "w":
            return False
        else:
            return True
    elif position == [4,4]:
        if direc == "e":
            return False
        else:
            return True
    elif position == [1,5]:
        return True
    elif position == [2,5]:
        if direc == "n":
            return False
        else:
            return True
    elif position == [3,5]:
        if direc == "w":
            return False
    elif position == [4,5]:
        if direc == "e":
            return False
        else:
            return True
    elif position == [2,6]:
        return True
    elif position == [4,6]:
        if Globals.doorUnlocked == True:
            if Globals.defeatBoss == False:
                combat([Globals.player, Gnoblin(Globals.levelInit+60)])
                Globals.defeatBoss = True
            return True
        else:
            print("You need a key to unlock this door!")
            return False
    else:
        return False
    return True
Example #3
0
def testCombat():
    entities = []
    entities.append(Globals.player)
    entities.append(Gnoblin(1))
    combat(entities)