本帖最后由 iamxyh 于 2010-01-22 01:39 编辑
启用经验上限之后,部分农田的虫子和草没人清理,为增加除虫的积极性,参照liuzhly的帖子(====开心农场====关于升级奖励优化方法及说明https://discuz.dismall.com/viewthread.php?tid=1543631)及山姆的3.1版农场,增加此礼包。下面是截图:
具体修改如下:
1、新增字段pest,int(10),默认为值0。
2、修改代码:红色为修改或新增的,请对照自己的程序修改,不要照搬。
if ( $_REQUEST['mod'] == "farmlandstatus" && $_REQUEST['act'] == "spraying" )
{
$farm = $_SGLOBAL['db']->result( $_SGLOBAL['db']->query( "SELECT farmlandstatus FROM ".tname( "plug_newfarm" )." where uid=".intval( $_POST['ownerId'] ) ), 0 );
$query = $_SGLOBAL['db']->query( "SELECT pest,fertilizer,username FROM ".tname( "plug_newfarm" )." where uid=".$_SGLOBAL['supe_uid'] );
while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
{
$list[] = $value;
}
$fertilizer = json_decode( $list[0][fertilizer] );
$pest=$list[0][pest];
$farm = json_decode( $farm );
$money = 0;
$qlscj=6;
$getExp=0;
。。。
{省略若干代码}
。。。
$farm->farmlandstatus[$_REQUEST['place']]->i=$killer;
$farm_srt = json_encode( $farm );
$levelup_arr="false";
if ( $pest > 100 ){
$putonghuafei = 1;
$fertilizer->$putonghuafei = $fertilizer->$putonghuafei + 2;
$fertilizer = json_encode( $fertilizer );
$_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set fertilizer='".$fertilizer."',pest=pest-100 where uid=".$_SGLOBAL['supe_uid'] );
$levelup_arr="{\"title\":\"\\u9664\\u866B\\u5956\\u52B1\",\"eDesc\":\"".unicode_encodegb( $list[0][username] )."\\uFF0C\\u4F60\\u70ED\\u5FC3\\u5E2E\\u52A9\\u5927\\u5BB6\\u9664\\u866B\\u5DF2\\u7D2F\\u8BA1100\\u6B21\\uFF0C\\u5956\\u52B1\\u4F602\\u888B\\u666E\\u901A\\u5316\\u80A5\\u54E6\\uFF0C\\u5FEB\\u5230\\u80CC\\u5305\\u91CC\\u770B\\u770B\\u5427\\u3002\",\"item\":[{\"eType\":\"3\",\"eParam\":\"1\",\"eNum\":\"2\",\"name\":\"\\u666e\\u901a\\u5316\\u80a5\"}],\"level\":1}";
}
if($_REQUEST['tId']==6){
$fertilizer = json_encode( $fertilizer );
$_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set fertilizer='".$fertilizer."' where uid=".$_SGLOBAL['supe_uid'] );
}
if ( intval( $_POST['ownerId'] ) == $_SGLOBAL['supe_uid'] )
{
if ($getExp==0){$money=0;}
$_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set money=money+".$money.",exp=exp+".$getExp.",farmlandstatus='".$farm_srt."',pest=pest+1 where uid=".$_SGLOBAL['supe_uid'] );
if($farm->farmlandstatus[$_REQUEST['place']]->s==0){
$direction = "";
}else{
$direction = "\\u5927\\u866b\\u5b50\\u5f88\\u5389\\u5bb3\\uff0c\\u5feb\\u627e\\u597d\\u53cb\\u5e2e\\u5fd9\\u3002";//大虫子很厉害,快找好友帮忙。
}
}else{
$_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set farmlandstatus='".$farm_srt."' where uid=".intval( $_POST['ownerId'] ) );
if ($getExp==0){$money=0;}
$_SGLOBAL['db']->query( "UPDATE ".tname( "plug_newfarm" )." set money=money+".$money.",exp=exp+".$getExp.",pest=pest+1 where uid=".$_SGLOBAL['supe_uid'] );
if($farm->farmlandstatus[$_REQUEST['place']]->s==0){
$direction = "\\u8C22\\u8C22\\u4F60\\uFF0C\\u5927\\u866B\\u6E05\\u9664\\u5E72\\u51C0\\u4E86\\uFF01";//谢谢你,大虫清除干净了!
}else{
$direction = "\\u5927\\u866b\\u5b50\\u5f88\\u5389\\u5bb3\\uff0c\\u5feb\\u627e\\u597d\\u53cb\\u5e2e\\u5fd9\\u3002";//大虫子很厉害,快找好友帮忙。
}
}
echo "{\"tId\":".$_REQUEST['tId'].",\"farmlandIndex\":".$_REQUEST['place'].",\"code\":1,\"poptype\":1,\"direction\":\"".$direction."\",\"money\":".$money.",\"exp\":".$getExp.",\"levelUp\":".$levelup_arr.",\"humidity\":".$farm->farmlandstatus[$_REQUEST['place']]->h.",\"pest\":".$farm->farmlandstatus[$_REQUEST['place']]->g.",\"weed\":".$farm->farmlandstatus[$_REQUEST['place']]->f.",\"pId\":".$farm->farmlandstatus[$_REQUEST['place']]->s.",\"nph\":".$farm->farmlandstatus[$_REQUEST['place']]->t.",\"mph\":".$farm->farmlandstatus[$_REQUEST['place']]->u.",\"killer\":".json_encode( $farm->farmlandstatus[$_REQUEST['place']]->i )."}";
} |