[stampa,valore] * * con la 'chiave' la lettera che rappresenta il punto per tutti i target, 'stampa' la stringa che viene visualizzata * nelle viste e 'valore' il valore numerico della lettera usato per i conti. */ $LetterPoint=array ( "A" => array("P" => "M", "N" => "0"), "B" => array("P" => "1", "N" => "1"), "C" => array("P" => "2", "N" => "2"), "D" => array("P" => "3", "N" => "3"), "E" => array("P" => "4", "N" => "4"), "F" => array("P" => "5", "N" => "5"), "G" => array("P" => "6", "N" => "6"), "H" => array("P" => "7", "N" => "7"), "I" => array("P" => "8", "N" => "8"), "J" => array("P" => "9", "N" => "9"), "K" => array("P" => "X", "N" => "10"), "L" => array("P" => "10", "N" => "10"), "M" => array("P" => "11", "N" => "11") ); /* * Di seguito sono definiti i vettori che rappresentano i bersagli. * Il nome della variabile deve terminare con 'Small' per indicare un bersaglio * non completo. */ // Bersaglio OutDoor $TrgOutdoor = array ( // Punti non dubbi "A" => array("P" => "M", "N" => "0", "R" => "M"), "B" => array("P" => "1", "N" => "1", "R" => "1"), "C" => array("P" => "2", "N" => "2", "R" => "2"), "D" => array("P" => "3", "N" => "3", "R" => "3"), "E" => array("P" => "4", "N" => "4", "R" => "4"), "F" => array("P" => "5", "N" => "5", "R" => "5"), "G" => array("P" => "6", "N" => "6", "R" => "6"), "H" => array("P" => "7", "N" => "7", "R" => "7"), "I" => array("P" => "8", "N" => "8", "R" => "8"), "J" => array("P" => "9", "N" => "9", "R" => "9"), "K" => array("P" => "X", "N" => "10", "R" => "X"), "L" => array("P" => "10", "N" => "10", "R" => "10"), // Punti dubbi "a" => array("P" => "M*", "N" => "0", "R" => "M*"), "b" => array("P" => "1*", "N" => "1", "R" => "1*"), "c" => array("P" => "2*", "N" => "2", "R" => "2*"), "d" => array("P" => "3*", "N" => "3", "R" => "3*"), "e" => array("P" => "4*", "N" => "4", "R" => "4*"), "f" => array("P" => "5*", "N" => "5", "R" => "5*"), "g" => array("P" => "6*", "N" => "6", "R" => "6*"), "h" => array("P" => "7*", "N" => "7", "R" => "7*"), "i" => array("P" => "8*", "N" => "8", "R" => "8*"), "j" => array("P" => "9*", "N" => "9", "R" => "9*"), "k" => array("P" => "X*", "N" => "10", "R" => "X*"), "l" => array("P" => "10*", "N" => "10", "R" => "10*") ); // Bersaglio Campagna $TrgField = array ( // Punti non dubbi "A" => array("P" => "M", "N" => "0", "R" => "M"), "B" => array("P" => "M", "N" => "0", "R" => "1"), "C" => array("P" => "M", "N" => "0", "R" => "2"), "D" => array("P" => "M", "N" => "0", "R" => "3"), "E" => array("P" => "M", "N" => "0", "R" => "4"), "F" => array("P" => "1", "N" => "1", "R" => "5"), "G" => array("P" => "2", "N" => "2", "R" => "6"), "H" => array("P" => "3", "N" => "3", "R" => "7"), "I" => array("P" => "4", "N" => "4", "R" => "8"), "J" => array("P" => "5", "N" => "5", "R" => "9"), "K" => array("P" => "6", "N" => "6", "R" => "X"), "L" => array("P" => "6", "N" => "6", "R" => "10"), // Punti dubbi "a" => array("P" => "M*", "N" => "0", "R" => "M*"), "b" => array("P" => "M*", "N" => "0", "R" => "1*"), "c" => array("P" => "M*", "N" => "0", "R" => "2*"), "d" => array("P" => "M*", "N" => "0", "R" => "3*"), "e" => array("P" => "M*", "N" => "0", "R" => "4*"), "f" => array("P" => "1*", "N" => "1", "R" => "5*"), "g" => array("P" => "2*", "N" => "2", "R" => "6*"), "h" => array("P" => "3*", "N" => "3", "R" => "7*"), "i" => array("P" => "4*", "N" => "4", "R" => "8*"), "j" => array("P" => "5*", "N" => "5", "R" => "9*"), "k" => array("P" => "6*", "N" => "6", "R" => "X*"), "l" => array("P" => "6*", "N" => "6", "R" => "10*") ); // OLIMPICO INDOOR Completo $TrgIndComplete = array ( // Punti non dubbi "A" => array("P" => "M", "N" => "0", "R" => "M"), "B" => array("P" => "1", "N" => "1", "R" => "1"), "C" => array("P" => "2", "N" => "2", "R" => "2"), "D" => array("P" => "3", "N" => "3", "R" => "3"), "E" => array("P" => "4", "N" => "4", "R" => "4"), "F" => array("P" => "5", "N" => "5", "R" => "5"), "G" => array("P" => "6", "N" => "6", "R" => "6"), "H" => array("P" => "7", "N" => "7", "R" => "7"), "I" => array("P" => "8", "N" => "8", "R" => "8"), "J" => array("P" => "9", "N" => "9", "R" => "9"), "K" => array("P" => "10", "N" => "10", "R" => "X"), "L" => array("P" => "10", "N" => "10", "R" => "10"), // Punti dubbi "a" => array("P" => "M*", "N" => "0", "R" => "M*"), "b" => array("P" => "1*", "N" => "1", "R" => "1*"), "c" => array("P" => "2*", "N" => "2", "R" => "2*"), "d" => array("P" => "3*", "N" => "3", "R" => "3*"), "e" => array("P" => "4*", "N" => "4", "R" => "4*"), "f" => array("P" => "5*", "N" => "5", "R" => "5*"), "g" => array("P" => "6*", "N" => "6", "R" => "6*"), "h" => array("P" => "7*", "N" => "7", "R" => "7*"), "i" => array("P" => "8*", "N" => "8", "R" => "8*"), "j" => array("P" => "9*", "N" => "9", "R" => "9*"), "k" => array("P" => "10*", "N" => "10", "R" => "X*"), "l" => array("P" => "10*", "N" => "10", "R" => "10*") ); // OLIMPICO INDOOR ridotto $TrgIndSmall = array ( // Punti non dubbi "A" => array("P" => "M", "N" => "0", "R" => "M"), "B" => array("P" => "M", "N" => "0", "R" => "1"), "C" => array("P" => "M", "N" => "0", "R" => "2"), "D" => array("P" => "M", "N" => "0", "R" => "3"), "E" => array("P" => "M", "N" => "0", "R" => "4"), "F" => array("P" => "M", "N" => "0", "R" => "5"), "G" => array("P" => "6", "N" => "6", "R" => "6"), "H" => array("P" => "7", "N" => "7", "R" => "7"), "I" => array("P" => "8", "N" => "8", "R" => "8"), "J" => array("P" => "9", "N" => "9", "R" => "9"), "K" => array("P" => "10", "N" => "10", "R" => "X"), "L" => array("P" => "10", "N" => "10", "R" => "10"), // Punti dubbi "a" => array("P" => "M*", "N" => "0", "R" => "M*"), "b" => array("P" => "M*", "N" => "0", "R" => "1*"), "c" => array("P" => "M*", "N" => "0", "R" => "2*"), "d" => array("P" => "M*", "N" => "0", "R" => "3*"), "e" => array("P" => "M*", "N" => "0", "R" => "4*"), "f" => array("P" => "M*", "N" => "0", "R" => "5*"), "g" => array("P" => "6*", "N" => "6", "R" => "6*"), "h" => array("P" => "7*", "N" => "7", "R" => "7*"), "i" => array("P" => "8*", "N" => "8", "R" => "8*"), "j" => array("P" => "9*", "N" => "9", "R" => "9*"), "k" => array("P" => "10*", "N" => "10", "R" => "X*"), "l" => array("P" => "10*", "N" => "10", "R" => "10*") ); // COMPOUND Indoor Completo $TrgCOIndComplete = array ( // Punti non dubbi "A" => array("P" => "M", "N" => "0", "R" => "M"), "B" => array("P" => "1", "N" => "1", "R" => "1"), "C" => array("P" => "2", "N" => "2", "R" => "2"), "D" => array("P" => "3", "N" => "3", "R" => "3"), "E" => array("P" => "4", "N" => "4", "R" => "4"), "F" => array("P" => "5", "N" => "5", "R" => "5"), "G" => array("P" => "6", "N" => "6", "R" => "6"), "H" => array("P" => "7", "N" => "7", "R" => "7"), "I" => array("P" => "8", "N" => "8", "R" => "8"), "J" => array("P" => "9", "N" => "9", "R" => "9"), "K" => array("P" => "10", "N" => "10", "R" => "X"), "L" => array("P" => "9", "N" => "9", "R" => "10"), // Punti dubbi "a" => array("P" => "M*", "N" => "0", "R" => "M*"), "b" => array("P" => "1*", "N" => "1", "R" => "1*"), "c" => array("P" => "2*", "N" => "2", "R" => "2*"), "d" => array("P" => "3*", "N" => "3", "R" => "3*"), "e" => array("P" => "4*", "N" => "4", "R" => "4*"), "f" => array("P" => "5*", "N" => "5", "R" => "5*"), "g" => array("P" => "6*", "N" => "6", "R" => "6*"), "h" => array("P" => "7*", "N" => "7", "R" => "7*"), "i" => array("P" => "8*", "N" => "8", "R" => "8*"), "j" => array("P" => "9*", "N" => "9", "R" => "9*"), "k" => array("P" => "10*", "N" => "10", "R" => "X*"), "l" => array("P" => "9*", "N" => "9", "R" => "10*") ); // Compound Indoor $TrgCOIndSmall = array ( // Punti non dubbi "A" => array("P" => "M", "N" => "0", "R" => "M"), "B" => array("P" => "M", "N" => "0", "R" => "1"), "C" => array("P" => "M", "N" => "0", "R" => "2"), "D" => array("P" => "M", "N" => "0", "R" => "3"), "E" => array("P" => "M", "N" => "0", "R" => "4"), "F" => array("P" => "M", "N" => "0", "R" => "5"), "G" => array("P" => "6", "N" => "6", "R" => "6"), "H" => array("P" => "7", "N" => "7", "R" => "7"), "I" => array("P" => "8", "N" => "8", "R" => "8"), "J" => array("P" => "9", "N" => "9", "R" => "9"), "K" => array("P" => "10", "N" => "10", "R" => "X"), "L" => array("P" => "9", "N" => "9", "R" => "10"), // Punti dubbi "a" => array("P" => "M*", "N" => "0", "R" => "M*"), "b" => array("P" => "M*", "N" => "0", "R" => "1*"), "c" => array("P" => "M*", "N" => "0", "R" => "2*"), "d" => array("P" => "M*", "N" => "0", "R" => "3*"), "e" => array("P" => "M*", "N" => "0", "R" => "4*"), "f" => array("P" => "M*", "N" => "0", "R" => "5*"), "g" => array("P" => "6*", "N" => "6", "R" => "6*"), "h" => array("P" => "7*", "N" => "7", "R" => "7*"), "i" => array("P" => "8*", "N" => "8", "R" => "8*"), "j" => array("P" => "9*", "N" => "9", "R" => "9*"), "k" => array("P" => "10*", "N" => "10", "R" => "X*"), "l" => array("P" => "9*", "N" => "9", "R" => "10*") ); // Hit/Miss Outdoor $TrgHMOutComplete = array ( // Punti non dubbi "A" => array("P" => "M", "N" => "0", "R" => "M"), "B" => array("P" => "M", "N" => "0", "R" => "1"), "C" => array("P" => "M", "N" => "0", "R" => "2"), "D" => array("P" => "M", "N" => "0", "R" => "3"), "E" => array("P" => "M", "N" => "0", "R" => "4"), "F" => array("P" => "M", "N" => "0", "R" => "5"), "G" => array("P" => "M", "N" => "0", "R" => "6"), "H" => array("P" => "M", "N" => "0", "R" => "7"), "I" => array("P" => "M", "N" => "0", "R" => "8"), "J" => array("P" => "1", "N" => "1", "R" => "9"), "K" => array("P" => "1", "N" => "1", "R" => "X"), "L" => array("P" => "1", "N" => "1", "R" => "10"), // Punti dubbi "a" => array("P" => "M*", "N" => "0", "R" => "M*"), "b" => array("P" => "M*", "N" => "0", "R" => "1*"), "c" => array("P" => "M*", "N" => "0", "R" => "2*"), "d" => array("P" => "M*", "N" => "0", "R" => "3*"), "e" => array("P" => "M*", "N" => "0", "R" => "4*"), "f" => array("P" => "M*", "N" => "0", "R" => "5*"), "g" => array("P" => "M*", "N" => "0", "R" => "6*"), "h" => array("P" => "M*", "N" => "0", "R" => "7*"), "i" => array("P" => "M*", "N" => "0", "R" => "8*"), "j" => array("P" => "1*", "N" => "1", "R" => "9*"), "k" => array("P" => "1*", "N" => "1", "R" => "X*"), "l" => array("P" => "1*", "N" => "1", "R" => "10*") ); // Hit/Miss Outdoor $Trg3DComplete = array ( // Punti non dubbi "A" => array("P" => "M", "N" => "0", "R" => "M"), "B" => array("P" => "M", "N" => "0", "R" => "1"), "C" => array("P" => "M", "N" => "0", "R" => "2"), "D" => array("P" => "M", "N" => "0", "R" => "3"), "E" => array("P" => "M", "N" => "0", "R" => "4"), "F" => array("P" => "5", "N" => "5", "R" => "5"), "G" => array("P" => "M", "N" => "0", "R" => "6"), "H" => array("P" => "M", "N" => "0", "R" => "7"), "I" => array("P" => "8", "N" => "8", "R" => "8"), "J" => array("P" => "M", "N" => "0", "R" => "9"), "K" => array("P" => "11", "N" => "11", "R" => "11"), "L" => array("P" => "10", "N" => "10", "R" => "10"), // Punti dubbi "a" => array("P" => "M*", "N" => "0", "R" => "M*"), "b" => array("P" => "M*", "N" => "0", "R" => "M*"), "c" => array("P" => "M*", "N" => "0", "R" => "M*"), "d" => array("P" => "M*", "N" => "0", "R" => "M*"), "e" => array("P" => "M*", "N" => "0", "R" => "M*"), "f" => array("P" => "5*", "N" => "5", "R" => "5*"), "g" => array("P" => "M*", "N" => "0", "R" => "M*"), "h" => array("P" => "M*", "N" => "0", "R" => "M*"), "i" => array("P" => "8*", "N" => "8", "R" => "8*"), "j" => array("P" => "M*", "N" => "0", "R" => "M*"), "k" => array("P" => "11*", "N" => "11", "R" => "11*"), "l" => array("P" => "10*", "N" => "10", "R" => "10*") ); /* * Sta roba qua serve perchè php è ignorante e non usa bene le var globali. * Queste globals verranno usate nelle classi di import/export arf */ $GLOBALS['LetterPoint']=$LetterPoint; $GLOBALS['TrgOutdoor']=$TrgOutdoor; $GLOBALS['TrgField']=$TrgField; $GLOBALS['TrgIndComplete']=$TrgIndComplete; $GLOBALS['TrgIndSmall']=$TrgIndSmall; $GLOBALS['TrgCOIndComplete']=$TrgCOIndComplete; $GLOBALS['TrgCOIndSmall']=$TrgCOIndSmall; $GLOBALS['TrgHMOutComplete']=$TrgHMOutComplete; $GLOBALS['Trg3DComplete']=$Trg3DComplete; /* - GetTargetType($EventCode,$TeamEvent=0) Ritorna la variabile che contiene il target. $EventCode � l'evento. $TeamEvent vale 1 se l'evento � a squadre oppure 0 se � individuale $TourId vale -1 se va usato $_SESSION['TourId'] altrimenti è l'id del torneo */ function GetTargetType($EventCode,$TeamEvent=0,$TourId=-1) { $Target = 'TrgOutdoor'; $ToId=($TourId!=-1 ? $TourId : StrSafe_DB($_SESSION['TourId'])); $Select = "SELECT EvCode,EvFinalTargetType,TarArray " . "FROM Events INNER JOIN Targets ON EvFinalTargetType=TarId AND EvTeamEvent=" . StrSafe_DB($TeamEvent) . " " . "WHERE EvTournament=" . $ToId . " AND EvCode=" . StrSafe_DB($EventCode) . " "; $Rs=safe_r_sql($Select); //print $Select;exit; if (safe_num_rows($Rs)==1) { $MyRow=safe_fetch($Rs); $Target = $MyRow->TarArray ; } return $Target; } /** * Ritorna true se il bersaglio $Target è completo * * @param String $Target: Nome della variabile che rappresenta il bersaglio * * @return boolean: true se il bersaglio è completo; false altrimenti */ function TargetIsComplete($Target) { $Ret=true; //print substr($Target,-5,5);exit; if (substr($Target,-5,5)=='Small') { $Ret=false; } return $Ret; } /** * Nuova ver di ValutaArrowString. * Valuta l'arrowstring usando $LetterPoint * * @param string $Letter: lettera chiave di $LetterPoint * @return string: stringa vuota in caso di problemi oppure colonna "P" di $LetterPoint */ //XXX Tolto il parametro $MySym e sganciato dal sorgente function ValutaArrowString($MyStr) { global $LetterPoint; $Tot=0; for ($i=0;$i'; //print_r($X).'
'; //exit; for ($i=0;$i $Value) { if ($P==$Value['P']) { return $Value['N']; } } return 0; } /* - GetLetterFromSearch($Value,$Target) Dato $Value il valore di Ricerca sul bersaglio, ritorna la chiave di $Target */ function GetLetterFromSearch($Value,$Target) { $R = strtoupper($Value); //print 'R->' . $R . '
'; foreach ($Target as $Key => $Value) { /*print '
';
			print_r($Value);
			print '
';*/ if ($R==$Value['R']) { return $Key; } } } /** * Nuova ver di GetLetterFromPrint * Dato il valore di stampa ritorna la lettera di codifica (la chiave di $LetterPoint). * NOTA: se nel valore di stampa c'è l' "*" la funzione ritorna la chiave in minuscolo * che significa punto dubbio. * * @param string $Value: valore di stampa da cercare * @return string: chiave di $LetterPoint. Se c'è qualche problema ritorna ' ' */ //XXX tolto il parametro $Target e sganciato dal sorgente function GetLetterFromPrint($Value) { global $LetterPoint; $maybe=false; $P = strtoupper($Value); if (strpos($P,'*')!==false) $maybe=true; $P = str_replace('*','',$P); foreach ($LetterPoint as $Key => $Value) { if ($P==$Value['P']) { return ($maybe ? strtolower($Key) : $Key); } } return ' '; } /** * GetHigherTargetValue * ritorna il valore numerico più alto per un dato bersaglio */ function GetHigherTargetValue($Target) { global $LetterPoint; $ret=0; foreach(array_keys($LetterPoint) as $index) if($Target[$index]['N']>$ret) $ret=$Target[$index]['N']; return $ret; } /* - GetMaxScores($EventCode, $MatchNo, $TeamEvent=0, $TourId=-1) Returns an array of Maxvalues for that match. $EventCode is the event. $MatchNo is the number of the match (refer to table Grid) $TeamEvent = 1 for team events, 0 for individual $TourId: if -1 will use $_SESSION['TourId'] The return array is Arrows => array of accepted arrows: 'key': same code as $LetterPoint val[0] = size of ring val[1] = fill color val[2] = border color MaxPoint = maximum arrow point value; MaxEnd = maximum per end MaxMatch = maximum per match MaxSetPoints = 0 if no SET system, Setpoints to win if SET system MaxSO = maximum TOTAL ShootOff arrows */ function GetMaxScores($EventCode, $MatchNo=0, $TeamEvent=0, $TourId=-1) { global $LetterPoint; $ret = array(); $ToId=($TourId!=-1 ? $TourId : StrSafe_DB($_SESSION['TourId'])); $Select = "SELECT" . " Targets.* " . " , EvMatchMode" . " , @Phase:=ifnull(2*pow(2,truncate(log2($MatchNo/2),0)),1) Phase" . ' , @PhaseMatch:=(@Phase & EvMatchArrowsNo)' . ' , if(@PhaseMatch, EvElimEnds, EvFinEnds) CalcEnds' . ' , if(@PhaseMatch, EvElimArrows, EvFinArrows) CalcArrows' . ' , if(@PhaseMatch, EvElimSO, EvFinSO) CalcSO ' . "FROM" . " Events" . " INNER JOIN Targets ON EvFinalTargetType=TarId " . "WHERE" . " EvTournament=" . $ToId . "" . " AND EvCode=" . StrSafe_DB($EventCode) . " " . " AND EvTeamEvent=" . StrSafe_DB($TeamEvent) . " "; $Rs=safe_r_sql($Select); if ($MyRow=safe_fetch($Rs)) { $ret['Arrows']=array('A' => array(0, '', '')); $ret['MaxPoint']=0; $oldcolor=''; foreach(range('A','M') as $key) { if($MyRow->{$key.'_size'}) { // fills the accepted arrows array $ret['Arrows'][$key]=array($MyRow->{$key.'_size'}, $MyRow->{$key.'_color'}, ($MyRow->{$key.'_color'}=='000000' && $oldcolor=='000000')?'FFFFFF':'000000'); $oldcolor=$MyRow->{$key.'_color'}; // check the maxpoint if($LetterPoint[$key]['N']>$ret['MaxPoint']) $ret['MaxPoint']=$LetterPoint[$key]['N']; } } $ret['MaxEnd']=$ret['MaxPoint']*$MyRow->CalcArrows; $ret['MaxMatch']=$ret['MaxEnd']*$MyRow->CalcEnds; $ret['MaxSetPoints']=($MyRow->EvMatchMode ? $MyRow->CalcEnds+2 : 0); $ret['MaxSO']=$ret['MaxPoint']*$MyRow->CalcSO; } return $ret; } ?>