コード例 #1
0
         $score += $add;
         //dbg("role=$t task=$w x=$x add=$add score=$score");
     }
 }
 $score = 0;
 $sql = "select id,last_name as ln from users where group_id = " . $o->group_id;
 dbg($sql);
 $rs = dbExec($sql);
 while (!$rs->EOF) {
     $go = $rs->FetchNextObj();
     //$tk = $go->id == $id ? $trk : tracking_rec($go->id);
     $tk = tracking_rec($go->id);
     for ($w = 1; $w <= $game_weeks; $w++) {
         $sv = "w" . $w . "vendor";
         $sc = "w" . $w . "cost";
         $vnum = getvnum($w, trim($tk[$sv]), trim($tk[$sc]));
         $x = $w . "-" . $vnum;
         if (isset($scoretable1[$x])) {
             $add = $scoretable1[$x];
             $score += $add;
         }
         dbg("name=" . $go->ln . " uid=" . $go->id . " vnum={$vnum}   w={$w} x={$x}   add={$add} score={$score}");
     }
 }
 dbg($score);
 $team_score = round($score / 48 * 100);
 if ($team_score >= 80) {
     $team_score_grade = 4;
 } else {
     if ($team_score >= 60) {
         $team_score_grade = 3;
コード例 #2
0
ファイル: scorelib.php プロジェクト: piter65/spilldec
function raisedbystudent($uid, &$tvc)
{
    $w1vendortotal = 0;
    $w2vendortotal = 0;
    $w3vendortotal = 0;
    $trk = dbGetObj("select * from tracking where user_id={$uid}");
    $pro = dbGetObj("select * from progress where user_id={$uid}");
    $wk = getfld("week", "users", "where id={$uid}");
    $errors = 0;
    $space = "&nbsp;&nbsp;&nbsp;&nbsp;";
    if ($wk > 1) {
        $w1vendorcost = $trk->w1cost;
        $w1vendortotal = 0;
        $w1multiplier = 0;
        if ($w1vendorcost > 0) {
            $w1vendor = $trk->w1vendor;
            $w1vendortotal = 25000;
            //Max amount a vendor can raise
            //determine how much of the max amount the vendor actually raised
            $vnum = getvnum(1, $w1vendor, $w1vendorcost);
            if ($vnum == 1) {
                $w1multiplier = 1.0;
            } else {
                if ($vnum == 2) {
                    $w1multiplier = 0.75;
                } else {
                    if ($vnum == 3) {
                        $w1multiplier = 0.5;
                    } else {
                        if ($vnum == 4) {
                            $w1multiplier = 0.25;
                        } else {
                            $errors++;
                            rerr("tsk1: student id={$uid} {$space} w1vendor=\"{$w1vendor}\" {$space} w1vendorcost={$w1vendorcost}");
                            $w1multiplier = 0.625;
                        }
                    }
                }
            }
            //Determine the adjusted vendortotal
            $w1vendortotal *= $w1multiplier;
            $w1vendortotal -= $w1vendorcost;
        }
        //Dock them for hiring an extra vendor
        if (substr($pro->w1nlc_utt, 0, 1) == "c") {
            $w1vendortotal -= 3000;
        }
    }
    if ($wk > 2) {
        $w2vendorcost = $trk->w2cost;
        $w2vendortotal = 0;
        $w2multiplier = 0;
        if ($w2vendorcost > 0) {
            $w2vendor = $trk->w2vendor;
            $w2vendortotal = 50000;
            //Max amount a vendor can raise
            $vnum = getvnum(2, $w2vendor, $w2vendorcost);
            if ($vnum == 1) {
                $w2multiplier = 1.0;
            } else {
                if ($vnum == 2) {
                    $w2multiplier = 0.75;
                } else {
                    if ($vnum == 3) {
                        $w2multiplier = 0.5;
                    } else {
                        if ($vnum == 4) {
                            $w2multiplier = 0.25;
                        } else {
                            $errors++;
                            rerr("tsk2: student id={$uid} {$space} w2vendor=\"{$w2vendor}\" {$space} w2vendorcost={$w2vendorcost}");
                            $w2multiplier = 0.625;
                        }
                    }
                }
            }
            //Determine the adjusted vendortotal
            $w2vendortotal *= $w2multiplier;
            $w2vendortotal -= $w2vendorcost;
        }
        //Dock them for getting insurance
        if (substr($pro->w2nlc_utt, 0, 1) == "c") {
            $w2vendortotal -= 1500;
        }
    }
    if ($wk > 3) {
        $w3vendorcost = $trk->w3cost;
        $w3vendortotal = -12500;
        $w3vendor = $trk->w3vendor;
        if (substr($w3vendor, 0, 7) == "Ramblin") {
            $w3vendor = substr($w3vendor, 0, 7);
        }
        //if($w3vendor != null)
        //p("$uid - w3vendor = $w3vendor");
        //else
        //p("w3vendor = null");
        if ($w3vendor != "" && $w3vendor != null) {
            $vnum = getvnum(3, $w3vendor, $w3vendorcost);
            // p("&emsp; vnum = $vnum");
            if ($vnum < 4) {
                $w3vendortotal = -8000;
                // Arrested wrong vendor
            } else {
                if ($vnum == 4) {
                    $w3vendortotal = 0;
                    // Arrested the correct vendor
                } else {
                    $errors++;
                    rerr("tsk3: student id={$uid} {$space} w3vendor=\"{$w3vendor}'\" {$space} w3vendorcost={$w3vendorcost}");
                }
            }
            //p("&emsp w3vendortotal = $w3vendortotal");
            //p("");
        }
        //Dock them for hiring an assistant
        if (substr($pro->w3nlc_utt, 0, 1) == "c") {
            $w3vendortotal -= 1500;
        }
        dbexec("update tracking set w3cost={$w3vendortotal} where user_id={$uid}");
    }
    // Test Calculation
    /*if(($w1vendortotal+$w2vendortotal+$w3vendortotal) > 0){
    		p("$uid - w1raised = $w1vendortotal - w2raised = $w2vendortotal - w3raised = $w3vendortotal");
    		p("Total = ".($w1vendortotal+$w2vendortotal+$w3vendortotal));
    		}*/
    // ===========================
    $raised = $w1vendortotal + $w2vendortotal + $w3vendortotal;
    dbExec("update tracking set raisedmoney={$raised}, errors={$errors} where user_id=" . $uid);
    setvar($uid, 'RAISED', $raised);
    dbExec("update results set raised={$raised} where uid={$uid}");
    $tvc = $w1vendorcost + $w2vendorcost;
    // xxx currently not used ?
    if ($w1vendor == "") {
        $w1vendor = "no one";
    }
    if ($w2vendor == "") {
        $w2vendor = "no one";
    }
    if ($w3vendor == "") {
        $w3vendor = "no one";
    }
    return $raised;
}
コード例 #3
0
ファイル: studentreport.php プロジェクト: piter65/spilldec
         } else {
             if ($research >= 15) {
                 $research_grade = 1;
             } else {
                 $research_grade = 0;
             }
         }
     }
 }
 // BChance: (2016-11-21) - Added choices score calculations.
 $score = 0;
 $tk = tracking_rec($id);
 for ($w = 1; $w <= $game_weeks; $w++) {
     $wv = "w" . $w . "vendor";
     $wc = "w" . $w . "cost";
     $vnum = getvnum($w, trim($tk[$wv]), trim($tk[$wc]));
     $x = $w . "-" . $vnum;
     if (isset($scoretable1[$x])) {
         $add = $scoretable1[$x];
         $score += $add;
     }
 }
 $choices_score = $score;
 $choices_rating = round($choices_score / ($game_weeks * 4) * 100);
 $choices_grade = floor($choices_rating / 20);
 // BChance: (2016-11-21) - Added negotiations score calculations.
 $score = 0;
 if (isset($tk["w1cost"]) && $tk["w1cost"] > 0) {
     $score += 4000 / $tk["w1cost"];
 }
 if (isset($tk["w2cost"]) && $tk["w2cost"] > 0) {