mirror of
				https://github.com/furyfire/trueskill.git
				synced 2025-11-04 02:02:29 +01:00 
			
		
		
		
	More stringable
This commit is contained in:
		@@ -7,7 +7,7 @@ namespace DNW\Skills;
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * Represents a player who has a Rating.
 | 
					 * Represents a player who has a Rating.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class Player implements ISupportPartialPlay, ISupportPartialUpdate, \Stringable
 | 
					class Player implements ISupportPartialPlay, ISupportPartialUpdate
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    private const DEFAULT_PARTIAL_PLAY_PERCENTAGE = 1.0; // = 100% play time
 | 
					    private const DEFAULT_PARTIAL_PLAY_PERCENTAGE = 1.0; // = 100% play time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -20,7 +20,7 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate, \Stringable
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Constructs a player.
 | 
					     * Constructs a player.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param mixed  $Id                      The identifier for the player, such as a name.
 | 
					     * @param mixed $Id                      The identifier for the player, such as a name.
 | 
				
			||||||
     * @param float $partialPlayPercentage   The weight percentage to give this player when calculating a new rank.
 | 
					     * @param float $partialPlayPercentage   The weight percentage to give this player when calculating a new rank.
 | 
				
			||||||
     * @param float $partialUpdatePercentage Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update.
 | 
					     * @param float $partialUpdatePercentage Indicated how much of a skill update a player should receive where 0 represents no update and 1.0 represents 100% of the update.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -59,9 +59,9 @@ class Player implements ISupportPartialPlay, ISupportPartialUpdate, \Stringable
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        return $this->PartialUpdatePercentage;
 | 
					        return $this->PartialUpdatePercentage;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
    public function __toString(): string
 | 
					    public function __toString(): string
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return (string)$this->Id;
 | 
					        return (string)$this->Id;
 | 
				
			||||||
    }
 | 
					    }*/
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,8 +7,6 @@ namespace DNW\Skills\TrueSkill\Layers;
 | 
				
			|||||||
use DNW\Skills\FactorGraphs\ScheduleStep;
 | 
					use DNW\Skills\FactorGraphs\ScheduleStep;
 | 
				
			||||||
use DNW\Skills\FactorGraphs\ScheduleSequence;
 | 
					use DNW\Skills\FactorGraphs\ScheduleSequence;
 | 
				
			||||||
use DNW\Skills\PartialPlay;
 | 
					use DNW\Skills\PartialPlay;
 | 
				
			||||||
use DNW\Skills\Player;
 | 
					 | 
				
			||||||
use DNW\Skills\Team;
 | 
					 | 
				
			||||||
use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
 | 
					use DNW\Skills\TrueSkill\Factors\GaussianWeightedSumFactor;
 | 
				
			||||||
use DNW\Skills\FactorGraphs\Variable;
 | 
					use DNW\Skills\FactorGraphs\Variable;
 | 
				
			||||||
use DNW\Skills\FactorGraphs\KeyedVariable;
 | 
					use DNW\Skills\FactorGraphs\KeyedVariable;
 | 
				
			||||||
@@ -91,7 +89,7 @@ class PlayerPerformancesToTeamPerformancesLayer extends TrueSkillFactorGraphLaye
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private function createOutputVariable(array $team): Variable
 | 
					    private function createOutputVariable(array $team): Variable
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $memberNames = array_map(static fn($currentPlayer): string => (string)($currentPlayer->getKey()), $team);
 | 
					        $memberNames = array_map(static fn($currentPlayer): string => (string)($currentPlayer->getKey()->getId()), $team);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $teamMemberNames = \implode(', ', $memberNames);
 | 
					        $teamMemberNames = \implode(', ', $memberNames);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -77,6 +77,6 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
 | 
				
			|||||||
        $parentFactorGraph = $this->getParentFactorGraph();
 | 
					        $parentFactorGraph = $this->getParentFactorGraph();
 | 
				
			||||||
        $variableFactory = $parentFactorGraph->getVariableFactory();
 | 
					        $variableFactory = $parentFactorGraph->getVariableFactory();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $variableFactory->createKeyedVariable($key, $key . "'s skill");
 | 
					        return $variableFactory->createKeyedVariable($key, (string)$key->getId() . "'s skill");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,7 +48,7 @@ class PlayerSkillsToPerformancesLayer extends TrueSkillFactorGraphLayer
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private function createOutputVariable(mixed $key): KeyedVariable
 | 
					    private function createOutputVariable(mixed $key): KeyedVariable
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, $key . "'s performance");
 | 
					        return $this->getParentFactorGraph()->getVariableFactory()->createKeyedVariable($key, (string)$key->getId() . "'s performance");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function createPriorSchedule(): ?ScheduleSequence
 | 
					    public function createPriorSchedule(): ?ScheduleSequence
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,6 @@ class PlayerTest extends TestCase
 | 
				
			|||||||
    public function testPlayerObjectGetterSetter(): void
 | 
					    public function testPlayerObjectGetterSetter(): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $p = new Player('dummy', 0.1, 0.2);
 | 
					        $p = new Player('dummy', 0.1, 0.2);
 | 
				
			||||||
        $this->assertEquals('dummy', (string)$p);
 | 
					 | 
				
			||||||
        $this->assertEquals('dummy', $p->getId());
 | 
					        $this->assertEquals('dummy', $p->getId());
 | 
				
			||||||
        $this->assertEquals(0.1, $p->getPartialPlayPercentage());
 | 
					        $this->assertEquals(0.1, $p->getPartialPlayPercentage());
 | 
				
			||||||
        $this->assertEquals(0.2, $p->getPartialUpdatePercentage());
 | 
					        $this->assertEquals(0.2, $p->getPartialUpdatePercentage());
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user