Check if a player reached the seeds number to win and returns it.
Or return null.

@return int|null
485784
private function getPlayerWithMoreThanHalfSeeds()
    {
        $seedsToWin = $this->getSeedsNeededToWin();

        if ($this->grid[Awale::PLAYER_0]['attic'] > $seedsToWin) {
            return self::PLAYER_0;
        }

        if ($this->grid[Awale::PLAYER_1]['attic'] > $seedsToWin) {
            return self::PLAYER_1;
        }

        return null;
    }
1109463
public function getNumberOfPlayers($gameId = null)
    {
        $em = $this->getServiceManager()->get('doctrine.entitymanager.orm_default');
        $rsm = new \Doctrine\ORM\Query\ResultSetMapping;
        $rsm->addScalarResult('c', 'c');
        if ($gameId !== null) {
            $game = $this->getServiceManager()
                ->get('playgroundgame_lottery_service')
                ->getGameMapper()
                ->findById($gameId);

            if ($game && $game->getAnonymousAllowed()) {
                $query = $em->createNativeQuery('
                    SELECT COUNT(distinct e.anonymous_identifier) AS c
                    FROM game_entry e
                    WHERE e.game_id = '.((int) $gameId).'
                ', $rsm);
            } else {
                $query = $em->createNativeQuery('
                    SELECT COUNT(distinct e.user_id) AS c
                    FROM game_entry e
                    WHERE e.game_id = '.((int) $gameId).'
                ', $rsm);
            }
        } else {
            $query = $em->createNativeQuery('
                    SELECT COUNT(distinct e.user_id) AS c
                    FROM game_entry e
                ', $rsm);
        }
        
        $count = $query->getSingleScalarResult();
        return $count;
    }
1199238
public static function count($where = null): int
    {
        $select = static::select();

        if ($where !== null) {
            if ($where instanceof Where) {
                $select->field('COUNT(*)', 'total');
                $select->where(clone $where);

            } else if (is_array($where)) {
                $select->field('COUNT(*)', 'total');
                foreach ($where as $field => $value) {
                    $select->where($field, $value);
                }

            } else if (!is_array(static::$primaryKey) && (is_numeric($where) || is_string($where))) {
                $select->field('COUNT(' . static::$primaryKey . ')', 'total');
                $select->where(static::$primaryKey, $where);

            }
        } else {
            $pk = is_string(static::$primaryKey) ? static::$primaryKey : '*';
            $select->field('COUNT(' . $pk . ')', 'total');
        }

        $results = $select->fetchAll();

        if (isset($results[0])) {
            $r = $results[0];
            if (array_key_exists('total', $r)) {
                return (int)$r['total'];
            } else {
                return 0;
            }
        } else {
            return 0;
        }
    }
1177710
public function next()
    {
        if (count($this->data) > 0) {
            array_shift($this->data);
        }
        ++$this->position;

        if (count($this->data) == 0 && !is_null($this->resumptionToken)) {
            $this->fetchMore();
        }

        if (count($this->data) == 0) {
            return null;
        }
    }
565531
public function status(): ?int
    {
        if ($this->agent != null) {
            return $this->agent->isConnected() ? self::STATUS_CONNECTED : self::STATUS_DISCONNECTED;
        }

        return null;
    }
667306
protected function check()
    {
        try {
            $options = $this->getOptions();

            // retrieve player count
            $response = $this->mcStatus->query(true);

            if (!is_array($response)
                || !array_key_exists('player_count', $response)
            ) {
                $this->setMessage('No response from Minecraft server query.');
                $this->setCode(self::STATE_UNKNOWN);

                return $this;
            }

            $playerCount = $response['player_count'];

            if ($playerCount >= (int)$options['thresholdCritical']) {
                $this->setMessage(
                    sprintf(
                        'CRITICAL - %1$u players currently logged in|users=%1$u',
                        $response['player_count']
                    )
                );
                $this->setCode(self::STATE_CRITICAL);

                return $this;
            }

            if ($playerCount >= (int)$options['thresholdWarning']) {
                $this->setMessage(
                    sprintf(
                        'WARNING - %u players currently logged in|users=%1$u',
                        $response['player_count']
                    )
                );
                $this->setCode(self::STATE_WARNING);

                return $this;
            }

            $this->setMessage(
                sprintf(
                    'OK - %u players currently logged in|users=%1$u',
                    $playerCount
                )
            );
            $this->setCode(self::STATE_OK);

            return $this;

        } catch (\Exception $e) {
            $this->setMessage('Error from Mcstat: ' . $e->getMessage());
            $this->setCode(self::STATE_UNKNOWN);

            return $this;
        }
    }
1246917
public function getPrevSibling()
	{
		$right = $this->getLeftValue() - 1;
		if ($right <= 0) {
			return null;
		}
		$searchCondition = $this->repository->createSearchCondition()
				->rightEqualsTo($right);

		$prevSibling = $this->repository->search($searchCondition);
		if ( ! isset($prevSibling[0])) {
			return null;
		}
		$prevSibling = $prevSibling[0];
		
		return $prevSibling;
	}
494989
public function getLoser () : ?int
    {
        // Cache
        if ( $this->_CondorcetLoser !== null ) :
            return $this->_CondorcetLoser;
        endif;

            //////

        // Basic Condorcet calculation
        foreach ( $this->_selfElection->getPairwise(false) as $candidate_key => $candidat_detail ) :
            $loser = true;

            foreach ( $candidat_detail['lose'] as $challenger_key => $lose_count ) :
                if  ( $lose_count <= $candidat_detail['win'][$challenger_key] ) :
                    $loser = false;
                    break;
                endif;
            endforeach;

            if ($loser) :
                $this->_CondorcetLoser = $candidate_key;
                return $this->_CondorcetLoser;
            endif;
        endforeach;

        return null;
    }
1182886
public function getNextAutoIncrement() {
		$query = "SHOW TABLE STATUS WHERE name = '" . $this->getTable() . "'";
		$statement = $this->_connection->execute($query);
		$result = $statement->fetch();
		if (!isset($result[10])) {
			return false;
		}
		return (int)$result[10];
	}
1114960
public function first() {
		$this->limit(1);
		$result = $this->find();
		return empty($result) ? null : $result[0];
	}
1128352
public function scoreResult()
    {
        $result = false;

        if($this->sessionSecret)
        {
            $fields = array(
                'session_secret' => urlencode($this->sessionSecret),
                'scoring_key'    => $this->scoringKey
            );

            $resp = $this->doHttpsPostReturnJSONArray($this->webService, '/ws/scoreGame', $fields);

            if($resp) {
                $result = ($resp->status_code == 1);
            }
        }

        return $result;
    }
1202648
final public function current()
    {
        if (!$this->valid()) {

            return null;
        }

        /*
         * Multiple calls to current() should be idempotent
         */
        if ($this->_lastPositionExecuted !== $this->_position) {

            $this->runToNextYieldStatement();
        }

        return $this->valid() ? $this->getLastYieldedValue() : null;
    }
1329835
public function first()
    {
        $sql = clone($this);
        $sql->limit(1);
        $result = $this->_adapter->query($sql, $sql->getParameters());
        return  (count($result) > 0) ? $result[0]: null;
    }
1330740
public function hasSeeds($player)
    {
        foreach ($this->grid[$player]['seeds'] as $box) {
            if ($box > 0) {
                return true;
            }
        }

        return false;
    }
1254369
public function getPrevious()
    {
        $pos = $this->getPosition();
        if ($pos == 0) {
            return null;
        } else {
            $this->getInternalIterator()->seek($pos - 1);

            return $this->getCurrent();
        }
    }
313667
protected function run()
    {
        $isComposed = $this->position > 0;
        if (!$isComposed) {
            // If this analyzer was not called from another analyzer at a
            // specific position, we find the correct position here.
            $this->seek();
            return $this->read(self::class);
        }

        $players = [];
        // The first player in this list will be the "main" co-op player.
        $coopPartners = [];
        for ($i = 0; $i <= 8; $i += 1) {
            $player = $this->readPlayerMeta($i);
            if ($player->humanRaw === 0 || $player->humanRaw === 1) {
                continue;
            }
            $players[] = $player;
            $coopPartners[$player->index][] = $player;
        }

        foreach ($players as $player) {
            $player->setCoopPartners($coopPartners[$player->index]);
        }

        return $players;
    }
759547
public function getRandom()
    {
        return empty($this->entities) ? null : $this->entities[array_rand($this->entities)];
    }