CLEANED UP DA CODE

This commit is contained in:
Jeroen De Meerleer 2020-11-22 17:13:13 +01:00
parent aac0322491
commit 400780ef54
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
18 changed files with 1992 additions and 1785 deletions

View File

@ -51,7 +51,9 @@
<option name="BINARY_OPERATION_WRAP" value="5" /> <option name="BINARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_WRAP" value="5" /> <option name="TERNARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" /> <option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
<option name="MODIFIER_LIST_WRAP" value="true" />
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" /> <option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="5" /> <option name="FOR_STATEMENT_WRAP" value="5" />
<option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" /> <option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" /> <option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />

View File

@ -2,7 +2,10 @@
"name": "jeroened/libpairtwo", "name": "jeroened/libpairtwo",
"type": "library", "type": "library",
"description": "Export chess tournaments directly on the web", "description": "Export chess tournaments directly on the web",
"keywords": ["chess", "pairing"], "keywords": [
"chess",
"pairing"
],
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"authors": [ "authors": [
{ {

View File

@ -5,7 +5,7 @@
"url": "../" "url": "../"
} }
], ],
"require": { "require": {
"jeroened/libpairtwo": "//VERSION//" "jeroened/libpairtwo": "//VERSION//"
}, },
"minimum-stability": "dev" "minimum-stability": "dev"

23
dist/template.php vendored
View File

@ -27,7 +27,10 @@ use JeroenED\Libpairtwo\IOFactory;
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';
if (!file_exists($pairingfile)) { if (!file_exists($pairingfile)) {
trigger_error('Your file is not set or doesn\'t exist! Edit the file: ' . __FILE__ . ' and try again', E_USER_ERROR); trigger_error(
'Your file is not set or doesn\'t exist! Edit the file: ' . __FILE__ . ' and try again',
E_USER_ERROR
);
} }
$reader = IOFactory::createReader($fileformat); $reader = IOFactory::createReader($fileformat);
@ -49,8 +52,18 @@ foreach ($reader->Tournament->Rounds as $round) {
foreach ($round->GamesByBoard as $game) { foreach ($round->GamesByBoard as $game) {
echo '<tr>' . PHP_EOL; echo '<tr>' . PHP_EOL;
echo '<td>' . ($game->Board + 1) . '</td>' . PHP_EOL; echo '<td>' . ($game->Board + 1) . '</td>' . PHP_EOL;
echo '<td>' . $game->White->Player->Name . ' (' . $game->White->Player->getElo($reader->Tournament->PriorityElo) . ')</td>' . PHP_EOL; echo '<td>' .
echo '<td>' . $game->Black->Player->Name . ' (' . $game->Black->Player->getElo($reader->Tournament->PriorityElo) . ')</td>' . PHP_EOL; $game->White->Player->Name .
' (' .
$game->White->Player->getElo($reader->Tournament->PriorityElo) .
')</td>' .
PHP_EOL;
echo '<td>' .
$game->Black->Player->Name .
' (' .
$game->Black->Player->getElo($reader->Tournament->PriorityElo) .
')</td>' .
PHP_EOL;
echo '<td>' . $game->Result->getValue() . '</td>' . PHP_EOL; echo '<td>' . $game->Result->getValue() . '</td>' . PHP_EOL;
echo '</tr>' . PHP_EOL; echo '</tr>' . PHP_EOL;
} }
@ -101,7 +114,7 @@ echo '</table>' . PHP_EOL;
<?php <?php
echo '<h2>Rankings per Category</h2>' . PHP_EOL; echo '<h2>Rankings per Category</h2>' . PHP_EOL;
foreach($reader->Tournament->Categories as $category) { foreach ($reader->Tournament->Categories as $category) {
echo '<table>' . PHP_EOL; echo '<table>' . PHP_EOL;
echo '<caption>' . $category . '</caption>'; echo '<caption>' . $category . '</caption>';
echo '<thead>' . PHP_EOL; echo '<thead>' . PHP_EOL;
@ -126,6 +139,6 @@ foreach($reader->Tournament->Categories as $category) {
echo '</table>' . PHP_EOL; echo '</table>' . PHP_EOL;
} }
?> ?>
<script src="js/scripts.js"></script> <script src="js/scripts.js"></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -1,215 +1,340 @@
<HTML> <HTML>
<HEAD> <HEAD>
<style type="text/css"> <style type="text/css">
body { font-size: 10pt; font-family: verdana;} body {
h1 {background-color: navy;color: #FDE0AA;font-size: 24pt;font-weight:bold;font-family:Arial;text-align:center;} font-size: 10pt;
th {background-color: #408080; font-size: 20pt; text-align: center;} font-family: verdana;
.rh {background-color: #408080; font-size: 16pt; text-align: center;} }
.vh {font-size: 10pt; text-align: center;}
.thr {font-size: 10pt; text-align: right}
.thl {font-size: 10pt; text-align: left}
.thc {font-size: 10pt; text-align: center}
.tdr {font-size: 8pt; text-align: right}
.tdl {font-size: 8pt; text-align: left}
.tdc {font-size: 8pt; text-align: center;}
.tdp {font-size: 10pt; font-weight:bold;text-align: center; background-color='yellow'}
.tde {font-size: 8pt; font-style:italic;text-align: right; background-color='#ceceff'}
table {font-size: 10pt; font-family: Arial}
a { text-decoration: none; color: blue;}
a:visited { text-decoration: none; color: blue;}
a:hover { text-decoration:none ; color: red;}
</style>
<TITLE>Libpairtwo Tournament</TITLE> h1 {
<META name='DESCRIPTION' content='Classement, Résultats, Appariement, Grille Américaine'> background-color: navy;
<META name='AUTHOR' content='Georges Marchal'> color: #FDE0AA;
<META name='KEYWORDS' content='échecs,echecs,chess,jeux,game,belgique,belgium,forum'> font-size: 24pt;
<META name='KEYWORDS' content='liège,liege,666,elo,classement,tournoi,interclub'> font-weight: bold;
<META name='KEYWORDS' content='pairtwo, kbsb,frbe,fefb,666'> font-family: Arial;
<META name='ROBOTS' content='INDEX,FOLLOW'> text-align: center;
}
th {
background-color: #408080;
font-size: 20pt;
text-align: center;
}
.rh {
background-color: #408080;
font-size: 16pt;
text-align: center;
}
.vh {
font-size: 10pt;
text-align: center;
}
.thr {
font-size: 10pt;
text-align: right
}
.thl {
font-size: 10pt;
text-align: left
}
.thc {
font-size: 10pt;
text-align: center
}
.tdr {
font-size: 8pt;
text-align: right
}
.tdl {
font-size: 8pt;
text-align: left
}
.tdc {
font-size: 8pt;
text-align: center;
}
.tdp {
font-size: 10pt;
font-weight: bold;
text-align: center;
background-color = 'yellow'
}
.tde {
font-size: 8pt;
font-style: italic;
text-align: right;
background-color = '#ceceff'
}
table {
font-size: 10pt;
font-family: Arial
}
a {
text-decoration: none;
color: blue;
}
a:visited {
text-decoration: none;
color: blue;
}
a:hover {
text-decoration: none;
color: red;
}
</style>
<TITLE>Libpairtwo Tournament</TITLE>
<META content='Classement, R<>sultats, Appariement, Grille Am<41>ricaine' name='DESCRIPTION'>
<META content='Georges Marchal' name='AUTHOR'>
<META content='<27>checs,echecs,chess,jeux,game,belgique,belgium,forum' name='KEYWORDS'>
<META content='li<6C>ge,liege,666,elo,classement,tournoi,interclub' name='KEYWORDS'>
<META content='pairtwo, kbsb,frbe,fefb,666' name='KEYWORDS'>
<META content='INDEX,FOLLOW' name='ROBOTS'>
</HEAD> </HEAD>
<BODY> <BODY>
<A name=Top></A> <A name=Top></A>
<!-- TITRE GENERAL EN BLEU --> <!-- TITRE GENERAL EN BLEU -->
<!-- ===================== --> <!-- ===================== -->
<TABLE width='90%' align='center' bgColor='#000080' border='0'> <TABLE align='center' bgColor='#000080' border='0' width='90%'>
<TR><TD><H1>Libpairtwo Tournament</H1></TD></TR></TABLE> <TR>
<TD><H1>Libpairtwo Tournament</H1></TD>
</TR>
</TABLE>
<!-- =============== --> <!-- =============== -->
<!-- INFO DU TOURNOI --> <!-- INFO DU TOURNOI -->
<!-- =============== --><br> <!-- =============== --><br>
<table align='center' border='1''> <table align='center' border='1'
<tr><td align='center' valign='middle'><font size='+2'><b>313</b></font></td> '>
<td><TABLE border='1' align='center' style='font-size: 8pt; font-family: verdana;'> <tr>
<tr><td align='center' bgColor='#000090'><font color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></td> <td align='center' valign='middle'><font size='+2'><b>313</b></font></td>
<td align='center' bgColor='#000090'><font color='white' size='-1'><b>PairTwo 6.13 (2015/08/10)</b></font></td></tr> <td>
<tr><td><i> Org. : </i></td><td>Libpairtwo Organiser ,Libpairtwo Place ,2019</td></tr> <TABLE align='center' border='1' style='font-size: 8pt; font-family: verdana;'>
<tr><td><i>Arbit. : </i></td><td>Libpairtwo Organiser</td></tr> <tr>
<tr><td><i> Tempo : </i></td><td>40c/2h + 1h QPF</td></tr> <td align='center' bgColor='#000090'><font color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></td>
<tr><td><i>Tie Break</i></td><td>Pts,&nbsp;Mutual Result,&nbsp;Number of Victories,&nbsp;Number of game Black played,&nbsp;Bucholtz Cut 1,&nbsp;SonneBorn-Berger</td></tr> <td align='center' bgColor='#000090'><font color='white' size='-1'><b>PairTwo 6.13
</TABLE> (2015/08/10)</b></font></td>
</td> </tr>
<td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td> <tr>
<td><i> Org. : </i></td>
<td>Libpairtwo Organiser ,Libpairtwo Place ,2019</td>
</tr>
<tr>
<td><i>Arbit. : </i></td>
<td>Libpairtwo Organiser</td>
</tr>
<tr>
<td><i> Tempo : </i></td>
<td>40c/2h + 1h QPF</td>
</tr>
<tr>
<td><i>Tie Break</i></td>
<td>Pts,&nbsp;Mutual Result,&nbsp;Number of Victories,&nbsp;Number of game Black played,&nbsp;Bucholtz
Cut 1,&nbsp;SonneBorn-Berger
</td>
</tr>
</TABLE>
</td>
<td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td>
</tr> </tr>
</table> </table>
<!-- ================== --> <!-- ================== -->
<!-- === REFERENCES === --> <!-- === REFERENCES === -->
<!-- ================== --> <!-- ================== -->
<br><TABLE align='center' border='3' bgcolor='#ffffdd'> <br>
<TR> <TABLE align='center' bgcolor='#ffffdd' border='3'>
<TD class='vh'><A HREF='#Round1'>R1</A></TD> <TR>
<TD class='vh'><A HREF='#Round2'>R2</A></TD> <TD class='vh'><A HREF='#Round1'>R1</A></TD>
<TD class='vh'><A HREF='#Round3'>R3</A></TD> <TD class='vh'><A HREF='#Round2'>R2</A></TD>
</TR> <TD class='vh'><A HREF='#Round3'>R3</A></TD>
<TR><TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD></TR> </TR>
<TR>
<TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD>
</TR>
</TABLE> </TABLE>
<br> <br>
<DIV ALIGN='CENTER'> <DIV ALIGN='CENTER'>
<TABLE align='center' bgcolor='#ffffdd' border='1'> <TABLE align='center' bgcolor='#ffffdd' border='1'>
<!-- =========================== --> <!-- =========================== -->
<!-- === DEBUT DU CLASSEMENT === --> <!-- === DEBUT DU CLASSEMENT === -->
<!-- =========================== --> <!-- =========================== -->
<TR><TH>Ranking after round 3</TH></TR> <TR>
<TR><TD><PRE> <TH>Ranking after round 3</TH>
</TR>
<TR>
<TD><PRE>
<b><u>Tit Name Rati F/M Club Cou Pts Res Vic #Bla BC1 S B </u></b> <b><u>Tit Name Rati F/M Club Cou Pts Res Vic #Bla BC1 S B </u></b>
1<b> FM</b> <b>Libpairtwo Player 2 </b> (1802) M Liga Vlaams-Brabant (VSF) BEL <b> 3.0</b>/<i>3 </i> 0.0 0 0 0.0 0.00 1<b> FM</b> <b>Libpairtwo Player 2 </b> (1802) M Liga Vlaams-Brabant (VSF) BEL <b> 3.0</b>/<i>3 </i> 0.0 0 0 0.0 0.00
2<b> *</b> <b>Libpairtwo Player 1 </b> (1801) M Liga Antwerpen (VSF) BEL <b> 1.5</b>/<i>3 </i> 0.0 0 0 0.0 0.00 2<b> *</b> <b>Libpairtwo Player 1 </b> (1801) M Liga Antwerpen (VSF) BEL <b> 1.5</b>/<i>3 </i> 0.0 0 0 0.0 0.00
3<b> IM</b> <b>Libpairtwo Player 3 </b> (1803) F Liga West Vlaanderen (VSF) BEL <b> 1.0</b>/<i>2 </i> 0.0 0 0 0.0 0.00 3<b> IM</b> <b>Libpairtwo Player 3 </b> (1803) F Liga West Vlaanderen (VSF) BEL <b> 1.0</b>/<i>2 </i> 0.0 0 0 0.0 0.00
4<b> GM</b> <b>Libpairtwo Player 4 </b> (1804) F Liga Oost Vlaanderen (VSF) BEL <b> 0.5</b>/<i>2 </i> 0.0 0 0 0.0 0.00 4<b> GM</b> <b>Libpairtwo Player 4 </b> (1804) F Liga Oost Vlaanderen (VSF) BEL <b> 0.5</b>/<i>2 </i> 0.0 0 0 0.0 0.00
<A href='#Top'>Top of Page</A> <A href='#Top'>Top of Page</A>
</PRE></TD></TR> </PRE>
<TR><TH class='rh'><A NAME='Round1' style='color: black'>Round 1 (01-01-2019)</A></TH></TR> </TD>
<TR><TD><PRE> </TR>
<TR>
<TH class='rh'><A NAME='Round1' style='color: black'>Round 1 (01-01-2019)</A></TH>
</TR>
<TR>
<TD><PRE>
1 Libpairtwo Player 2 ( 3) <b>1-0 </b>Libpairtwo Player 4 ( 1) 1 Libpairtwo Player 2 ( 3) <b>1-0 </b>Libpairtwo Player 4 ( 1)
2 Libpairtwo Player 3 ( 2) <b>0-1 </b>Libpairtwo Player 1 ( 4) 2 Libpairtwo Player 3 ( 2) <b>0-1 </b>Libpairtwo Player 1 ( 4)
</pre> </pre>
<A HREF="#Top">(Go to Top)</A> <A HREF="#Top">(Go to Top)</A>
</TD> </TD>
<TR><TH class='rh'><A NAME='Round2' style='color: black'>Round 2 (06-01-2019)</A></TH></TR> <TR>
<TR><TD><PRE> <TH class='rh'><A NAME='Round2' style='color: black'>Round 2 (06-01-2019)</A></TH>
</TR>
<TR>
<TD><PRE>
1 Libpairtwo Player 1 ( 4) <b>0-1 </b>Libpairtwo Player 2 ( 3) 1 Libpairtwo Player 1 ( 4) <b>0-1 </b>Libpairtwo Player 2 ( 3)
2 Libpairtwo Player 3 ( 2) <font color='red'> Bye</font> 2 Libpairtwo Player 3 ( 2) <font color='red'> Bye</font>
Libpairtwo Player 4 ( 1)<font color='red'> Absent </font> Libpairtwo Player 4 ( 1)<font color='red'> Absent </font>
</pre> </pre>
<A HREF="#Top">(Go to Top)</A> <A HREF="#Top">(Go to Top)</A>
</TD> </TD>
<TR><TH class='rh'><A NAME='Round3' style='color: black'>Round 3 (11-01-2019)</A></TH></TR> <TR>
<TR><TD><PRE> <TH class='rh'><A NAME='Round3' style='color: black'>Round 3 (11-01-2019)</A></TH>
1 Libpairtwo Player 4 ( 1) <b>½-½ </b>Libpairtwo Player 1 ( 4) </TR>
<TR>
<TD><PRE>
1 Libpairtwo Player 4 ( 1) <b><EFBFBD>-<2D> </b>Libpairtwo Player 1 ( 4)
2 Libpairtwo Player 2 ( 3) <font color='red'> Bye</font> 2 Libpairtwo Player 2 ( 3) <font color='red'> Bye</font>
Libpairtwo Player 3 ( 2)<font color='red'> Absent </font> Libpairtwo Player 3 ( 2)<font color='red'> Absent </font>
</pre> </pre>
<A HREF="#Top">(Go to Top)</A> <A HREF="#Top">(Go to Top)</A>
</TD> </TD>
</table></div> </table>
</div>
<!-- ================= --> <!-- ================= -->
<!-- GRILLE AMERICAINE --> <!-- GRILLE AMERICAINE -->
<!-- ================= --> <!-- ================= -->
<DIV ALIGN='CENTER'> <DIV ALIGN='CENTER'>
<TABLE align='center' bgcolor='#ffffdd' border='1'> <TABLE align='center' bgcolor='#ffffdd' border='1'>
<TR> <TR>
<TH colspan='14'> <TH colspan='14'>
<FONT size='+2'>American Ranking</FONT> <FONT size='+2'>American Ranking</FONT>
<A name=Americaine></A></TH></TR> <A name=Americaine></A></TH>
</TR>
<TR bgcolor='#cccccc'> <TR bgcolor='#cccccc'>
<TD class='thr'>&nbsp;</TD> <TD class='thr'>&nbsp;</TD>
<TD class='thl'><B>Name</B></TD> <TD class='thl'><B>Name</B></TD>
<TD class='thr'><B>Rating</B></TD> <TD class='thr'><B>Rating</B></TD>
<TD class='thr'><B> Pts</B></TD> <TD class='thr'><B> Pts</B></TD>
<TD class='thr'><B>Perf </B></TD> <TD class='thr'><B>Perf </B></TD>
<TD class='thc'><B>R1</B></TD> <TD class='thc'><B>R1</B></TD>
<TD class='thc'><B>R2</B></TD> <TD class='thc'><B>R2</B></TD>
<TD class='thc'><B>R3</B></TD> <TD class='thc'><B>R3</B></TD>
<TD class='thr'><b><i>Res </i></b></TD> <TD class='thr'><b><i>Res </i></b></TD>
<TD class='thr'><b><i>Vic </i></b></TD> <TD class='thr'><b><i>Vic </i></b></TD>
<TD class='thr'><b><i>#Bla</i></b></TD> <TD class='thr'><b><i>#Bla</i></b></TD>
<TD class='thr'><b><i>BC1 </i></b></TD> <TD class='thr'><b><i>BC1 </i></b></TD>
<TD class='thr'><b><i>S B </i></b></TD> <TD class='thr'><b><i>S B </i></b></TD>
</tr> </tr>
<tr> <tr>
<td class='tdr' bgcolor='#eeeeee'> 1</td> <td bgcolor='#eeeeee' class='tdr'> 1</td>
<td class='tdl' bgcolor='#eeeeee'><B>Libpairtwo Player 2 (FM)</B></td> <td bgcolor='#eeeeee' class='tdl'><B>Libpairtwo Player 2 (FM)</B></td>
<td class='tdr' bgcolor='#eeeeee'>1802</td> <td bgcolor='#eeeeee' class='tdr'>1802</td>
<td class='tdr' bgcolor='#eeeeee'><B>3.0</B></td> <td bgcolor='#eeeeee' class='tdr'><B>3.0</B></td>
<td class='tdr' bgcolor='#eeeeee'><i>2602</i></td> <td bgcolor='#eeeeee' class='tdr'><i>2602</i></td>
<td class='tdc' bgcolor='#eeeeee'> 4W +</td> <td bgcolor='#eeeeee' class='tdc'> 4W +</td>
<td class='tdc' bgcolor='#eeeeee'> 2B +</td> <td bgcolor='#eeeeee' class='tdc'> 2B +</td>
<td class='tdc' bgcolor='#eeeeee'>bye</td> <td bgcolor='#eeeeee' class='tdc'>bye</td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td> <td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td> <td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td> <td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td> <td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.00</i></td> <td bgcolor='#eeeeee' class='tdc'><i> 0.00</i></td>
</tr> </tr>
<tr> <tr>
<td class='tdr' bgcolor='#cccccc'> 2</td> <td bgcolor='#cccccc' class='tdr'> 2</td>
<td class='tdl' bgcolor='#cccccc'><B>Libpairtwo Player 1 (*)</B></td> <td bgcolor='#cccccc' class='tdl'><B>Libpairtwo Player 1 (*)</B></td>
<td class='tdr' bgcolor='#cccccc'>1801</td> <td bgcolor='#cccccc' class='tdr'>1801</td>
<td class='tdr' bgcolor='#cccccc'><B>1.5</B></td> <td bgcolor='#cccccc' class='tdr'><B>1.5</B></td>
<td class='tdr' bgcolor='#cccccc'><i>1810</i></td> <td bgcolor='#cccccc' class='tdr'><i>1810</i></td>
<td class='tdc' bgcolor='#cccccc'> 3B +</td> <td bgcolor='#cccccc' class='tdc'> 3B +</td>
<td class='tdc' bgcolor='#cccccc'> 1W -</td> <td bgcolor='#cccccc' class='tdc'> 1W -</td>
<td class='tdc' bgcolor='#cccccc'> 4B =</td> <td bgcolor='#cccccc' class='tdc'> 4B =</td>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td> <td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td> <td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td> <td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td> <td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.00</i></td> <td bgcolor='#cccccc' class='tdc'><i> 0.00</i></td>
</tr> </tr>
<tr> <tr>
<td class='tdr' bgcolor='#eeeeee'> 3</td> <td bgcolor='#eeeeee' class='tdr'> 3</td>
<td class='tdl' bgcolor='#eeeeee'><B>Libpairtwo Player 3 (IM)</B></td> <td bgcolor='#eeeeee' class='tdl'><B>Libpairtwo Player 3 (IM)</B></td>
<td class='tdr' bgcolor='#eeeeee'>1803</td> <td bgcolor='#eeeeee' class='tdr'>1803</td>
<td class='tdr' bgcolor='#eeeeee'><B>1.0</B></td> <td bgcolor='#eeeeee' class='tdr'><B>1.0</B></td>
<td class='tdr' bgcolor='#eeeeee'><i>1331</i></td> <td bgcolor='#eeeeee' class='tdr'><i>1331</i></td>
<td class='tdc' bgcolor='#eeeeee'> 2W -</td> <td bgcolor='#eeeeee' class='tdc'> 2W -</td>
<td class='tdc' bgcolor='#eeeeee'>bye</td> <td bgcolor='#eeeeee' class='tdc'>bye</td>
<td class='tdc' bgcolor='#eeeeee'>...</td> <td bgcolor='#eeeeee' class='tdc'>...</td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td> <td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td> <td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td> <td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td> <td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.00</i></td> <td bgcolor='#eeeeee' class='tdc'><i> 0.00</i></td>
</tr> </tr>
<tr> <tr>
<td class='tdr' bgcolor='#cccccc'> 4</td> <td bgcolor='#cccccc' class='tdr'> 4</td>
<td class='tdl' bgcolor='#cccccc'><B>Libpairtwo Player 4 (GM)</B></td> <td bgcolor='#cccccc' class='tdl'><B>Libpairtwo Player 4 (GM)</B></td>
<td class='tdr' bgcolor='#cccccc'>1804</td> <td bgcolor='#cccccc' class='tdr'>1804</td>
<td class='tdr' bgcolor='#cccccc'><B>0.5</B></td> <td bgcolor='#cccccc' class='tdr'><B>0.5</B></td>
<td class='tdr' bgcolor='#cccccc'><i>1626</i></td> <td bgcolor='#cccccc' class='tdr'><i>1626</i></td>
<td class='tdc' bgcolor='#cccccc'> 1B -</td> <td bgcolor='#cccccc' class='tdc'> 1B -</td>
<td class='tdc' bgcolor='#cccccc'>...</td> <td bgcolor='#cccccc' class='tdc'>...</td>
<td class='tdc' bgcolor='#cccccc'> 2W =</td> <td bgcolor='#cccccc' class='tdc'> 2W =</td>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td> <td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td> <td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td> <td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td> <td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.00</i></td> <td bgcolor='#cccccc' class='tdc'><i> 0.00</i></td>
</tr> </tr>
</TABLE></DIV> </TABLE>
</DIV>
<P align='center'><A href='#Top'><FONT size='-1'>Top of Page</FONT></A> <P align='center'><A href='#Top'><FONT size='-1'>Top of Page</FONT></A>
</TABLE> </TABLE>
<!-- ========= --> <!-- ========= -->
<!-- COPYRIGHT --> <!-- COPYRIGHT -->
<!-- ========= --> <!-- ========= -->
<p><TABLE border='0'> <p>
<TR><TD align='center' bgColor='#000090'> <TABLE border='0'>
<FONT color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></TD> <TR>
<TD align='center' bgColor='#000090'> <TD align='center' bgColor='#000090'>
<FONT color='white' size='-1'><b>PairTwo 6.13 (2015/08/10)</b></font></td></tr> <FONT color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></TD>
</TD></TR></TABLE></p> <TD align='center' bgColor='#000090'>
</body></html> <FONT color='white' size='-1'><b>PairTwo 6.13 (2015/08/10)</b></font></td>
</tr>
</TD></TR></TABLE>
</p>
</body>
</html>

View File

@ -28,7 +28,7 @@ use JeroenED\Libpairtwo\Enums\Result;
*/ */
class Constants class Constants
{ {
public const WON = [Result::WON, Result::WON_FORFAIT, Result::WON_BYE, Result::WON_ADJOURNED]; public const BLACK = [Color::BLACK];
public const DRAW = [Result::DRAW, Result::DRAW_ADJOURNED]; public const DRAW = [Result::DRAW, Result::DRAW_ADJOURNED];
@ -49,7 +49,7 @@ class Constants
Result::ADJOURNED Result::ADJOURNED
]; ];
public const BLACK = [Color::BLACK];
public const WHITE = [Color::WHITE]; public const WHITE = [Color::WHITE];
public const WON = [Result::WON, Result::WON_FORFAIT, Result::WON_BYE, Result::WON_ADJOURNED];
} }

View File

@ -14,8 +14,6 @@
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
use JeroenED\Libpairtwo\Enums\Gameresult; use JeroenED\Libpairtwo\Enums\Gameresult;
use JeroenED\Libpairtwo\Pairing;
use DateTime;
/** /**
* Class Games * Class Games
@ -29,13 +27,6 @@ use DateTime;
*/ */
class Game class Game
{ {
/**
* The pairing for this games as seen from white's side
*
* @var Pairing | null
*/
public $White;
/** /**
* The pairing for this games as seen from black's side * The pairing for this games as seen from black's side
* *
@ -43,13 +34,6 @@ class Game
*/ */
public $Black; public $Black;
/**
* The calculated game result
*
* @var GameResult | null
*/
private $CalculatedResult;
/** /**
* The board where this game is held * The board where this game is held
* *
@ -57,11 +41,26 @@ class Game
*/ */
public $Board; public $Board;
/**
* The calculated game result
*
* @var GameResult | null
*/
private $CalculatedResult;
/**
* The pairing for this games as seen from white's side
*
* @var Pairing | null
*/
public $White;
/** /**
* Returns fields that were not directly assigned. * Returns fields that were not directly assigned.
* Class Game contains the special field Result containing the result of the game * Class Game contains the special field Result containing the result of the game
* *
* @param string $key * @param string $key
*
* @return Gameresult * @return Gameresult
*/ */
public function __get(string $key) public function __get(string $key)
@ -69,6 +68,7 @@ class Game
if ($key == 'Result') { if ($key == 'Result') {
return $this->calculateResult(); return $this->calculateResult();
} }
return null; return null;
} }
@ -91,19 +91,19 @@ class Game
$blacksplit = explode(" ", $blackResult); $blacksplit = explode(" ", $blackResult);
$special = ''; $special = '';
if (isset($whitesplit[1]) && $whitesplit[1] != 'Bye') { if (isset($whitesplit[ 1 ]) && $whitesplit[ 1 ] != 'Bye') {
$special = ' ' . $whitesplit[1]; $special = ' ' . $whitesplit[ 1 ];
} }
if (isset($blacksplit[1]) && $blacksplit[1] != 'Bye') { if (isset($blacksplit[ 1 ]) && $blacksplit[ 1 ] != 'Bye') {
$special = ' ' . $blacksplit[1]; $special = ' ' . $blacksplit[ 1 ];
} }
if ($whitesplit[0] == '*') { if ($whitesplit[ 0 ] == '*') {
$whitesplit[0] = ''; $whitesplit[ 0 ] = '';
} }
if ($blacksplit[0] == '*') { if ($blacksplit[ 0 ] == '*') {
$blacksplit[0] = ''; $blacksplit[ 0 ] = '';
} }
$result = new Gameresult($whitesplit[0] . '-' . $blacksplit[0] . $special); $result = new Gameresult($whitesplit[ 0 ] . '-' . $blacksplit[ 0 ] . $special);
$this->CalculatedResult = $result; $this->CalculatedResult = $result;
return $result; return $result;
@ -112,7 +112,8 @@ class Game
/** /**
* Checks if 2 games are equal * Checks if 2 games are equal
* *
* @param Game $game * @param Game $game
*
* @return bool * @return bool
*/ */
public function equals(Game $game): bool public function equals(Game $game): bool

View File

@ -15,7 +15,6 @@ namespace JeroenED\Libpairtwo;
use JeroenED\LibPairtwo\Exceptions\LibpairtwoException; use JeroenED\LibPairtwo\Exceptions\LibpairtwoException;
use JeroenED\Libpairtwo\Interfaces\ReaderInterface; use JeroenED\Libpairtwo\Interfaces\ReaderInterface;
use JeroenED\Libpairtwo\Readers\Pairtwo6;
/** /**
* Class IOFactory * Class IOFactory
@ -35,29 +34,29 @@ abstract class IOFactory
* @var array * @var array
*/ */
private static $Readers = [ private static $Readers = [
'Swar-4' => Readers\Swar4::class, 'Swar-4' => Readers\Swar4::class,
'Pairtwo-6' => Readers\Pairtwo6::class, 'Pairtwo-6' => Readers\Pairtwo6::class,
'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical 'Pairtwo-5' => Readers\Pairtwo6::class // File structure identical
]; ];
/** /**
* Creates a reader for $type * Creates a reader for $type
* *
* Compatible types are Swar-4, Pairtwo-5, Pairtwo-6 * Compatible types are Swar-4, Pairtwo-5, Pairtwo-6
* *
* @param string $type * @param string $type
*
* @return ReaderInterface * @return ReaderInterface
* @throws LibpairtwoException * @throws LibpairtwoException
*/ */
public static function createReader(string $type): ReaderInterface public static function createReader(string $type): ReaderInterface
{ {
if (!isset(self::$Readers[$type])) { if (!isset(self::$Readers[ $type ])) {
throw new LibpairtwoException("Cannot read type $type"); throw new LibpairtwoException("Cannot read type $type");
} }
// create reader class // create reader class
$readerClass = self::$Readers[$type]; $readerClass = self::$Readers[ $type ];
return new $readerClass(); return new $readerClass();
} }

View File

@ -13,8 +13,6 @@
namespace JeroenED\Libpairtwo\Interfaces; namespace JeroenED\Libpairtwo\Interfaces;
use JeroenED\Libpairtwo\Tournament;
/** /**
* Interface ReaderInterface * Interface ReaderInterface
* *
@ -31,6 +29,7 @@ interface ReaderInterface
* Reads out $filename * Reads out $filename
* *
* @param $filename * @param $filename
*
* @return void * @return void
*/ */
public function read(string $filename): void; public function read(string $filename): void;

View File

@ -29,11 +29,19 @@ use JeroenED\Libpairtwo\Enums\Result;
class Pairing class Pairing
{ {
/** /**
* The player of the pairing. Please note this means the pairing was seen from the point of view of this player * The number of the board where the game was held
* *
* @var Player | null * @var int
*/ */
public $Player; public $Board;
/**
* The color of the player.
* Possible values are Black and White
*
* @var Color
*/
public $Color;
/** /**
* The opponent of player * The opponent of player
@ -43,12 +51,11 @@ class Pairing
public $Opponent; public $Opponent;
/** /**
* The color of the player. * The player of the pairing. Please note this means the pairing was seen from the point of view of this player
* Possible values are Black and White
* *
* @var Color * @var Player | null
*/ */
public $Color; public $Player;
/** /**
* The result of the Game. Possible values contain Won, Lost, Draw, Forfait, Bye, etc. * The result of the Game. Possible values contain Won, Lost, Draw, Forfait, Bye, etc.
@ -63,11 +70,4 @@ class Pairing
* @var int * @var int
*/ */
public $Round; public $Round;
/**
* The number of the board where the game was held
*
* @var int
*/
public $Board;
} }

View File

@ -13,9 +13,9 @@
namespace JeroenED\Libpairtwo; namespace JeroenED\Libpairtwo;
use DateTime;
use JeroenED\Libpairtwo\Enums\Gender; use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Title; use JeroenED\Libpairtwo\Enums\Title;
use DateTime;
/** /**
* Class Player * Class Player
@ -30,25 +30,19 @@ use DateTime;
class Player class Player
{ {
/** /**
* Name of the player * Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/**
* The category the player belongs to
* *
* @var string * @var string
*/ */
public $Name; public $Category;
/**
* The player ids for the player. Possible keys are, but not limited to nation and fide
*
* @var int[]
*/
public $Ids;
/**
* The Elos for the player. Possible keys are, but not limited to nation and fide
*
* @var int[]
*/
public $Elos;
/** /**
* Birthday of the player * Birthday of the player
@ -58,33 +52,11 @@ class Player
public $DateOfBirth; public $DateOfBirth;
/** /**
* Tiebreak points of the player. These values are calculated when Tournament->Ranking is called * The Elos for the player. Possible keys are, but not limited to nation and fide
* *
* @var float[] * @var int[]
*/ */
public $Tiebreaks = []; public $Elos;
/**
* The nation the player belongs to. Be noted this does not actually mean this is his main nationality. A player can be signed USCF but may be Italian
*
* @var string
*/
public $Nation;
// TODO: Implement categories
/**
* The category the player belongs to
*
* @var string
*/
public $Category;
/**
* The title of the player. Possible values can be GM, IM, IA, etc.
*
* @var Title
*/
public $Title;
/** /**
* The gender of the player. Possible values contain Male, Female and Neutral * The gender of the player. Possible values contain Male, Female and Neutral
@ -93,6 +65,30 @@ class Player
*/ */
public $Gender; public $Gender;
/**
* The player ids for the player. Possible keys are, but not limited to nation and fide
*
* @var int[]
*/
public $Ids;
// TODO: Implement categories
/**
* Name of the player
*
* @var string
*/
public $Name;
/**
* The nation the player belongs to. Be noted this does not actually mean this is his main nationality. A player
* can be signed USCF but may be Italian
*
* @var string
*/
public $Nation;
/** /**
* The pairings of the player * The pairings of the player
* *
@ -101,12 +97,112 @@ class Player
public $Pairings = []; public $Pairings = [];
/** /**
* Binary data that was read out of the pairing file * Tiebreak points of the player. These values are calculated when Tournament->Ranking is called
* *
* @var bool|DateTime|int|string[] * @var float[]
*/ */
public $Tiebreaks = [];
private $BinaryData; /**
* The title of the player. Possible values can be GM, IM, IA, etc.
*
* @var Title
*/
public $Title;
/**
* Returns the performance rating of the player
*
* WARNING: Calculation currently incorrect. Uses the rule of 400 as temporary solution
*
* @param $type
* @param $unratedElo
*
* @return float
*/
public function Performance(string $type, int $unratedElo): float
{
$total = 0;
$opponents = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::NOTPLAYED) === false) {
$opponentElo = $pairing->Opponent->getElo($type);
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
if (array_search($pairing->Result, Constants::WON) !== false) {
$total += $opponentElo + 400;
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
$total += $opponentElo - 400;
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$total += $opponentElo;
}
$opponents++;
}
}
return round($total / $opponents);
}
/**
* Returns an array of Player objects where name matches $search
*
* @param string $search
* @param Tournament $tournament
*
* @return Player[]
*/
public static function PlayersByName(string $search, Tournament $tournament): array
{
/**
* @var Player[]
*/
$players = $tournament->Players;
/**
* @var Player[]
*/
$return = [];
foreach ($players as $player) {
if (fnmatch($search, $player->Name)) {
$return[] = $player;
}
}
return $return;
}
/**
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
*
* @param string $key
*
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
{
if ($key == 'PlayedGames') {
return $this->playedGames();
} elseif ($key == 'NoOfWins') {
return $this->noOfWins();
} elseif ($key == 'Opponents') {
return $this->opponents();
} elseif (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[ $key ];
}
return null;
}
/**
* Sets binary data that is read out the pairing file but is not needed immediately
*
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void
{
$this->BinaryData[ $key ] = $value;
}
/** /**
* Adds a pairing to the tournament * Adds a pairing to the tournament
@ -120,102 +216,6 @@ class Player
$this->Pairings = $newArray; $this->Pairings = $newArray;
} }
/**
* Returns an array of Player objects where name matches $search
*
* @param string $search
* @param Tournament $tournament
* @return Player[]
*/
public static function PlayersByName(string $search, Tournament $tournament): array
{
/**
* @var Player[]
*/
$players = $tournament->Players;
/**
* @var Player[]
*/
$return = [];
foreach ($players as $player) {
if (fnmatch($search, $player->Name)) {
$return[] = $player;
}
}
return $return;
}
/**
* Returns the elo of elotype for the player
*
* @param string $type
* @return int
*/
public function getElo(string $type): int
{
return $this->Elos[$type];
}
/**
* Sets the elo of elotype for the player
*
* @param string $type
* @param int $value
*/
public function setElo(string $type, int $value): void
{
$currentElos = $this->Elos;
$currentElos[$type] = $value;
$this->Elos = $currentElos;
}
/**
* Returns the identifier of type for the player
*
* Common possible values are Fide or National
*
* @param string $type
* @return string
*/
public function getId(string $type): string
{
return $this->Ids[$type];
}
/**
* Sets the identifier of type for the player
*
* Common possible values are Fide or National
*
* @param string $type
* @param string $value
*/
public function setId(string $type, string $value): void
{
$currentIds = $this->Ids;
$currentIds[$type] = $value;
$this->Ids = $currentIds;
}
/**
* Returns the number of won matches for the player
*
* @return int
*/
private function noOfWins(): int
{
$wins = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::WON) !== false) {
$wins++;
}
}
return $wins;
}
/** /**
* Returns the points of the player after round $round * Returns the points of the player after round $round
* *
@ -223,7 +223,8 @@ class Player
* 0.5 points are awarded for draw * 0.5 points are awarded for draw
* 0 points are awarded for loss * 0 points are awarded for loss
* *
* @param int $round * @param int $round
*
* @return float * @return float
*/ */
public function calculatePoints(int $round = -1): float public function calculatePoints(int $round = -1): float
@ -238,25 +239,10 @@ class Player
} }
} }
} }
return $points; return $points;
} }
/**
* Returns the points of a virtual player as described in the Fide Handbook C.02 chapter 13.15.2.
*
* Return the same score for all rounds until $byeround and added with a half point for each subsequent round
*
* @param int $byeround
* @return float
*/
public function calculatePointsForVirtualPlayer(int $byeround): float
{
$points = $this->calculatePoints($byeround);
foreach (array_slice($this->Pairings, $byeround + 1) as $key => $pairing) {
$points += 0.5;
}
return $points;
}
/** /**
* Returns the points of the player that should be used for tiebreaking systems. * Returns the points of the player that should be used for tiebreaking systems.
* *
@ -278,38 +264,111 @@ class Player
$points = $points + 0.5; $points = $points + 0.5;
} }
} }
return $points; return $points;
} }
/** /**
* Returns the performance rating of the player * Returns the points of a virtual player as described in the Fide Handbook C.02 chapter 13.15.2.
* *
* WARNING: Calculation currently incorrect. Uses the rule of 400 as temporary solution * Return the same score for all rounds until $byeround and added with a half point for each subsequent round
*
* @param int $byeround
* *
* @param $type
* @param $unratedElo
* @return float * @return float
*/ */
public function Performance(string $type, int $unratedElo): float public function calculatePointsForVirtualPlayer(int $byeround): float
{ {
$total = 0; $points = $this->calculatePoints($byeround);
$opponents = 0; foreach (array_slice($this->Pairings, $byeround + 1) as $key => $pairing) {
foreach ($this->Pairings as $pairing) { $points += 0.5;
if (array_search($pairing->Result, Constants::NOTPLAYED) === false) {
$opponentElo = $pairing->Opponent->getElo($type);
$opponentElo = $opponentElo != 0 ? $opponentElo : $unratedElo;
if (array_search($pairing->Result, Constants::WON) !== false) {
$total += $opponentElo + 400;
} elseif (array_search($pairing->Result, Constants::LOST) !== false) {
$total += $opponentElo - 400;
} elseif (array_search($pairing->Result, Constants::DRAW) !== false) {
$total += $opponentElo;
}
$opponents++;
}
} }
return round($total / $opponents);
return $points;
} }
/**
* Returns the elo of elotype for the player
*
* @param string $type
*
* @return int
*/
public function getElo(string $type): int
{
return $this->Elos[ $type ];
}
/**
* Returns the identifier of type for the player
*
* Common possible values are Fide or National
*
* @param string $type
*
* @return string
*/
public function getId(string $type): string
{
return $this->Ids[ $type ];
}
/**
* Returns if player has played against all players of the array
*
* @param Player[] $players
*
* @return bool
*/
public function hasPlayedAllPlayersOfArray(array $players): bool
{
$ownkey = array_search($this, $players);
if ($ownkey !== false) {
unset($players[ $ownkey ]);
}
$total = 0;
foreach ($players as $player) {
if (array_search($player, $this->Opponents) !== false) {
$total++;
}
}
return $total == count($players);
}
/**
* Returns the number of won matches for the player
*
* @return int
*/
private function noOfWins(): int
{
$wins = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::WON) !== false) {
$wins++;
}
}
return $wins;
}
/**
* Returns all opponents of $this
*
* @return Player[]
*/
private function opponents()
{
$return = [];
foreach ($this->Pairings as $pairing) {
if (!empty($pairing->Opponent)) {
$return[] = $pairing->Opponent;
}
}
return $return;
}
/** /**
* Returns the number of played games of the player * Returns the number of played games of the player
@ -324,75 +383,35 @@ class Player
$total++; $total++;
} }
} }
return $total; return $total;
} }
/** /**
* Returns if player has played against all players of the array * Sets the elo of elotype for the player
* *
* @param Player[] $players * @param string $type
* @return bool * @param int $value
*/ */
public function hasPlayedAllPlayersOfArray(array $players): bool public function setElo(string $type, int $value): void
{ {
$ownkey = array_search($this, $players); $currentElos = $this->Elos;
if ($ownkey !== false) { $currentElos[ $type ] = $value;
unset($players[$ownkey]); $this->Elos = $currentElos;
}
$total = 0;
foreach ($players as $player) {
if (array_search($player, $this->Opponents) !== false) {
$total++;
}
}
return $total == count($players);
} }
/** /**
* Returns all opponents of $this * Sets the identifier of type for the player
* *
* @return Player[] * Common possible values are Fide or National
*/
private function opponents()
{
$return = array();
foreach ($this->Pairings as $pairing) {
if (!empty($pairing->Opponent)) {
$return[] = $pairing->Opponent;
}
}
return $return;
}
/**
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
* *
* @param string $key * @param string $type
* @return bool|DateTime|int|string|null * @param string $value
*/ */
public function __get(string $key) public function setId(string $type, string $value): void
{ {
if ($key == 'PlayedGames') { $currentIds = $this->Ids;
return $this->playedGames(); $currentIds[ $type ] = $value;
} elseif ($key == 'NoOfWins') { $this->Ids = $currentIds;
return $this->noOfWins();
} elseif ($key == 'Opponents') {
return $this->opponents();
} elseif (isset($this->BinaryData[$key])) {
return $this->BinaryData[$key];
}
return null;
}
/**
* Sets binary data that is read out the pairing file but is not needed immediately
*
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void
{
$this->BinaryData[$key] = $value;
} }
} }

View File

@ -13,6 +13,7 @@
namespace JeroenED\Libpairtwo\Readers; namespace JeroenED\Libpairtwo\Readers;
use DateTime;
use InvalidArgumentException; use InvalidArgumentException;
use JeroenED\Libpairtwo\Enums\Color; use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gender; use JeroenED\Libpairtwo\Enums\Gender;
@ -26,7 +27,6 @@ use JeroenED\Libpairtwo\Pairing;
use JeroenED\Libpairtwo\Player; use JeroenED\Libpairtwo\Player;
use JeroenED\Libpairtwo\Round; use JeroenED\Libpairtwo\Round;
use JeroenED\Libpairtwo\Tournament; use JeroenED\Libpairtwo\Tournament;
use DateTime;
/** /**
* Reader Pairtwo6 * Reader Pairtwo6
@ -40,15 +40,22 @@ use DateTime;
*/ */
class Pairtwo6 implements ReaderInterface class Pairtwo6 implements ReaderInterface
{ {
public const COMPATIBLE_VERSIONS = ['6.', '5.'];
public const PT_DAYFACTOR = 32; public const PT_DAYFACTOR = 32;
public const PT_MONTHFACTOR = 16; public const PT_MONTHFACTOR = 16;
public const PT_YEARFACTOR = 512;
public const PT_PASTOFFSET = 117; public const PT_PASTOFFSET = 117;
public const COMPATIBLE_VERSIONS = ['6.', '5.']; public const PT_YEARFACTOR = 512;
/**
* Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/** /**
* Version of Pairtwo this file was created with * Version of Pairtwo this file was created with
@ -64,24 +71,19 @@ class Pairtwo6 implements ReaderInterface
*/ */
public $Tournament; public $Tournament;
/**
* Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/** /**
* Returns binary data that was read out the pairtwo file but was not needed immediately * Returns binary data that was read out the pairtwo file but was not needed immediately
* *
* @param string $key * @param string $key
*
* @return bool|DateTime|int|string|null * @return bool|DateTime|int|string|null
*/ */
public function __get(string $key) public function __get(string $key)
{ {
if (isset($this->BinaryData[$key])) { if (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[$key]; return $this->BinaryData[ $key ];
} }
return null; return null;
} }
@ -93,13 +95,67 @@ class Pairtwo6 implements ReaderInterface
*/ */
public function __set(string $key, $value): void public function __set(string $key, $value): void
{ {
$this->BinaryData[$key] = $value; $this->BinaryData[ $key ] = $value;
}
/**
* Adds the first tiebreak to the tournament
*/
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::KEIZER:
$firstElement = new Tiebreak(Tiebreak::KEIZER);
break;
case TournamentSystem::AMERICAN:
case TournamentSystem::CLOSED:
case TournamentSystem::SWISS:
$firstElement = new Tiebreak(Tiebreak::POINTS);
break;
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
}
/**
* Converts integer value to a date representation
*
* @param int $date
*
* @return bool|DateTime
*/
private function convertUIntToTimestamp(int $date)
{
$curyear = date('Y');
$yearoffset = $curyear - self::PT_PASTOFFSET;
// Day
$day = $date % self::PT_DAYFACTOR;
if ($day < 1) {
$day = 1;
}
// Month
$month = ($date / self::PT_DAYFACTOR) % self::PT_MONTHFACTOR;
if ($month < 1) {
$month = 1;
}
// Year
$year = ($date / self::PT_YEARFACTOR) + $yearoffset;
$concat = $month . '/' . $day . '/' . intval($year);
$format = 'm/d/Y';
return DateTime::createFromFormat($format, $concat);
} }
/** /**
* Actually reads the Swar-File * Actually reads the Swar-File
* *
* @param string $filename * @param string $filename
*
* @throws IncompatibleReaderException * @throws IncompatibleReaderException
*/ */
public function read(string $filename): void public function read(string $filename): void
@ -110,7 +166,6 @@ class Pairtwo6 implements ReaderInterface
$offset = 0; $offset = 0;
$length = 4; $length = 4;
$this->Release = $this->readData('String', substr($swscontents, $offset, $length)); $this->Release = $this->readData('String', substr($swscontents, $offset, $length));
$offset += $length; $offset += $length;
@ -321,10 +376,10 @@ class Pairtwo6 implements ReaderInterface
} }
// Categorie // Categorie
for($i = 0; $i < 10; $i++) { for ($i = 0; $i < 10; $i++) {
$length = 4; $length = 4;
$category = $this->readData('Int', substr($swscontents, $offset, $length)); $category = $this->readData('Int', substr($swscontents, $offset, $length));
if($category != 0) { if ($category != 0) {
$this->Tournament->addCategory('+' . $category); $this->Tournament->addCategory('+' . $category);
} }
$offset += $length; $offset += $length;
@ -406,7 +461,8 @@ class Pairtwo6 implements ReaderInterface
$offset += $length; $offset += $length;
$length = 1; $length = 1;
$player->Category = $this->Tournament->Categories[$this->readData('Int', substr($swscontents, $offset, $length)) -1]; $player->Category =
$this->Tournament->Categories[ $this->readData('Int', substr($swscontents, $offset, $length)) - 1 ];
$offset += $length; $offset += $length;
$length = 1; $length = 1;
@ -756,9 +812,10 @@ class Pairtwo6 implements ReaderInterface
* * Bool (Boolean representation of $data. Default: false) * * Bool (Boolean representation of $data. Default: false)
* * Date (Date representation of $data. Default: 1902/01/01) * * Date (Date representation of $data. Default: 1902/01/01)
* *
* @param string $type * @param string $type
* @param string $data * @param string $data
* @param mixed $default * @param mixed $default
*
* @return bool|DateTime|int|string * @return bool|DateTime|int|string
*/ */
private function readData(string $type, string $data, $default = null) private function readData(string $type, string $data, $default = null)
@ -769,6 +826,7 @@ class Pairtwo6 implements ReaderInterface
if ($data == '') { if ($data == '') {
return (is_null($default)) ? '' : $default; return (is_null($default)) ? '' : $default;
} }
return iconv('windows-1252', 'utf-8', $data); return iconv('windows-1252', 'utf-8', $data);
case 'Hex': case 'Hex':
case 'Int': case 'Int':
@ -779,7 +837,7 @@ class Pairtwo6 implements ReaderInterface
foreach ($hex as $key => $item) { foreach ($hex as $key => $item) {
if ($item == "00") { if ($item == "00") {
$hex[$key] = ""; $hex[ $key ] = "";
} else { } else {
break; break;
} }
@ -791,16 +849,19 @@ class Pairtwo6 implements ReaderInterface
if ($hex == '00') { if ($hex == '00') {
return (is_null($default)) ? '00' : $default; return (is_null($default)) ? '00' : $default;
} }
return $hex; return $hex;
} elseif ($type == 'Int') { } elseif ($type == 'Int') {
if ($hex == '00') { if ($hex == '00') {
return (is_null($default)) ? 0 : $default; return (is_null($default)) ? 0 : $default;
} }
return hexdec($hex); return hexdec($hex);
} elseif ($type == 'Date') { } elseif ($type == 'Date') {
if ($hex == '00') { if ($hex == '00') {
return (is_null($default)) ? $this->convertUIntToTimestamp(0) : $default; return (is_null($default)) ? $this->convertUIntToTimestamp(0) : $default;
} }
return $this->convertUIntToTimestamp(hexdec($hex)); return $this->convertUIntToTimestamp(hexdec($hex));
} elseif ($type == 'Bool') { } elseif ($type == 'Bool') {
return ($hex == "01"); return ($hex == "01");
@ -812,58 +873,4 @@ class Pairtwo6 implements ReaderInterface
return false; return false;
} }
/**
* Converts integer value to a date representation
*
* @param int $date
* @return bool|DateTime
*/
private function convertUIntToTimestamp(int $date)
{
$curyear = date('Y');
$yearoffset = $curyear - self::PT_PASTOFFSET;
// Day
$day = $date % self::PT_DAYFACTOR;
if ($day < 1) {
$day = 1;
}
// Month
$month = ($date / self::PT_DAYFACTOR) % self::PT_MONTHFACTOR;
if ($month < 1) {
$month = 1;
}
// Year
$year = ($date / self::PT_YEARFACTOR) + $yearoffset;
$concat = $month . '/' . $day . '/' . intval($year);
$format = 'm/d/Y';
return DateTime::createFromFormat($format, $concat);
}
/**
* Adds the first tiebreak to the tournament
*/
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::KEIZER:
$firstElement = new Tiebreak(Tiebreak::KEIZER);
break;
case TournamentSystem::AMERICAN:
case TournamentSystem::CLOSED:
case TournamentSystem::SWISS:
$firstElement = new Tiebreak(Tiebreak::POINTS);
break;
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
}
} }

View File

@ -13,6 +13,7 @@
namespace JeroenED\Libpairtwo\Readers; namespace JeroenED\Libpairtwo\Readers;
use DateTime;
use InvalidArgumentException; use InvalidArgumentException;
use JeroenED\Libpairtwo\Enums\Color; use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gender; use JeroenED\Libpairtwo\Enums\Gender;
@ -26,7 +27,6 @@ use JeroenED\Libpairtwo\Pairing;
use JeroenED\Libpairtwo\Player; use JeroenED\Libpairtwo\Player;
use JeroenED\Libpairtwo\Round; use JeroenED\Libpairtwo\Round;
use JeroenED\Libpairtwo\Tournament; use JeroenED\Libpairtwo\Tournament;
use DateTime;
/** /**
* Reader Swar4 * Reader Swar4
@ -40,27 +40,6 @@ use DateTime;
*/ */
class Swar4 implements ReaderInterface class Swar4 implements ReaderInterface
{ {
/**
* Version of Pairtwo this file was created with
*
* @var string
*/
public $Release;
/**
* The tournament
*
* @var Tournament
*/
public $Tournament;
/**
* Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/** /**
* @var array * @var array
*/ */
@ -127,6 +106,92 @@ class Swar4 implements ReaderInterface
] ]
]; ];
/**
* Binary data that was read out of the pairing file
*
* @var bool|DateTime|int|string[]
*/
private $BinaryData;
/**
* Version of Pairtwo this file was created with
*
* @var string
*/
public $Release;
/**
* The tournament
*
* @var Tournament
*/
public $Tournament;
/**
* Returns binary data that was read out the swar file but was not needed immediately
*
* @param string $key
*
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
{
if (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[ $key ];
}
return null;
}
/**
* Sets binary data that is read out the swar file but is not needed immediately
*
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void
{
$this->BinaryData[ $key ] = $value;
}
/**
* Adds the first tiebreak to the tournament
*/
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::AMERICAN:
case TournamentSystem::CLOSED:
case TournamentSystem::SWISS:
default:
$firstElement = new Tiebreak(Tiebreak::POINTS);
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
}
/**
* Converts a swar-4 string to a \DateTime object
*
* @param string $string
*
* @return DateTime
*/
public function convertStringToDate(string $string): DateTime
{
if (strlen($string) == 10) {
return DateTime::createFromFormat('d/m/Y', $string);
} elseif (strlen($string) == 8) {
return DateTime::createFromFormat('Ymd', $string);
} else {
$default = new DateTime();
$default->setTimestamp(0);
return $default;
}
}
/** /**
* Actually reads the Swar-File * Actually reads the Swar-File
* *
@ -533,7 +598,7 @@ class Swar4 implements ReaderInterface
* * Date (Date representation of $data. Default: 1902/01/01) * * Date (Date representation of $data. Default: 1902/01/01)
* *
* @param string $type * @param string $type
* @param $handle * @param $handle
* @param null $default * @param null $default
* *
* @return array|bool|DateTime|false|float|int|string|null * @return array|bool|DateTime|false|float|int|string|null
@ -601,68 +666,4 @@ class Swar4 implements ReaderInterface
return false; return false;
} }
/**
* Returns binary data that was read out the swar file but was not needed immediately
*
* @param string $key
*
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
{
if (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[ $key ];
}
return null;
}
/**
* Sets binary data that is read out the swar file but is not needed immediately
*
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function __set(string $key, $value): void
{
$this->BinaryData[ $key ] = $value;
}
/**
* Converts a swar-4 string to a \DateTime object
*
* @param string $string
*
* @return DateTime
*/
public function convertStringToDate(string $string): DateTime
{
if (strlen($string) == 10) {
return DateTime::createFromFormat('d/m/Y', $string);
} elseif (strlen($string) == 8) {
return DateTime::createFromFormat('Ymd', $string);
} else {
$default = new DateTime();
$default->setTimestamp(0);
return $default;
}
}
/**
* Adds the first tiebreak to the tournament
*/
private function addTiebreaks(): void
{
switch ($this->Tournament->System) {
case TournamentSystem::AMERICAN:
case TournamentSystem::CLOSED:
case TournamentSystem::SWISS:
default:
$firstElement = new Tiebreak(Tiebreak::POINTS);
}
$tiebreaks = $this->Tournament->Tiebreaks;
array_unshift($tiebreaks, $firstElement);
$this->Tournament->Tiebreaks = $tiebreaks;
}
} }

View File

@ -42,6 +42,13 @@ class Round
*/ */
public $Games = []; public $Games = [];
/**
* Array of all pairings for this round
*
* @var Pairing[]
*/
public $Pairings = [];
/** /**
* Number of the round * Number of the round
* *
@ -50,11 +57,44 @@ class Round
public $RoundNo; public $RoundNo;
/** /**
* Array of all pairings for this round * Magic method to read out several fields. If field was not found it is being searched in the binary data fields
* *
* @var Pairing[] * @param string $key
*
* @return bool|DateTime|int|string|null
*/ */
public $Pairings = []; public function __get(string $key)
{
if ($key == 'Bye') {
return $this->bye();
} elseif ($key == 'Absent') {
return $this->absent();
} elseif ($key == 'GamesByBoard') {
return $this->gamesByBoard();
} elseif (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[ $key ];
}
return null;
}
/**
* Returns an array of pairings where the player is absent
*
* @return Pairing[]
*/
private function absent(): array
{
$allPairings = $this->Pairings;
$absentPairings = [];
foreach ($allPairings as $pairing) {
if ($pairing->Result == Result::ABSENT) {
$absentPairings[] = $pairing;
}
}
return $absentPairings;
}
/** /**
* Adds a game to the round * Adds a game to the round
@ -94,24 +134,8 @@ class Round
$byePairings[] = $pairing; $byePairings[] = $pairing;
} }
} }
return $byePairings;
}
/** return $byePairings;
* Returns an array of pairings where the player is absent
*
* @return Pairing[]
*/
private function absent(): array
{
$allPairings = $this->Pairings;
$absentPairings = [];
foreach ($allPairings as $pairing) {
if ($pairing->Result == Result::ABSENT) {
$absentPairings[] = $pairing;
}
}
return $absentPairings;
} }
/** /**
@ -122,15 +146,17 @@ class Round
private function gamesByBoard(): array private function gamesByBoard(): array
{ {
$allGames = $this->Games; $allGames = $this->Games;
usort($allGames, array($this, 'sortByBoard')); usort($allGames, [$this, 'sortByBoard']);
return $allGames; return $allGames;
} }
/** /**
* Sort by board * Sort by board
* *
* @param Game $a * @param Game $a
* @param Game $b * @param Game $b
*
* @return int * @return int
*/ */
private function sortByBoard(Game $a, Game $b): int private function sortByBoard(Game $a, Game $b): int
@ -138,26 +164,7 @@ class Round
if (($a->Board == $b->Board) || ($a->Board === false) || ($b->Board === false)) { if (($a->Board == $b->Board) || ($a->Board === false) || ($b->Board === false)) {
return 0; return 0;
} }
return ($a->Board > $b->Board) ? +1 : -1; return ($a->Board > $b->Board) ? +1 : -1;
} }
/**
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields
*
* @param string $key
* @return bool|DateTime|int|string|null
*/
public function __get(string $key)
{
if ($key == 'Bye') {
return $this->bye();
} elseif ($key == 'Absent') {
return $this->absent();
} elseif ($key == 'GamesByBoard') {
return $this->gamesByBoard();
} elseif (isset($this->BinaryData[$key])) {
return $this->BinaryData[$key];
}
return null;
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
use JeroenED\Libpairtwo\IOFactory; use JeroenED\Libpairtwo\IOFactory;
require_once '../vendor/autoload.php'; require_once '../vendor/autoload.php';
@ -30,16 +31,15 @@ require_once '../vendor/autoload.php';
$sws = IOFactory::createReader('Swar-4'); $sws = IOFactory::createReader('Swar-4');
$sws->read('../res/testswar.swar'); $sws->read('../res/testswar.swar');
echo "Release: " . $sws->Release . PHP_EOL; echo "Release: " . $sws->Release . PHP_EOL;
echo "Name: " . $sws->Tournament->Name . PHP_EOL; echo "Name: " . $sws->Tournament->Name . PHP_EOL;
echo "Organiser: " . $sws->Tournament->Organiser. PHP_EOL; echo "Organiser: " . $sws->Tournament->Organiser . PHP_EOL;
echo "TempoIndex: " . $sws->Tournament->TempoIndex . PHP_EOL; echo "TempoIndex: " . $sws->Tournament->TempoIndex . PHP_EOL;
echo "TempoType: " . $sws->Tournament->TournoiStd . PHP_EOL; echo "TempoType: " . $sws->Tournament->TournoiStd . PHP_EOL;
echo "Tempo: " . $sws->Tournament->Tempo . PHP_EOL; echo "Tempo: " . $sws->Tournament->Tempo . PHP_EOL;
echo "Place: " . $sws->Tournament->OrganiserPlace . PHP_EOL; echo "Place: " . $sws->Tournament->OrganiserPlace . PHP_EOL;
echo "Arbiter 1: " . $sws->Tournament->Arbiters[0] . PHP_EOL; echo "Arbiter 1: " . $sws->Tournament->Arbiters[ 0 ] . PHP_EOL;
echo "Arbiter 2: " . $sws->Tournament->Arbiters[1] . PHP_EOL; echo "Arbiter 2: " . $sws->Tournament->Arbiters[ 1 ] . PHP_EOL;
echo "Rounds: " . $sws->Tournament->NoOfRounds . PHP_EOL; echo "Rounds: " . $sws->Tournament->NoOfRounds . PHP_EOL;
echo "Fidehomol: " . $sws->Tournament->FideHomol . PHP_EOL; echo "Fidehomol: " . $sws->Tournament->FideHomol . PHP_EOL;
echo "Start-Date: " . $sws->Tournament->StartDate->format('d/m/Y') . PHP_EOL; echo "Start-Date: " . $sws->Tournament->StartDate->format('d/m/Y') . PHP_EOL;
@ -70,26 +70,28 @@ echo "Category P3: " . $sws->Tournament->PlayerById(2)->Category . PHP_EOL;
echo "Date Round 1: " . $sws->Tournament->RoundByNo(0)->Date->format('d/m/Y') . PHP_EOL; echo "Date Round 1: " . $sws->Tournament->RoundByNo(0)->Date->format('d/m/Y') . PHP_EOL;
echo "Date Round 2: " . $sws->Tournament->RoundByNo(1)->Date->format('d/m/Y') . PHP_EOL; echo "Date Round 2: " . $sws->Tournament->RoundByNo(1)->Date->format('d/m/Y') . PHP_EOL;
echo "Date Round 3: " . $sws->Tournament->RoundByNo(2)->Date->format('d/m/Y') . PHP_EOL; echo "Date Round 3: " . $sws->Tournament->RoundByNo(2)->Date->format('d/m/Y') . PHP_EOL;
echo "Game Round 1: " . $sws->Tournament->RoundByNo(0)->Games[0]->Result->getValue() . PHP_EOL; echo "Game Round 1: " . $sws->Tournament->RoundByNo(0)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Game Round 2: " . $sws->Tournament->RoundByNo(1)->Games[0]->Result->getValue() . PHP_EOL; echo "Game Round 2: " . $sws->Tournament->RoundByNo(1)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Game Round 3: " . $sws->Tournament->RoundByNo(2)->Games[0]->Result->getValue() . PHP_EOL; echo "Game Round 3: " . $sws->Tournament->RoundByNo(2)->Games[ 0 ]->Result->getValue() . PHP_EOL;
echo "Color Pairing 1: " . $sws->Tournament->Pairings[1]->Color->getKey() . PHP_EOL; echo "Color Pairing 1: " . $sws->Tournament->Pairings[ 1 ]->Color->getKey() . PHP_EOL;
echo "Color Pairing 2: " . $sws->Tournament->Pairings[2]->Color->getKey() . PHP_EOL; echo "Color Pairing 2: " . $sws->Tournament->Pairings[ 2 ]->Color->getKey() . PHP_EOL;
echo "Color Pairing 3: " . $sws->Tournament->Pairings[3]->Color->getKey() . PHP_EOL; echo "Color Pairing 3: " . $sws->Tournament->Pairings[ 3 ]->Color->getKey() . PHP_EOL;
echo "Player Pairing 1: " . $sws->Tournament->Pairings[0]->Player->Name . PHP_EOL; echo "Player Pairing 1: " . $sws->Tournament->Pairings[ 0 ]->Player->Name . PHP_EOL;
echo "Player Pairing 2: " . $sws->Tournament->Pairings[1]->Player->Name . PHP_EOL; echo "Player Pairing 2: " . $sws->Tournament->Pairings[ 1 ]->Player->Name . PHP_EOL;
echo "Player Pairing 3: " . $sws->Tournament->Pairings[2]->Player->Name . PHP_EOL; echo "Player Pairing 3: " . $sws->Tournament->Pairings[ 2 ]->Player->Name . PHP_EOL;
echo "Bye Round 1: " . $sws->Tournament->RoundByNo(2)->Bye[0]->Player->Name . PHP_EOL; echo "Bye Round 1: " . $sws->Tournament->RoundByNo(2)->Bye[ 0 ]->Player->Name . PHP_EOL;
echo "Absent Round 1: " . $sws->Tournament->RoundByNo(2)->Absent[0]->Player->Name . PHP_EOL; echo "Absent Round 1: " . $sws->Tournament->RoundByNo(2)->Absent[ 0 ]->Player->Name . PHP_EOL;
echo "Tiebreak 1: " . $sws->Tournament->Tiebreaks[0]->getValue() . PHP_EOL; echo "Tiebreak 1: " . $sws->Tournament->Tiebreaks[ 0 ]->getValue() . PHP_EOL;
echo "Tiebreak 2: " . $sws->Tournament->Tiebreaks[1]->getValue() . PHP_EOL; echo "Tiebreak 2: " . $sws->Tournament->Tiebreaks[ 1 ]->getValue() . PHP_EOL;
echo "Tiebreak 3: " . $sws->Tournament->Tiebreaks[2]->getValue() . PHP_EOL; echo "Tiebreak 3: " . $sws->Tournament->Tiebreaks[ 2 ]->getValue() . PHP_EOL;
echo "Tiebreak 4: " . $sws->Tournament->Tiebreaks[3]->getValue() . PHP_EOL; echo "Tiebreak 4: " . $sws->Tournament->Tiebreaks[ 3 ]->getValue() . PHP_EOL;
echo "Tiebreak 5: " . $sws->Tournament->Tiebreaks[4]->getValue() . PHP_EOL; echo "Tiebreak 5: " . $sws->Tournament->Tiebreaks[ 4 ]->getValue() . PHP_EOL;
echo "Tiebreak 6: " . $sws->Tournament->Tiebreaks[5]->getValue() . PHP_EOL; echo "Tiebreak 6: " . $sws->Tournament->Tiebreaks[ 5 ]->getValue() . PHP_EOL;
echo "Average Elo: " . $sws->Tournament->AverageElo . PHP_EOL; echo "Average Elo: " . $sws->Tournament->AverageElo . PHP_EOL;
foreach ($sws->Tournament->RankingForCategory('+2500') as $player) { foreach ($sws->Tournament->RankingForCategory('+2500') as $player) {
echo str_pad($player->Name . '(' . $player->getElo($sws->Tournament->PriorityElo) . ') ', 35) . implode_pad(' ', $player->Tiebreaks, 5, ' ') . PHP_EOL; echo str_pad($player->Name . '(' . $player->getElo($sws->Tournament->PriorityElo) . ') ', 35) .
implode_pad(' ', $player->Tiebreaks, 5, ' ') .
PHP_EOL;
} }
function implode_pad($glue, $collection, $padlength, $padstring): string function implode_pad($glue, $collection, $padlength, $padstring): string
@ -98,5 +100,6 @@ function implode_pad($glue, $collection, $padlength, $padstring): string
foreach ($collection as $elem) { foreach ($collection as $elem) {
$newarray[] = str_pad($elem, $padlength, $padstring); $newarray[] = str_pad($elem, $padlength, $padstring);
} }
return implode($glue, $newarray); return implode($glue, $newarray);
} }