mirror of
https://github.com/Deutscher-Tischfussballbund/com_sportsmanager.git
synced 2026-06-10 06:27:52 +00:00
fix: revert removal of distribution methods
This commit is contained in:
@@ -209,10 +209,10 @@ class MathParser
|
||||
/**
|
||||
* Public for performance reasons.
|
||||
* @see getVariableResolver function for more info.
|
||||
* @var string
|
||||
* @var string|null
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $VariableResolver;
|
||||
public ?string $VariableResolver = null;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
@@ -325,10 +325,10 @@ class MathParser
|
||||
* the problem domain is too big to define the variables ahead of time. In such cases, it makes sense
|
||||
* to parse with the assumption that it is a valid variable and resolve it's value when needed on demand during
|
||||
* evaluation.
|
||||
* @return string
|
||||
* @return string|null
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getVariableResolver(): string
|
||||
public function getVariableResolver(): ?string
|
||||
{
|
||||
return $this->VariableResolver;
|
||||
}
|
||||
@@ -493,7 +493,7 @@ class MathParser
|
||||
throw new Exception($this->getMessage1("NtVarNm", $varName));
|
||||
}
|
||||
//create the variable:
|
||||
$var = new Mathparser_Variable($upcName, $newVal, $fn_valueProvider);
|
||||
$var = new Mathparser_Variable($this, $upcName, $newVal, $fn_valueProvider);
|
||||
$this->Variables[$upcName] = $var;
|
||||
$this->Dirty = true;
|
||||
}
|
||||
@@ -1824,6 +1824,12 @@ class MathParser
|
||||
class Mathparser_Variable
|
||||
{
|
||||
|
||||
/**
|
||||
* The parent parser instance, used to call the VariableResolver if needed.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $Parser;
|
||||
|
||||
/**
|
||||
* Name of this variable.
|
||||
* @since 1.0.0
|
||||
@@ -1843,10 +1849,21 @@ class Mathparser_Variable
|
||||
* <br /><br /> function VariableResolver($parser, $varName);<br /><br />
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $ValueProvider;
|
||||
public $ValueProvider;
|
||||
|
||||
public function __construct($aName, $newVal, $valueProvider)
|
||||
/**
|
||||
* If the $this->ValueProvider is set, then this method uses it to get the runtime value.
|
||||
* Otherwise, this method returns the value of $this->Value;
|
||||
* @since 1.0.0
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getRuntimeValue(){
|
||||
return !is_callable($this->ValueProvider) ? $this->Value : ($this->ValueProvider)($this->Parser, $this->Name);
|
||||
}
|
||||
|
||||
public function __construct($parser, $aName, $newVal, $valueProvider)
|
||||
{
|
||||
$this->Parser = $parser;
|
||||
$this->Name = $aName;
|
||||
$this->Value = $newVal;
|
||||
$this->ValueProvider = $valueProvider;
|
||||
|
||||
@@ -18,6 +18,16 @@ defined('_JEXEC') or die('Restricted access');
|
||||
require_once JPATH_SITE . '/components/com_sportsmanager/mathparser.php';
|
||||
require_once JPATH_SITE . '/components/com_sportsmanager/database/init.php';
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
function mathParserVerteilung($rohpunkte, $platz, $teilnehmer, $multiplikator) {
|
||||
return max(round($multiplikator * round(((($rohpunkte - 1) * (-log($platz / $teilnehmer) * (1 - ($platz / $teilnehmer)))) / (-log(1 / $teilnehmer) * (1 - (1 / $teilnehmer)))) + 1)), 1);
|
||||
}
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
function mathParserVerteilungR($rohpunkte, $platz, $teilnehmer, $multiplikator) {
|
||||
return max(round(((($multiplikator * $rohpunkte - 1) * (-log($platz / $teilnehmer) * (1 - ($platz / $teilnehmer)))) / (-log(1 / $teilnehmer) * (1 - (1 / $teilnehmer)))) + 1), 1);
|
||||
}
|
||||
|
||||
class MathParserSM extends MathParser
|
||||
{
|
||||
// Verteilung nach Klostermann/Wahle
|
||||
|
||||
Reference in New Issue
Block a user