Merge branch 'task/categories' into develop

This commit is contained in:
Jeroen De Meerleer 2020-11-22 17:13:17 +01:00
commit a39fdbbf89
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": [
{ {

19
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;
} }

View File

@ -6,11 +6,10 @@
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#" xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns="http://www.w3.org/2000/svg"
width="134.01421mm" width="134.01421mm"
height="89.507103mm" height="89.507103mm"
viewBox="0 0 134.01421 89.507103" viewBox="0 0 134.01421 89.507103"

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -6,11 +6,10 @@
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#" xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns="http://www.w3.org/2000/svg"
width="134.01421mm" width="134.01421mm"
height="89.507103mm" height="89.507103mm"
viewBox="0 0 134.01421 89.507103" viewBox="0 0 134.01421 89.507103"

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -1,53 +1,153 @@
<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} h1 {
.thl {font-size: 10pt; text-align: left} background-color: navy;
.thc {font-size: 10pt; text-align: center} color: #FDE0AA;
.tdr {font-size: 8pt; text-align: right} font-size: 24pt;
.tdl {font-size: 8pt; text-align: left} font-weight: bold;
.tdc {font-size: 8pt; text-align: center;} font-family: Arial;
.tdp {font-size: 10pt; font-weight:bold;text-align: center; background-color='yellow'} text-align: center;
.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;} th {
a:visited { text-decoration: none; color: blue;} background-color: #408080;
a:hover { text-decoration:none ; color: red;} 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> </style>
<TITLE>Libpairtwo Tournament</TITLE> <TITLE>Libpairtwo Tournament</TITLE>
<META name='DESCRIPTION' content='Classement, Résultats, Appariement, Grille Américaine'> <META content='Classement, R<EFBFBD>sultats, Appariement, Grille Am<41>ricaine' name='DESCRIPTION'>
<META name='AUTHOR' content='Georges Marchal'> <META content='Georges Marchal' name='AUTHOR'>
<META name='KEYWORDS' content='échecs,echecs,chess,jeux,game,belgique,belgium,forum'> <META content='<27>checs,echecs,chess,jeux,game,belgique,belgium,forum' name='KEYWORDS'>
<META name='KEYWORDS' content='liège,liege,666,elo,classement,tournoi,interclub'> <META content='li<6C>ge,liege,666,elo,classement,tournoi,interclub' name='KEYWORDS'>
<META name='KEYWORDS' content='pairtwo, kbsb,frbe,fefb,666'> <META content='pairtwo, kbsb,frbe,fefb,666' name='KEYWORDS'>
<META name='ROBOTS' content='INDEX,FOLLOW'> <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
(2015/08/10)</b></font></td>
</tr>
<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> </TABLE>
</td> </td>
<td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td> <td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td>
@ -56,13 +156,16 @@ a:hover { text-decoration:none ; color: red;}
<!-- ================== --> <!-- ================== -->
<!-- === REFERENCES === --> <!-- === REFERENCES === -->
<!-- ================== --> <!-- ================== -->
<br><TABLE align='center' border='3' bgcolor='#ffffdd'> <br>
<TABLE align='center' bgcolor='#ffffdd' border='3'>
<TR> <TR>
<TD class='vh'><A HREF='#Round1'>R1</A></TD> <TD class='vh'><A HREF='#Round1'>R1</A></TD>
<TD class='vh'><A HREF='#Round2'>R2</A></TD> <TD class='vh'><A HREF='#Round2'>R2</A></TD>
<TD class='vh'><A HREF='#Round3'>R3</A></TD> <TD class='vh'><A HREF='#Round3'>R3</A></TD>
</TR> </TR>
<TR><TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD></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'>
@ -70,25 +173,36 @@ a:hover { text-decoration:none ; color: red;}
<!-- =========================== --> <!-- =========================== -->
<!-- === 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>
@ -96,16 +210,20 @@ a:hover { text-decoration:none ; color: red;}
<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 -->
<!-- ================= --> <!-- ================= -->
@ -114,7 +232,8 @@ a:hover { text-decoration:none ; color: red;}
<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>
@ -133,83 +252,89 @@ a:hover { text-decoration:none ; color: red;}
</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'>
<TR>
<TD align='center' bgColor='#000090'>
<FONT color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></TD> <FONT color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></TD>
<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>PairTwo 6.13 (2015/08/10)</b></font></td>
</TD></TR></TABLE></p> </tr>
</body></html> </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;
} }
@ -113,6 +113,7 @@ 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
@ -40,13 +39,13 @@ abstract class IOFactory
'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
*/ */

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,23 +97,49 @@ 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;
/** /**
* Adds a pairing to the tournament * The title of the player. Possible values can be GM, IM, IA, etc.
* *
* @param Pairing $pairing * @var Title
*/ */
public function addPairing(Pairing $pairing): void 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
{ {
$newArray = $this->Pairings; $total = 0;
$newArray[] = $pairing; $opponents = 0;
$this->Pairings = $newArray; 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);
} }
/** /**
@ -125,6 +147,7 @@ class Player
* *
* @param string $search * @param string $search
* @param Tournament $tournament * @param Tournament $tournament
*
* @return Player[] * @return Player[]
*/ */
public static function PlayersByName(string $search, Tournament $tournament): array public static function PlayersByName(string $search, Tournament $tournament): array
@ -149,71 +172,48 @@ class Player
} }
/** /**
* Returns the elo of elotype for the player * Magic method to read out several fields. If field was not found it is being searched in the binary data fields
* *
* @param string $type * @param string $key
* @return int *
* @return bool|DateTime|int|string|null
*/ */
public function getElo(string $type): int public function __get(string $key)
{ {
return $this->Elos[$type]; 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 the elo of elotype for the player * Sets binary data that is read out the pairing file but is not needed immediately
* *
* @param string $type * @param string $key
* @param int $value * @param bool|int|DateTime|string $value
*/ */
public function setElo(string $type, int $value): void public function __set(string $key, $value): void
{ {
$currentElos = $this->Elos; $this->BinaryData[ $key ] = $value;
$currentElos[$type] = $value;
$this->Elos = $currentElos;
} }
/** /**
* Returns the identifier of type for the player * Adds a pairing to the tournament
* *
* Common possible values are Fide or National * @param Pairing $pairing
*
* @param string $type
* @return string
*/ */
public function getId(string $type): string public function addPairing(Pairing $pairing): void
{ {
return $this->Ids[$type]; $newArray = $this->Pairings;
} $newArray[] = $pairing;
$this->Pairings = $newArray;
/**
* 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;
} }
/** /**
@ -224,6 +224,7 @@ class Player
* 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,59 +264,60 @@ 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 number of played games of the player * Returns the elo of elotype for the player
*
* @param string $type
* *
* @return int * @return int
*/ */
private function playedGames(): int public function getElo(string $type): int
{ {
$total = 0; return $this->Elos[ $type ];
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::PLAYED) !== false) {
$total++;
} }
}
return $total; /**
* 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 * Returns if player has played against all players of the array
* *
* @param Player[] $players * @param Player[] $players
*
* @return bool * @return bool
*/ */
public function hasPlayedAllPlayersOfArray(array $players): bool public function hasPlayedAllPlayersOfArray(array $players): bool
@ -349,6 +336,23 @@ class Player
return $total == count($players); 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 * Returns all opponents of $this
* *
@ -356,43 +360,58 @@ class Player
*/ */
private function opponents() private function opponents()
{ {
$return = array(); $return = [];
foreach ($this->Pairings as $pairing) { foreach ($this->Pairings as $pairing) {
if (!empty($pairing->Opponent)) { if (!empty($pairing->Opponent)) {
$return[] = $pairing->Opponent; $return[] = $pairing->Opponent;
} }
} }
return $return; return $return;
} }
/** /**
* Magic method to read out several fields. If field was not found it is being searched in the binary data fields * Returns the number of played games of the player
* *
* @param string $key * @return int
* @return bool|DateTime|int|string|null
*/ */
public function __get(string $key) private function playedGames(): int
{ {
if ($key == 'PlayedGames') { $total = 0;
return $this->playedGames(); foreach ($this->Pairings as $pairing) {
} elseif ($key == 'NoOfWins') { if (array_search($pairing->Result, Constants::PLAYED) !== false) {
return $this->noOfWins(); $total++;
} elseif ($key == 'Opponents') {
return $this->opponents();
} elseif (isset($this->BinaryData[$key])) {
return $this->BinaryData[$key];
} }
return null; }
return $total;
} }
/** /**
* Sets binary data that is read out the pairing file but is not needed immediately * Sets the elo of elotype for the player
* *
* @param string $key * @param string $type
* @param bool|int|DateTime|string $value * @param int $value
*/ */
public function __set(string $key, $value): void public function setElo(string $type, int $value): void
{ {
$this->BinaryData[$key] = $value; $currentElos = $this->Elos;
$currentElos[ $type ] = $value;
$this->Elos = $currentElos;
}
/**
* 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;
} }
} }

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,17 +71,11 @@ 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)
@ -82,6 +83,7 @@ class Pairtwo6 implements ReaderInterface
if (isset($this->BinaryData[ $key ])) { if (isset($this->BinaryData[ $key ])) {
return $this->BinaryData[ $key ]; return $this->BinaryData[ $key ];
} }
return null; return null;
} }
@ -96,10 +98,64 @@ class Pairtwo6 implements ReaderInterface
$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;
@ -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;
@ -759,6 +815,7 @@ class Pairtwo6 implements ReaderInterface
* @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':
@ -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
* *
@ -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,7 +146,8 @@ 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;
} }
@ -131,6 +156,7 @@ class Round
* *
* @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,7 +31,6 @@ 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;
@ -89,7 +89,9 @@ 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);
} }