Coder Social home page Coder Social logo

acta2000 / open-websoccer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ihofmann/open-websoccer

1.0 1.0 0.0 4.96 MB

A PHP based online football/soccer manager game.

License: GNU Lesser General Public License v3.0

PHP 85.22% JavaScript 7.10% HTML 7.19% CSS 0.46% Shell 0.03% Makefile 0.01%

open-websoccer's People

Contributors

acta2000 avatar ihofmann avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

open-websoccer's Issues

Vereinspokale Code

<html>
<head>
<style>

.vitrine {
overflow:hidden;
}

.pokal {
float: left;
height:  220px;
margin-right:5px;
margin-bottom:10px;


}

.pokalbild {
position: relative;
height: 170px;
border-top: 4px solid #D0D2D5;
border-left: 4px solid #D0D2D5;
border-right: 4px solid #D0D2D5;
}

.layer {
position: absolute;
bottom: 0;
}

.pokalbild img {
max-width: 120px;
}

.pokal .titel {
background-color: #0088cc;
color: #fff;
width: 128px;
height: 50px;
display:table-cell;
vertical-align:middle;
text-align:center;
font-size: 12px;


}

</style>

</head>

<div class="vitrine">

<div class="pokal">
<div class="pokalbild">
  <div class="layer"> <img src="https://round-football.de/websoccer/uploads/league/e7a7ba877ebee372328b288789916836.png" title="Meisterschaft"></div></div>
  <div class="titel">Champions League 2018/2019</div>
 
</div>

<div class="pokal">
<div class="pokalbild">
  <div class="layer"><img src="https://round-football.de/websoccer/uploads/league/e7a7ba877ebee372328b288789916836.png" title="Meisterschaft"></div></div>
  <div class="titel">FT-Pokal 2018/2019</div>

</div>
<div class="pokal">
<div class="pokalbild">
 <div class="layer"> <img src="https://moocit.de/images/5/5c/DFL-Meister-Schale_web.png" title="Meisterschaft"></div></div>
  <div class="titel">1. Bundesliga 2018/2019</div>
</div>

<div class="pokal">
<div class="pokalbild">
 <div class="layer"> <img src="https://moocit.de/images/5/5c/DFL-Meister-Schale_web.png" title="Meisterschaft"></div></div>
  <div class="titel">1. Bundesliga 2018/2019</div>
</div>

<div class="pokal">
<div class="pokalbild">
 <div class="layer"> <img src="https://moocit.de/images/5/5c/DFL-Meister-Schale_web.png" title="Meisterschaft"></div></div>
  <div class="titel">1. Bundesliga 2018/2019</div>
</div>

<div class="pokal">
<div class="pokalbild">
 <div class="layer"> <img src="https://moocit.de/images/5/5c/DFL-Meister-Schale_web.png" title="Meisterschaft"></div></div>
  <div class="titel">1. Bundesliga 2018/2019</div>
</div>

<div class="pokal">
<div class="pokalbild">
 <div class="layer"> <img src="https://moocit.de/images/5/5c/DFL-Meister-Schale_web.png" title="Meisterschaft"></div></div>
  <div class="titel">1. Bundesliga 2018/2019</div>
</div>

<div class="pokal">
<div class="pokalbild">
 <div class="layer"> <img src="https://moocit.de/images/5/5c/DFL-Meister-Schale_web.png" title="Meisterschaft"></div></div>
  <div class="titel">1. Bundesliga 2018/2019</div>
</div>

<div class="pokal">
<div class="pokalbild">
 <div class="layer"> <img src="https://moocit.de/images/5/5c/DFL-Meister-Schale_web.png" title="Meisterschaft"></div></div>
  <div class="titel">1. Bundesliga 2018/2019</div>
</div>

</div>
</body>
</html>

TL-Generator einzelne Player auswählen

For Player in Players

checkbox in my teamoverview.twig

value: player.id
name: players[]

Das ganze kommt dann als Array an.

<?php

$base5 = array("Sonntag","Montag","Dienstag");

foreach ($base5 as $value) {

$pattern91a = '#';
$pattern91b = '#Uis';
$pattern91 = $pattern91a.$value.$pattern91b;
$ts = preg_replace($pattern91, $replacement, $ts);
}
// $arr ist nun array(2, 4, 6, 8)
unset($value); // Entferne die Referenz auf das letzte Element

echo $ts;

Neues Feld Vereins-Pokale

websoccer/modules/clubs/entitymessages_de.xml
websoccer/templates/default/views/upload_clublogo.twig
open-websoccer/websoccer/modules/clubslogo/module.xml
websoccer/classes/actions/UploadClubPictureController.class.php

open-websoccer/websoccer/modules/clubs/module.xml
Bereich editform

Leihspieler in Teamübersicht anzeigen

modules/lending/module.xml

<block id="lent-players-teamdetails"
            template="lent_players"
            model="LentPlayersModel"
            role="user,guest"
            includepages="all"
			area="custom" />

			
			oder 
			
			
<block id="lent-players-teamdetails"
            template="lent_players"
            model="LentPlayersTeamDetailsModel"
            role="user,guest"
            includepages="all"
			area="custom" />


{{ viewHandler.renderBlock('lent-players-teamdetails')|raw }}

default/views/team-details.twig

 <li><a href="#lents" data-toggle="tab" class="ajaxLink"
data-ajaxtarget="lentplayers" data-ajaxblock="lent-players-teamdetails" data-ajaxquerystr="teamid={{ team.team_id }}">{{ i18n.getMessage("results_tab_latest_results") }}</a></li>

  <div class="tab-pane" id="lents">
  	<div id="lentplayers">{{ viewHandler.renderBlock('lent-players-teamdetails')|raw }}</div>
</div>


models/LentPlayersTeamDetailsModel.class.php

<?php
/******************************************************
  This file is part of OpenWebSoccer-Sim.
  OpenWebSoccer-Sim is free software: you can redistribute it 
  and/or modify it under the terms of the 
  GNU Lesser General Public License 
  as published by the Free Software Foundation, either version 3 of
  the License, or any later version.
  OpenWebSoccer-Sim is distributed in the hope that it will be
  useful, but WITHOUT ANY WARRANTY; without even the implied
  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  See the GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public 
  License along with OpenWebSoccer-Sim.  
  If not, see <http://www.gnu.org/licenses/>.
******************************************************/
/**
 * Provides players of own team which are lended to other teams.
 */
class LentPlayersTeamDetailsModel implements IModel {
	private $_db;
	private $_i18n;
	private $_websoccer;
	
	public function __construct($db, $i18n, $websoccer) {
		$this->_db = $db;
		$this->_i18n = $i18n;
		$this->_websoccer = $websoccer;
	}
	
	/**
	 * (non-PHPdoc)
	 * @see IModel::renderView()
	 */
	public function renderView() {
		return TRUE;
	}
	
	/**
	 * (non-PHPdoc)
	 * @see IModel::getTemplateParameters()
	 */
	public function getTemplateParameters() {
		
		$teamId = $this->_websoccer->getRequestParameter('teamid');
		$columns = array(
				"P.id" => "id",
				"vorname" => "firstname",
				"nachname" => "lastname",
				"kunstname" => "pseudonym",
				"position" => "position",
				"position_main" => "position_main",
				"position_second" => "position_second",
				"nation" => "player_nationality",
				"lending_matches" => "lending_matches",
				"lending_fee" => "lending_fee",
				"C.id" => "team_id",
				"C.name" => "team_name"
		);
		
		if ($this->_websoccer->getConfig('players_aging') == 'birthday') {
			$ageColumn = 'TIMESTAMPDIFF(YEAR,geburtstag,CURDATE())';
		} else {
			$ageColumn = 'age';
		}
		$columns[$ageColumn] = 'age';
		
		$dbPrefix = $this->_websoccer->getConfig("db_prefix");
		$fromTable = $dbPrefix . "_spieler P INNER JOIN " . $dbPrefix . "_verein C ON C.id = P.verein_id";
		$whereCondition = "P.status = 1 AND lending_owner_id = %d";
		
		$whereCondition .= " ORDER BY lending_matches ASC, position ASC, position_main ASC, nachname ASC, vorname ASC";
		
		$result = $this->_db->querySelect($columns, $fromTable, $whereCondition, $teamId, 50);
		
		$players = array();
		while ($player = $result->fetch_array()) {
			$player["position"] = PlayersDataService::_convertPosition($player["position"]);
			$players[] = $player;
		}
		$result->free();
		
		return array('lentplayers' => $players);
	}
	
}
?>

user erfolge

<?php
/******************************************************

  This file is part of OpenWebSoccer-Sim.

  OpenWebSoccer-Sim is free software: you can redistribute it 
  and/or modify it under the terms of the 
  GNU Lesser General Public License 
  as published by the Free Software Foundation, either version 3 of
  the License, or any later version.

  OpenWebSoccer-Sim is distributed in the hope that it will be
  useful, but WITHOUT ANY WARRANTY; without even the implied
  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  See the GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public 
  License along with OpenWebSoccer-Sim.  
  If not, see <http://www.gnu.org/licenses/>.

******************************************************/

class TeamDetailsModel implements IModel {
	private $_db;
	private $_i18n;
	private $_websoccer;
	
	public function __construct($db, $i18n, $websoccer) {
		$this->_db = $db;
		$this->_i18n = $i18n;
		$this->_websoccer = $websoccer;
	}
	
	/**
	 * (non-PHPdoc)
	 * @see IModel::renderView()
	 */
	public function renderView() {
		return TRUE;
	}
	
	/**
	 * (non-PHPdoc)
	 * @see IModel::getTemplateParameters()
	 */
	public function getTemplateParameters() {
		
		$teamId = (int) $this->_websoccer->getRequestParameter('id');
		if ($teamId < 1) {
			throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND));
		}
		
		$team = TeamsDataService::getTeamById($this->_websoccer, $this->_db, $teamId);
		if (!isset($team['team_id'])) {
			throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND));
		}
		
		$stadium = StadiumsDataService::getStadiumByTeamId($this->_websoccer, $this->_db, $teamId);
		
		// compute strength level of national team
		if ($team['is_nationalteam']) {
			$dbPrefix = $this->_websoccer->getConfig('db_prefix') ;
			$result = $this->_db->querySelect('AVG(P.w_staerke) AS avgstrength', 
					$dbPrefix . '_spieler AS P INNER JOIN ' . $dbPrefix . '_nationalplayer AS NP ON P.id = NP.player_id', 
					'NP.team_id = %d', $team['team_id']);
			$players = $result->fetch_array();
			$result->free();
			if ($players) {
				$team['team_strength'] = $players['avgstrength'];
			}
		}
		
		if (!$team['is_nationalteam']) {
			$playerfacts = $this->getPlayerFacts($teamId);
		} else {
			$playerfacts = array();
		}
		
		$team['victories'] = $this->getVictories($team['team_id'], $team['team_league_id']);
		$team['cupvictories'] = $this->getCupVictories($team['team_id']);
		return array('team' => $team, 'stadium' => $stadium, 'playerfacts' => $playerfacts);
	}
	
	private function getVictories($teamId, $leagueId) {
		
		$fromTable = $this->_websoccer->getConfig('db_prefix') .'_saison AS S INNER JOIN ' . $this->_websoccer->getConfig('db_prefix') . '_liga AS L ON L.id = S.liga_id';
		
		$columns['S.name'] = 'season_name';
		$columns['L.name'] = 'league_name';
		$columns['L.pokal'] = 'league_pokal';
		$columns['platz_1_id'] = 'season_first';
		$columns['platz_2_id'] = 'season_second';
		$columns['platz_3_id'] = 'season_third';
		$columns['platz_4_id'] = 'season_fourth';
		$columns['platz_5_id'] = 'season_fivth';
		
		$whereCondition = 'beendet = 1 AND (platz_1_id = %d)';
		$parameters = $teamId;
		
		$victories = array();
		
		$result = $this->_db->querySelect($columns, $fromTable, $whereCondition, $parameters);
		while ($season = $result->fetch_array()) {
			$place = 1;
			if ($season['season_second'] == $teamId) {
				$place = 2;
			} else if ($season['season_third'] == $teamId) {
				$place = 3;
			} else if ($season['season_fourth'] == $teamId) {
				$place = 4;
			} else if ($season['season_fivth'] == $teamId) {
				$place = 5;
			}
			
			$victories[] = array('season_name' => $season['season_name'], 'season_place' => $place, 'league_name' => $season['league_name'], 'league_pokal' => $season['league_pokal']);
		}
		$result->free();
		return $victories;
	}
	
	private function getCupVictories($teamId) {
		$fromTable = $this->_websoccer->getConfig('db_prefix') .'_cup';
		$whereCondition = 'winner_id = %d ORDER BY name ASC';
		$result = $this->_db->querySelect('id AS cup_id,name AS cup_name,logo AS cup_logo', $fromTable, $whereCondition, $teamId);
		
		$victories = array();
		while ($cup = $result->fetch_array()) {
			$victories[] = $cup;;
		}
		$result->free();
		return $victories;
	}
	
	private function getPlayerFacts($teamId) {
		$columns = array(
				'COUNT(*)' => 'numberOfPlayers'
				);
		
		// age
		if ($this->_websoccer->getConfig('players_aging') == 'birthday') {
			$ageColumn = 'TIMESTAMPDIFF(YEAR,geburtstag,CURDATE())';
		} else {
			$ageColumn = 'age';
		}
		$columns['AVG(' . $ageColumn . ')'] = 'avgAge';
		
		// marketvalue
		if ($this->_websoccer->getConfig('transfermarket_computed_marketvalue')) {
			$columns['SUM(w_staerke)'] = 'sumStrength';
			$columns['SUM(w_technik)'] = 'sumTechnique';
			$columns['SUM(w_frische)'] = 'sumFreshness';
			$columns['SUM(w_zufriedenheit)'] = 'sumSatisfaction';
			$columns['SUM(w_kondition)'] = 'sumStamina';
		} else {
			$columns['SUM(marktwert)'] = 'sumMarketValue';
		}
		
		$result = $this->_db->querySelect($columns, $this->_websoccer->getConfig('db_prefix') .'_spieler', 'verein_id = %d AND status = \'1\'', $teamId);
		$playerfacts = $result->fetch_array();
		$result->free();
		
		if ($this->_websoccer->getConfig('transfermarket_computed_marketvalue')) {
			$playerfacts['sumMarketValue'] = $this->computeMarketValue($playerfacts['sumStrength'], $playerfacts['sumTechnique'],
					$playerfacts['sumFreshness'], $playerfacts['sumSatisfaction'], $playerfacts['sumStamina']);
		}
		if ($playerfacts['numberOfPlayers'] > 0) {
			$playerfacts['avgMarketValue'] = $playerfacts['sumMarketValue'] / $playerfacts['numberOfPlayers'];
		} else {
			$playerfacts['avgMarketValue'] = 0;
		}
		
		
		return $playerfacts;
	}
	
	private function computeMarketValue($strength, $technique, $freshness, $satisfaction, $stamina) {
	
		$weightStrength = $this->_websoccer->getConfig('sim_weight_strength');
		$weightTech = $this->_websoccer->getConfig('sim_weight_strengthTech');
		$weightStamina = $this->_websoccer->getConfig('sim_weight_strengthStamina');
		$weightFreshness = $this->_websoccer->getConfig('sim_weight_strengthFreshness');
		$weightSatisfaction = $this->_websoccer->getConfig('sim_weight_strengthSatisfaction');
		
		$totalStrength = $weightStrength * $strength;
		$totalStrength += $weightTech * $technique;
		$totalStrength += $weightStamina * $freshness;
		$totalStrength += $weightFreshness * $satisfaction;
		$totalStrength += $weightSatisfaction * $stamina;
	
		$totalStrength /= $weightStrength + $weightTech + $weightStamina + $weightFreshness + $weightSatisfaction;
	
		return $totalStrength * $this->_websoccer->getConfig('transfermarket_value_per_strength');
	}
	
}

?>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.