public function getTemplateParameters() { $teamId = $this->_websoccer->getRequestParameter("teamid"); $players = array(); if ($teamId > 0) { $players = YouthPlayersDataService::getYouthPlayersOfTeam($this->_websoccer, $this->_db, $teamId); } return array("players" => $players); }
public function getTemplateParameters() { $teamId = $this->_websoccer->getUser()->getClubId($this->_websoccer, $this->_db); $players = array(); if ($teamId > 0) { $players = YouthPlayersDataService::getYouthPlayersOfTeam($this->_websoccer, $this->_db, $teamId); $noOfPlayers = count($players); for ($playerIndex = 0; $playerIndex < $noOfPlayers; $playerIndex++) { $players[$playerIndex]["nation_flagfile"] = PlayersDataService::getFlagFilename($players[$playerIndex]["nation"]); } } return array("players" => $players); }
/** * Creates a new formation for specified team. * Will simply take the first 11 players and place them in a 4-4-2 formation. * * @param WebSoccer $websoccer Application context. * @param DbConnection $db DB connection. * @param SimulationMatch $match match model. * @param SimulationTeam $team team model. */ private static function _createRandomFormation(WebSoccer $websoccer, DbConnection $db, SimulationMatch $match, SimulationTeam $team) { // better delete possible previous formation with too few players $db->queryDelete($websoccer->getConfig('db_prefix') . '_youthmatch_player', 'match_id = %d AND team_id = %d', array($match->id, $team->id)); // define the exact default formation $formationPositions = array('T', 'LV', 'IV', 'IV', 'RV', 'LM', 'ZM', 'ZM', 'RM', 'LS', 'RS'); $positionMapping = SimulationHelper::getPositionsMapping(); // set players $players = YouthPlayersDataService::getYouthPlayersOfTeam($websoccer, $db, $team->id); $positionIndex = 0; foreach ($players as $playerinfo) { $mainPosition = $formationPositions[$positionIndex]; $position = $positionMapping[$mainPosition]; $player = new SimulationPlayer($playerinfo['id'], $team, $position, $mainPosition, 3.0, DEFAULT_PLAYER_AGE, $playerinfo['strength'], $playerinfo['strength'], YOUTH_STRENGTH_STAMINA, YOUTH_STRENGTH_FRESHNESS, YOUTH_STRENGTH_SATISFACTION); $player->name = $playerinfo['firstname'] . ' ' . $playerinfo['lastname']; // strength adaption required? if ($player->position != $playerinfo['position']) { $player->strength = round($playerinfo['strength'] * (1 - $websoccer->getConfig('sim_strength_reduction_wrongposition') / 100)); } try { // create record $columns = array('match_id' => $match->id, 'team_id' => $team->id, 'player_id' => $player->id, 'playernumber' => $positionIndex + 1, 'position' => $player->position, 'position_main' => $player->mainPosition, 'name' => $player->name); $db->queryInsert($columns, $websoccer->getConfig('db_prefix') . '_youthmatch_player'); $team->positionsAndPlayers[$player->position][] = $player; } catch (Exception $e) { // could not be stored. Can happen when the youth player moved from the opponent to this team. // then we get a PK violation. We just don't add this player then. } $positionIndex++; if ($positionIndex == 11) { break; } } }