mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-24 15:31:00 +01:00
Merge branch 'task/add-total-games' into develop
This commit is contained in:
commit
c960e22129
@ -9,9 +9,10 @@ use JeroenED\Libpairtwo\Enums\Result;
|
|||||||
class Constants
|
class Constants
|
||||||
{
|
{
|
||||||
const Won = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned ];
|
const Won = [ Result::won, Result::wonforfait, Result::wonbye, Result::wonadjourned ];
|
||||||
const Draw = [ Result::draw, Result::drawadjourned];
|
const Draw = [ Result::draw, Result::drawadjourned ];
|
||||||
const Lost = [ Result::absent, Result::bye, Result::lost, Result::adjourned ];
|
const Lost = [ Result::absent, Result::bye, Result::lost, Result::adjourned ];
|
||||||
const NotPlayed = [ Result::bye, Result::wonbye, Result::absent ];
|
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 Black = [ Color::black ];
|
||||||
const White = [ Color::white ];
|
const White = [ Color::white ];
|
||||||
}
|
}
|
||||||
|
@ -151,4 +151,19 @@ class Player extends PlayerModel
|
|||||||
}
|
}
|
||||||
return round($total / $opponents);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user