function set_credits() { global $db, $tablepre, $winmode, $gamenum, $winner, $pdata, $gamblingon; $clist = $creditlist = $updatelist = array(); $result = $db->query("SELECT * FROM {$tablepre}users RIGHT JOIN {$tablepre}players ON {$tablepre}players.name={$tablepre}users.username WHERE {$tablepre}players.type='0'"); while ($data = $db->fetch_array($result)) { $clist[$data['name']] = $data; } foreach ($clist as $key => $val) { $credits = get_credit_up($val, $winner, $winmode) + $val['credits']; $credits2 = $val['credits2'] + 10; $validgames = $val['validgames'] + 1; $wingames = $key == $winner ? $val['wingames'] + 1 : $val['wingames']; $updatelist[$key] = array('username' => $key, 'credits' => $credits, 'credits2' => $credits2, 'wingames' => $wingames, 'validgames' => $validgames); } $db->multi_update("{$tablepre}users", $updatelist, 'username'); if ($gamblingon) { //赌注系统开启 $updatelist2 = get_gambling_result($clist, $winner, $winmode); if ($updatelist2) { //必须分两次,因为涉及字段不同 $db->multi_update("{$tablepre}users", $updatelist2, 'username'); } } //var_dump($updatelist); //$db->multi_update("{$tablepre}users", $updatelist2, 'username'); //$db->multi_update("{$tablepre}users", $updatelist2, 'username'); // $result = $db->query("SELECT * FROM {$tablepre}players WHERE type='0'"); // $list = $creditlist = $updatelist = Array(); // while($data = $db->fetch_array($result)){ // $list[$data['name']]['players'] = $data; // } // $result = $db->query("SELECT * FROM {$tablepre}users WHERE lastgame='$gamenum'"); // while($data = $db->fetch_array($result)){ // $list[$data['username']]['users'] = $data; // } // foreach($list as $key => $val){ // if(isset($val['players']) && isset($val['users'])){ // $credits = get_credit_up($val['players'],$winner,$winmode) + $val['users']['credits']; // $validgames = $val['users']['validgames'] + 1; // $wingames = $key == $winner ? $val['users']['wingames'] + 1 : $val['users']['wingames']; // $updatelist[] = Array('username' => $key, 'credits' => $credits, 'wingames' => $wingames, 'validgames' => $validgames); // if(!empty($obtain)){ // $udghkey[] = $key; // if($pdata['name'] == $key){ // $pdata['gainhonour'] = $obtain; // }else{ // $udghlist[] = Array('name' => $key, 'gainhonour' => $obtain); // } // } // } // } // $db->multi_update("{$tablepre}users", $updatelist, 'username'); // if(!empty($udghkey)){ // $udghkey = implode(',',$udghkey); // $db->multi_update("{$tablepre}players", $upghlist, 'name', "name IN ($udghkey)"); // } //更新成就 //$result = $db->query("SELECT * FROM {$tablepre}players WHERE {$tablepre}players.type='0'"); //while($data = $db->fetch_array($result)) //{ // $dlist[$data['name']] = $data['achievement']; //} //include_once GAME_ROOT.'./include/game/achievement.func.php'; //foreach($dlist as $key => $val) //{ //$v=$val; //normalize_achievement($v,$c1,$c2); //$res = $db->query("SELECT * FROM {$tablepre}users WHERE username='******'" ); //$data=$db->fetch_array($res); //$c1+=$data['credits']; $c2+=$data['credits2']; //$db->query("UPDATE {$tablepre}users SET achievement='$v' WHERE username='******'" ); //$db->query("UPDATE {$tablepre}users SET credits='$c1' WHERE username='******'" ); //$db->query("UPDATE {$tablepre}users SET credits2='$c2' WHERE username='******'" ); //} return; }
function set_credits() { global $db, $gtablepre, $tablepre, $winmode, $gamenum, $winner, $pdata, $now, $gametype; $result = $db->query("SELECT * FROM {$tablepre}players WHERE type='0'"); $list = $creditlist = $updatelist = array(); while ($data = $db->fetch_array($result)) { $list[$data['name']]['players'] = $data; } $result = $db->query("SELECT * FROM {$gtablepre}users WHERE lastgame='{$gamenum}'"); while ($data = $db->fetch_array($result)) { $list[$data['username']]['users'] = $data; } foreach ($list as $key => $val) { if (isset($val['players']) && isset($val['users'])) { $credits = get_credit_up($val['players'], $winner, $winmode) + $val['users']['credits']; $gold = get_gold_up($val['players'], $winner, $winmode) + $val['users']['gold']; $validgames = $val['users']['validgames'] + 1; $wingames = $key == $winner ? $val['users']['wingames'] + 1 : $val['users']['wingames']; //$obtain = get_honour_obtain($val['players'],$val['users']); //$honour = $val['users']['honour'] . $obtain; $lastwin = $val['users']['lastwin']; if ($winner == $val['players']['name'] && $now - $lastwin > 72000 && !in_array($gametype, array(10, 11, 12, 13, 14))) { if ($lastwin == 0) { $gold += 800; } //帐号首次获胜 $lastwin = $now; $gold += 200; //首胜 } $updatelist[] = array('username' => $key, 'credits' => $credits, 'wingames' => $wingames, 'validgames' => $validgames, 'lastwin' => $lastwin, 'gold' => $gold); // if(!empty($obtain)){ // $udghkey[] = $key; // if($pdata['name'] == $key){ // $pdata['gainhonour'] = $obtain; // }else{ // $udghlist[] = Array('name' => $key, 'gainhonour' => $obtain); // } // } } } $db->multi_update("{$gtablepre}users", $updatelist, 'username'); // if(!empty($udghkey)){ // $udghkey = implode(',',$udghkey); // $db->multi_update("{$tablepre}players", $upghlist, 'name', "name IN ($udghkey)"); // } return; }