MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / notifyTeamFighting

Method notifyTeamFighting

source/game/Player.cpp:444–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444void Player::notifyTeamFighting(Player* player, Tile* tile)
445{
446 // We check if there is a fight event currently near this tile. If yes, we update
447 // the time event. If not, we create a new fight event
448 bool isFirstFight = true;
449 for(PlayerEvent* event : mEvents)
450 {
451 if(event->getType() != PlayerEventType::fight)
452 continue;
453
454 // There is already another fight event. We check the distance
455 isFirstFight = false;
456 if(Pathfinding::squaredDistanceTile(*tile, *event->getTile()) < MIN_DIST_EVENT_SQUARED)
457 {
458 // A similar event is already on nearly. We only update it
459 event->setTimeRemain(BATTLE_TIME_COUNT);
460 return;
461 }
462 }
463
464 if(isFirstFight)
465 {
466 ServerNotification *serverNotification = new ServerNotification(
467 ServerNotificationType::playerFighting, this);
468 serverNotification->mPacket << player->getId();
469 ODServer::getSingleton().queueServerNotification(serverNotification);
470
471 std::vector<Seat*> seats;
472 seats.push_back(getSeat());
473 mGameMap->fireRelativeSound(seats, SoundRelativeKeeperStatements::WeAreUnderAttack);
474 }
475
476 // We add the fight event
477 mEvents.push_back(new PlayerEvent(PlayerEventType::fight, tile, BATTLE_TIME_COUNT));
478 fireEvents();
479}
480
481void Player::notifyNoSkillInQueue()
482{

Callers 1

playerIsFightingMethod · 0.80

Calls 7

squaredDistanceTileFunction · 0.85
setTimeRemainMethod · 0.80
fireRelativeSoundMethod · 0.80
getTypeMethod · 0.45
getTileMethod · 0.45
getIdMethod · 0.45

Tested by

no test coverage detected