mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 14:08:40 +00:00
fixes
This commit is contained in:
parent
1e19f72fc4
commit
6ac2d4d0e8
|
|
@ -35,6 +35,21 @@ final class Continuous
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comparing items
|
||||||
|
*
|
||||||
|
* @param Item[] $a Item
|
||||||
|
* @param Item[] $b Item
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static function continuousComparator(array $a, array $b) : int
|
||||||
|
{
|
||||||
|
return $b['item']->getValue() / $b['item']->getCost() <=> $a['item']->getValue() / $a['item']->getCost();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill the backpack with items
|
* Fill the backpack with items
|
||||||
*
|
*
|
||||||
|
|
@ -47,9 +62,7 @@ final class Continuous
|
||||||
*/
|
*/
|
||||||
public static function solve(array $items, BackpackInterface $backpack) : BackpackInterface
|
public static function solve(array $items, BackpackInterface $backpack) : BackpackInterface
|
||||||
{
|
{
|
||||||
\usort($items, function($a, $b) {
|
\usort($items, ['self', 'continuousComparator']);
|
||||||
return $a['item']->getValue() / $a['item']->getCost() < $b['item']->getValue() / $b['item']->getCost();
|
|
||||||
});
|
|
||||||
|
|
||||||
$availableSpace = $backpack->getMaxCost();
|
$availableSpace = $backpack->getMaxCost();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -363,11 +363,13 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
public static function clear() : void
|
public static function clear() : void
|
||||||
{
|
{
|
||||||
// clear parent and objects
|
// clear parent and objects
|
||||||
if (static::class === self::$parentMapper) {
|
if (static::class !== self::$parentMapper) {
|
||||||
self::$parentMapper = null;
|
return;
|
||||||
self::$conditionals = [];
|
|
||||||
self::$relations = RelationType::ALL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$parentMapper = null;
|
||||||
|
self::$conditionals = [];
|
||||||
|
self::$relations = RelationType::ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user