本文整理汇总了C++中CppSQLite3Query::getFloatField方法的典型用法代码示例。如果您正苦于以下问题:C++ CppSQLite3Query::getFloatField方法的具体用法?C++ CppSQLite3Query::getFloatField怎么用?C++ CppSQLite3Query::getFloatField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CppSQLite3Query
的用法示例。
在下文中一共展示了CppSQLite3Query::getFloatField方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadItemsData
//private
void RPGMapItemsMenuLayer::loadItemsData()
{
//道具数据
this->m_itemsList->removeAllObjects();
CppSQLite3Query query = this->m_db->execQuery(ITEMS_EXISTING_QUERY);
while(!query.eof())
{
RPGExistingItems *itemsData = RPGExistingItems::create();
itemsData->m_dataId = query.getIntField("id");
itemsData->m_name = query.getStringField("name_cns");
itemsData->m_buy = query.getIntField("buy");
itemsData->m_sell = query.getIntField("sell");
itemsData->m_type = query.getIntField("type");
itemsData->m_attack = query.getFloatField("attack");
itemsData->m_defense = query.getFloatField("defense");
itemsData->m_speed = query.getFloatField("speed");
itemsData->m_skillAttack = query.getFloatField("skill_attack");
itemsData->m_skillDefense = query.getFloatField("skill_defense");
itemsData->m_total = query.getIntField("total");
this->m_itemsList->addObject(itemsData);
query.nextRow();
}
query.finalize();
CCTableView *tableView = (CCTableView*)this->getChildByTag(kRPGMapItemsMenuLayerTagItemListTable);
tableView->reloadData();
}
示例2: battleSkill
int RPGResultsLogic::battleSkill(CppSQLite3DB* db, RPGBaseRole* srcObjData, int skillId, RPGBaseRole* targetObjData)
{
RPGSkill *skill = NULL;
CppSQLite3Query srcSkillQuery = db->execQuery(CCString::createWithFormat(SKILL_DETAIL_QUERY, skillId)->getCString());
while(!srcSkillQuery.eof())
{
skill = RPGSkill::create();
skill->m_dataId = srcSkillQuery.getIntField("id");
skill->m_MP = srcSkillQuery.getIntField("mp");
skill->m_name = srcSkillQuery.getStringField("name_cns");
skill->m_skillAttack = srcSkillQuery.getFloatField("skill_attack");
skill->m_attr = srcSkillQuery.getFloatField("attr");
srcSkillQuery.nextRow();
}
srcSkillQuery.finalize();
if(skill)
{
//扣减MP
srcObjData->m_MP -= skill->m_MP;
if(srcObjData->m_MP < 0)
srcObjData->m_MP = 0;
switch (skill->m_dataId)
{
case 2:
//回复
return RPGComputingResults::skillCureResults(srcObjData->m_skillAttack, skill->m_skillAttack);
break;
default:
{
//火焰
int val = RPGComputingResults::skillAttackResults(srcObjData->m_skillAttack, skill->m_skillAttack, (RPGSkillAttr)skill->m_attr, targetObjData->m_skillDefense, kRPGSkillAttrNormal); //后面的参数暂定为普通属性
return -val;
}
break;
}
}
return 0;
}
示例3: init
bool RPGMapSceneLayer::init(float showObjectTime)
{
if(RPGBaseSceneLayer::init())
{
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("joystick.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("main.plist");
//加载语言文件
string languageFile = CCFileUtils::sharedFileUtils()->fullPathForFilename("scene_map_cns.plist");
this->m_stringList = CCDictionary::createWithContentsOfFileThreadSafe(languageFile.c_str());
this->m_stringList->retain();
//数据库部分,读取进度记录
CppSQLite3Query query = this->m_db.execQuery(SAVEDATA_MAP_QUERY);
this->m_mapData.mapId = query.getIntField("map_id");
this->m_mapData.mapName = query.getStringField("map_name");
this->m_mapData.hasEnemy = query.getIntField("has_enemy") == 1 ? true : false;
this->m_mapData.bgAudio = query.getStringField("bg_audio");
this->m_mapData.playerToX = query.getFloatField("player_to_x");
this->m_mapData.playerToY = query.getFloatField("player_to_y");
this->m_mapData.playerDirection = query.getStringField("player_direction");
this->m_mapData.location = query.getStringField("location_cns");
this->m_mapData.gold = query.getIntField("gold");
query.finalize();
CCTMXTiledMap *bgMap = CCTMXTiledMap::create(this->m_mapData.mapName.c_str());
bgMap->setTag(kRPGMapSceneLayerTagBgMap);
bgMap->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - bgMap->getContentSize().width) / 2.0, (CCDirector::sharedDirector()->getWinSize().height - bgMap->getContentSize().height) / 2.0));
this->addChild(bgMap);
//背景音乐
if(SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
{
SimpleAudioEngine::sharedEngine()->stopBackgroundMusic(true);
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(this->m_mapData.bgAudio.c_str(), true);
}
this->m_playerMoveAct = NULL;
this->m_playerMoveSpeed = GAME_PLAYER_MOVESPEED;
this->m_touchedDialogNPC = NULL;
this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionNone;
this->m_hasEnemy = this->m_mapData.hasEnemy; //是否会遇敌
this->m_releaseTexture = false; //是否在释构方法里面释放占用纹理
this->scheduleOnce(schedule_selector(RPGMapSceneLayer::startPlay), showObjectTime);
// CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo();
return true;
}
return false;
}
示例4: LoadBlockMap
//必须在task 加载之后
int CPersistencManager::LoadBlockMap(CB_MAP &block_map,CT_MAP &task_map){
if(m_useLevelDB)
{
for(CT_MAP::iterator it = task_map.begin(); it != task_map.end(); it++)
{
const char* guid = it->first.c_str();
CCrackTask* pCT = it->second;
leveldb::ReadOptions ro;
leveldb::Status s;
string value;
int actual_num = 0;
//连在一起申请,不然在deleteTask函数释放时会出错
CCrackBlock* pCBs = new (std::nothrow)CCrackBlock[pCT->m_split_num];
if (!pCBs){
CLog::Log(LOG_LEVEL_ERROR, "Alloc object %d CCrackBlock Error\n", pCT->m_split_num);
return -2;
}
for(int i = 0; i < pCT->m_split_num; i++)
{
s = m_LevelDB->Get(ro, BLOCK_IDX(guid, i), &value);
if(!s.ok()) continue;
s = m_LevelDB->Get(ro, value, &value);
if(!s.ok()) continue;
actual_num ++;
CCrackBlock* item = (CCrackBlock*) value.data();
CCrackBlock *pCB = pCBs + i;
*pCB = *item;
pCB->task = pCT;
pCT->m_crackblock_map.insert(CB_MAP::value_type(pCB->guid,pCB));
block_map.insert(CB_MAP::value_type(pCB->guid, pCB));
}
pCT->m_split_num = actual_num;
}
return 0;
}
int ret = 0;
CT_MAP::iterator cur_iter ;
CT_MAP::iterator end_iter = task_map.end();
CCrackTask *pCT = NULL;
for(cur_iter = task_map.begin(); cur_iter != end_iter; cur_iter++)
{
const char* guid = cur_iter->first.c_str();
pCT = cur_iter->second;
//连在一起申请,不然在deleteTask函数释放时会出错
CCrackBlock* pCBs = new (std::nothrow)CCrackBlock[pCT->m_split_num];
if (!pCBs){
CLog::Log(LOG_LEVEL_ERROR, "Alloc object %d CCrackBlock Error\n", pCT->m_split_num);
return -2;
}
char cmd[1024];
_snprintf(cmd, sizeof(cmd), "select * from Block where taskid='%s'", guid);
CppSQLite3Query query = m_SQLite3DB.execQuery(cmd);
int idx = 0;
while (!query.eof())
{
CCrackBlock *pCB = pCBs + idx;
idx ++;
memset(pCB->john,0,sizeof(pCB->john));
memset(pCB->m_comp_guid,0,sizeof(pCB->m_comp_guid));
memset(pCB->guid,0,sizeof(pCB->guid));
memcpy(pCB->m_comp_guid,query.fieldValue("compip"),strlen(query.fieldValue("compip")));
memcpy(pCB->guid,query.fieldValue("blockid"),strlen(query.fieldValue("blockid")));
pCB->algo = pCT->algo;
pCB->charset = pCT->charset;
pCB->type = query.getIntField("type");
int len;
const unsigned char* info = query.getBlobField("info", len);
memcpy(&(pCB->start), info, len);
int tmpIndex = query.getIntField("index0");
pCB->hash_idx = tmpIndex;
memcpy(pCB->john,pCT->m_crackhash_list[pCB->hash_idx]->m_john,sizeof(pCT->m_crackhash_list[pCB->hash_idx]->m_john));
pCB->special = pCT->special;
pCB->task = pCT;
pCB->m_progress = query.getFloatField("progress");
pCB->m_speed = query.getFloatField("speed");
pCB->m_status = query.getIntField("status");
pCB->m_remaintime = query.getIntField("remaintime");
cur_iter->second->m_crackblock_map.insert(CB_MAP::value_type(pCB->guid,pCB));
//.........这里部分代码省略.........
示例5: LoadHash
//必须在task 加载之后
int CPersistencManager::LoadHash(CT_MAP &task_map){
if(m_useLevelDB)
{
string value;
leveldb::ReadOptions ro;
leveldb::Status s;
for(CT_MAP::iterator it = task_map.begin(); it != task_map.end(); it++)
{
CCrackTask* pCT = it->second;
const char* guid = it->first.c_str();
pCT->m_crackhash_list.resize(pCT->count);
//m_crackhash_list是连在一起的,所以必须一次性初始化,详见CCrackTask::SplitTaskFile
CCrackHash *pCHs = new CCrackHash[pCT->count];
if (!pCHs){
CLog::Log(LOG_LEVEL_ERROR,"Alloc object CCrackHash Error\n");
return -1;
}
for(int i = 0; i < pCT->count; i++)
{
s = m_LevelDB->Get(ro, HASH_KEY(guid, i), &value);
if(!s.ok()) continue;
CCrackHash* hash = (CCrackHash*)value.data();
CCrackHash* pCH = pCHs + i;
*pCH = *hash;
pCT->m_crackhash_list[i] = pCH;
}
}
return 0;
}
int ret = 0;
for(CT_MAP::iterator it = task_map.begin(); it != task_map.end(); it++)
{
const char* guid = it->first.c_str();
CCrackTask *pCT = it->second;
char cmd[1024];
_snprintf(cmd, sizeof(cmd), "select * from Hash where taskid='%s'", guid);
//必须将容器初始化大小
pCT->m_crackhash_list.resize(pCT->count);
//m_crackhash_list是连在一起的,所以必须一次性初始化,详见CCrackTask::SplitTaskFile
CCrackHash *pCHs = new (std::nothrow)CCrackHash[pCT->count];
if (!pCHs){
CLog::Log(LOG_LEVEL_ERROR,"Alloc object CCrackHash Error\n");
return -1;
}
CppSQLite3Query query = m_SQLite3DB.execQuery(cmd);
while (!query.eof())
{
int tmpIndex = query.getIntField("index0");
CCrackHash *pCH = pCHs + tmpIndex;
pCT->m_crackhash_list[tmpIndex] = pCH;
memset(pCH->m_john,0,sizeof(pCH->m_john));
memcpy(pCH->m_john,query.fieldValue("john"),strlen(query.fieldValue("john")));
memset(pCH->m_result,0,sizeof(pCH->m_result));
memcpy(pCH->m_result,query.fieldValue("result"),strlen(query.fieldValue("result")));
pCH->m_status = query.getIntField("status");
pCH->m_progress = query.getFloatField("progress");
query.nextRow();
}
}
return ret;
}
示例6: LoadTaskMap
int CPersistencManager::LoadTaskMap(CT_MAP &task_map){
if(m_useLevelDB)
{
string value;
vector<string> allguids;
leveldb::ReadOptions ro;
leveldb::Status s;
int task_count = 0;
s = m_LevelDB->Get(ro, TASK_COUNT, &value);
if(s.ok())
task_count = *(int*)value.data();
CLog::Log(LOG_LEVEL_DEBUG, "LoadTaskMap: count=%d\n", task_count);
for(int i = 1; i <= task_count; i++)
{
s = m_LevelDB->Get(ro, TASK_IDX(TASK_KEY, i), &value);
if(s.ok())
{
allguids.push_back(value);
}
}
for(int i = 0; i < allguids.size(); i++)
{
s = m_LevelDB->Get(ro, allguids[i], &value);
if(!s.ok()) continue;
//CCrackTask类里面有类,不能直接拷贝构造函数将内存按字节拷贝,咳!
CCrackTask* task = (CCrackTask*)value.data();
CCrackTask* pCT = new CCrackTask();
#ifndef USE_PLACEMANT_NEW
memcpy(pCT, (crack_task*)task, sizeof(crack_task));
memcpy(pCT->m_owner, task->m_owner, sizeof(task->m_owner));
int len = (char*)&task->m_filelen - (char*)&task->m_status + sizeof(task->m_filelen);
memcpy(&pCT->m_status, &task->m_status, len);
#else
memcpy(pCT, task, sizeof(CCrackTask));
//调用placement new对类成员进行初始化
new (&pCT->m_crackblock_map) CB_MAP();
new (&pCT->cur_crack_block) CB_MAP::iterator();
new (&pCT->m_crackhash_list) CRACK_HASH_LIST();
#endif
task_map.insert(CT_MAP::value_type(pCT->guid,pCT));
}
return 0;
}
int ret = 0;
CppSQLite3Query query = m_SQLite3DB.execQuery("select * from Task order by 1;");
while (!query.eof())
{
CCrackTask *pCT = new CCrackTask();
if (!pCT){
CLog::Log(LOG_LEVEL_ERROR,"Alloc object CCrackTask Error\n");
return -1;
}
memset(pCT->guid,0,sizeof(pCT->guid));
memcpy(pCT->guid,query.fieldValue("taskid"),strlen(query.fieldValue("taskid")));
pCT->algo = query.getIntField("algo");
pCT->charset = query.getIntField("charset");
pCT->type = query.getIntField("type");
pCT->special = query.getIntField("filetag");
pCT->single = query.getIntField("single");
int len;
const unsigned char* info = query.getBlobField("info", len);
memcpy(&(pCT->startLength), info, len);
memset(pCT->m_owner,0,sizeof(pCT->m_owner));
memcpy(pCT->m_owner,query.fieldValue("owner"),strlen(query.fieldValue("owner")));
pCT->m_status = query.getIntField("status");
pCT->m_split_num = query.getIntField("splitnum");
pCT->m_finish_num = query.getIntField("finishnum");
pCT->m_bsuccess = (strcmp(query.fieldValue("success"),"1") == 0)? true : false;
pCT->m_progress = query.getFloatField("progress");
pCT->m_speed = query.getFloatField("speed");
pCT->m_start_time = query.getIntField("starttime");
pCT->m_running_time = query.getIntField("runtime");
pCT->m_remain_time = query.getIntField("remaintime");
pCT->count = query.getIntField("count");
if(pCT->type == bruteforce)
CLog::Log(LOG_LEVEL_NOMAL, "[%d %d] %d\n", pCT->startLength, pCT->endLength, pCT->count);
else if(pCT->type == dict)
CLog::Log(LOG_LEVEL_NOMAL, "[dict=%d] %d\n", pCT->dict_idx, pCT->count);
else if(pCT->type == mask)
CLog::Log(LOG_LEVEL_NOMAL, "[mask=%s] %d\n", pCT->masks, pCT->count);
//.........这里部分代码省略.........
示例7: main
int main(int argc, char** argv)
{
try
{
int row;
CppSQLite3DB db;
cout << "SQLite Header Version: " << CppSQLite3DB::SQLiteHeaderVersion() << endl;
cout << "SQLite Library Version: " << CppSQLite3DB::SQLiteLibraryVersion() << endl;
cout << "SQLite Library Version Number: " << CppSQLite3DB::SQLiteLibraryVersionNumber() << endl;
remove(gszFile);
db.open(gszFile);
////////////////////////////////////////////////////////////////////////////////
// Demonstrate getStringField(), getIntField(), getFloatField()
////////////////////////////////////////////////////////////////////////////////
db.execDML("create table parts(no int, name char(20), qty int, cost number);");
db.execDML("insert into parts values(1, 'part1', 100, 1.11);");
db.execDML("insert into parts values(2, null, 200, 2.22);");
db.execDML("insert into parts values(3, 'part3', null, 3.33);");
db.execDML("insert into parts values(4, 'part4', 400, null);");
cout << endl << "CppSQLite3Query getStringField(), getIntField(), getFloatField() tests" << endl;
CppSQLite3Query q = db.execQuery("select * from parts;");
while (!q.eof())
{
cout << q.getIntField(0) << "|";
cout << q.getStringField(1) << "|";
cout << q.getInt64Field(2) << "|";
cout << q.getFloatField(3) << "|" << endl;
q.nextRow();
}
cout << endl << "specify NULL values tests" << endl;
q = db.execQuery("select * from parts;");
while (!q.eof())
{
cout << q.getIntField(0) << "|";
cout << q.getStringField(1, "NULL") << "|";
cout << q.getIntField(2, -1) << "|";
cout << q.getFloatField(3, -3.33) << "|" << endl;
q.nextRow();
}
cout << endl << "Specify fields by name" << endl;
q = db.execQuery("select * from parts;");
while (!q.eof())
{
cout << q.getIntField("no") << "|";
cout << q.getStringField("name") << "|";
cout << q.getInt64Field("qty") << "|";
cout << q.getFloatField("cost") << "|" << endl;
q.nextRow();
}
cout << endl << "specify NULL values tests" << endl;
q = db.execQuery("select * from parts;");
while (!q.eof())
{
cout << q.getIntField("no") << "|";
cout << q.getStringField("name", "NULL") << "|";
cout << q.getIntField("qty", -1) << "|";
cout << q.getFloatField("cost", -3.33) << "|" << endl;
q.nextRow();
}
q.finalize();
////////////////////////////////////////////////////////////////////////////////
// Demonstrate getStringField(), getIntField(), getFloatField()
// But this time on CppSQLite3Table
////////////////////////////////////////////////////////////////////////////////
cout << endl << "CppSQLite3Table getStringField(), getIntField(), getFloatField() tests" << endl;
CppSQLite3Table t = db.getTable("select * from parts;");
for (row = 0; row < t.numRows(); row++)
{
t.setRow(row);
cout << t.getIntField(0) << "|";
cout << t.getStringField(1) << "|";
cout << t.getIntField(2) << "|";
cout << t.getFloatField(3) << "|" << endl;
}
cout << endl << "specify NULL values tests" << endl;
for (row = 0; row < t.numRows(); row++)
{
t.setRow(row);
cout << t.getIntField(0, -1) << "|";
cout << t.getStringField(1, "NULL") << "|";
cout << t.getIntField(2, -1) << "|";
cout << t.getFloatField(3, -3.33) << "|" << endl;
}
cout << endl << "Specify fields by name" << endl;
for (row = 0; row < t.numRows(); row++)
{
t.setRow(row);
cout << t.getIntField("no") << "|";
cout << t.getStringField("name") << "|";
cout << t.getIntField("qty") << "|";
//.........这里部分代码省略.........
示例8: MarkAsPastedThread
UINT CProcessPaste::MarkAsPastedThread(LPVOID pParam)
{
DWORD startTick = GetTickCount();
static CEvent UpdateTimeEvent(TRUE, TRUE, _T("Ditto_Update_Clip_Time"), NULL);
UpdateTimeEvent.ResetEvent();
Log(_T("Start of MarkAsPastedThread"));
//If running from a U3 device then wait a little before updating the db
//updating the db can take a second or two and it delays the act of pasting
if(g_Opt.m_bU3)
{
Sleep(350);
}
BOOL bRet = FALSE;
int clipId = 0;
try
{
MarkAsPastedData* pData = (MarkAsPastedData*)pParam;
if(pData)
{
clipId = pData->clipId;
if(g_Opt.m_bUpdateTimeOnPaste)
{
try
{
if(pData->pastedFromGroup)
{
CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT clipGroupOrder FROM Main ORDER BY clipGroupOrder DESC LIMIT 1"));
if(q.eof() == false)
{
double latestDate = q.getFloatField(_T("clipGroupOrder"));
latestDate += 1;
Log(StrF(_T("Setting clipId: %d, GroupOrder: %f"), pData->clipId, latestDate));
theApp.m_db.execDMLEx(_T("UPDATE Main SET clipGroupOrder = %f where lID = %d;"), latestDate, pData->clipId);
theApp.RefreshClipOrder(pData->clipId);
}
}
else
{
CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT clipOrder FROM Main ORDER BY clipOrder DESC LIMIT 1"));
if(q.eof() == false)
{
double latestDate = q.getFloatField(_T("clipOrder"));
latestDate += 1;
Log(StrF(_T("Setting clipId: %d, order: %f"), pData->clipId, latestDate));
theApp.m_db.execDMLEx(_T("UPDATE Main SET clipOrder = %f where lID = %d;"), latestDate, pData->clipId);
theApp.RefreshClipOrder(pData->clipId);
}
}
}
CATCH_SQLITE_EXCEPTION
}
try
{
theApp.m_db.execDMLEx(_T("UPDATE Main SET lastPasteDate = %d where lID = %d;"), (int)CTime::GetCurrentTime().GetTime(), pData->clipId);
}
CATCH_SQLITE_EXCEPTION
delete pData;
bRet = TRUE;
}
}
CATCH_SQLITE_EXCEPTION
Log(_T("End of MarkAsPastedThread"));
DWORD endTick = GetTickCount();
if((endTick-startTick) > 350)
Log(StrF(_T("Paste Timing MarkAsPastedThread: %d, ClipId: %d"), endTick-startTick, clipId));
UpdateTimeEvent.SetEvent();
return bRet;
}
示例9: equip
void RPGResultsLogic::equip(CppSQLite3DB *db, int playerId, int itemsId)
{
CCString *playerSql = NULL;
CCString *itemsExistingSql = NULL;
int type;
float attack;
float defense;
float speed;
float skillAttack;
float skillDefense;
{
//查询该装备的类型和效果值
CppSQLite3Query query = db->execQuery(CCString::createWithFormat(ITEMS_SINGLE_QUERY, itemsId)->getCString());
while(!query.eof())
{
attack = query.getFloatField("attack");
defense = query.getFloatField("defense");
speed = query.getFloatField("speed");
skillAttack = query.getFloatField("skill_attack");
skillDefense = query.getFloatField("skill_defense");
type = query.getIntField("type");
query.nextRow();
}
query.finalize();
}
string itemField;
if(type == 1)
itemField = "items_id_arms";
else if(type == 2)
itemField = "items_id_armor";
else
return;
//如果已装备了则先卸掉此装备
{
CppSQLite3Query query = db->execQuery(CCString::createWithFormat(PLAYER_SINGLE_QUERY, playerId)->getCString());
while(!query.eof())
{
if(query.getIntField(itemField.c_str()) != 0)
RPGResultsLogic::removeEquip(db, playerId, type);
query.nextRow();
}
query.finalize();
}
//各个值的处理
{
CppSQLite3Query query = db->execQuery(CCString::createWithFormat(PLAYER_SINGLE_QUERY, playerId)->getCString());
while(!query.eof())
{
attack = query.getFloatField("attack") + attack;
defense = query.getFloatField("defense") + defense;
speed = query.getFloatField("speed") + speed;
skillAttack = query.getFloatField("skill_attack") + skillAttack;
skillDefense = query.getFloatField("skill_defense") + skillDefense;
//最大值的处理
if(attack > MAX_STATUS2) attack = MAX_STATUS2;
if(defense > MAX_STATUS2) defense = MAX_STATUS2;
if(speed > MAX_STATUS2) speed = MAX_STATUS2;
if(skillAttack > MAX_STATUS2) skillAttack = MAX_STATUS2;
if(skillDefense > MAX_STATUS2) skillDefense = MAX_STATUS2;
query.nextRow();
}
query.finalize();
}
//player装备了之后各个值发生变化
playerSql = CCString::createWithFormat(PLAYER_UPDATE_STATUS, attack, defense, speed, skillAttack, skillDefense, itemField.c_str(), itemsId, playerId);
{
//扣减装备了的道具
CppSQLite3Query query = db->execQuery(CCString::createWithFormat(EXISTING_ITEMS_TOTAL, itemsId)->getCString());
while(!query.eof())
{
if(query.getIntField(0) <= 1)
itemsExistingSql = CCString::createWithFormat(ITEMS_DISCARD, itemsId);
else
itemsExistingSql = CCString::createWithFormat(ITEMS_DEDUCTIONS, itemsId);
query.nextRow();
}
query.finalize();
}
if(playerSql)
db->execDML(playerSql->getCString());
if(itemsExistingSql)
db->execDML(itemsExistingSql->getCString());
}
示例10: removeEquip
void RPGResultsLogic::removeEquip(CppSQLite3DB *db, int playerId, int type)
{
//武器
CCString *playerSql = NULL;
CCString *itemsExistingSql = NULL;
int itemsId;
string itemField;
if(type == 1)
itemField = "items_id_arms";
else if(type == 2)
itemField = "items_id_armor";
else
return;
{
CppSQLite3Query query = db->execQuery(CCString::createWithFormat(PLAYER_SINGLE_QUERY, playerId)->getCString());
while(!query.eof())
{
itemsId = query.getIntField(itemField.c_str());
query.nextRow();
}
query.finalize();
}
float attack;
float defense;
float speed;
float skillAttack;
float skillDefense;
{
//player将装备卸下后各个值发生变化
CppSQLite3Query query = db->execQuery(CCString::createWithFormat(ITEMS_SINGLE_QUERY, itemsId)->getCString());
while(!query.eof())
{
attack = query.getFloatField("attack");
defense = query.getFloatField("defense");
speed = query.getFloatField("speed");
skillAttack = query.getFloatField("skill_attack");
skillDefense = query.getFloatField("skill_defense");
query.nextRow();
}
query.finalize();
}
//各个值的处理
{
CppSQLite3Query query = db->execQuery(CCString::createWithFormat(PLAYER_SINGLE_QUERY, playerId)->getCString());
while(!query.eof())
{
attack = query.getFloatField("attack") - attack;
defense = query.getFloatField("defense") - defense;
speed = query.getFloatField("speed") - speed;
skillAttack = query.getFloatField("skill_attack") - skillAttack;
skillDefense = query.getFloatField("skill_defense") - skillDefense;
//最小值的处理
if(attack < 0) attack = 0;
if(defense < 0) defense = 0;
if(speed < 0) speed = 0;
if(skillAttack < 0) skillAttack = 0;
if(skillDefense < 0) skillDefense = 0;
query.nextRow();
}
query.finalize();
}
int equipId = 0;
playerSql = CCString::createWithFormat(PLAYER_UPDATE_STATUS, attack, defense, speed, skillAttack, skillDefense, itemField.c_str(), equipId, playerId);
{
//将卸下的装备放回已有道具处
CppSQLite3Query query = db->execQuery(CCString::createWithFormat(EXIST_ITEMS, itemsId)->getCString());
while(!query.eof())
{
if(query.getIntField(0) <= 0)
itemsExistingSql = CCString::createWithFormat(ADD_EXISTING_ITEMS, itemsId);
else
itemsExistingSql = CCString::createWithFormat(UPDATE_EXISTING_ITEMS, itemsId);
query.nextRow();
}
query.finalize();
}
if(playerSql)
db->execDML(playerSql->getCString());
if(itemsExistingSql)
db->execDML(itemsExistingSql->getCString());
}
示例11: useSkillCure
bool RPGResultsLogic::useSkillCure(CppSQLite3DB *db, int srcPlayerId, int targetPlayerId, int srcSkillId)
{
RPGPlayer *srcPlayerData;
RPGSkill *srcSkillData;
RPGPlayer *targetPlayerData;
//查询使用技能的player
CppSQLite3Query srcPlayerQuery = db->execQuery(CCString::createWithFormat(PLAYER_DETAIL_QUERY, srcPlayerId)->getCString());
while(!srcPlayerQuery.eof())
{
srcPlayerData = RPGPlayer::create();
srcPlayerData->m_dataId = srcPlayerQuery.getIntField("id");
srcPlayerData->m_maxMP = srcPlayerQuery.getIntField("max_mp");
srcPlayerData->m_MP = srcPlayerQuery.getIntField("mp");
srcPlayerData->m_skillAttack = srcPlayerQuery.getFloatField("skill_attack");
srcPlayerQuery.nextRow();
}
srcPlayerQuery.finalize();
//查询使用的技能
CppSQLite3Query srcSkillQuery = db->execQuery(CCString::createWithFormat(SKILL_DETAIL_QUERY, srcSkillId)->getCString());
while(!srcSkillQuery.eof())
{
srcSkillData = RPGSkill::create();
srcSkillData->m_dataId = srcSkillQuery.getIntField("id");
srcSkillData->m_MP = srcSkillQuery.getIntField("mp");
srcSkillData->m_name = srcSkillQuery.getStringField("name_cns");
srcSkillData->m_skillAttack = srcSkillQuery.getFloatField("skill_attack");
srcSkillData->m_attr = srcSkillQuery.getFloatField("attr");
srcSkillQuery.nextRow();
}
srcSkillQuery.finalize();
//查询目标player
CppSQLite3Query targetPlayerQuery = db->execQuery(CCString::createWithFormat(PLAYER_DETAIL_QUERY, targetPlayerId)->getCString());
while(!targetPlayerQuery.eof())
{
targetPlayerData = RPGPlayer::create();
targetPlayerData->m_dataId = targetPlayerQuery.getIntField("id");
targetPlayerData->m_maxHP = targetPlayerQuery.getIntField("max_hp");
targetPlayerData->m_HP = targetPlayerQuery.getIntField("hp");
targetPlayerQuery.nextRow();
}
targetPlayerQuery.finalize();
//执行逻辑
if(srcPlayerData && srcSkillData && targetPlayerData)
{
//计算player时候技能后的效果值
int targetResults = RPGComputingResults::skillCureResults(srcPlayerData->m_skillAttack, srcSkillData->m_skillAttack);
targetPlayerData->m_HP += targetResults;
CCLog("player %i 回复了 %i HP", targetPlayerId, targetResults);
//超过HP最大值
if(targetPlayerData->m_HP > targetPlayerData->m_maxHP)
targetPlayerData->m_HP = targetPlayerData->m_maxHP;
db->execDML(CCString::createWithFormat(PLAYER_UPDATE, "hp", targetPlayerData->m_HP, targetPlayerData->m_dataId)->getCString());
//扣减使用者的MP
srcPlayerData->m_MP -= srcSkillData->m_MP;
if(srcPlayerData->m_MP < 0)
srcPlayerData->m_MP = 0;
CCLog("player %i 消耗了 %i MP", srcPlayerId, srcSkillData->m_MP);
db->execDML(CCString::createWithFormat(PLAYER_UPDATE, "mp", srcPlayerData->m_MP, srcPlayerData->m_dataId)->getCString());
}
return true;
}
示例12: RemoveOldEntries
BOOL RemoveOldEntries(bool checkIdleTime)
{
Log(StrF(_T("Beginning of RemoveOldEntries MaxEntries: %d - Keep days: %d"), CGetSetOptions::GetMaxEntries(), CGetSetOptions::GetExpiredEntries()));
try
{
CppSQLite3DB db;
CString csDbPath = CGetSetOptions::GetDBPath();
db.open(csDbPath);
if(CGetSetOptions::GetCheckForMaxEntries())
{
long lMax = CGetSetOptions::GetMaxEntries();
if(lMax >= 0)
{
CClipIDs IDs;
int clipId;
CppSQLite3Query q = db.execQueryEx(_T("SELECT lID, lShortCut, lParentID, lDontAutoDelete, stickyClipOrder, stickyClipGroupOrder FROM Main WHERE bIsGroup = 0 ORDER BY clipOrder DESC LIMIT -1 OFFSET %d"), lMax);
while(q.eof() == false)
{
int shortcut = q.getIntField(_T("lShortCut"));
int dontDelete = q.getIntField(_T("lDontAutoDelete"));
int parentId = q.getIntField(_T("lParentID"));
double stickyClipOrder = q.getFloatField(_T("stickyClipOrder"));
double stickyClipGroupOrder = q.getFloatField(_T("stickyClipGroupOrder"));
//Only delete entries that have no shortcut and don't have the flag set and aren't in groups and
if(shortcut == 0 &&
dontDelete == 0 &&
parentId <= 0 &&
stickyClipOrder == 0.0 &&
stickyClipGroupOrder == 0.0)
{
clipId = q.getIntField(_T("lID"));
IDs.Add(clipId);
Log(StrF(_T("From MaxEntries - Deleting Id: %d"), clipId));
}
q.nextRow();
}
if(IDs.GetCount() > 0)
{
IDs.DeleteIDs(false, db);
}
}
}
if(CGetSetOptions::GetCheckForExpiredEntries())
{
long lExpire = CGetSetOptions::GetExpiredEntries();
if(lExpire)
{
CTime now = CTime::GetCurrentTime();
now -= CTimeSpan(lExpire, 0, 0, 0);
CClipIDs IDs;
CppSQLite3Query q = db.execQueryEx(_T("SELECT lID FROM Main ")
_T("WHERE lastPasteDate < %d AND ")
_T("bIsGroup = 0 AND lShortCut = 0 AND lParentID <= 0 AND lDontAutoDelete = 0 AND stickyClipOrder = 0 AND stickyClipGroupOrder = 0"), (int)now.GetTime());
while(q.eof() == false)
{
IDs.Add(q.getIntField(_T("lID")));
Log(StrF(_T("From Clips Expire - Deleting Id: %d"), q.getIntField(_T("lID"))));
q.nextRow();
}
if(IDs.GetCount() > 0)
{
IDs.DeleteIDs(false, db);
}
}
}
int toDeleteCount = db.execScalar(_T("SELECT COUNT(clipID) FROM MainDeletes"));
Log(StrF(_T("Before Deleting emptied out data, count: %d, Idle Seconds: %f"), toDeleteCount, IdleSeconds()));
//Only delete 1 at a time, was finding that it was taking a long time to delete clips, locking the db and causing other queries
//to lock up
CppSQLite3Query q = db.execQueryEx(_T("SELECT * FROM MainDeletes LIMIT %d"), CGetSetOptions::GetMainDeletesDeleteCount());
int deleteCount = 0;
while(q.eof() == false)
{
double idleSeconds = IdleSeconds();
if(checkIdleTime == false || idleSeconds > CGetSetOptions::GetIdleSecondsBeforeDelete())
{
//delete any data items sitting out there that the main table data was deleted
//this was done to speed up deleted from the main table
deleteCount = db.execDMLEx(_T("DELETE FROM MainDeletes WHERE clipID=%d"), q.getIntField(_T("clipID")));
}
else
{
//.........这里部分代码省略.........