def value_bar(self, usr_data): if self.index == 1: print(fonts.font_dark('red') + fonts.bold() + 'HEALTH :', end='' + fonts.default()) elif self.index == 2: print(fonts.font_dark('yellow') + fonts.bold() + 'ATTACK :', end='' + fonts.default()) elif self.index == 8: print(fonts.font_light('blue') + fonts.bold() + 'COMPUTER HEALTH :', end='' + fonts.default()) if int(usr_data[self.index]) < 4: color1 = fonts.bar_dark('red') color2 = fonts.font_dark('red') elif 4 <= int(usr_data[self.index]) <= 7: color1 = fonts.bar_dark('blue') color2 = fonts.font_dark('blue') elif int(usr_data[self.index]) > 7: color1 = fonts.bar_dark('green') color2 = fonts.font_dark('green') else: color1 = fonts.default() color2 = fonts.default() print(color2, '( %d ) ' % int(usr_data[self.index]), end='') for x in range(0, int(usr_data[self.index])): print(color1, end='') print('=', end='') print(fonts.default(), end='') for x in range(int(usr_data[self.index]), 10): print(fonts.bold() + '-', end='') print(fonts.default(), end='')
def display_resource(self): """ Displays the current resource list: Magic cards, Health Point and Attack Point and Score :return: None """ # Bar 1 print(fonts.bar_dark('white')) self.io.print_spaces(90) print(fonts.default()) print() # Player Name print(' ', end='') print(fonts.font_dark('aqua') + fonts.bold() + "PLAYER : " + fonts.default(), end='') print(self.usr_data[0].upper()) # Magic Cards print(' ', end='') self.mc.display_card_resource(self.usr_data) # Player Health Point print(' ', end='') self.hp.value_bar(self.usr_data) # Break self.io.print_spaces(8) print('|', end='') self.io.print_spaces(8) # Computer Health Point self.chp.value_bar(self.usr_data) print() # Attack Point print(' ', end='') self.ap.value_bar(self.usr_data) # Break self.io.print_spaces(8) print('|', end='') self.io.print_spaces(8) # Score print(fonts.font_light('purple') + fonts.bold() + fonts.underline() + 'SCORE: ', self.usr_data[3]) print(fonts.default()) # Any active Magic Card if int(self.usr_data[4]) >= 0: # print(fonts.bar_light('grey'), ' ' + fonts.default() + ' ', end='') print(fonts.font_dark(self.mc.color_code[self.mc.card_list[self.usr_data[4]]]) + fonts.underline() + fonts.bold() + '* ' + self.mc.card_list[self.usr_data[4]], '*' + fonts.font_dark('grey') + ' is active!' + fonts.default()) # print(fonts.bar_light('grey'), ' ', end='') # Bar 2 (zebra) self.io.zebra_bar('grey', 'white', 96) print('\n')
def speech_tra(self, text, face=1): """ This method prints the speech of TRA :param face: 1: T-Rex personality, 2: Angel Personality :param text: His Speech. :return: None """ if face == 1: print(fonts.font_light('red') + fonts.bold() + 'T-REX: ', end='') self.typel(' ' + text, 0.1) print(fonts.default()) if face == 2: print(fonts.font_light('yellow') + fonts.bold() + 'ANGEL: ', end='') self.typel(' ' + text, 0.1) print(fonts.default())
def menu(): system('clear') print("+----------------------------+") print("|" + fonts.bar_dark('red') + fonts.bold() + fonts.font_dark('grey') + " LUCKY SKILLS " + fonts.default() + "|") print("+----------------------------+\n") print(" 1. " + fonts.font_light('green') + "NEW GAME" + fonts.default()) if path.isfile(war.dir_path + 'saved_game.txt'): print(" 2. " + fonts.font_light('yellow') + "LOAD SAVED GAME" + fonts.default()) print(" 3. " + fonts.font_light('blue') + "HIGH SCORE" + fonts.default()) print(" 4. " + fonts.font_dark('purple') + "STORY" + fonts.default()) print(" 5. " + fonts.font_light('white') + "INSTRUCTIONS" + fonts.default()) print(" 6. " + fonts.font_light('red') + "EXIT" + fonts.default()) print() choice = int(input(">>> ")) else: print(" 2. " + fonts.font_light('red') + "EXIT" + fonts.default()) print() choice = int(input(">>> ")) if choice == 2: choice = 6 return choice
def display_card_resource(self, usr_data): """ This function displays the current status of Magic Cards. Each card has a color code. :return:None """ index = 0 print(fonts.font_dark("green") + fonts.bold() + "MAGIC CARDS : ", end='') for card in self.card_list: print(fonts.font_dark(self.color_code[card]) + fonts.bold() + card + fonts.default() + ': %2d' % (usr_data[5][index]), end=' ', flush=stdout) index += 1 print()
def one_time_card(self, usr_data, card_no): """ This module implements the usage of One-Time-Magics-Cards. There are two OTMCs : Canon and Medipack. They are like use-and-through cards, independent of any future rounds. :param usr_data: the list of current game data :param card_no: The Magic Card number; 1: Canon, 2: Medipack :return: a list of updated game data """ print( fonts.font_dark(self.color_code[self.card_list[card_no]]) + fonts.underline() + fonts.bold() + '* ' + self.card_list[card_no] + ' is being deployed *' + fonts.default()) # Canon Card if card_no == 1: if usr_data[8] > 0: usr_data[8] -= 1 usr_data[5][1] -= 1 usr_data[6] = 0 # Medipack elif card_no == 2: if usr_data[1] <= 9: usr_data[1] += 1 usr_data[2] -= 1 usr_data[5][2] -= 1 usr_data[6] = 0 else: self.io.speech_bill( "Health already at max. No need for a Medipack!") return usr_data
def Draw(self, samus = None, automap = None): if samus is None: import engine samus = engine.engine.player automap = engine.engine.automap DrawEnergy(4, 4, samus.energy, samus.max_energy, disp=self.e_bar_value) #Draw missiles. if samus.equipment["Missiles"].max > 0: DrawHUDPiece(150, 4, 16, missile, str(samus.equipment["Missiles"].cur).zfill(3), samus.cur_state not in samus.morph_states and samus.equipment["Missiles"].cur > 0 and samus.cur_missile == 0 and samus.sec_armed) #Draw super missiles. if samus.equipment["Super Missiles"].max > 0: DrawHUDPiece(183, 4, 11, smissile, str(samus.equipment["Super Missiles"].cur).zfill(2), samus.cur_state not in samus.morph_states and samus.equipment["Super Missiles"].cur > 0 and samus.cur_missile == 1 and samus.sec_armed) #Draw power bombs. if samus.equipment["Power Bombs"].max > 0: DrawHUDPiece(216, 4, 11, pbomb, str(samus.equipment["Power Bombs"].cur).zfill(2), samus.cur_state in samus.morph_states and samus.equipment["Power Bombs"].cur > 0 and samus.sec_armed) #Draw minimap. minimap.Blit(280, 0) automap.Draw(280, 0, (automap.cur_map_x - 2, automap.cur_map_y - 1), (5, 3)) #Draw beam selection if self.display_beam: if self.beam_ticks > 200: a = 255 - min((self.beam_ticks - 200) * 255 / 100, 255) else: a = 255 #Display beam graphics. for i, img, name in zip(range(4), (power_beam, ice_beam, pulse_beam, grapple_beam), ("Power Beam", "Ice Beam", "Pulse Beam", "Grapple Beam")): if name in samus.equipment: DrawBeamIcon(8, 200, img, a, samus.cur_beam == i) #Draw metroid counter. if self.display_beam: if self.metroid_ticks < 100: c = ika.RGB(255, 255, 255, max(self.metroid_ticks * 255 / 100, 0)) elif self.metroid_ticks > 800: c = ika.RGB(255, 255, 255, 255 - min((self.metroid_ticks - 800) * 255 / 100, 255)) else: c = ika.RGB(255, 255, 255) metroid.Draw(285, 212, c) print >> fonts.hud_big(300, 220, "center"), color.ColorCode(c) + str(samus.metroids_killed) #Draw scan string. if self.display_scan: string, length, ticks = self.__scan if self.scan_ticks > ticks + 100: c = ika.RGB(255, 255, 255, 255 - min((self.scan_ticks - (ticks + 100)) * 255 / 100, 255)) else: c = ika.RGB(255, 255, 255) print >> fonts.bold(316, 30, "right"), color.ColorCode(c) + string[:self.scan_ticks * length / ticks]
def speech_bill(self, text, secure=1): """ This method prints the speechs of Bill Zuckerberg. :param secure: Whether he speaks by secure channel yo you(1, default) or directly to TRA (0) :param text: His Speech. :return: None """ if secure: print(fonts.font_light('aqua') + '[Bill: ', end='') self.typel(' ' + text + ']') print(fonts.default()) elif secure == 0: print(fonts.font_dark('aqua') + fonts.bold() + 'Bill : ', end='') self.typel(' ' + text) print(fonts.default())
def runtime_card_deploy(self, usr_data, card_no=None): """ This module is called upon when ever an LTMCs are set to take effect. :param usr_data: a list of current game data :param card_no: The Magic Card number; 0: Shield 3: Virus, 4: Insurance :return: a list of updated game data """ if card_no is None: card_no = usr_data[4] print( fonts.font_dark(self.color_code[self.card_list[card_no]]) + fonts.underline() + fonts.bold() + '* ' + self.card_list[card_no] + ' is being deployed *' + fonts.default()) # Shield if card_no == 0: usr_data[1] += 1 # Virus elif card_no == 3: if usr_data[8] > 0: usr_data -= 1 # Insurance elif card_no == 4: if usr_data[2] < 1: self.io.speech_bill( "We can\'t pay the Premium. We don't have enough Attack Points." ) self.io.speech_tra( "Haha, you lost your Insurance Card didn\'t you? Oh! pittyful Humans! " ) usr_data[4] = -1 elif usr_data[1] == 10: self.io.speech_bill( "Yay, full life boost! Come on now, lets finish this game!", 0) else: usr_data[2] -= 1 if usr_data[1] < 10: usr_data += 1 return usr_data
def battle(self): """ The main battle is fought here. This module is called by new_round module. # Check who wins & take measures add more dialogs here 1. check for any active card if yes do action 2. If the user wins, ask for his action if his attack point > 3 whether he wants to attack or pass. if he passes, Attack point + 1 if he attacks, asks for the attack strength Attack point - strength and computer health point - Strength if his AP <= 3: prompt he can't attack Increase the win_counter. check if the counter is 3 or not. If 3, launch magic card generation. 3. If player looses user HP - 1 win_counter = 0 :return: None """ usr_input, tra_input = self.usr_input, self.tra_input # when user looses if tra_input > usr_input: self.io.speech_tra('haha, I won this round...', 1) if self.usr_data[4] == 0: self.io.speech_bill('Hold Your horses... My have my Shield Card...') self.io.speech_tra('Damn you, Humaaan!', 1) self.usr_data[4] = -1 elif self.usr_data[4] != 0: self.io.speech_bill('We lost our active Magic Card! :( and 1 Health Point!') if self.usr_data[1] > 0: self.usr_data[1] -= 1 else: print(fonts.bold() + fonts.bar_light('red') + "* YOU ARE DEAD! *" + fonts.default()) self.usr_data[4] = -1 # reset the win-counter self.usr_data[6] = 0 # when user wins elif tra_input < usr_input: self.io.speech_tra('Damn it. I will win next round.', 1) self.usr_data[6] += 1 self.usr_data[3] += 100 if self.usr_data[2] > 3: self.io.speech_bill('Should we attack?') ch = input(fonts.font_light('aqua') + '>>> ' + fonts.default()) if ch.upper() == 'Y' or ch.upper() == 'YES' or ch.upper() == 'YUP': self.usr_data[2] -= 1 self.usr_data[8] -= 1 self.usr_data[3] += 50 self.io.speech_bill('Heyo TRA, here goes your life point! Haha!', 0) if self.usr_data[1] > 5: self.io.speech_bill('You know what TRA, I\'m loving this game!', 0) self.io.speech_tra('Don\'t fly too high, Suckerberg!', 1) elif ch.upper() == 'N' or ch.upper() == 'NO' or ch.upper() == 'NOPE': self.io.speech_bill('Great idea! Let\'s this round and increase the Attack point') self.io.speech_bill('I\'ll pass this round!', 0) if self.usr_data[2] < 10: self.usr_data[2] += 1 else: print("* Attack Point is already Full *") else: self.io.speech_bill('Damn, again that Time Machine Glitched!') self.io.speech_bill('Sorry didn\'t got you!. Anyway, passing this round!') if self.usr_data[2] < 10: self.usr_data[2] += 1 else: print("* Attack Point is already Full *") else: self.io.speech_bill('Damn, our Attack point is too low to attack!') self.usr_data[2] += 1 if self.usr_data[4] == 3 or self.usr_data[4] == 4: self.io.speech_bill("But wait, the round is still left! Wait till the Magic Card kicks in...") self.io.speech_tra("Hey, wait... your Magic Card effect is still left, isn't it?", 2) self.io.speech_bill("Hell Yeah!", 0) self.mc.runtime_card_deploy(self.usr_data) # Mach draw. else: self.io.speech_bill('See TRA, we are so much alike. we even think the same!', 0) self.io.speech_tra('Oh! Shut up!', 1) if self.usr_data[4] == 3 or self.usr_data[4] == 4: self.io.speech_tra('Come on, play you shit card! what are you waiting for?', 1) self.io.speech_bill('You asked for it...', 0) self.mc.runtime_card_deploy(self.usr_data, self.usr_data[4]) elif self.usr_data[4] == 0: self.io.speech_bill('We lost our Shield Card! Bad Luck!') self.usr_data[4] = -1 self.usr_data[6] = 0 # Grant a MC if Win_count = 3 and a bonus score boost if self.usr_data[6] == 3: self.mc.gen_mc_normal(self.usr_data) self.io.speech_bill('Score Bonus... +300 for continuous 3 wins!') self.usr_data[3] += 300