本帖最后由 liuzhly 于 2010-01-13 20:20 编辑
为了修改程序方便,特将农牧场商店代码直接调用系统定义的函数,减少以后更新麻烦,以后只需修改配置文件即可~~~
打开 :newfarmjson.php ,找到 :
if ( $_REQUEST['mod'] == "shop" && $_REQUEST['act'] == "getShopInfo" )
{
if ( $_REQUEST['type'] == "1" )
{
echo "{\"1\":[{\"cId\":40,\"cName\":。。。。。。代码太多,省略了
exit( );
}
if ( $_REQUEST['type'] == "3,4" )
{
echo "{\"3\":[{\"tId\":9,\"tName\":\"。。。。。。代码太多,省略了
exit( );
}
if ( $_REQUEST['type'] == "2" )
{
echo "{\"2\":[{\"itemId\":\"61\",\"itemName\":\"。。。。。。代码太多,省略了
exit( );
}
}
修改为如下简单代码:
if ( $_REQUEST['mod'] == "shop" && $_REQUEST['act'] == "getShopInfo" ){ //[=2=]
if ( $_REQUEST['type'] == "1" ){ //种子、花种
foreach ( $crops as $key => $value ){
$shop_list[] = $value;
}
$shop_list_str = str_replace( "\\\u", "\u", json_encode($shop_list) );
echo "{\"1\":{$shop_list_str}}";
}elseif ( $_REQUEST['type'] == "3,4" ){//工具、狗
foreach ( $tools as $key => $value ){
$shop_list[] = $value;
}
$shop_list_str = str_replace( "\\\u", "\u", json_encode($shop_list));
foreach ( $dogs as $key => $value ){
$dog_list[] = $value;
}
$dog_list_str = str_replace( "\\\u", "\u", json_encode($dog_list));
echo "{\"3\":{$shop_list_str},\"4\":{$dog_list_str}}";
}elseif ( $_REQUEST['type'] == "2" ){//装饰
foreach ( $decorative as $key => $value ){
$key > 4 && $shop_list[] = $value;
}
$shop_list_str = str_replace( "\\\u", "\u", json_encode($shop_list));
echo "{\"2\":{$shop_list_str}}";
}
exit();
} //[=2=] //商店列表
下面是牧场商店:
找到:
if ( $_REQUEST['mod'] == "cgi_get_animals" )
{
echo "[{\"byproductprice\":17,\"cId\":1001,\"cLevel\":0,\"cName\":\"\\u9E21\",\"consum\":1,\"cub\":14400,\"cycle\":21600,\"expect\":0,\"growing\":\"14400,14400,129600,180\",\"growthCycle\":0,\"harvestbExp\":10,\"harvestpExp\":30,\"maturingTime\":28800,\"output\":20,\"price\":700,\"procreation\":129600,\"productime\":180,\"productprice\":860},{\"byproductprice\":39,\"cId\":1002,\"cLevel\":1,\"cName\":\"\\u5154\\u5B50\",\"consum\":2,\"cub\":18000,\"cycle\":28800,\"expect\":0,\"growing\":\"18000,18000,129600,180\",\"growthCycle\":0,\"harvestbExp\":12,\"harvestpExp\":32,\"maturingTime\":36000,\"output\":12,\"price\":1200,\"procreation\":129600,\"productime\":180,\"productprice\":1460},{\"byproductprice\":29,\"cId\":1501,\"cLevel\":2,\"cName\":\"\\u7F8A\",\"consum\":4,\"cub\":27000,\"cycle\":43200,\"expect\":0,\"growing\":\"27000,27000,172800,180\",\"growthCycle\":0,\"harvestbExp\":16,\"harvestpExp\":38,\"maturingTime\":54000,\"output\":24,\"price\":2000,\"procreation\":172800,\"productime\":180,\"productprice\":2860},{\"byproductprice\":19,\"cId\":1003,\"cLevel\":3,\"cName\":\"\\u9E45\",\"consum\":3,\"cub\":16200,\"cycle\":25200,\"expect\":0,\"growing\":\"16200,16200,151200,180\",\"growthCycle\":0,\"harvestbExp\":11,\"harvestpExp\":36,\"maturingTime\":32400,\"output\":20,\"price\":900,\"procreation\":151200,\"productime\":180,\"productprice\":1060},{\"byproductprice\":55,\"cId\":1502,\"cLevel\":4,\"cName\":\"\\u725B\",\"consum\":5,\"cub\":32400,\"cycle\":43200,\"expect\":0,\"growing\":\"32400,32400,216000,180\",\"growthCycle\":0,\"harvestbExp\":17,\"harvestpExp\":40,\"maturingTime\":64800,\"output\":12,\"price\":3000,\"procreation\":216000,\"productime\":180,\"productprice\":4260},{\"byproductprice\":56,\"cId\":1004,\"cLevel\":5,\"cName\":\"\\u732B\",\"consum\":2,\"cub\":34200,\"cycle\":32400,\"expect\":0,\"growing\":\"34200,34200,216000,180\",\"growthCycle\":0,\"harvestbExp\":14,\"harvestpExp\":37,\"maturingTime\":68400,\"output\":12,\"price\":3200,\"procreation\":216000,\"productime\":180,\"productprice\":4060},{\"byproductprice\":58,\"cId\":1503,\"cLevel\":6,\"cName\":\"\\u7334\\u5B50\",\"consum\":4,\"cub\":36000,\"cycle\":36000,\"expect\":0,\"growing\":\"36000,36000,216000,180\",\"growthCycle\":0,\"harvestbExp\":14,\"harvestpExp\":38,\"maturingTime\":72000,\"output\":12,\"price\":4000,\"procreation\":216000,\"productime\":180,\"productprice\":5260},{\"byproductprice\":35,\"cId\":1005,\"cLevel\":7,\"cName\":\"\\u5B54\\u96C0\",\"consum\":3,\"cub\":37800,\"cycle\":43200,\"expect\":0,\"growing\":\"37800,37800,237600,180\",\"growthCycle\":0,\"harvestbExp\":16,\"harvestpExp\":39,\"maturingTime\":75600,\"output\":24,\"price\":5000,\"procreation\":237600,\"productime\":180,\"productprice\":6060},{\"byproductprice\":64,\"cId\":1504,\"cLevel\":8,\"cName\":\"\\u888B\\u9F20\",\"consum\":5,\"cub\":39600,\"cycle\":43200,\"expect\":0,\"growing\":\"39600,39600,237600,180\",\"growthCycle\":0,\"harvestbExp\":16,\"harvestpExp\":40,\"maturingTime\":79200,\"output\":12,\"price\":8000,\"procreation\":237600,\"productime\":180,\"productprice\":9860},{\"byproductprice\":68,\"cId\":1006,\"cLevel\":9,\"cName\":\"\\u4F01\\u9E45\",\"consum\":3,\"cub\":41400,\"cycle\":54000,\"expect\":0,\"growing\":\"41400,41400,259200,180\",\"growthCycle\":0,\"harvestbExp\":22,\"harvestpExp\":44,\"maturingTime\":82800,\"output\":16,\"price\":10000,\"procreation\":259200,\"productime\":180,\"productprice\":11860},{\"byproductprice\":69,\"cId\":1007,\"cLevel\":10,\"cName\":\"\\u4e4c\\u9f9f\",\"consum\":4,\"cub\":27000,\"cycle\":36000,\"expect\":0,\"growing\":\"27000,27000,216000,180\",\"growthCycle\":0,\"harvestbExp\":14,\"harvestpExp\":26,\"maturingTime\":54000,\"output\":12,\"price\":11000,\"procreation\":216000,\"productime\":180,\"productprice\":12000},{\"byproductprice\":70,\"cId\":1505,\"cLevel\":11,\"cName\":\"\\u6885\\u82B1\\u9E7F\",\"consum\":4,\"cub\":32400,\"cycle\":36000,\"expect\":0,\"growing\":\"32400,32400,216000,180\",\"growthCycle\":0,\"harvestbExp\":22,\"harvestpExp\":44,\"maturingTime\":64800,\"output\":12,\"price\":12000,\"procreation\":216000,\"productime\":180,\"productprice\":13330},{\"byproductprice\":71,\"cId\":1008,\"cLevel\":12,\"cName\":\"\\u677E\\u9F20\",\"consum\":5,\"cub\":36000,\"cycle\":39600,\"expect\":0,\"growing\":\"36000,36000,288000,180\",\"growthCycle\":0,\"harvestbExp\":16,\"harvestpExp\":29,\"maturingTime\":72000,\"output\":13,\"price\":12640,\"procreation\":288000,\"productime\":180,\"productprice\":14570},{\"byproductprice\":72,\"cId\":1009,\"cLevel\":13,\"cName\":\"\\u6CE2\\u65AF\\u732B\",\"consum\":5,\"cub\":37800,\"cycle\":43200,\"expect\":0,\"growing\":\"37800,37800,302400,180\",\"growthCycle\":0,\"harvestbExp\":17,\"harvestpExp\":30,\"maturingTime\":75600,\"output\":14,\"price\":13000,\"procreation\":302400,\"productime\":180,\"productprice\":14790},{\"byproductprice\":77,\"cId\":1507,\"cLevel\":15,\"cName\":\"\\u7F9A\\u7F8A\",\"consum\":2,\"cub\":39600,\"cycle\":46800,\"expect\":0,\"growing\":\"39600,39600,331200,180\",\"growthCycle\":0,\"harvestbExp\":18,\"harvestpExp\":40,\"maturingTime\":79200,\"output\":15,\"price\":13470,\"procreation\":331200,\"productime\":180,\"productprice\":15020},{\"byproductprice\":78,\"cId\":1010,\"cLevel\":17,\"cName\":\"\\u4ED3\\u9F20\",\"consum\":2,\"cub\":41400,\"cycle\":50400,\"expect\":0,\"growing\":\"41400,41400,403200,180\",\"growthCycle\":0,\"harvestbExp\":20,\"harvestpExp\":32,\"maturingTime\":82800,\"output\":16,\"price\":14100,\"procreation\":403200,\"productime\":180,\"productprice\":16940},{\"byproductprice\":79,\"cId\":1508,\"cLevel\":19,\"cName\":\"\\u9E35\\u9E1F\",\"consum\":2,\"cub\":43200,\"cycle\":54000,\"expect\":0,\"growing\":\"43200,43200,432000,180\",\"growthCycle\":0,\"harvestbExp\":21,\"harvestpExp\":33,\"maturingTime\":86400,\"output\":17,\"price\":14430,\"procreation\":43200,\"productime\":180,\"productprice\":17610}]";
}
修改为如下简单代码:
if ( $_REQUEST['mod'] == "cgi_get_animals" ){ //商店
foreach ( $shop as $key => $value ){
$shop_list[] = $value;
}
$shop_list_str = json_encode($shop_list);
$shop_list_str = str_replace( "\\\u", "\u", $shop_list_str );
echo $shop_list_str;
exit();
}
使用会感觉商店动物排列和以前不一样,只要调整 MC.PHP 里的 $shop = array(
下面动物的位置即可~~~ |