CLEANED UP DA CODE

pull/14/head
Jeroen De Meerleer 2 years ago
parent aac0322491
commit 400780ef54
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

@ -51,7 +51,9 @@
<option name="BINARY_OPERATION_WRAP" value="5" />
<option name="TERNARY_OPERATION_WRAP" value="5" />
<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_CLASSES_IN_ONE_LINE" value="true" />
<option name="FOR_STATEMENT_WRAP" value="5" />
<option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
<option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />

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

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

23
dist/template.php vendored

@ -27,7 +27,10 @@ use JeroenED\Libpairtwo\IOFactory;
require_once 'vendor/autoload.php';
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);
@ -49,8 +52,18 @@ foreach ($reader->Tournament->Rounds as $round) {
foreach ($round->GamesByBoard as $game) {
echo '<tr>' . 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>' . $game->Black->Player->Name . ' (' . $game->Black->Player->getElo($reader->Tournament->PriorityElo) . ')</td>' . PHP_EOL;
echo '<td>' .
$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 '</tr>' . PHP_EOL;
}
@ -101,7 +114,7 @@ echo '</table>' . PHP_EOL;
<?php
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 '<caption>' . $category . '</caption>';
echo '<thead>' . PHP_EOL;
@ -126,6 +139,6 @@ foreach($reader->Tournament->Categories as $category) {
echo '</table>' . PHP_EOL;
}
?>
<script src="js/scripts.js"></script>
<script src="js/scripts.js"></script>
</body>
</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

@ -1,215 +1,340 @@
<HTML>
<HEAD>
<style type="text/css">
body { font-size: 10pt; font-family: verdana;}
h1 {background-color: navy;color: #FDE0AA;font-size: 24pt;font-weight:bold;font-family:Arial;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 name='DESCRIPTION' content='Classement, Résultats, Appariement, Grille Américaine'>
<META name='AUTHOR' content='Georges Marchal'>
<META name='KEYWORDS' content='échecs,echecs,chess,jeux,game,belgique,belgium,forum'>
<META name='KEYWORDS' content='liège,liege,666,elo,classement,tournoi,interclub'>
<META name='KEYWORDS' content='pairtwo, kbsb,frbe,fefb,666'>
<META name='ROBOTS' content='INDEX,FOLLOW'>
</HEAD>
<BODY>
<A name=Top></A>
<!-- TITRE GENERAL EN BLEU -->
<!-- ===================== -->
<TABLE width='90%' align='center' bgColor='#000080' border='0'>
<TR><TD><H1>Libpairtwo Tournament</H1></TD></TR></TABLE>
<!-- =============== -->
<!-- INFO DU TOURNOI -->
<!-- =============== --><br>
<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><td align='center' bgColor='#000090'><font color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></td>
<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>
</td>
<td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td>
</tr>
</table>
<!-- ================== -->
<!-- === REFERENCES === -->
<!-- ================== -->
<br><TABLE align='center' border='3' bgcolor='#ffffdd'>
<TR>
<TD class='vh'><A HREF='#Round1'>R1</A></TD>
<TD class='vh'><A HREF='#Round2'>R2</A></TD>
<TD class='vh'><A HREF='#Round3'>R3</A></TD>
</TR>
<TR><TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD></TR>
</TABLE>
<br>
<DIV ALIGN='CENTER'>
<TABLE align='center' bgcolor='#ffffdd' border='1'>
<!-- =========================== -->
<!-- === DEBUT DU CLASSEMENT === -->
<!-- =========================== -->
<TR><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>
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
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
<A href='#Top'>Top of Page</A>
</PRE></TD></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)
2 Libpairtwo Player 3 ( 2) <b>0-1 </b>Libpairtwo Player 1 ( 4)
</pre>
<A HREF="#Top">(Go to Top)</A>
</TD>
<TR><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)
2 Libpairtwo Player 3 ( 2) <font color='red'> Bye</font>
Libpairtwo Player 4 ( 1)<font color='red'> Absent </font>
</pre>
<A HREF="#Top">(Go to Top)</A>
</TD>
<TR><TH class='rh'><A NAME='Round3' style='color: black'>Round 3 (11-01-2019)</A></TH></TR>
<TR><TD><PRE>
1 Libpairtwo Player 4 ( 1) <b>½-½ </b>Libpairtwo Player 1 ( 4)
2 Libpairtwo Player 2 ( 3) <font color='red'> Bye</font>
Libpairtwo Player 3 ( 2)<font color='red'> Absent </font>
</pre>
<A HREF="#Top">(Go to Top)</A>
</TD>
</table></div>
<!-- ================= -->
<!-- GRILLE AMERICAINE -->
<!-- ================= -->
<DIV ALIGN='CENTER'>
<TABLE align='center' bgcolor='#ffffdd' border='1'>
<TR>
<TH colspan='14'>
<FONT size='+2'>American Ranking</FONT>
<A name=Americaine></A></TH></TR>
<TR bgcolor='#cccccc'>
<TD class='thr'>&nbsp;</TD>
<TD class='thl'><B>Name</B></TD>
<TD class='thr'><B>Rating</B></TD>
<TD class='thr'><B> Pts</B></TD>
<TD class='thr'><B>Perf </B></TD>
<TD class='thc'><B>R1</B></TD>
<TD class='thc'><B>R2</B></TD>
<TD class='thc'><B>R3</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>#Bla</i></b></TD>
<TD class='thr'><b><i>BC1 </i></b></TD>
<TD class='thr'><b><i>S B </i></b></TD>
</tr>
<tr>
<td class='tdr' bgcolor='#eeeeee'> 1</td>
<td class='tdl' bgcolor='#eeeeee'><B>Libpairtwo Player 2 (FM)</B></td>
<td class='tdr' bgcolor='#eeeeee'>1802</td>
<td class='tdr' bgcolor='#eeeeee'><B>3.0</B></td>
<td class='tdr' bgcolor='#eeeeee'><i>2602</i></td>
<td class='tdc' bgcolor='#eeeeee'> 4W +</td>
<td class='tdc' bgcolor='#eeeeee'> 2B +</td>
<td class='tdc' bgcolor='#eeeeee'>bye</td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.00</i></td>
</tr>
<tr>
<td class='tdr' bgcolor='#cccccc'> 2</td>
<td class='tdl' bgcolor='#cccccc'><B>Libpairtwo Player 1 (*)</B></td>
<td class='tdr' bgcolor='#cccccc'>1801</td>
<td class='tdr' bgcolor='#cccccc'><B>1.5</B></td>
<td class='tdr' bgcolor='#cccccc'><i>1810</i></td>
<td class='tdc' bgcolor='#cccccc'> 3B +</td>
<td class='tdc' bgcolor='#cccccc'> 1W -</td>
<td class='tdc' bgcolor='#cccccc'> 4B =</td>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.00</i></td>
</tr>
<tr>
<td class='tdr' bgcolor='#eeeeee'> 3</td>
<td class='tdl' bgcolor='#eeeeee'><B>Libpairtwo Player 3 (IM)</B></td>
<td class='tdr' bgcolor='#eeeeee'>1803</td>
<td class='tdr' bgcolor='#eeeeee'><B>1.0</B></td>
<td class='tdr' bgcolor='#eeeeee'><i>1331</i></td>
<td class='tdc' bgcolor='#eeeeee'> 2W -</td>
<td class='tdc' bgcolor='#eeeeee'>bye</td>
<td class='tdc' bgcolor='#eeeeee'>...</td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i>0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.0</i></td>
<td class='tdc' bgcolor='#eeeeee'><i> 0.00</i></td>
</tr>
<tr>
<td class='tdr' bgcolor='#cccccc'> 4</td>
<td class='tdl' bgcolor='#cccccc'><B>Libpairtwo Player 4 (GM)</B></td>
<td class='tdr' bgcolor='#cccccc'>1804</td>
<td class='tdr' bgcolor='#cccccc'><B>0.5</B></td>
<td class='tdr' bgcolor='#cccccc'><i>1626</i></td>
<td class='tdc' bgcolor='#cccccc'> 1B -</td>
<td class='tdc' bgcolor='#cccccc'>...</td>
<td class='tdc' bgcolor='#cccccc'> 2W =</td>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td>
<td class='tdc' bgcolor='#cccccc'><i>0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.0</i></td>
<td class='tdc' bgcolor='#cccccc'><i> 0.00</i></td>
</tr>
</TABLE></DIV>
<P align='center'><A href='#Top'><FONT size='-1'>Top of Page</FONT></A>
</TABLE>
<!-- ========= -->
<!-- COPYRIGHT -->
<!-- ========= -->
<p><TABLE border='0'>
<TR><TD align='center' bgColor='#000090'>
<FONT color='white' size='-1'><b>(&copy;) FRBE 2005</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></TABLE></p>
</body></html>
<HTML>
<HEAD>
<style type="text/css">
body {
font-size: 10pt;
font-family: verdana;
}
h1 {
background-color: navy;
color: #FDE0AA;
font-size: 24pt;
font-weight: bold;
font-family: Arial;
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>
<BODY>
<A name=Top></A>
<!-- TITRE GENERAL EN BLEU -->
<!-- ===================== -->
<TABLE align='center' bgColor='#000080' border='0' width='90%'>
<TR>
<TD><H1>Libpairtwo Tournament</H1></TD>
</TR>
</TABLE>
<!-- =============== -->
<!-- INFO DU TOURNOI -->
<!-- =============== --><br>
<table align='center' border='1'
'>
<tr>
<td align='center' valign='middle'><font size='+2'><b>313</b></font></td>
<td>
<TABLE align='center' border='1' style='font-size: 8pt; font-family: verdana;'>
<tr>
<td align='center' bgColor='#000090'><font color='white' size='-1'><b>(&copy;) FRBE 2005</b></font></td>
<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>
</td>
<td align='center' valign='middle'><font size='+2'><b>F.R.B.E.</b></font></td>
</tr>
</table>
<!-- ================== -->
<!-- === REFERENCES === -->
<!-- ================== -->
<br>
<TABLE align='center' bgcolor='#ffffdd' border='3'>
<TR>
<TD class='vh'><A HREF='#Round1'>R1</A></TD>
<TD class='vh'><A HREF='#Round2'>R2</A></TD>
<TD class='vh'><A HREF='#Round3'>R3</A></TD>
</TR>
<TR>
<TD class='vh' colspan='3'><A HREF='#Americaine'>American Ranking</A></TD>
</TR>
</TABLE>
<br>
<DIV ALIGN='CENTER'>
<TABLE align='center' bgcolor='#ffffdd' border='1'>
<!-- =========================== -->
<!-- === DEBUT DU CLASSEMENT === -->
<!-- =========================== -->
<TR>
<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>
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
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
<A href='#Top'>Top of Page</A>
</PRE>
</TD>
</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)
2 Libpairtwo Player 3 ( 2) <b>0-1 </b>Libpairtwo Player 1 ( 4)
</pre>
<A HREF="#Top">(Go to Top)</A>
</TD>
<TR>
<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)
2 Libpairtwo Player 3 ( 2) <font color='red'> Bye</font>
Libpairtwo Player 4 ( 1)<font color='red'> Absent </font>
</pre>
<A HREF="#Top">(Go to Top)</A>
</TD>
<TR>
<TH class='rh'><A NAME='Round3' style='color: black'>Round 3 (11-01-2019)</A></TH>
</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>
Libpairtwo Player 3 ( 2)<font color='red'> Absent </font>
</pre>
<A HREF="#Top">(Go to Top)</A>
</TD>
</table>
</div>
<!-- ================= -->
<!-- GRILLE AMERICAINE -->
<!-- ================= -->
<DIV ALIGN='CENTER'>
<TABLE align='center' bgcolor='#ffffdd' border='1'>
<TR>
<TH colspan='14'>
<FONT size='+2'>American Ranking</FONT>
<A name=Americaine></A></TH>
</TR>
<TR bgcolor='#cccccc'>
<TD class='thr'>&nbsp;</TD>
<TD class='thl'><B>Name</B></TD>
<TD class='thr'><B>Rating</B></TD>
<TD class='thr'><B> Pts</B></TD>
<TD class='thr'><B>Perf </B></TD>
<TD class='thc'><B>R1</B></TD>
<TD class='thc'><B>R2</B></TD>
<TD class='thc'><B>R3</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>#Bla</i></b></TD>
<TD class='thr'><b><i>BC1 </i></b></TD>
<TD class='thr'><b><i>S B </i></b></TD>
</tr>
<tr>
<td bgcolor='#eeeeee' class='tdr'> 1</td>
<td bgcolor='#eeeeee' class='tdl'><B>Libpairtwo Player 2 (FM)</B></td>
<td bgcolor='#eeeeee' class='tdr'>1802</td>
<td bgcolor='#eeeeee' class='tdr'><B>3.0</B></td>
<td bgcolor='#eeeeee' class='tdr'><i>2602</i></td>
<td bgcolor='#eeeeee' class='tdc'> 4W +</td>
<td bgcolor='#eeeeee' class='tdc'> 2B +</td>
<td bgcolor='#eeeeee' class='tdc'>bye</td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.00</i></td>
</tr>
<tr>
<td bgcolor='#cccccc' class='tdr'> 2</td>
<td bgcolor='#cccccc' class='tdl'><B>Libpairtwo Player 1 (*)</B></td>
<td bgcolor='#cccccc' class='tdr'>1801</td>
<td bgcolor='#cccccc' class='tdr'><B>1.5</B></td>
<td bgcolor='#cccccc' class='tdr'><i>1810</i></td>
<td bgcolor='#cccccc' class='tdc'> 3B +</td>
<td bgcolor='#cccccc' class='tdc'> 1W -</td>
<td bgcolor='#cccccc' class='tdc'> 4B =</td>
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td bgcolor='#cccccc' class='tdc'><i> 0.00</i></td>
</tr>
<tr>
<td bgcolor='#eeeeee' class='tdr'> 3</td>
<td bgcolor='#eeeeee' class='tdl'><B>Libpairtwo Player 3 (IM)</B></td>
<td bgcolor='#eeeeee' class='tdr'>1803</td>
<td bgcolor='#eeeeee' class='tdr'><B>1.0</B></td>
<td bgcolor='#eeeeee' class='tdr'><i>1331</i></td>
<td bgcolor='#eeeeee' class='tdc'> 2W -</td>
<td bgcolor='#eeeeee' class='tdc'>bye</td>
<td bgcolor='#eeeeee' class='tdc'>...</td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i>0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.0</i></td>
<td bgcolor='#eeeeee' class='tdc'><i> 0.00</i></td>
</tr>
<tr>
<td bgcolor='#cccccc' class='tdr'> 4</td>
<td bgcolor='#cccccc' class='tdl'><B>Libpairtwo Player 4 (GM)</B></td>
<td bgcolor='#cccccc' class='tdr'>1804</td>
<td bgcolor='#cccccc' class='tdr'><B>0.5</B></td>
<td bgcolor='#cccccc' class='tdr'><i>1626</i></td>
<td bgcolor='#cccccc' class='tdc'> 1B -</td>
<td bgcolor='#cccccc' class='tdc'>...</td>
<td bgcolor='#cccccc' class='tdc'> 2W =</td>
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td bgcolor='#cccccc' class='tdc'><i>0</i></td>
<td bgcolor='#cccccc' class='tdc'><i> 0.0</i></td>
<td bgcolor='#cccccc' class='tdc'><i> 0.00</i></td>
</tr>
</TABLE>
</DIV>
<P align='center'><A href='#Top'><FONT size='-1'>Top of Page</FONT></A>
</TABLE>
<!-- ========= -->
<!-- COPYRIGHT -->
<!-- ========= -->
<p>
<TABLE border='0'>
<TR>
<TD align='center' bgColor='#000090'>
<FONT color='white' size='-1'><b>(&copy;) FRBE 2005</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></TABLE>
</p>
</body>
</html>

@ -28,7 +28,7 @@ use JeroenED\Libpairtwo\Enums\Result;
*/
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];
@ -49,7 +49,7 @@ class Constants
Result::ADJOURNED
];
public const BLACK = [Color::BLACK];
public const WHITE = [Color::WHITE];
public const WON = [Result::WON, Result::WON_FORFAIT, Result::WON_BYE, Result::WON_ADJOURNED];
}

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

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

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

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

@ -13,9 +13,9 @@
namespace JeroenED\Libpairtwo;
use DateTime;
use JeroenED\Libpairtwo\Enums\Gender;
use JeroenED\Libpairtwo\Enums\Title;
use DateTime;
/**
* Class Player
@ -30,25 +30,19 @@ use DateTime;
class Player
{
/**
* Name of the player
* Binary data that was read out of the pairing file
*
* @var string
* @var bool|DateTime|int|string[]
*/
public $Name;
/**
* The player ids for the player. Possible keys are, but not limited to nation and fide
*
* @var int[]
*/
public $Ids;
private $BinaryData;
/**
* The Elos for the player. Possible keys are, but not limited to nation and fide
* The category the player belongs to
*
* @var int[]
* @var string
*/
public $Elos;
public $Category;
/**
* Birthday of the player
@ -58,40 +52,42 @@ class Player
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
* The gender of the player. Possible values contain Male, Female and Neutral
*
* @var string
* @var Gender
*/
public $Nation;
public $Gender;
// TODO: Implement categories
/**
* The category the player belongs to
* The player ids for the player. Possible keys are, but not limited to nation and fide
*
* @var string
* @var int[]
*/
public $Category;
public $Ids;
// TODO: Implement categories
/**
* The title of the player. Possible values can be GM, IM, IA, etc.
* Name of the player
*
* @var Title
* @var string
*/
public $Title;
public $Name;
/**
* The gender of the player. Possible values contain Male, Female and Neutral
* 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 Gender
* @var string
*/
public $Gender;
public $Nation;
/**
* The pairings of the player
@ -101,42 +97,69 @@ class Player
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;
/**
* Adds a pairing to the tournament
* Returns the performance rating of the player
*
* @param Pairing $pairing
* WARNING: Calculation currently incorrect. Uses the rule of 400 as temporary solution
*
* @param $type
* @param $unratedElo
*
* @return float
*/
public function addPairing(Pairing $pairing): void
public function Performance(string $type, int $unratedElo): float
{
$newArray = $this->Pairings;
$newArray[] = $pairing;
$this->Pairings = $newArray;
$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
* @param string $search
* @param Tournament $tournament
*
* @return Player[]
*/
public static function PlayersByName(string $search, Tournament $tournament): array
{
/**
* @var Player[]
*/
* @var Player[]
*/
$players = $tournament->Players;
/**
* @var Player[]
*/
* @var Player[]
*/
$return = [];
foreach ($players as $player) {
@ -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
* @return int
*/
public function getElo(string $type): int
{
return $this->Elos[$type];
}
/**
* Sets the elo of elotype for the player
* @param string $key
*
* @param string $type
* @param int $value
* @return bool|DateTime|int|string|null
*/
public function setElo(string $type, int $value): void
public function __get(string $key)
{
$currentElos = $this->Elos;
$currentElos[$type] = $value;
$this->Elos = $currentElos;
}
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 ];
}
/**
* 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];
return null;
}
/**
* Sets the identifier of type for the player
*
* Common possible values are Fide or National
* Sets binary data that is read out the pairing file but is not needed immediately
*
* @param string $type
* @param string $value
* @param string $key
* @param bool|int|DateTime|string $value
*/
public function setId(string $type, string $value): void
public function __set(string $key, $value): void
{
$currentIds = $this->Ids;
$currentIds[$type] = $value;
$this->Ids = $currentIds;
$this->BinaryData[ $key ] = $value;
}
/**
* Returns the number of won matches for the player
* Adds a pairing to the tournament
*
* @return int
* @param Pairing $pairing
*/
private function noOfWins(): int
public function addPairing(Pairing $pairing): void
{
$wins = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::WON) !== false) {
$wins++;
}
}
return $wins;
$newArray = $this->Pairings;
$newArray[] = $pairing;
$this->Pairings = $newArray;
}
/**
@ -223,7 +223,8 @@ class Player
* 0.5 points are awarded for draw
* 0 points are awarded for loss
*
* @param int $round
* @param int $round
*
* @return float
*/
public function calculatePoints(int $round = -1): float
@ -238,25 +239,10 @@ class Player
}
}
}
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.
*
@ -278,66 +264,67 @@ class Player
$points = $points + 0.5;
}
}
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
*/
public function Performance(string $type, int $unratedElo): float
public function calculatePointsForVirtualPlayer(int $byeround): 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++;
}
$points = $this->calculatePoints($byeround);
foreach (array_slice($this->Pairings, $byeround + 1) as $key => $pairing) {
$points += 0.5;
}
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
*/
private function playedGames(): int
public function getElo(string $type): int
{
$total = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::PLAYED) !== false) {
$total++;
}
}
return $total;
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
* @param Player[] $players
*
* @return bool
*/
public function hasPlayedAllPlayersOfArray(array $players): bool
{
$ownkey = array_search($this, $players);
if ($ownkey !== false) {
unset($players[$ownkey]);
unset($players[ $ownkey ]);
}
$total = 0;
foreach ($players as $player) {
@ -349,6 +336,23 @@ class Player
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
*
@ -356,43 +360,58 @@ class Player
*/
private function opponents()
{
$return = array();
$return = [];
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
* Returns the number of played games of the player
*
* @param string $key
* @return bool|DateTime|int|string|null
* @return int
*/
public function __get(string $key)
private function playedGames(): int
{
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];
$total = 0;
foreach ($this->Pairings as $pairing) {
if (array_search($pairing->Result, Constants::PLAYED) !== false) {
$total++;
}
}
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 bool|int|DateTime|string $value
* @param string $type
* @param int $value
*/
public function __set(string $key, $value): void
public function setElo(string $type, int $value): void
{
$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
{
$this->BinaryData[$key] = $value;
$currentIds = $this->Ids;
$currentIds[ $type ] = $value;
$this->Ids = $currentIds;
}
}

@ -13,6 +13,7 @@
namespace JeroenED\Libpairtwo\Readers;
use DateTime;
use InvalidArgumentException;
use JeroenED\Libpairtwo\Enums\Color;
use JeroenED\Libpairtwo\Enums\Gender;
@ -26,7 +27,6 @@ use JeroenED\Libpairtwo\Pairing;
use JeroenED\Libpairtwo\Player;
use JeroenED\Libpairtwo\Round;
use JeroenED\Libpairtwo\Tournament;
use DateTime;
/**