def battle(playerEnt, mobEnt): while playerEnt.hp > 0 and mobEnt.hp > 0: updateScreen() actionBar(1) print("Press A to attack") cmd = getch() while cmd.lower() != "a": cmd = getch() if cmd.lower() == "a": player.attack(mobEnt) mobEnt.attack(playerEnt) time.sleep(3) if playerEnt.hp == 0: # If at the end of the battle, the player's hp is null, then the player has died. Game over. print("Game over!") else: # Post-battle executions, xp gain, drops and levelup check r = random.random() xp = EXPTABLE[mobEnt.name]*(playerEnt.level*0.5) + r print("You killed %s! You obtain %.2f experience points!"%(mobEnt.name, xp)) mobEnt.drop(playerEnt) playerEnt.exp += xp playerEnt.checkLevelup() playerEnt.checkDead() mobEnt.checkDead() time.sleep(3) updateScreen()
def battle(playerEnt, mobEnt): while playerEnt.hp > 0 and mobEnt.hp > 0: updateScreen() actionBar(1) print("Press A to attack") cmd = getch() while cmd.lower() != "a": cmd = getch() if cmd.lower() == "a": player.attack(mobEnt) mobEnt.attack(playerEnt) time.sleep(3) if playerEnt.hp == 0: # If at the end of the battle, the player's hp is null, then the player has died. Game over. print("Game over!") else: # Post-battle executions, xp gain, drops and levelup check r = random.random() xp = EXPTABLE[mobEnt.name] * (playerEnt.level * 0.5) + r print("You killed %s! You obtain %.2f experience points!" % (mobEnt.name, xp)) mobEnt.drop(playerEnt) playerEnt.exp += xp playerEnt.checkLevelup() playerEnt.checkDead() mobEnt.checkDead() time.sleep(3) updateScreen()
def get_current_char(seq): inf = getch() while not inf in seq + ['q']: if inf == 's': print() save() inf = getch() return inf
def main(): # Iterates over every entity and plots it into the map // DEPRECATED currentMap = MAPLIST["Current"] for e in ENTITYLIST: currentMap.plot(e.coords, e.rep) mainLoop = True player = ENTITYLIST[0] currentMap.setSpawn() # Updates the screen updateScreen() while mainLoop: for mob in currentMap.mobsInMap: mob.detectPlayer() mob.autoMove() key = getch() # Waits for user keypress if key.lower() == "w": player.moveUp() updateScreen() elif key.lower() == "s": player.moveDown() updateScreen() elif key.lower() == "a": player.moveLeft() updateScreen() elif key.lower() == "d": player.moveRight() updateScreen()
def check_if_play(self): while True: print(self.intro) answer = getch() # decoding to use as a string b'a string'.decode('ascii') answer = answer.decode("ascii") if answer.isalpha(): if answer.lower()[0] == "y": break elif answer.lower()[0] == "n": # Will be calling the farewell and then # exit the program self.fareWell() # will add this if they have input somthing that is # not right self.add_explan()
hexa.dualPrint("Starting Movement") # Code starts here jointAngle = [[0, 0, 0]] * 6 for i in range(6): for j in range(3): jointAngle[i][j] = hexa.getJointAngle(jointLeg[i][j]) ch = '0' selectedJoint = 0 selectedLeg = 0 change = 'l' while (ch != 'q'): ch = getchar.getch() if (ch == 'l'): change = 'l' hexa.dualPrint("Leg Selection") elif (ch == 'j'): change = 'j' hexa.dualPrint("Joint Selection") elif (change == 'j' and ch >= '1' and ch <= '3'): selectedJoint = int(ch) - int('1') hexa.dualPrint("Leg: " + str(selectedLeg + 1) + ", Joint: " + str(selectedJoint + 1)) elif (change == 'l' and ch >= '1' and ch <= '6'): selectedLeg = int(ch) - int('1') hexa.dualPrint("Leg: " + str(selectedLeg + 1) + ", Joint: " + str(selectedJoint + 1)) elif (ch == 'w'):