void Fight::moveUnit( FightCell * cell ) { GenericFightCell * current; QStack<GenericFightCell> path = _map->computePath( _activeUnit, cell ); while( ! path.isEmpty() ) { current = path.pop(); _socket->sendFightUnitMove( giveClass( _activeUnit ), giveNum( _activeUnit ), current ); } _socket->sendFightUnitEndMove(); _activeUnit->setActive( false ); _map->clearPath(); }
void Fight::slot_mouseLeftPressed( FightCell * cell ) { if( _activeUnit && _isActive ) { switch( cell->getAccess() ) { case NEAR: moveUnit( cell ); break; case NEAR_OCCUPIED: moveUnit( cell ); break; case FAR_OCCUPIED: if( ( _activeUnit->getDistAttack() > 0 ) && ( isOpponent( cell->getUnit() ) ) ) { _socket->sendFightDistAttack( giveClass( cell->getUnit() ), giveNum( cell->getUnit() ) ); _socket->sendFightUnitEndMove(); } break; default: break; } } }
void Fight::slot_mouseLeftPressed( FightCell * cell, bool isUnit ) { AttalPopup * popup = this->findChild<AttalPopup *>("AttalFightPopup"); if( popup && popup->isVisible() ) { popup->hide(); popup->setType(); return; } AttalCommon::FightCellAccess access = cell->getAccess(); TRACE("left pressed cell access %d, active unit %p , isActive %d", access, _activeUnit, _isActive); TRACE("cell->getUnit %p, isUnit %d dist %d", cell->getUnit(), isUnit, cell->getDist() ); TRACE("cell row %d, col %d", cell->getRow(), cell->getCol() ); GenericFightCell * neib = NULL; GenericFightUnit * oppunit = cell->getUnit(); if( oppunit && !isOpponent( oppunit ) ) { return; } if( _activeUnit && _isActive ) { switch( access ) { case AttalCommon::NEAR_FREE : TRACE("NEAR_FREE"); moveUnit( cell ); break; case AttalCommon::NEAR_OCCUPIED: TRACE("NEAR_OCCUPIED"); if( _activeUnit->getDistAttack() > 0 && oppunit ) { _socket->sendFightDistAttack( giveClass( oppunit ), giveNum( oppunit ) ); _socket->sendFightUnitEndMove(); } else if ( oppunit ) { moveUnit( cell ); } else { neib = _map->getHeadCell( cell ,_activeUnit->isLookingToRight() ); if( neib ) { oppunit = neib->getUnit(); if ( ( oppunit ) && ( isOpponent ( oppunit ) ) ) { moveUnit( neib ); } } } break; case AttalCommon::FAR_OCCUPIED: TRACE("FAR_OCCUPIED"); if( ( oppunit ) && ( _activeUnit->getDistAttack() > 0 ) ) { _socket->sendFightDistAttack( giveClass( oppunit ), giveNum( oppunit ) ); _socket->sendFightUnitEndMove(); } else { neib = _map->getHeadCell( cell , !_activeUnit->isLookingToRight() ); if( neib ) { oppunit = neib->getHeadUnit(); if( oppunit && neib->getAccess()== AttalCommon::NEAR_OCCUPIED && ( isOpponent ( oppunit ) ) ) { moveUnit( neib ); } } } break; default: break; } } }
int main(int argc, const char* argv[]) { int out; out = giveNum(); return out; }