bool ChatHandler::BoutiqueLevel(const char* args) { int asklvl = 0; int points = 0; int currentlevel = 0; int prix_level = 0; int i = 0; int bilan = 0; if (!*args) return false; char* px = strtok((char*)args, " "); asklvl = atoi(px); if (asklvl < 0) return false; Player* character = m_session->GetPlayer(); Player* plTarget = NULL; if(!plTarget) plTarget = character; QueryResult result = CharacterDatabase.PQuery("SELECT `points` FROM `compte` WHERE `acct` = '%u'",character->GetSession()->GetAccountId()); if (!result) return false; Field* fields = result->Fetch(); if (!fields) return false; points = fields[0].GetUInt32(); currentlevel = character->getLevel(); if ((currentlevel == 80)||(currentlevel+asklvl > 80)) { m_session->SendNotification("Erreur sur le level demande"); return false; } while (i<asklvl) { currentlevel = character->getLevel() + i; if(coutlevel(currentlevel) == 0) return true; prix_level += coutlevel(currentlevel); i++; } if (prix_level > points) { m_session->SendNotification("Vous n'avez pas assez de points.Il vous faut %u points pour votre demande.",prix_level); return false; } bilan = points - prix_level; CharacterDatabase.PQuery("UPDATE `compte` SET `points` = '%u' WHERE acct='%u'",bilan,character->GetSession()->GetAccountId()); CharacterDatabase.PQuery("INSERT INTO `shop_log` (`id`,`acct`,`type`,`valeur1`,`valeur2`) VALUES ('','%u','level','%u','%u')",character->GetSession()->GetAccountId(),character->getLevel(),asklvl); Levelup(asklvl); m_session->SendNotification("Il vous reste %u points sur votre compte",bilan); return true; }
// 敵抽選はBefore_Battle.cppで行う int BattleMgr( Character_t *Character, EnemySelect_t EnemySelect){ MessageFrame(); switch(BattlePhase){ // 初期化 敵の枠に代入 case 0:for(int i=0;i<4;i++){ if(EnemySelect.Enemy[i]!=0)Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)]); if(EnemySelect.Enemy[i]==0)Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)], FALSE); SecondIni( Enemy[i], i); }BattlePhase=1;break; // 戦闘に入ったとこ case 1:if(DrawBattleMessageString( 0, 1, BattleMenuString)==100)BattlePhase=2;break; // 何を行うかの選択 case 2:switch(DrawMenu( 2, 2, KEY_INPUT_Z, BattleMenu )){ case 0:BattlePhase=4;SpeedChecker( Character, Enemy );break; case 1:break; case 2:BattlePhase=3;break; case 3:break; }break; // 逃げる時の文表示 case 3:if( DrawBattleMessageString( 2, 2, BattleMenuString ) == 100 ){BattlePhase=0;MenuSelect=0;return 2;}break; // 攻撃する敵を選択数 case 4:{ switch(MenuSelect){ case 0:{ DrawFormatString(230,380,GetColor(255,255,255),"勇者はどの敵を攻撃する?"); Attack[0]=DrawCursor( Enemy ); if(Attack[0]!=100){ if(Attack[0]!=200)MenuSelect++; BattlePhase=2; } }break; case 1:{ DrawFormatString(230,380,GetColor(255,255,255),"勇者(二人目)どの敵を攻撃する?"); Attack[1]=DrawCursor( Enemy ); if(Attack[1]!=100){ if(Attack[1]==200)BattlePhase=2; else MenuSelect++; } }break; case 2:{MenuSelect=0;BattlePhase=5;}break; } }break; // 攻撃実行 case 5:{ // 敵四体 for(int i=0;i<4;i++){ if( Enemy[i].Speed==Data[BattleTurn] && doing==0 && (Enemy[i].Speed2==0)){ doing=1; if( Enemy[i].Defense && Enemy[i].HP>0){ switch( DrawBattleMessageString( 5, 6, BattleMenuString, Enemy[i].NameNumber, Damage )){ case 0:if(once==0){Rand=GetRand(1);Damage=DamageCalc( Enemy[i], *(Character+Rand) );once++;}break; case 1:if(Rand!=2)(Character+Rand)->HP-=Damage;Rand=2;break; case 100:Enemy[i].Speed2=1;Rand=0;BattleTurn++;once=0;break; } }else if( Enemy[i].HP<=0 ){ BattleTurn++; Enemy[i].Speed2++; Enemy[i].Flag=0; } } } if( !Character->Speed2 && Character->Speed==Data[BattleTurn] && !doing ){ doing=1; if(Enemy[Attack[0]].Flag){ switch( DrawBattleMessageString( 3, 4, BattleMenuString, Enemy[Attack[0]].NameNumber, Damage )){ case 0:if(!once){Damage=DamageCalc( *Character, Enemy[Attack[0]] );once++;}break; case 1:if(Rand!=2)Enemy[Attack[0]].HP-=Damage;Rand=2;break; case 100:Character->Speed2=1;if(Enemy[Attack[0]].HP<=0)Enemy[Attack[0]].Flag=0;Rand=0;BattleTurn++;once=0;break; } }else BattleTurn+=1; } if( !(Character+1)->Speed2 && (Character+1)->Speed==Data[BattleTurn] && !doing){ doing=1; if(Enemy[Attack[1]].Flag){ switch( DrawBattleMessageString( 3, 4, BattleMenuString, Enemy[Attack[1]].NameNumber, Damage )){ case 0:if(once==0){Damage=DamageCalc( *(Character+1), Enemy[Attack[1]] );once++;}break; case 1:if(Rand!=2)Enemy[Attack[1]].HP-=Damage;Rand=2;break; case 100:(Character+1)->Speed2=1;if(Enemy[Attack[1]].HP<=0)Enemy[Attack[1]].Flag=0;Rand=0;BattleTurn++;once=0;break; } }else BattleTurn+=1; } //BattleTurnが6は全員行動したことになっている if( !doing && BattleTurn==6){ doing=1; BattlePhase=2; for(int i=0; i<4; i++ )Enemy[i].Speed2=0; for(int i=0; i<2; i++)(Character+i)->Speed2=0; //敵全滅 if( Enemy[0].HP<=0 && Enemy[1].HP<=0 && Enemy[2].HP<=0 && Enemy[3].HP<=0 ){ for(int i=0 ; i<4; i++){ //先に経験値の合計を求める EnemyExpSum+=Enemy[i].Ex; Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)], FALSE); } BattlePhase=6; } else BattleTurn=0; } }doing=0;break;//case 5の終了 // 戦闘終了後の処理 case 6:{ if( DrawBattleMessageString( 7, 8, BattleMenuString,0,EnemyExpSum ) == 100 ){ doing=0; BattlePhase=0; BattleTurn=0; for(int i=0; i<4; i++ )Enemy[i].Speed2=0; for(int i=0; i<2; i++)(Character+i)->Speed2=0; if(Character->HP>=0)Character->Ex+=EnemyExpSum; // EnemyExpSumは一度の戦闘で手に入れた経験値の合計 EnemyExpSum=0; if(Levelup(Character)==1)BattlePhase=7; else return 2; } }break; // レベルアップ時 case 7:{ if( DrawBattleMessageString( 9, 9, BattleMenuString, 0, Character->LEVEL) == 100 ){ BattlePhase=0; return 2; } }break; }//switchの終了 //数字表示系 敵の数字を表示 DrawFormatString(420,360,GetColor(255,255,255),"BattleTurn:%d",BattleTurn); DrawFormatString(150,100,GetColor(255,255,255),"%d,%d,%d,%d,%d,%d",Data[0],Data[1],Data[2],Data[3],Data[4],Data[5]); DrawFormatString(150,120,GetColor(0,255,0),"%d",Character->Ex); for(int i=0;i<4;i++)DrawFormatString(320,240+20*i,GetColor(255,255,255),"%d",EnemySelect.Enemy[i]); //条件を満たしている敵の枠のみ表示 for(int i=0; i<4; i++)if(Enemy[i].HP>0 && Enemy[i].Flag==1)DrawGraph( Enemy[i].X+80*i, Enemy[i].Y, Enemy[i].Graph, TRUE ); //勇者側のステータス表示 for(int i=0; i<2; i++){ if( (Character+i)->HP > 0 ){ DrawGauge( 15, 16+35*i, (Character+i)->MaxHP, (Character+i)->HP, GetColor( 0, 255, 0 ), GetColor(0, 255/2, 0),TRUE); DrawGauge( 15, 31+35*i, (Character+i)->MaxMP, (Character+i)->MP, GetColor( 255, 255, 0 ),GetColor( 255/2, 255/2, 0 ),TRUE ); }else if( (Character+i)->HP <=0 ) (Character+i)->HP=0; } if(CheckHitKey(KEY_INPUT_H)==1)return 2; return 4; }