<?php
!function_exists('readover') && exit('Forbidden');

/****

@name:運氣卡
@type:會員類
@effect:使用後隨機加減積分。

****/

if($tooldb['type']!=2){
	Showmsg('tooluse_type_error');  // 判斷道具類型是否設置錯誤
}
$num=$newcredit='';
$rt = $db->get_one("SELECT currency FROM pw_memberdata WHERE uid=".pwEscape($winduid));
$num=mt_rand(-300,300);
$newcurrency= $rt['currency']+$num;
$db->update("UPDATE pw_memberdata SET currency=".pwEscape($newcurrency)."WHERE uid=".pwEscape($winduid));
$db->update("UPDATE pw_usertool SET nums=nums-1 WHERE uid=".pwEscape($winduid)."AND toolid=".pwEscape($toolid));
$logdata=array(
	'type'		=>	'use',
	'descrip'	=>	'tool_15_descrip',
	'uid'		=>	$winduid,
	'username'	=>	$windid,
	'ip'		=>	$onlineip,
	'time'		=>	$timestamp,
	'toolname'	=>	$tooldb['name'],
	'newcurrency'=>$newcurrency,
);

writetoollog($logdata);
$msg='';
if($num>0){
	$msg='祝賀您獲得'.$num.'個交易幣';
}elseif($num<0){
	$msg='不幸，您的交易幣被扣除'.$num.'個';
}
Showmsg($msg);
?>