Merge branch 'task/add-total-games' into develop

This commit is contained in:
Jeroen De Meerleer 2019-06-05 13:39:05 +02:00
commit c960e22129
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 17 additions and 1 deletions

View File

@ -12,6 +12,7 @@ class Constants
const Draw = [ Result::draw, Result::drawadjourned ];
const Lost = [ Result::absent, Result::bye, Result::lost, Result::adjourned ];
const NotPlayed = [ Result::bye, Result::wonbye, Result::absent ];
const Played = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned, Result::draw, Result::drawadjourned, Result::absent, Result::bye, Result::lost, Result::adjourned ];
const Black = [ Color::black ];
const White = [ Color::white ];
}

View File

@ -151,4 +151,19 @@ class Player extends PlayerModel
}
return round($total / $opponents);
}
/**
* @return int
*/
public function getPlayedGames(): int
{
$total = 0;
foreach ($this->getPairings() as $pairing) {
if (array_search($pairing->getResult(), Constants::Played) !== false) {
$total++;
}
}
return $total;
}
}