/**
  * @see ISimulationObserver::onGoal()
  */
 public function onGoal(SimulationMatch $match, SimulationPlayer $scorer, SimulationPlayer $goaly)
 {
     $assistPlayerName = $match->getPreviousPlayerWithBall() !== NULL && $match->getPreviousPlayerWithBall()->team->id == $scorer->team->id ? $match->getPreviousPlayerWithBall()->name : '';
     if (strlen($assistPlayerName)) {
         $this->_createMessage($match, 'Tor_mit_vorlage', array($scorer->name, $assistPlayerName), $scorer->team->id == $match->homeTeam->id);
     } else {
         $this->_createMessage($match, 'Tor', array($scorer->name, $goaly->name), $scorer->team->id == $match->homeTeam->id);
     }
 }
 private static function updateMatch(WebSoccer $websoccer, DbConnection $db, SimulationMatch $match)
 {
     if ($match->isCompleted) {
         $columns['berechnet'] = 1;
     }
     $columns['minutes'] = $match->minute;
     $columns['soldout'] = $match->isSoldOut ? '1' : '0';
     $columns['home_tore'] = $match->homeTeam->getGoals();
     $columns['gast_tore'] = $match->guestTeam->getGoals();
     $columns['home_setup'] = $match->homeTeam->setup;
     $columns['gast_setup'] = $match->guestTeam->setup;
     $columns['home_offensive'] = $match->homeTeam->offensive;
     $columns['gast_offensive'] = $match->guestTeam->offensive;
     $columns['home_noformation'] = $match->homeTeam->noFormationSet ? '1' : '0';
     $columns['guest_noformation'] = $match->guestTeam->noFormationSet ? '1' : '0';
     $columns['home_longpasses'] = $match->homeTeam->longPasses ? '1' : '0';
     $columns['gast_longpasses'] = $match->guestTeam->longPasses ? '1' : '0';
     $columns['home_counterattacks'] = $match->homeTeam->counterattacks ? '1' : '0';
     $columns['gast_counterattacks'] = $match->guestTeam->counterattacks ? '1' : '0';
     $columns['home_morale'] = $match->homeTeam->morale;
     $columns['gast_morale'] = $match->guestTeam->morale;
     if ($match->getPlayerWithBall() != null) {
         $columns['player_with_ball'] = $match->getPlayerWithBall()->id;
     } else {
         $columns['player_with_ball'] = 0;
     }
     if ($match->getPreviousPlayerWithBall() != null) {
         $columns['prev_player_with_ball'] = $match->getPreviousPlayerWithBall()->id;
     } else {
         $columns['prev_player_with_ball'] = 0;
     }
     $columns['home_freekickplayer'] = $match->homeTeam->freeKickPlayer != NULL ? $match->homeTeam->freeKickPlayer->id : '';
     $columns['gast_freekickplayer'] = $match->guestTeam->freeKickPlayer != NULL ? $match->guestTeam->freeKickPlayer->id : '';
     // substitutions
     if (is_array($match->homeTeam->substitutions)) {
         $subIndex = 1;
         foreach ($match->homeTeam->substitutions as $substitution) {
             $columns['home_w' . $subIndex . '_raus'] = $substitution->playerOut->id;
             $columns['home_w' . $subIndex . '_rein'] = $substitution->playerIn->id;
             $columns['home_w' . $subIndex . '_minute'] = $substitution->minute;
             $columns['home_w' . $subIndex . '_condition'] = $substitution->condition;
             $columns['home_w' . $subIndex . '_position'] = $substitution->position;
             $subIndex++;
         }
     }
     if (is_array($match->guestTeam->substitutions)) {
         $subIndex = 1;
         foreach ($match->guestTeam->substitutions as $substitution) {
             $columns['gast_w' . $subIndex . '_raus'] = $substitution->playerOut->id;
             $columns['gast_w' . $subIndex . '_rein'] = $substitution->playerIn->id;
             $columns['gast_w' . $subIndex . '_minute'] = $substitution->minute;
             $columns['gast_w' . $subIndex . '_condition'] = $substitution->condition;
             $columns['gast_w' . $subIndex . '_position'] = $substitution->position;
             $subIndex++;
         }
     }
     $fromTable = $websoccer->getConfig('db_prefix') . '_spiel';
     $whereCondition = 'id = %d';
     $parameters = $match->id;
     $db->queryUpdate($columns, $fromTable, $whereCondition, $parameters);
 }
 private function _kickoff(SimulationMatch $match, SimulationPlayer $scorer)
 {
     // let kick-off the opponent
     $match->setPlayerWithBall(SimulationHelper::selectPlayer(SimulationHelper::getOpponentTeam($scorer, $match), PLAYER_POSITION_DEFENCE, null));
 }
 /**
  * (non-PHPdoc)
  * @see ISimulationObserver::onCorner()
  */
 public function onCorner(SimulationMatch $match, SimulationPlayer $concededByPlayer, SimulationPlayer $targetPlayer)
 {
     // simply improve mark for successful pass
     $match->setPlayerWithBall($concededByPlayer);
     $concededByPlayer->improveMark(MARK_IMPROVE_BALLPASS_SUCCESS);
     $concededByPlayer->setPassesSuccessed($concededByPlayer->getPassesSuccessed() + 1);
 }