Example #1
0
        uint16_t get_egg_group_id(const pkmn::pkstring& egg_group_name)
        {
            CONNECT_TO_DB(db);
            if(egg_group_name == "None") return Egg_Groups::NONE;

            std::ostringstream query_stream;
            query_stream << "SELECT egg_group_id FROM egg_group_prose WHERE name='" << egg_group_name << "'";
            SQLite::Statement query(*db, query_stream.str().c_str());
            return get_num_from_query<uint16_t>(query);
        }
Example #2
0
        uint16_t get_ball_id(const pkmn::pkstring& ball_name)
        {
            CONNECT_TO_DB(db);
            if(ball_name == "None" or ball_name == "Unknown") return Balls::UNKNOWN;

            std::ostringstream query_stream;
            query_stream << "SELECT id FROM balls WHERE name='" << ball_name << "'";
            SQLite::Statement query(*db, query_stream.str().c_str());
            return get_num_from_query<uint16_t>(query);
        }
Example #3
0
        pkmn::pkstring get_ball_name(uint16_t ball_id)
        {
            CONNECT_TO_DB(db);
            if(ball_id == Balls::UNKNOWN) return "None";

            std::ostringstream query_stream;
            query_stream << "SELECT name FROM balls WHERE id=" << ball_id;
            SQLite::Statement query(*db, query_stream.str().c_str());
            return get_pkstring_from_query(query);
        }
Example #4
0
        pkmn::pkstring get_egg_group_name(uint16_t egg_group_id)
        {
            CONNECT_TO_DB(db);
            if(egg_group_id == Egg_Groups::NONE) return "None";

            std::ostringstream query_stream;
            query_stream << "SELECT name FROM egg_group_prose WHERE local_language_id=9 AND egg_group_id=" << egg_group_id;
            SQLite::Statement query(*db, query_stream.str().c_str());
            return get_pkstring_from_query(query);
        }
Example #5
0
        pkmn::pkstring get_ability_description(uint16_t ability_id, uint16_t version_id)
        {
            CONNECT_TO_DB(db);
            if(ability_id == Abilities::NONE) return "None";

            std::ostringstream query_stream;
            query_stream << "SELECT flavor_text FROM ability_flavor_text WHERE language_id=9 AND ability_id=" << ability_id
                         << " AND version_group_id=" << get_version_group_id(version_id);
            SQLite::Statement query(*db, query_stream.str().c_str());
            return get_pkstring_from_query(query);
        }
Example #6
0
        uint32_t get_experience(uint16_t species_id, uint16_t level)
        {
            CONNECT_TO_DB(db);
            if(species_id == 0 or level == 0) return 0;

            std::ostringstream query_stream;
            query_stream << "SELECT experience.experience "
                         << "FROM   pokemon_species "
                         << " INNER JOIN experience "
                         << " ON pokemon_species.growth_rate_id = experience.growth_rate_id "
                         << "WHERE  ( pokemon_species.id = " << species_id << " ) "
                         << " AND ( experience.level = " << level << " ) "
                         << "ORDER  BY experience.experience";
            SQLite::Statement query(*db, query_stream.str().c_str());
            return get_num_from_query<uint32_t>(query);
        }
Example #7
0
        uint16_t PKMN_API get_form_id(const pkmn::pkstring& species_name, const pkmn::pkstring& form_name)
        {
            CONNECT_TO_DB(db);

            std::ostringstream query_stream;
            query_stream << "SELECT form_id FROM libpkmn_pokemon_form_names WHERE name='"
                         << form_name << "'";
            SQLite::Statement query(*db, query_stream.str().c_str());
            std::vector<uint16_t> form_ids;
            while(query.executeStep()) form_ids.push_back(query.getColumn(0));
            BOOST_FOREACH(uint16_t id, form_ids)
            {
                query_stream.str("");
                query_stream << "SELECT species_id FROM pokemon WHERE id="
                             << "(SELECT pokemon_id FROM pokemon_forms WHERE id="
                             << id << ")";
                uint16_t species_id = db->execAndGet(query_stream.str().c_str());

                if(database::get_species_id(species_name) == species_id) return id;
            }
void LOGIN_BATCH::RUN_BATCH()
{
    if( G_YONETIM_DB->SQL_TABLES_EXISTS("") EQ true  ) {
        int user_db_count = GET_USER_DB_COUNT( m_user_info->kullanici_id );

        if ( user_db_count > 1 ) {
            int veritabani_secimi = VERITABANI_SEC( m_user_info->kullanici_id , &(m_user_info->veritabani_kodu)
                                                                      , &(m_user_info->veritabani_tanimi),this );
            if ( veritabani_secimi EQ -1 ) {
                return;
            }
        }
        else if (user_db_count EQ 1 ) {
            m_user_info->veritabani_kodu = GET_VERITABANI_ISMI( m_user_info );
        }
    }
    else {
        int secim = MSG_YES_NO( "Veritabanında Tablolar Yok Oluşturulsun mu ?", NULL );
        if ( secim EQ ADAK_YES ) {
            m_user_info->is_first_login = true;
        }
    }

    if ( m_user_info->veritabani_kodu.isEmpty() EQ false ) {

        if ( m_user_info->sql_motoru EQ "YOK" ) {
            if ( PROGRAM_DB_VAR_MI( m_user_info->veritabani_kodu ) EQ false ) {
                MSG_WARNING( "Veritabanı yok!", NULL );
                return;
            }
            else {
                CONNECT_TO_DB( ADAK_PROGRAM, m_user_info, false );
            }
        }
        else {
            DB = CREATE_ADAK_SQL_CONNECTION( GET_PROGRAM_DB_STRUCTS(), QString(SQL_DBNAME_ONEK()+ "adak_" + m_user_info->veritabani_kodu ),
                                              GET_SQL_DB_DRIVER_ENUM( m_user_info->sql_motoru ) );

            if( DB->CONNECT_TO_DATABASE( false ) EQ ADAK_FAIL ) {
                 MSG_WARNING( "Veritabanı yok!", NULL );
                return;
            }
        }

        if( DB->SQL_TABLES_EXISTS("") EQ false ) {
            int secim = MSG_YES_NO( "Veritabanında Tablolar Yok Oluşturulsun mu ?", NULL );
            if ( secim EQ ADAK_YES ) {
               // m_user_info->is_first_login = true;
            }
        }

    }

    m_user_info->kullanici_kodu    = m_ui->line_edit_kullanici_kodu->text();
    m_user_info->kullanici_sifre  = m_ui->line_edit_kullanici_sifre->text();

    *m_all_informations_completed = true;

    m_user_info->is_auto_login = m_ui->check_box_otomatik_login->isChecked();



}
Example #9
0
    move_entry_t::move_entry_t(int version_id,
                               int move_id)
    {   
        CONNECT_TO_DB(db);
        if(not entries_created)
            create_none_invalid_entries();

        if(move_id == Moves::NONE)
        {
            *this = none_entry;
            return;
        }
        else if(move_id == Moves::INVALID)
        {
            *this = invalid_entry;
            return;
        }

        int generation = database::get_generation(version_id);

        std::ostringstream query_stream;
        query_stream << "SELECT generation_id FROM moves WHERE id=" << move_id;
        if(int(db->execAndGet(query_stream.str().c_str())) > generation)
            throw std::runtime_error("This move did not exist in this generation.");

        /*
         * The "moves" table should give us most things.
         */
        query_stream.str("");
        query_stream << "SELECT * FROM moves WHERE id=" << move_id;
        SQLite::Statement moves_query(*db, query_stream.str().c_str());
        moves_query.executeStep();

        name = database::get_move_name(move_id);
        type = database::get_type_name(moves_query.getColumn(3)); // type_id
        damage_class = database::get_move_damage_class_name(int(moves_query.getColumn(9))); // damage_class_id

        power = moves_query.getColumn(4); // power
        pp = moves_query.getColumn(5); // pp
        accuracy = float(moves_query.getColumn(6)) / float(100.0); // accuracy
        priority = moves_query.getColumn(7); // priority

        // effect = 
        effect_chance = float(moves_query.getColumn(11)) / float(100.0); // effect_chance

        /*
         * Description
         */
        query_stream.str("");
        query_stream << "SELECT flavor_text FROM move_flavor_text WHERE move_id="
                     << move_id << " AND language_id=9 AND version_group_id="
                     << database::get_version_group_id(version_id);
        SQLite::Statement flavor_text_query(*db, query_stream.str().c_str());
        try
        {
            description = get_pkstring_from_query(flavor_text_query);
        }
        catch(...)
        {
            description = "Unavailable";
        }

        /*
         * Target
         */
        query_stream.str("");
        query_stream << "SELECT name FROM move_target_prose WHERE move_target_id="
                     << moves_query.getColumn(8) << " AND local_language_id=9"; // target_id
        SQLite::Statement move_target_prose_query(*db, query_stream.str().c_str());
        target = get_pkstring_from_query(move_target_prose_query);

        /*
         * Effect
         * TODO: parse tokens in short_effect
         */
        query_stream.str("");
        query_stream << "SELECT short_effect FROM move_effect_prose WHERE move_effect_id="
                     << moves_query.getColumn(10);  // effect_id
        SQLite::Statement move_effect_prose_query(*db, query_stream.str().c_str());
        effect = get_pkstring_from_query(move_effect_prose_query);

        /*
         * Contest type
         */
        query_stream.str("");
        query_stream << "SELECT name FROM contest_type_names WHERE contest_type_id="
                     << moves_query.getColumn(12) << " AND local_language_id=9"; // contest_type_id
        SQLite::Statement contest_type_names_query(*db, query_stream.str().c_str());
        contest_type = get_pkstring_from_query(contest_type_names_query);

        /*
         * Contest effect
         */
        query_stream.str("");
        query_stream << "SELECT flavor_text FROM contest_effect_prose WHERE contest_effect_id="
                     << moves_query.getColumn(13) << " AND local_language_id=9"; // contest_effect_id
        SQLite::Statement contest_effect_prose_query(*db, query_stream.str().c_str());
        contest_effect = get_pkstring_from_query(contest_effect_prose_query);

        /*
         * Super Contest effect
         */
        query_stream.str("");
        query_stream << "SELECT flavor_text FROM super_contest_effect_prose"
                     << " WHERE super_contest_effect_id=" << moves_query.getColumn(14)
                     << " AND local_language_id=9"; // super_contest_effect_id
        SQLite::Statement super_contest_effect_prose_query(*db, query_stream.str().c_str());
        super_contest_effect = get_pkstring_from_query(super_contest_effect_prose_query);

        /*
         * Database values are valid for Generation VI, this fixes entries
         * from earlier generations.
         */
        if(generation < 6)
        {
            std::ostringstream query_stream;
            query_stream << "SELECT gen" << generation << "_accuracy FROM old_move_accuracies WHERE move_id=" << move_id;
            SQLite::Statement accuracy_query(*db, query_stream.str().c_str());
            if(accuracy_query.executeStep()) accuracy = float(accuracy_query.getColumn(0)) / 100.0;
        
            // Hypnosis varies in accuracy between games
            if(move_id == Moves::HYPNOSIS and (version_id == Versions::DIAMOND or version_id == Versions::PEARL))
                accuracy = 0.7f;

            query_stream.str("");
            query_stream << "SELECT gen" << generation << "_power FROM old_move_powers WHERE move_id=" << move_id;
            SQLite::Statement power_query(*db, query_stream.str().c_str());
            if(power_query.executeStep()) power = power_query.getColumn(0);

            // Shadow Rush varies in power between Gamecube games
            if(move_id == Moves::SHADOW_RUSH and version_id == Versions::COLOSSEUM)
                power = 90; 

            query_stream.str("");
            query_stream << "SELECT gen" << generation << "_pp FROM old_move_pps WHERE move_id=" << move_id;
            SQLite::Statement pp_query(*db, query_stream.str().c_str());
            if(pp_query.executeStep())
                pp = pp_query.getColumn(0);

            // Not enough type changes to warrant a database table
            if(generation == 1)
            {
                if(move_id == Moves::BITE or move_id == Moves::GUST or
                   move_id == Moves::KARATE_CHOP or move_id == Moves::SAND_ATTACK)
                    type = "Normal";
            }
            else if(move_id == Moves::CURSE and generation < 4)
                type = "???";
            else if(move_id == Moves::CHARM or move_id == Moves::MOONLIGHT or
                    move_id == Moves::SWEET_KISS)
                type = "Normal";

            // Only one move changes categories before Generation IV
            if(generation == 1 and move_id == Moves::BITE)
                damage_class = "Physical";
        
            // TODO: targeting changes, making contact

            query_stream.str("");
            query_stream << "SELECT gen" << generation << "_priority FROM old_move_priorities WHERE move_id=" << move_id;
            SQLite::Statement priority_query(*db, query_stream.str().c_str());
            if(priority_query.executeStep())
                priority = priority_query.getColumn(0);

            // Only one move changed name between Generation II-III
            if(move_id == Moves::CONVERSION_2 and generation < 3)
                name = "Conversion2";

            query_stream.str("");
            query_stream << "SELECT name FROM old_move_names WHERE move_id=" << move_id;
            SQLite::Statement name_query(*db, query_stream.str().c_str());
            if(name_query.executeStep())
                name = name_query.getColumn(0);

            if(generation != 4)
                super_contest_effect = "None";

            if(generation < 4)
            {
                query_stream.str("");
                query_stream << "SELECT name FROM move_damage_class_prose WHERE local_language_id=9"
                             << " AND move_damage_class_id=(SELECT damage_class_id FROM types WHERE"
                             << " id=" << database::get_type_id(type) << ")";
                std::string damage_class_name = db->execAndGet(query_stream.str().c_str());
                damage_class_name[0] = ::toupper(damage_class_name[0]);
                damage_class = damage_class_name;
            }

            if(generation < 3)
            {
                contest_type   = "None";
                contest_effect = "None";
            }
        }
    }