Пример #1
0
 */
// Calculates percent complete statistics for all locales.
// Must be run from tools/i18n directory.
$root_dir = '../../interface/locale';
if (count($argv) > 1) {
    $root_dir = $argv[1];
}
$d = opendir($root_dir);
if ($d) {
    echo "calculating locale statistics...\n";
    $outpath = $root_dir . '/' . 'locale_stats.txt';
    $fh = fopen($outpath, 'w');
    $ignore_dirs = array('.', '..', 'CVS');
    while (false !== ($file = readdir($d))) {
        if (is_dir($root_dir . '/' . $file) && !in_array($file, $ignore_dirs)) {
            $stats = calcStats($root_dir, $file);
            $pct = $stats['pct_complete'];
            $team = $stats['team'];
            fwrite($fh, "{$file}|{$pct}|{$team}\n");
        }
    }
    closedir($d);
    fclose($fh);
    echo "done. stats saved in {$outpath}\n";
}
function calcStats($root_dir, $locale)
{
    $messages = 0;
    $translations = 0;
    $fuzzy = 0;
    $team = '';
Пример #2
0
}
if ($minute != 0) {
    exit;
}
$mdb = new Mdb();
$types = ['characterID', 'corporationID', 'allianceID', 'factionID', 'groupID', 'shipTypeID', 'solarSystemID', 'regionID'];
$timer = new Timer();
$ninetyDayKillID = MongoFilter::getKillIDFromTime(time() - 90 * 86400);
$date = new MongoDate(strtotime(date('Y-m-d')));
// Clear out ranks more than two weeks old
$mdb->remove('ranksProgress', ['date' => ['$lt' => $mdb->now(-86400 * 14)]]);
foreach ($types as $type) {
    Util::out("Started recent calcs for {$type}");
    $calcStats = $mdb->find('information', ['type' => $type]);
    foreach ($calcStats as $row) {
        calcStats($row, $ninetyDayKillID);
    }
    Util::out("Completed recent calcs for {$type}");
}
function calcStats($row, $ninetyDayKillID)
{
    global $mdb, $debug;
    $type = $row['type'];
    $id = $row['id'];
    $killID = (int) @$row['killID'];
    $key = ['type' => $type, 'id' => $id];
    if ($killID < $ninetyDayKillID) {
        $mdb->getCollection('statistics')->update($key, ['$unset' => ['recentShipsLost' => 1, 'recentPointsLost' => 1, 'recentIskLost' => 1, 'recentShipsDestroyed' => 1, 'recentPointsDestroyed' => 1, 'recentIskDestroyed' => 1, 'recentOverallRank' => 1, 'recentOverallScore' => 1]]);
        return;
    }
    $stats = [];
Пример #3
0
function productsData()
{
    $data = getData($GLOBALS['sql']['stats']['all'] . ", IFNULL(products.name, '[None]') as name " . $GLOBALS['sql']['tables']['products'] . $GLOBALS['sql']['link']['products'] . " GROUP BY products.name ORDER BY total DESC;");
    calcStats($data);
    return codekey($data, "name");
}
Пример #4
0
require_once '../init.php';
$timer = new Timer();
$children = [];
$inProgress = [];
$maxChildren = 10;
$maxTime = 295000;
$queueStats = new RedisQueue('queueStats');
do {
    if ($redis->llen("queueServer") > 100) {
        exit;
    }
    $row = $queueStats->pop();
    if ($row !== null) {
        $id = $row['id'];
        $type = $row['type'];
        calcStats($row);
    }
} while ($timer->stop() <= $maxTime);
$status = 0;
function calcStats($row)
{
    global $mdb, $debug;
    $type = $row['type'];
    $id = $row['id'];
    $newSequence = $row['sequence'];
    $key = ['type' => $type, 'id' => $id];
    $stats = $mdb->findDoc('statistics', $key);
    if ($stats === null) {
        $stats = [];
        $stats['type'] = $type;
        $stats['id'] = $id;
Пример #5
0
    $d = 0;
    $a = 0;
    foreach ($inv as $item) {
        $d += $item->damage;
        $a += $item->armor;
    }
    return array('h' => 100, 'a' => $a, 'd' => $d);
}
function isWinner(array $player, array $boss)
{
    $playerDamage = max(array(1, $player['d'] - $boss['a']));
    $bossDamage = max(array(1, $boss['d'] - $player['a']));
    return ceil($player['h'] / $bossDamage) >= ceil($boss['h'] / $playerDamage);
}
$lowestCost = PHP_INT_MAX;
foreach ($items['w'] as $w) {
    foreach ($items['a'] as $a) {
        foreach ($items['r'] as $r1) {
            foreach ($items['r'] as $r2) {
                if ($r1 === $r2) {
                    continue;
                }
                $playerItems = array($w, $a, $r1, $r2);
                if (isWinner(calcStats($playerItems), $bossStats)) {
                    $lowestCost = min(array($lowestCost, calcCost($playerItems)));
                }
            }
        }
    }
}
echo 'Answer: ' . $lowestCost;