function generateProducts($file, $con)
{
    global $products;
    $products = checkProductsGlobalVariable($con);
    $multiplier = 0.15;
    $n_node = retrieveNodesCount($file, $con);
    for ($i = 0; $i < ceil($n_node * $multiplier); $i++) {
        execute_sql('<create_initial_products.php>', $con, "INSERT INTO products (name, base_cost, max_cost, global_quantity) VALUES ('P" . $i . "', '" . 0 . "', '" . frand() . "', '" . 0 . "')");
    }
    $products = fetch_nodes_toArray($con);
}
Beispiel #2
0
function generate_code($length = 7)
{
    global $wovels, $wovelsnoy, $consonants, $start, $mid, $end, $freqs;
    for ($i = 0; $i < $length; $i++) {
        if ($i == 0) {
            $chars = $wovelsnoy . $consonants;
        } elseif ($i == 1) {
            $chars = wcdispatch($result[$i - 1], $start);
        } elseif (in_array($result[$i - 1], mbStringToArray($wovels)) && in_array($result[$i - 2], mbStringToArray($wovels))) {
            $chars = $consonants;
        } elseif (in_array($result[$i - 1], mbStringToArray($consonants)) && in_array($result[$i - 2], mbStringToArray($consonants))) {
            $chars = checkharmony($result[$i - 1]);
        } elseif ($i == $length - 1) {
            $chars = wcdispatch($result[$i - 1], $end);
        } else {
            $chars = wcdispatch($result[$i - 1], $mid);
        }
        $charset = mbStringToArray($chars);
        $sum = 0;
        foreach ($charset as $char) {
            $sum += $freqs[$char];
        }
        $xfq = array();
        $bsum = 0;
        foreach ($charset as $char) {
            $balanced = $freqs[$char] / $sum;
            $bsum += $balanced;
            $xfq[(string) $bsum] = $char;
        }
        $roll = frand();
        foreach ($xfq as $freq => $letter) {
            if ($roll < $freq) {
                $result[$i] = $letter;
                $roll = 2;
            }
        }
    }
    mt_srand(make_seed());
    $array_mix = preg_split('//', mb_strtoupper(implode("", $result)), -1, PREG_SPLIT_NO_EMPTY);
    return implode("", $array_mix);
}
Beispiel #3
0
function fopens($level = 1)
{
    $arr = array();
    $a0 = array(0, 1, 2, 9, 10, 11, 18, 19, 20);
    $a1 = array(3, 4, 5, 12, 13, 14, 21, 22, 23);
    $a2 = array(6, 7, 8, 15, 16, 17, 24, 25, 26);
    $a3 = array(27, 28, 29, 36, 37, 38, 45, 46, 47);
    $a4 = array(30, 31, 32, 39, 40, 41, 48, 49, 50);
    $a5 = array(33, 34, 35, 42, 43, 44, 51, 52, 53);
    $a6 = array(54, 55, 56, 63, 64, 65, 72, 73, 74);
    $a7 = array(57, 58, 59, 66, 67, 68, 75, 76, 77);
    $a8 = array(60, 61, 62, 69, 70, 71, 78, 79, 80);
    $areas = array($a0, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $a8);
    switch ($level) {
        case 2:
            $arrow = array(3, 3, 3, 3, 3, 3, 4, 4, 4);
            // 30/51
            shuffle($arrow);
            break;
        case 3:
            $arrow = array(3, 3, 3, 3, 3, 3, 3, 3, 3);
            // 27/54
            break;
        case 4:
            $arrow = array(2, 2, 2, 3, 3, 3, 3, 3, 3);
            // 24/57
            shuffle($arrow);
            break;
        default:
            $arrow = array(3, 3, 3, 3, 4, 4, 4, 4, 4);
            // 32/49
            shuffle($arrow);
            break;
    }
    for ($i = 0; $i < 9; $i++) {
        $arr = array_merge($arr, frand($arrow[$i], $areas[$i]));
    }
    return $arr;
}
Beispiel #4
0
 public function getPrice()
 {
     return frand(120.52, 122.5, 2);
 }
Beispiel #5
0
function map_gen_lesson($uid, $unit, $sb)
{
    global $course, $now;
    if (frand() < $sb->attr) {
        $action = BOLT_ACTION_NONE;
        $t = $now;
    } else {
        $action = BOLT_ACTION_NEXT;
        $t = $now + urand($sb->time_mean, $sb->time_dev);
    }
    $mode = BOLT_MODE_LESSON;
    BoltView::insert("(user_id, course_id, item_name, action, mode, start_time, end_time) values ({$uid}, {$course->id}, '{$unit->name}', {$action}, {$mode}, {$now}, {$t})");
    return $action == BOLT_ACTION_NEXT;
}
function generateProductFailSafe($index, $serves)
{
    global $products;
    for ($i = 0; $i < sizeof($products); $i++) {
        if ($serves != $i && floor(frand(3, 5, 7, 3)) % 2 == 0) {
            return $i;
        }
    }
    // if no product was chosen, try again
    return generateProductFailSafe($index, $serves);
}
Beispiel #7
0
function payDay($con, $nodes)
{
    addToLog(";--------------------------------\n;        PAYDAY\n;--------------------------------");
    foreach ($nodes as $node) {
        $node['money'] += frand(20);
    }
}