All pastes #84272 Raw Edit

Mine

public php v1 · immutable
·published 2006-07-10 19:45 UTC
rendered paste body
<?php# Quake Match Calculator!error_reporting(E_ALL ^ E_NOTICE);$data =array(	array(		'name' => 'waste',		'wars' =>		array(			array(				'opponent' => 'qj',				'matches' =>				array(					array('map' => 'ospdm5', 'score_self' => 12, 'score_others' => 0),					array('map' => 'ospdm6', 'score_self' => 9, 'score_others' => 3)				)			),			array(				'opponent' => 'cfs',				'matches' =>				array(					array('map' => 'pro-q3dm6', 'score_self' => 20, 'score_others' => 4),					array('map' => 'ospdm6', 'score_self' => 27, 'score_others' => 2)				)			),			array(				'opponent' => 'raf',				'matches' =>				array(					array('map' => 'q3dm7', 'score_self' => 12, 'score_others' => 5),					array('map' => 'ospdm6', 'score_self' => 9, 'score_others' => 1)				)			),			array(				'opponent' => 'bol',				'matches' =>				array(					array('map' => 'q3dm7', 'score_self' => 16, 'score_others' => 4),					array('map' => 'ospdm5', 'score_self' => 9, 'score_others' => 8)				)			)		)	),	array(		'name' => 'bol',		'wars' =>		array(			array(				'opponent' => 'shs',				'matches' =>				array(					array('map' => 'pro-q3dm6', 'score_self' => 15, 'score_others' => 8),					array('map' => 'q3dm7', 'score_self' => 14, 'score_others' => 4)				)			),			array(				'opponent' => 'cov',				'matches' =>				array(					array('map' => 'pro-q3dm6', 'score_self' => 15, 'score_others' => 11),					array('map' => 'cpm4', 'score_self' => 6, 'score_others' => 9),					array('map' => 'q3dm7', 'score_self' => 15, 'score_others' => 8)				)			),			array(				'opponent' => 'fai',				'matches' =>				array(					array('map' => 'pro-q3dm6', 'score_self' => 16, 'score_others' => 10),					array('map' => 'ospdm5', 'score_self' => 3, 'score_others' => 22),					array('map' => 'q3dm7', 'score_self' => 7, 'score_others' => 24)				)			),			array(				'opponent' => 'qj',				'matches' =>				array(					array('map' => 'q3dm7', 'score_self' => 18, 'score_others' => 2),					array('map' => 'ospdm5', 'score_self' => 11, 'score_others' => 6)				)			),			array(				'opponent' => 'waste',				'matches' =>				array(					array('map' => 'q3dm7', 'score_self' => 4, 'score_others' => 16),					array('map' => 'ospdm5', 'score_self' => 8, 'score_others' => 9)				)			)		)	),	array(		'name' => 'qj',		'wars' =>		array(			array(				'opponent' => 'waste',				'matches' =>				array(					array('map' => 'ospdm5', 'score_self' => 0, 'score_others' => 12),					array('map' => 'ospdm6', 'score_self' => 3, 'score_others' => 9)				)			),			array(				'opponent' => 'raf',				'matches' =>				array(					array('map' => 'ospdm5', 'score_self' => 6, 'score_others' => 13),					array('map' => 'q3dm7', 'score_self' => 8, 'score_others' => 20)				)			),			array(				'opponent' => 'qj',				'matches' =>				array(					array('map' => 'q3dm7', 'score_self' => 2, 'score_others' => 18),					array('map' => 'ospdm5', 'score_self' => 6, 'score_others' => 11)				)			)		)	));class GameSkillCalculator {	var $_cache = array();	var $_clans = array();	var $_calculation = array();		function GameSkill() {			}		function addClan(&$clan) {		if(!is_a($clan, 'GameClan'))			trigger_error('');					if($this->_clans[$clan->getName()] = &$clan)			$this->_cache['clans'][$clan->getName()] = true;	}		function &getClan($clan) {		if(isset($this->_cache['clans'][$clan]))			return $this->_clans[$clan];				return false;	}}class GameClan {	var $_name;	var $_wars = array();		function GameClan($name) {		$this->_name = $name;	}		function getName() {		return $this->_name;	}		function addWar(&$war) {		if(!is_a($war, 'GameMatch'))			trigger_error('');					$this->_wars[] = &$war;	}}class GameMatch {	var $_opponent;	var $_map;	var $_scores = array('self' => NULL, 'others' => NULL);		function GameWar($opponent, $map, $scores) {		$this->_opponent = $opponent;		$this->_map = $map;		$this->_scores = $scores;	}		function getOpponent() {		return $this->_opponent;	}		function getMap() {		return $this->_map;	}		function getScores() {		return $this->_scores;	}}$calc = &new GameSkillCalculator();foreach($data as $_clan) {	$clan = &new GameClan($_clan['name']);		foreach($_clan['wars'] as $_war) {		$opponent = $_war['opponent'];				foreach($_war['matches'] as $_match) {			$match = &new GameMatch($opponent, $_match['map'], array($_match['score_self'], $_match['score_others']));						$clan->addWar($match);		}	}		$calc->addClan($clan);}print '<pre>';var_dump($calc->_clans);print '</pre>';?>