예제 #1
0
파일: auth2.php 프로젝트: piter65/spilldec
         $o = $rs->FetchNextObj();
         $txt2 = gdDecode(getField("users", "gamedata", "where id=" . $o->id));
         $txt2 = preg_replace("/tm_\\d_w\\d(vndr|vendor|cost) = \\d+\r\n/", "", $txt2);
         //$txt2 = preg_replace("/\n/", "\n        ", $txt2);
         //echo "## class=".$o->class." id=".$o->id." ".$txt2;
         for ($i = 1; $i <= 4; $i++) {
             $m = array();
             $vn = 0;
             $mstr = "|w" . (int) $i . "vendor = ([0-9]+)|";
             //echo "mstr=$mstr\n";
             if (preg_match($mstr, $txt2, $m)) {
                 $vn = (int) $m[1];
             }
             $add .= "tm_" . $o->class . "_w" . $i . "vendor = " . $vn . "\r\n";
         }
         $trk = tracking_rec($o->id);
         for ($i = 1; $i <= 3; $i++) {
             $vn = $trk["w" . $i . "cost"];
             $add .= "tm_" . $o->class . "_w" . $i . "cost = " . $vn . "\r\n";
         }
     }
 }
 //$add .= "tm_added = 1\r\n";
 $txt .= $add;
 //print($txt); exit;
 //}
 $gd = gdEncode($txt);
 //print($ogd."\n");
 //print($gd."\n"); exit;
 echo "result ok\n";
 echo "gamedata {$gd}\n";
예제 #2
0
         $research_grade = 3;
     } else {
         if ($research >= 50) {
             $research_grade = 2;
         } 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;
예제 #3
0
 for ($t = 3; $t <= 6; $t++) {
     for ($w = 1; $w <= $game_weeks; $w++) {
         $x = $w . "-" . $gd["tm_" . $t . "_w" . $w . "vendor"];
         $add = isset($scoretable1[$x]) ? $scoretable1[$x] : 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) {
예제 #4
0
<?php

$gid = gidFromSid($id);
dbg("id={$id}");
dbg("gid={$gid}");
$sql = "select id, last_name as ln from users where active=1 and group_id={$gid} and user_type='s'";
$rs = dbExec($sql);
$rc = $rs->RecordCount();
dbg("rc={$rc}");
assert($rc >= 1 && $rc <= 4);
$add = 0;
$avg = 0;
$tot = 0;
for ($i = 0; $i < 4; $i++) {
    if ($i < $rc) {
        $stid = $rs->fields[0];
        $name = $rs->fields[1];
        $sttr = tracking_rec($stid);
        $rm = $sttr["raisedmoney"];
        $tot += $rm;
        $add += $rm;
        $avg = $add / ($i + 1);
        $rs->MoveNext();
        dbg("name={$name} stid={$stid} rm={$rm} tot={$tot} add={$add} avg={$avg}");
    } else {
        $tot += $avg;
        dbg("(no one) tot={$tot} ({$tot} + {$avg})");
    }
}
dbg("final tot={$tot}");
$raisedbyteam = (int) $tot;