Пример #1
0
 def choose_attack(self, pokemon=None):
     if pokemon is None:
         return None
     if pokemon.has_status_effect(constants.status_bide):
         return pokemon.get_move(move_name="Bide")
     if pokemon.has_status_effect(constants.status_encore):
         return pokemon.get_status_effect(
             constants.status_encore)[constants.status_encore]
     print "choose_attack\n"
     while True:
         for move in pokemon.moves:
             print str(move)
         cmd = raw_input("\nChoose move: ")
         if cmd in 'back' or cmd in 'cancel':
             return 'back'
         for move in pokemon.moves:
             if cmd.lower() in move.name.lower():
                 if move.pp > 0:
                     if not (pokemon.has_status_effect(
                             constants.disables_move)
                             and pokemon.get_status_effect(
                                 constants.disables_move)
                             [constants.disables_move].name is move.name):
                         return move
                     else:
                         print "{} is disabled!".format(move.name)
                         continue
                 else:
                     print "{} has no pp left!".format(move.name)
                     continue
         print self.input_error_text.format(cmd)
Пример #2
0
 def choose_attack(self, pokemon=None):
     if pokemon is None:
         return None
     if pokemon.has_status_effect(constants.status_bide):
         return pokemon.get_move(move_name="Bide")
     if pokemon.has_status_effect(constants.status_encore):
         return pokemon.get_status_effect(constants.status_encore)[constants.status_encore]
     print "choose_attack\n"
     while True:
         for move in pokemon.moves:
             print str(move)
         cmd = raw_input("\nChoose move: ")
         if cmd in 'back' or cmd in 'cancel':
             return 'back'
         for move in pokemon.moves:
             if cmd.lower() in move.name.lower():
                 if move.pp > 0:
                     if not (pokemon.has_status_effect(constants.disables_move) and pokemon.get_status_effect(constants.disables_move)[constants.disables_move].name is move.name):
                         return move
                     else:
                         print "{} is disabled!".format(move.name)
                         continue
                 else:
                     print "{} has no pp left!".format(move.name)
                     continue
         print self.input_error_text.format(cmd)
Пример #3
0
    def choose_battle_option(self,
                             trainer=None,
                             pokemon=None,
                             opposing_pokemon=None,
                             options=None):  #, priority_list=None):
        #
        if pokemon is None:
            print "No pokemon.  Pokemon is None."
            return None
        #if priority_list is None:
        #    print "Priority list is none."
        #    return None
        if options is None:
            options = [constants.btl_opt_attack]
        option = None
        #
        while True:
            if len(options) > 1:
                print "What will {} do?".format(pokemon.nickname)
                for opt in options:
                    print opt
                cmd = raw_input("Choose an option: ")
                #ATTACK
                if cmd.lower() in constants.btl_opt_attack.lower(
                ) and constants.btl_opt_attack in options:
                    #ATTACK PRIORITTY -7 to 8
                    move = self.choose_attack(pokemon=pokemon)
                    if move is 'back':
                        continue
                    if pokemon.has_status_effect(constants.status_bide):
                        move = move  # dont use
                    else:
                        pokemon.use_move(move)
                    return {
                        constants.btl_opt_attack: move,
                        'priority': str(move.priority),
                        'pokemon': pokemon,
                        'trainer': trainer,
                        'target': opposing_pokemon
                    }

                #Pokemon
                elif cmd.lower() in constants.btl_opt_pokemon.lower(
                ) and constants.btl_opt_pokemon in options:
                    #Pokemon PRIORITTY 6
                    new_pokemon = self.choose_pokemon(trainer=trainer)
                    if new_pokemon is 'back':
                        continue
                    if pokemon.has_status_effect(status_effect=constants.
                                                 status_trapped):  # Is Trapped
                        print "{} is trapped and cannot escape".format(
                            pokemon.nickname)
                        continue
                    return {
                        constants.btl_opt_switch: new_pokemon,
                        'priority': '6',
                        'pokemon': pokemon,
                        'trainer': trainer
                    }
                #Items
                elif cmd.lower() in constants.btl_opt_items.lower(
                ) and constants.btl_opt_items in options:
                    #Items PRIORITTY 6
                    item = self.choose_item(trainer=trainer)
                    if item is 'back':
                        continue
                    elif (item.type is constants.item_type_medicine
                          or item.type is constants.item_type_berry):
                        wanted_pokemon = self.choose_pokemon_from_list(
                            pokemon_list=trainer.party)
                        if wanted_pokemon is None or (
                                wanted_pokemon.is_fainted()
                                and "Revive" not in item.name):
                            print "You cannot use {} that pokemon!".format(
                                item.name)
                            continue
                        return {
                            constants.btl_opt_items: item,
                            'priority': '6',
                            'pokemon': wanted_pokemon,
                            'trainer': trainer
                        }
                    elif item.type is constants.item_type_poke_ball:
                        if opposing_pokemon.original_trainer is None:
                            return {
                                constants.btl_opt_items: item,
                                'priority': '6',
                                'pokemon': pokemon,
                                'trainer': trainer,
                                'target': opposing_pokemon
                            }
                        else:
                            print "Dont be a theif.  Only catch WILD Pokemon."
                            continue
                    else:
                        print "You cannot use that {} now!".format(item.name)
                        continue
                #Call
                elif cmd.lower() in constants.btl_opt_call.lower(
                ) and constants.btl_opt_call in options:
                    #Call PRIORITTY 6
                    return {
                        constants.btl_opt_call: pokemon,
                        'priority': '6',
                        'pokemon': pokemon,
                        'trainer': trainer
                    }
                #Flee
                elif cmd.lower() in constants.btl_opt_flee.lower(
                ) and constants.btl_opt_flee in options:
                    #Flee PRIORITTY 0,
                    if cmd.lower() is 'back':
                        continue
                    priority = 6
                    if trainer is None:
                        priority = 0
                    return {
                        constants.btl_opt_flee: constants.btl_opt_flee,
                        'priority': '6',
                        'pokemon': pokemon,
                        'trainer': trainer
                    }
                #
                else:
                    print self.input_error_text.format(cmd)
                    continue
Пример #4
0
 def choose_battle_option(self, trainer=None, pokemon=None, opposing_pokemon=None, options=None):#, priority_list=None):
     #
     if pokemon is None:
         print "No pokemon.  Pokemon is None."
         return None
     #if priority_list is None:
     #    print "Priority list is none."
     #    return None
     if options is None:
         options = [constants.btl_opt_attack]
     option = None
     #
     while True:
         if len(options) > 1:
             print "What will {} do?".format(pokemon.nickname)
             for opt in options:
                 print opt
             cmd = raw_input("Choose an option: ")
             #ATTACK
             if cmd.lower() in constants.btl_opt_attack.lower() and constants.btl_opt_attack in options:
                 #ATTACK PRIORITTY -7 to 8
                 move = self.choose_attack(pokemon=pokemon)
                 if move is 'back':
                     continue
                 if pokemon.has_status_effect(constants.status_bide):
                     move = move # dont use 
                 else:
                     pokemon.use_move(move)
                 return {constants.btl_opt_attack: move, 'priority': str(move.priority), 'pokemon': pokemon, 'trainer': trainer, 'target':opposing_pokemon} 
                 
             #Pokemon
             elif cmd.lower() in constants.btl_opt_pokemon.lower() and constants.btl_opt_pokemon in options:
                 #Pokemon PRIORITTY 6
                 new_pokemon = self.choose_pokemon(trainer=trainer)
                 if new_pokemon is 'back':
                     continue
                 if pokemon.has_status_effect(status_effect=constants.status_trapped): # Is Trapped
                     print "{} is trapped and cannot escape".format(pokemon.nickname)
                     continue
                 return {constants.btl_opt_switch: new_pokemon, 'priority': '6', 'pokemon': pokemon, 'trainer': trainer} 
             #Items
             elif cmd.lower() in constants.btl_opt_items.lower() and constants.btl_opt_items in options:
                 #Items PRIORITTY 6
                 item = self.choose_item(trainer=trainer)
                 if item is 'back':
                     continue
                 elif (item.type is constants.item_type_medicine or item.type is constants.item_type_berry):
                     wanted_pokemon = self.choose_pokemon_from_list(pokemon_list=trainer.party)
                     if wanted_pokemon is None or (wanted_pokemon.is_fainted() and "Revive" not in item.name):
                         print "You cannot use {} that pokemon!".format(item.name)
                         continue
                     return {constants.btl_opt_items: item, 'priority': '6', 'pokemon': wanted_pokemon, 'trainer': trainer} 
                 elif item.type is constants.item_type_poke_ball:
                     if opposing_pokemon.original_trainer is None:
                         return {constants.btl_opt_items: item, 'priority': '6', 'pokemon': pokemon, 'trainer': trainer, 'target':opposing_pokemon} 
                     else:
                         print "Dont be a theif.  Only catch WILD Pokemon."
                         continue
                 else:
                     print "You cannot use that {} now!".format(item.name)
                     continue
             #Call
             elif cmd.lower() in constants.btl_opt_call.lower() and constants.btl_opt_call in options:
                 #Call PRIORITTY 6
                 return {constants.btl_opt_call: pokemon, 'priority': '6', 'pokemon': pokemon, 'trainer': trainer} 
             #Flee
             elif cmd.lower() in constants.btl_opt_flee.lower() and constants.btl_opt_flee in options:
                 #Flee PRIORITTY 0, 
                 if cmd.lower()  is 'back':
                     continue
                 priority = 6
                 if trainer is None:
                     priority = 0
                 return {constants.btl_opt_flee: constants.btl_opt_flee, 'priority': '6', 'pokemon': pokemon, 'trainer': trainer} 
             #
             else:
                 print self.input_error_text.format(cmd)
                 continue