/** * @see ISimulationObserver::onAfterTackle() */ public function onAfterTackle(SimulationMatch $match, SimulationPlayer $winner, SimulationPlayer $looser) { // show mercy when player already is a hero if ($looser->getGoals() > 0 && $looser->getGoals() < 3 && $looser->getAssists() > 0 && $looser->getAssists() < 3) { $looser->downgradeMark(MARK_DOWNGRADE_TACKLE_LOOSER * 0.5); } elseif ($looser->getGoals() < 3 && $looser->getAssists() < 3) { $looser->downgradeMark(MARK_DOWNGRADE_TACKLE_LOOSER); } $winner->improveMark(MARK_IMPROVE_TACKLE_WINNER); $winner->setWonTackles($winner->getWonTackles() + 1); $looser->setLostTackles($winner->getLostTackles() + 1); }
/** * Update overall player statistics and match records of player. * * @param SimulationMatch $match * @param SimulationPlayer $player * @param $isOnPitch TRUE if player is on pitch in the end, FALSE if got removed (substitution or red card or injury). */ private function _updatePlayer(SimulationMatch $match, SimulationPlayer $player, $isOnPitch) { // update match statistics $columns = array('name' => $player->name, 'position_main' => $player->mainPosition, 'grade' => $player->getMark(), 'minutes_played' => $player->getMinutesPlayed(), 'card_yellow' => $player->yellowCards, 'card_red' => $player->redCard, 'goals' => $player->getGoals(), 'strength' => $player->strength, 'ballcontacts' => $player->getBallContacts(), 'wontackles' => $player->getWonTackles(), 'shoots' => $player->getShoots(), 'passes_successed' => $player->getPassesSuccessed(), 'passes_failed' => $player->getPassesFailed(), 'assists' => $player->getAssists(), 'state' => $isOnPitch ? '1' : 'Ausgewechselt'); $this->_db->queryUpdate($columns, $this->_websoccer->getConfig('db_prefix') . '_youthmatch_player', 'match_id = %d AND player_id = %d', array($match->id, $player->id)); // update player record, if actually played if ($this->_websoccer->getConfig('sim_played_min_minutes') <= $player->getMinutesPlayed()) { // query existing statistics $result = $this->_db->querySelect('*', $this->_websoccer->getConfig('db_prefix') . '_youthplayer', 'id = %d', $player->id); $playerinfo = $result->fetch_array(); $result->free(); $strengthChange = $this->_computeStrengthChange($player); // trigger plug-ins $event = new YouthPlayerPlayedEvent($this->_websoccer, $this->_db, I18n::getInstance($this->_websoccer->getConfig('supported_languages')), $player, $strengthChange); PluginMediator::dispatchEvent($event); $yellowRedCards = 0; if ($player->yellowCards == 2) { $yellowCards = 1; $yellowRedCards = 1; } else { $yellowCards = $player->yellowCards; } // ensure that new strength does not exceed boundaries (max/min strength) $strength = $playerinfo['strength'] + $strengthChange; $maxStrength = $this->_websoccer->getConfig('youth_scouting_max_strength'); $minStrength = $this->_websoccer->getConfig('youth_scouting_min_strength'); if ($strength > $maxStrength) { $strengthChange = 0; $strength = $maxStrength; } else { if ($strength < $minStrength) { $strengthChange = 0; $strength = $minStrength; } } // save $columns = array('strength' => $strength, 'strength_last_change' => $strengthChange, 'st_goals' => $playerinfo['st_goals'] + $player->getGoals(), 'st_matches' => $playerinfo['st_matches'] + 1, 'st_assists' => $playerinfo['st_assists'] + $player->getAssists(), 'st_cards_yellow' => $playerinfo['st_cards_yellow'] + $yellowCards, 'st_cards_yellow_red' => $playerinfo['st_cards_yellow_red'] + $yellowRedCards, 'st_cards_red' => $playerinfo['st_cards_red'] + $player->redCard); $this->_db->queryUpdate($columns, $this->_websoccer->getConfig('db_prefix') . '_youthplayer', 'id = %d', $player->id); } }
private static function getPlayerColumns($matchId, SimulationPlayer $player, $fieldArea) { $columns['spiel_id'] = $matchId; $columns['spieler_id'] = $player->id; $columns['team_id'] = $player->team->id; $columns['name'] = $player->name; $columns['note'] = $player->getMark(); $columns['minuten_gespielt'] = $player->getMinutesPlayed(); $columns['karte_gelb'] = $player->yellowCards; $columns['karte_rot'] = $player->redCard; $columns['verletzt'] = $player->injured; $columns['gesperrt'] = $player->blocked; $columns['tore'] = $player->getGoals(); $columns['feld'] = $fieldArea; $columns['position'] = $player->position; $columns['position_main'] = $player->mainPosition; $columns['age'] = $player->age; $columns['w_staerke'] = $player->strength; $columns['w_technik'] = $player->strengthTech; $columns['w_kondition'] = $player->strengthStamina; $columns['w_frische'] = $player->strengthFreshness; $columns['w_zufriedenheit'] = $player->strengthSatisfaction; $columns['ballcontacts'] = $player->getBallContacts(); $columns['wontackles'] = $player->getWonTackles(); $columns['losttackles'] = $player->getLostTackles(); $columns['shoots'] = $player->getShoots(); $columns['passes_successed'] = $player->getPassesSuccessed(); $columns['passes_failed'] = $player->getPassesFailed(); $columns['assists'] = $player->getAssists(); return $columns; }