def getNewEvent(self): self.eventNumber += 1 style.displayMessage("title", "Event " + str(self.eventNumber)) if EventQueue.QUEUE != None: temp = EventQueue.QUEUE EventQueue.QUEUE = None return temp elif self.eventNumber == 1: return NameEvent() elif self.eventNumber == 2: return ChooseWeaponEvent() elif self.eventNumber == 3: return ExploreAreaEvent() elif gameInfo.area != None and gameInfo.area.numberOfFights < 9: if random.randint(1, 5) == 2: return getRandomQuiz() if gameInfo.area.numberOfFights < 8: enemy = gameInfo.area.getEnemy() if enemy.enemyType == "Steal": return StealEvent(enemy) elif enemy.enemyType == "Fight": return BattleEvent(enemy) else: gameInfo.area.numberOfFights += 1 return BattleEvent(gameInfo.area.getBoss()) else: #No more events gameInfo.isEnded = True return None
def displayTurn(self): style.displayMessage("title", "Random Stealing Event") style.displayMessage("command", self.currentTurn.eventMessage) if self.isSuccess != None: if not self.isSuccess: style.displayMessage("command", "You lost " + str(self.coinLoss) + " coin(s)!") style.displayMessage("command", "You have " + str(gameInfo.player.coins) + " coin(s) remaining") else: style.displayMessage("command", "The " + self.enemy.name + " tries to fight back!")
def displayFinalScore(): style.displayMessage("title", "Game Over") print("\n\tPlayer Name:", gameInfo.player.name) print("\tWeapon:", gameInfo.player.weapon.name) print("\tArea:", gameInfo.area.name) print("\tFinal Health:", gameInfo.player.health) print("\tFinal Coins:", gameInfo.player.coins) print("\tFinal Experience:", gameInfo.player.exp) print("\tFinal Score:", gameInfo.player.health + gameInfo.player.coins * 2 + gameInfo.player.exp) print("\nThank you for playing!")
def processEnemyEffect(self): if self.enemyCastEffect != None: if self.enemyCastEffect.turnRemaining > 0: self.enemyCastEffect.turnRemaining -= 1 damage = self.enemyCastEffect.damage self.enemy.health = max(self.enemy.health - damage, 0) style.displayMessage( "command", "{} took {} damage because of the {}!".format( self.enemy.name, damage, self.enemyCastEffect.name)) else: self.enemyCastEffect = None
def displayTurn(self): style.displayMessage("title", "Battle Event") if self.state == "DisplayBattle": self.currentTurn = self.fightData self.displayBattle() elif self.state == "DisplayHit": self.currentTurn = self.hitData self.displayHit() self.processEnemyEffect() elif self.state == "DisplayWinner": self.signalEndBattleEvent()
def displayHit(self): message = "{} attacks {}. ".format(self.previousTurnHit["Attacker"], self.previousTurnHit["Defender"]) if not self.previousTurnHit["Miss"]: message += "{} loses {} health! ".format( self.previousTurnHit["Defender"], self.previousTurnHit["Damage"]) if self.previousTurnHit["Effect"] != None: message += "{} got {}!".format( self.previousTurnHit["Defender"], self.previousTurnHit["Effect"]) else: message += "{} missed!".format(self.previousTurnHit["Attacker"]) style.displayMessage("command", message)
def displayBattle(self): if (self.turnNumber == 0): style.displayMessage( "command", gameInfo.player.name + " have encountered a " + self.enemy.name) self.fightData.eventMessage = self.getEnemyStatus() style.displayMessage("command", self.fightData.eventMessage) numberOfOptions = len(self.fightData.optionMessages) for i in range(0, numberOfOptions): style.displayMessage("choice", self.fightData.optionMessages[i]) style.displayMessage("command", self.getPlayerStatus())
def displayTurn(self): style.displayMessage("title", "Choose Weapon Event") style.displayMessage("command", self.chooseWeaponTurnData.eventMessage) options = self.chooseWeaponTurnData.optionMessages for i in range(len(options)): style.displayMessage("choice", str(i + 1) + ". " + options[i])
def displayTurn(self): style.displayMessage("title", "Explore An Area Event") style.displayMessage("command", self.exploreAreaTurnData.eventMessage) options = self.exploreAreaTurnData.optionMessages for i in range(len(options)): style.displayMessage("choice", str(i + 1) + ". " + options[i])
def main(): while not gameInfo.isEnded: event = eventManager.getNewEvent() if event != None: while not event.isEnded: event.displayTurn() userInput = input( style.displayMessage("input", event.getInputMessage())) event.processUserInput(userInput) os.system("cls") else: os.system("cls") break os.system("cls") displayFinalScore()
def signalEndBattleEvent(self): self.currentTurn = self.hitData if self.enemy.health <= 0: style.displayMessage("command", "{} died!".format(self.enemy.name)) style.displayMessage( "command", gameInfo.player.name + " gained {} health, {} coins, and {} experience!".format( self.gain["Health"], self.gain["Coins"], self.gain["Exp"])) player = gameInfo.player player.health += self.gain["Health"] player.coins += self.gain["Coins"] player.exp += self.gain["Exp"] else: style.displayMessage("command", gameInfo.player.name + " died!") gameInfo.isEnded = True self.isEnded = True
def displayTurn(self): style.displayMessage("title", "Name Event") style.displayMessage("command", self.nameTurnData.eventMessage)
def checkPlayerHealth(self): if (gameInfo.player.health <= 0): style.displayMessage("command", gameInfo.player.name + " died!") gameInfo.isEnded = True
def displayTurn(self): style.displayMessage("title", "Quiz Event") if self.state == "Pending": style.displayMessage("command", self.currentTurnData.header) style.displayMessage("command", self.currentTurnData.choiceQuestion) numberOfQuestions = len(self.currentTurnData.choicesList) - 1 for i in range(0, numberOfQuestions + 1): style.displayMessage( "choice", str(i + 1) + ". " + self.currentTurnData.choicesList[i]) elif self.state == "Win": style.displayMessage("command", gameInfo.player.name + " is correct!") style.displayMessage( "command", gameInfo.player.name + " gained " + str(self.currentTurnData.rewardCount) + " " + self.currentTurnData.rewardType) self.inputMessage = "Press Enter to continue" self.isEnded = True self.checkPlayerHealth() elif self.state == "Lose": style.displayMessage("command", gameInfo.player.name + " is wrong!") style.displayMessage( "command", gameInfo.player.name + " lost " + str(self.currentTurnData.punishmentCount) + " " + self.currentTurnData.punishmentType) self.inputMessage = "Press Enter to continue" self.isEnded = True self.checkPlayerHealth()