本文整理汇总了C++中Battle类的典型用法代码示例。如果您正苦于以下问题:C++ Battle类的具体用法?C++ Battle怎么用?C++ Battle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Battle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxLogWarning
void BattleListTab::OnHost( wxCommandEvent& /*unused*/ )
{
if ( !ui().IsConnected() )
{
wxLogWarning( _T( "Trying to host while offline" ) );
customMessageBoxNoModal( SL_MAIN_ICON, _( "You cannot host a game while being offline. Please connect to a lobby server." ), _( "Not Online." ), wxOK );
ui().ShowConnectWindow();
return;
}
if ( !ui().IsSpringCompatible() )
{
wxLogWarning( _T( "Hosting is disabled due to the incompatible version " ) );
customMessageBoxNoModal( SL_MAIN_ICON, _( "Hosting is disabled due to the incompatible version you're using" ), _( "Spring error" ), wxICON_EXCLAMATION | wxOK );
return;
}
Battle* battle = ui().mw().GetJoinTab().GetCurrentBattle();
if ( battle != 0 )
{
if ( ui().Ask( _( "Already in a battle" ), _( "You are already in a battle.\n\nDo you want to leave current battle to start a new?" ) ) ) {
battle->Leave();
ui().mw().GetJoinTab().LeaveCurrentBattle();
}
else
{
return;
}
}
SL::RunHostBattleDialog( this );
}
示例2: wxLogDebugFunc
void ServerEvents::OnUserQuit( const wxString& nick )
{
wxLogDebugFunc( _T("") );
try
{
User &user=m_serv.GetUser( nick );
Battle* userbattle = user.GetBattle();
if ( userbattle )
{
int battleid = userbattle->GetID();
try
{
if ( &userbattle->GetFounder() == &user )
{
for ( int i = 0; i < int(userbattle->GetNumUsers()); i ++ )
{
User& battleuser = userbattle->GetUser( i );
OnUserLeftBattle( battleid, battleuser.GetNick() );
}
OnBattleClosed( battleid );
}
else OnUserLeftBattle( battleid, user.GetNick() );
}catch(...){}
}
ui().OnUserOffline( user );
m_serv._RemoveUser( nick );
if ( useractions().DoActionOnUser( UserActions::ActNotifLogin, nick ) )
actNotifBox( SL_MAIN_ICON, nick + _(" just went offline") );
}
catch (std::runtime_error &except)
{
}
}
示例3: wxLogDebugFunc
void SimpleServerEvents::OnUserQuit( const wxString& nick )
{
wxLogDebugFunc( _T("") );
try
{
User &user=m_serv.GetUser( nick );
Battle* userbattle = user.GetBattle();
if ( userbattle )
{
int battleid = userbattle->GetID();
try
{
if ( &userbattle->GetFounder() == &user )
{
for ( int i = 0; i < int(userbattle->GetNumUsers()); i ++ )
{
User& battleuser = userbattle->GetUser( i );
OnUserLeftBattle( battleid, battleuser.GetNick() );
}
OnBattleClosed( battleid );
}
else OnUserLeftBattle( battleid, user.GetNick() );
}catch(...){}
}
// ui().OnUserOffline( user );
m_serv._RemoveUser( nick );
}
catch (std::runtime_error &except)
{ }
}
示例4: judge_dragon_ship_btl_over
bool judge_dragon_ship_btl_over(Player * player) {
Battle * btl = player->btl;
if (btl->pvp_lv() == pvp_dragon_ship && !btl->is_battle_ended()) {
//failed
Player * player_1 = btl->get_one_player();
if (player_1 && player_1->my_summon) {
if (player_1->pos().x() + 10 >= player_1->my_summon->pos().x() &&
player_1->my_summon->i_ai->common_flag1_) {
end_pvp_on_player_dead(btl, player_1, player_1->team);
return true;
}
}
Player* player_2 = btl->get_one_other_player(player_1);
if (player_2 && player_2->my_summon) {
if (player_2->pos().x() + 10 >= player_2->my_summon->pos().x() &&
player_2->my_summon->i_ai->common_flag1_) {
end_pvp_on_player_dead(btl, player_2, player_2->team);
return true;
}
}
}
return false;
}
示例5:
bool battle_mgr::is_battle_exist(uint32_t battle_id)
{
std::list<Battle*>::iterator pItr = btl_list.begin();
for(; pItr != btl_list.end(); ++pItr)
{
Battle* btl = *pItr;
if(btl->get_battle_id() == battle_id)return true;
}
return false;
}
示例6: setViewString
void BattleEvent::start() {
setViewString("A monster has appeared!");
Battle *nb = new Battle();
MonsterManager &mm = MonsterManager::getInstance();
//Monster *mon = mm.getMonster("centaur"); //mm.randomMonster();
Monster* mon = mm.randomMonster();
rewardval = mon->getReward();
nb->addMonster(mon);
SceneManager::getInstance().push(nb);
}
示例7: battleChanged
void BattleInfo::battleChanged(const Battle & battle)
{
if (battle.id() == battleId_)
{
if (currentMapImage_ != battle.mapName())
{
setMapImage(battle);
}
setHeaderText(battle);
}
}
示例8: centerOnMonsterInTB
void ScourgeView::centerOnMonsterInTB() {
scourge->getMap()->setMapCenterCreature( NULL );
if ( scourge->inTurnBasedCombat() ) {
Battle *battle = scourge->getCurrentBattle();
Creature *c = battle->getCreature();
if ( !c->isPartyMember() || c->getStateMod( StateMod::possessed ) ) {
scourge->getMap()->setMapCenterCreature( c );
scourge->getMap()->center( toint( c->getX() ), toint( c->getY() ), true );
}
}
}
示例9: main
void main(int argc, char** argv) {
/* TODO: Parsing and options */
Battle battle;
battle.initBattle();
Game game;
game.setBattle();
while(!game.isFinished()) {
game.limitFPS();
game.step();
}
return 0;
};
示例10: Battle
size_t AmbushEvent::failure() {
Battle* battle = new Battle(_storage, _raid_participants, _raid_slaves, _raid_resources, _raid_loot);
battle->generate_enemies(FS_MEDIUM);
size_t battle_outcome = battle->play();
delete battle;
if (battle_outcome == BO_RAIDERS_WON) {
increase_misc_stat(MI_MORALE, BATTLE_MORALE_BOOST);
return EO_SUCCESS;
} else {
decrease_misc_stat(MI_MORALE, BATTLE_MORALE_BOOST);
return EO_FAILURE;
}
}
示例11: get_battle_by_id
Battle* battle_mgr::get_battle_by_id(uint32_t battle_id)
{
std::list<Battle*>::iterator pItr = btl_list.begin();
for(; pItr != btl_list.end(); ++pItr)
{
Battle* btl = *pItr;
if(btl->get_battle_id() == battle_id)
{
return btl;
}
}
return NULL;
}
示例12: player_roll_item_cmd
int player_roll_item_cmd(Player* p, uint8_t* body, uint32_t bodylen)
{
CHECK_VAL_EQ(bodylen, (uint32_t)sizeof(player_roll_item_t));
player_roll_item_t* pRoll = reinterpret_cast<player_roll_item_t*>(body);
int32_t roll_point = 0;
bool ret = set_player_roll_point(p, pRoll->battle_id, pRoll->roll_id, pRoll->roll_flag, roll_point);
if( !ret){
return send_header_to_player(p, p->waitcmd, cli_err_roll_item_fail, 1);
}
Battle *btl = p->btl;
//notify the other team player execpt myself and not clear waitcmd
btl->notify_team_roll_point(pRoll->roll_id, p->id, roll_point, p->id);
//notify myself and clear waitcmd
return send_roll_point(p, pRoll->roll_id, roll_point);
}
示例13: Battle
bool EnemyCard::encounter(Character* character, Game* game)
{
game->getUI()->announce("You have encountered a " + this->title() + "!");
Battle * battle = new Battle();
int results = battle->cardFight(character, this, game);
if (results == 1) {
//Player won! Card is added to trophies and removed from the tile.
character->addTrophy(this);
return true;
}
else {
//Stand-off or player has lost. Do not remove card from the tile.
return false;
}
}
示例14: AutoCheckCommandSpam
void SimpleServerEvents::AutoCheckCommandSpam( Battle& battle, User& user )
{
wxString nick = user.GetNick();
MessageSpamCheck info = m_spam_check[nick];
time_t now = time( 0 );
if ( info.lastmessage == now ) info.count++;
else info.count = 0;
info.lastmessage = now;
m_spam_check[nick] = info;
if ( info.count == 7 )
{
battle.DoAction( _T("is autokicking ") + nick + _T(" due to command spam.") );
battle.KickPlayer( user );
}
}
示例15: battle
void BattleInfo::battle(Battle const & battle)
{
battleId_ = battle.id();
setMapImage(battle);
setHeaderText(battle);
}