コード例 #1
0
ファイル: attribute.py プロジェクト: t3chn0tr0n/lucky_skills
    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='')
コード例 #2
0
    def inputs(self):
        """
        This function checks for a correct input from user and TRA!
        :return: None
        """

        # User input
        self.usr_input = int(input(fonts.font_dark('green') + "Your Chance: " + fonts.default()))

        while self.usr_input > 9 or self.usr_input <= 0:
            print(fonts.bar_dark('red') + '* Please enter correctly *' + fonts.default())
            self.usr_input = int(input(fonts.font_dark('green') + "Your Chance: " + fonts.default()))

        while self.usr_input in self.usr_data[9]:
            print(fonts.font_dark('red') + '* Number Locked *' + fonts.default())
            self.usr_input = int(input(fonts.font_dark('green') + "Your Chance: " + fonts.default()))

        self.usr_data[9].append(self.usr_input - 1)
        self.usr_data[9].append(self.usr_input)
        self.usr_data[9].append(self.usr_input + 1)

        if self.usr_data[7] >= 3:
            self.usr_data[9].pop(0)
            self.usr_data[9].pop(1)
            self.usr_data[9].pop(2)

        # computer input
        tra_input_temp = int(randint(1, 90) % 20) or randint(1, 19)
        while self.tra_input == tra_input_temp:
            tra_input_temp = int(randint(1, 90) % 20) or randint(1, 19)
        self.tra_input = tra_input_temp
        self.io.speech_tra('I took %d' % self.tra_input, 1)
コード例 #3
0
    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')
コード例 #4
0
    def zebra_bar(self, color1, color2, lenght):

        for x in range(0, int(lenght/10)):
            print(fonts.bar_dark(color1) + '     ', end='' + fonts.default())
            print(fonts.bar_dark(color2) + '     ', end='' + fonts.default())
        print()
        #print(fonts.bar_light('grey'), ' ' + fonts.default(), end='')
        for x in range(0, int(lenght/10)):
            print(fonts.bar_dark(color2) + '     ', end='' + fonts.default())
            print(fonts.bar_dark(color1) + '     ', end='' + fonts.default())
コード例 #5
0
ファイル: lucky_skills.py プロジェクト: Schubisu/lucky_skills
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('red') + "EXIT" + fonts.default())
        print()
        choice = int(input(">>> "))

    else:
        print(" 2. " + fonts.font_light('blue') + "HIGH SCORE" +
              fonts.default())
        print(" 3. " + fonts.font_dark('purple') + "STORY" + fonts.default())
        print(" 4. " + fonts.font_light('red') + "EXIT" + fonts.default())
        print()
        choice = int(input(">>> "))
        if choice >= 2:
            choice += 1

    return choice
コード例 #6
0
ファイル: War.py プロジェクト: t3chn0tr0n/lucky_skills
    def new_game(self):
        """

        :return:
        """
        try:
            self.io.speech_bill("Whats your name?")
            name = input(fonts.font_light('aqua') + '>>> ' + fonts.default())
            self.usr_data[0] = name

            self.set_stage()
            while self.usr_data[1] != 0 or self.usr_data[8] != 0:
                self.new_round()
            if self.usr_data[8] == 0:
                system('clear')
                if not path.isfile(
                        path.dirname(path.abspath(__file__)) + '/intro'):
                    print('YOU WON')
                else:
                    with open(
                            path.isfile(
                                path.dirname(path.abspath(__file__)) +
                                '/extro_win')) as file:
                        for line in file:
                            self.io.speech_bill(line)
                sleep(2)

            elif self.usr_data[1] == 0:
                system('clear')
                if not path.isfile(
                        path.dirname(path.abspath(__file__)) + '/extro_loose'):
                    print("YOU LOST")
                else:
                    with open(
                            path.isfile(
                                path.dirname(path.abspath(__file__)) +
                                '/extro_loose')) as file:
                        for line in file:
                            self.io.speech_bill(line)
                sleep(2)
            self.high_score()
        except KeyboardInterrupt:
            print(
                fonts.font_dark('red') + "\n\n* Keyboard Interrupt *\n" +
                fonts.default())
            print(
                fonts.font_light('green') +
                "* Auto-saving Game Progress *\n\n" + fonts.default())
            self.save_game()
            sleep(2)
            system('clear')
コード例 #7
0
 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())
コード例 #8
0
 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())
コード例 #9
0
ファイル: MagicCards.py プロジェクト: t3chn0tr0n/lucky_skills
    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
コード例 #10
0
ファイル: MagicCards.py プロジェクト: t3chn0tr0n/lucky_skills
    def choose_card(self, usr_data, act=1):
        """
            This module lets the player choose a magic card from this collection.
            :param usr_data: the list of current game data
            :param act: if the user wants to activate 1, else 0
            :return: modified data, activated
            """
        dialog = randint(1, 2)
        if dialog == 1:
            self.io.speech_tra(
                "Enter the card you want: (Ignore case. I can spell!)", 1)
            usr_card = input(
                fonts.font_light('red') + '>>> ' + fonts.default()).upper()
        else:
            self.io.speech_bill("Which card should we take?")
            usr_card = input(
                fonts.font_light('aqua') + '>>> ' + fonts.default()).upper()

        if usr_card in self.card_list:
            usr_data[5][self.card_index[usr_card]] += 1
            # add a dialog : Yay, we got what we needed.

            if act == 1:
                if self.card_index[usr_card] in [0, 3, 4]:
                    usr_data = self.runtime_card_init(
                        usr_data, self.card_index[usr_card])
                else:
                    usr_data = self.one_time_card(usr_data,
                                                  self.card_index[usr_card])

            else:
                self.io.speech_tra(
                    "You got your card. Enjoy as long as you can", 1)
            usr_data[6] = 0
        else:
            self.io.speech_tra("Sorry, you can't make your own Magic card!", 2)
            self.io.speech_tra("Stop fooling around....", 1)

        return usr_data
コード例 #11
0
ファイル: MagicCards.py プロジェクト: t3chn0tr0n/lucky_skills
 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()
コード例 #12
0
ファイル: MagicCards.py プロジェクト: t3chn0tr0n/lucky_skills
    def runtime_card_init(self, usr_data, card_no):
        """
            This module initialises Long-Time-Magic-Cards.
            LTMCs are of 3 types: Shield, Insurance and Virus.
            These are the cards that are played at one round, but it remains active till future rounds.
            This module is called upon, when the card is played.
            :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 usr_data[4] != -1:
            self.io.speech_bill(
                'You have a card active : ' +
                fonts.font_dark(self.color_code[self.card_list[usr_data[4]]]) +
                self.card_list[usr_data[4]])
            self.io.speech_bill(
                'Are you sure you want to proceed? (say yes(y) or No(n): ')
            ch = input(fonts.font_light('aqua') + '>>> ' + fonts.default())
            if ch.upper() == 'Y' or ch.upper() == 'YES':
                usr_data[4] = -1
            else:
                self.io.speech_tra('Cant Decide eh?', 2)
                return usr_data

        if usr_data[4] == -1:
            # Shield
            if card_no == 0:
                usr_data[4] = 0

            # Virus
            elif card_no == 3:
                if usr_data[2] <= 1:
                    self.io.speech_bill(
                        "We cant do that! We don't have enough Attack Points.")
                else:
                    usr_data[4] = card_no
                    usr_data[2] -= 2

            # Insurance
            elif card_no == 4:
                if usr_data[2] < 1:
                    self.io.speech_bill(
                        "We cant do that! We don't have enough Attack Points.")
                else:
                    usr_data[4] = card_no
                    usr_data[2] -= 1
        return usr_data
コード例 #13
0
    def new_game(self):
        """

        :return:
        """
        self.io.speech_bill("Whats your name?")
        name = input(fonts.font_light('aqua') + '>>> ' + fonts.default())
        self.usr_data[0] = name

        self.set_stage()
        while self.usr_data[1] != 0 or self.usr_data[8] != 0:
            self.new_round()
        if self.usr_data[8] == 0:
            system('clear')
            print('YOU WON')
        elif self.usr_data[1] == 0:
            print("YOU LOOSE")
        self.high_score()
コード例 #14
0
ファイル: MagicCards.py プロジェクト: t3chn0tr0n/lucky_skills
    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
コード例 #15
0
    def new_round(self):
        """
            Stores the High Score if the score is greater than High Score in game_stats.txt file.
            Asks if wants to save the game or not. (3s time-limit) (default ans: Yes)
            If yes, performs the following:
                > calls save_game module.

            Asks for if the user wants to exit or not (3s time-limit) (default ans: No)

            If not exited, then sets up the stage for a new round!
                > Clears up the screen.
                > Calls for resource module to print resources.
                > calls for battle module for battle.

            :return: None
        """

        system('clear')
        self.display_resource()

        # Ask if user wants to activate any MC or not
        # if yes, take action
        if [n for n in self.usr_data[5] if n >= 2]:
            self.io.speech_bill("Should we generate a magic card?[Then we can't activate any other card this round")
            ch = input(fonts.font_light('aqua') + '>>> ' + fonts.default())
            if ch.upper() == 'Y' or ch.upper() == 'YES' or ch.upper() == 'YUP':
                self.io.speech_bill('I want a magic card no!', 0)
                self.mc.gen_mc_force(self.usr_data)
            elif ch.upper() == 'N' or ch.upper() == 'NO' or ch.upper() == 'NOPE':
                self.io.speech_bill('Okay!')
            else:
                self.io.speech_bill('[Bill: There might have been an transmission error in the Time Line.'
                                    'Didn\'t got you! skipping it!')

        elif self.mc.check_cards_if_any(self.usr_data):
            print(fonts.font_light('aqua') + '[Bill: Wanna activate any of our Magic Cards? Now would be a great time!]'
                  + fonts.default())

            ch = input(fonts.font_light('aqua') + '>>> ' + fonts.default())
            if ch.upper() == 'Y' or ch.upper() == 'YES' or ch.upper() == 'YUP':
                self.usr_data = self.mc.choose_card(self.usr_data, 1)
            elif ch.upper() == 'N' or ch.upper() == 'NO' or ch.upper() == 'NOPE':
                self.io.speech_bill('Okay!')
            else:
                self.io.speech_bill('[Bill: There might have been an transmission error in the Time Line.'
                                    'Didn\'t got you!')
        self.battle()

        # check if health is 1
        # if yes, activate Medipack if any
        # if no medipack, prompt no medipack, and ask to activate  Insurance (default is yes)

        # If round%3 == 0, Computer's Health rejuvenates. and let the uer know that
        # Used a few different cases to let the user know that same thing! fancy eh!
        if self.usr_data[7] % 3 == 0 and self.usr_data[7] > 2:

            if self.usr_data[8] < 10:
                self.usr_data[8] += 1
                dialog = randint(1, 4)
            else:
                print("* Computer's Health is already Full, So no increment is made *")
                dialog = 0

            if dialog == 1:
                self.io.speech_tra('Yo Suckerberg, my life boosts at this point.', 1)
                self.io.speech_bill('You can\'t win like this. I will. Just to prove you are wrong.', 0)
            elif dialog == 2:
                self.io.speech_tra('Hey Bill, my life point gets a boost at this point. :D', 2)
                self.io.speech_bill('Great! But let\'s hope that helps you!', 0)
            elif dialog == 3:
                self.io.speech_tra('Yo man.. yes! I was waiting for this. Exxxxxtra life points...', 1)
                self.io.speech_bill('You can\'t win like this. I will. Just to prove you are wrong.', 0)
            elif dialog == 4 and self.usr_data[7] > 3:
                self.io.speech_tra('Your demise is near... mine health got boosted, again.', 1)
                self.io.speech_bill('Come on, get real. the game has just begun!', 0)

        # prompt to save game
        self.io.speech_bill('Hey, lets make a check point here. My time machine can handle that.')
        self.io.speech_bill('What do you say?')
        ch = input(fonts.font_light('aqua') + '>>> ' + fonts.default())
        if ch.upper() == 'Y' or ch.upper() == 'YES' or ch.upper() == 'YUP':
            # Deploy more dialogs
            self.io.speech_bill('Great idea!')
            self.save_game()

        elif ch.upper() == 'N' or ch.upper() == 'NO' or ch.upper() == 'NOPE':
            # Deploy more dialogs
            self.io.speech_bill('Great! you are not tired yet or are you soo confident?')
            # self.io.speech_bill('Wow, humans of past were soo cool. So let\'s bring that Machine to senses.')

        else:
            self.io.speech_bill('God damn this Time Machine. Sorry din\'t got that. Saving Anyway.')
            self.save_game()
        sleep(3)

        self.io.speech_bill('Would you like to quit? is yes, press y/Y with in 3 sec!')
        exc = self.io.timer_input('>>> ')
        if exc == 'e' or exc == 'E':
            self.save_game()
            self.io.speech_bill("Hope to see you soon!")
            exit()
コード例 #16
0
    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
コード例 #17
0
ファイル: MagicCards.py プロジェクト: t3chn0tr0n/lucky_skills
    def gen_mc_force(self, usr_data):
        """
        This function generates a Magic Card when ever the user wishes
        what's the catch?
        Simple, trade two other existing magic cards. :D
        And remember, the win_counter in reset after this.

        A few important points if you are trying to understand what are these lines of if-else and
        loops used here!
            >  using a loop we are iterating all the type of Magic Cards.
            >  break the loop once 2 cards are given
            >  don't show cards with card count 0
            >  choice1 and choice2 are 'list' variables, where 0th element is the Magic Card name
                and 1st element is the number of cards.
            >  choice1 takes one type of card, and
                choice2 takes another type of card; only when number of cards in choice1 is 1.
                if there are two cards for choice1, choice2 is not utilised.
            >  using a while loop to force player to give correct input.
            >  Once a correct input is provided, we generate a magic card as per user's choice.
        :return: None
        """
        # Find if there are any cards at-all or not
        total_number_of_cards = 0
        choice1 = [-1, 0]  # [card_index, numbers_to_be_trades]
        choice2 = [-1, 0]
        for number in usr_data[5]:
            total_number_of_cards += int(number)

        # If there are atleast 2 Magic Cards, carry on...
        if total_number_of_cards >= 2:
            print(
                "\nEnter the number of cards you want to trade:"
                "(\n0 to skip that card, or the number of cards you want(1 or 2)\n"
            )

            index = 0
            for number in usr_data[5]:
                # Break the loop if two cards have been chosen.
                if choice1[1] == 2 or choice1[1] + choice2[1] == 2:
                    index += 1
                    break

                # Don't show a Magic Card with count 0
                if number == 0:
                    index += 1
                    continue

                if choice1[1] == 0:
                    choice1[0] = index
                    choice1[1] = int(
                        input(
                            fonts.font_dark(self.color_code[
                                self.card_list[index]]) +
                            self.card_list[index] + fonts.default() + ': '))

                    # Force the user to give correct input only.
                    # Add Dialog
                    while choice1[1] > 2 or choice1[1] < 0:
                        if choice1[1] > 2:
                            self.io.speech_tra(
                                "How nice of you to sacrifice more than 2 cards.",
                                2)
                            self.io.speech_tra(
                                "But you don\'t need to be so good!", 2)
                            self.io.speech_bill("Enter Correctly")
                            choice1[1] = int(
                                input(
                                    fonts.font_light('aqua') + '>>> ' +
                                    fonts.default()))
                        else:
                            self.io.speech_tra("Stop trying my patience!", 1)
                            self.io.speech_tra("Enter Correctly:", 2)
                            choice1[1] = int(
                                input(
                                    fonts.font_light('red') + '>>> ' +
                                    fonts.default()))
                else:
                    choice2[0] = index
                    choice2[1] = int(
                        input(
                            fonts.font_dark(self.color_code[
                                self.card_list[index]]) +
                            self.card_list[index] + fonts.default() + ': '))
                    while choice2[1] > 1:
                        self.io.speech_tra("Please! That won\'t work.", 2)
                        self.io.speech_tra("Enter Correctly:", 2)
                        choice2[1] = int(
                            input(
                                fonts.font_light('red') + '>>> ' +
                                fonts.default()))
                index += 1

            if choice1[1] + choice2[1] == 2:
                self.io.speech_bill("Are you Sure? ")
                ch = input(fonts.font_light('aqua') + '>>> ' + fonts.default())
                if ch.upper() == 'Y' or ch.upper() == 'YES' or ch.upper(
                ) == 'YUP':
                    usr_data[5][choice1[0]] -= choice1[1]
                    if choice1[1] <= 1:
                        usr_data[5][choice2[0]] -= choice2[1]
                    CustomIO.CustomIO().loading()
                    print()
                    usr_data = self.choose_card(usr_data, 2)

                elif ch.upper() == 'N' or ch.upper() == 'NO' or ch.upper(
                ) == 'NOPE':
                    # add dialog
                    self.io.speech_tra(
                        "None of your cards were touched. I knew you couldn't decide...",
                        2)

                else:
                    # add dialog
                    self.io.speech_tra(
                        "Say only what you are asked. Taking 'No' as your answer...",
                        1)

            else:
                self.io.speech_tra(
                    "You know, I'm not a fool! Please stop trying cheap tricks!",
                    1)
                self.io.speech_tra(
                    "I'm not going to ask you to enter correctly! Next time, remember this.",
                    2)
        else:
            self.io.speech_tra("Duh! You don\'t have enough cards to trade", 2)
        return usr_data
コード例 #18
0
            input("Press any key to continue!")
            system('clear')
            resolve_menu()

        # Exit
        elif choice == 6:
            print("* Hope to see you soon *")
            sleep(2)
            system('clear')
            exit()

        else:
            print(
                'This program haven\'t been programed with any operation for this input, sorry!'
            )
            system('clear')
            resolve_menu()

    except KeyboardInterrupt:
        print("\n\n SEE YOU SOON... \n")
        sleep(2)
        system('clear')


if __name__:
    print(
        fonts.font_dark('green') +
        "\nPlease switch to full screen, if not already!\n" + fonts.default())
    sleep(3)
    resolve_menu()
コード例 #19
0
ファイル: War.py プロジェクト: t3chn0tr0n/lucky_skills
    def resume(self):
        """
            This helps to resume a previously saved game.
            Restores the saved values from the file saved_game.txt to the current game.

            :return: the list user data if the game can be resumed.
        """
        try:

            print(" * Please wait, resuming game", end='')
            self.io.typel('... *', 1)
            print()
            index = 0
            if path.isfile(self.dir_path + 'saved_game.txt'):
                with open(self.dir_path + 'saved_game.txt') as file:
                    for line in file:
                        if index == 0:
                            self.usr_data[index] = line[0:-1]
                        elif index == 5 or index == 9:
                            l = [
                                int(x) for x in line
                                if x not in ['[', ']', ',', ' ', '\n']
                            ]
                            self.usr_data[index] = l
                        else:
                            self.usr_data[index] = int(line[:-1])
                        index += 1
            else:
                print("* There is no saved file. Can't resume game. *")
                print("* Starting a new game! *")
                self.usr_data = [
                    'Bill Zuckerberg', 6, 3, 100, 0, [0, 0, 1, 0, 0], 0, 0, 7
                ]

            while self.usr_data[1] != 0 or self.usr_data[8] != 0:
                self.new_round()
            if self.usr_data[8] == 0:
                system('clear')
                if not path.isfile(
                        path.dirname(path.abspath(__file__)) + '/intro'):
                    print('YOU WON')
                else:
                    with open(
                            path.isfile(
                                path.dirname(path.abspath(__file__)) +
                                '/extro_win')) as file:
                        for line in file:
                            self.io.speech_bill(line)
                sleep(2)

            elif self.usr_data[1] == 0:
                system('clear')
                if not path.isfile(
                        path.dirname(path.abspath(__file__)) + '/extro_loose'):
                    print("YOU LOST")
                else:
                    with open(
                            path.isfile(
                                path.dirname(path.abspath(__file__)) +
                                '/extro_loose')) as file:
                        for line in file:
                            self.io.speech_bill(line)
                sleep(2)
            self.high_score()
        except KeyboardInterrupt:
            print(
                fonts.font_dark('red') + "\n\n* Keyboard Interrupt *\n" +
                fonts.default())
            print(
                fonts.font_light('green') +
                "* Auto-saving Game Progress *\n\n" + fonts.default())
            self.save_game()
            sleep(2)
            system('clear')