user_id = $userID; $farmDbData->bg_image_id = GameConfigServices::getParamByPath('init.1.bg_image_id', 104004);//背景物品ID if (!$farmDbData->save()) throw new StatusException(ResultStatusServices::RS_SAVE_DB_ERROR,$farmDbData->getErrors()); //向仓库中添加默认背景物品 $itemConfig = GameConfigServices::getParamByPath('item_list.' . $farmDbData->bg_image_id); $item = new Item(); $item->user_id = $userID; $item->item_id = $farmDbData->bg_image_id; $item->name = $itemConfig['name']; $item->type = $itemConfig['type2']; if (!$item->save()) return false; //新建土地 $land_num = GameConfigServices::getParamByPath('init.1.land_num', 1);//背景图片图形ID $land_num=1; for ($i = 0; $i < $land_num; $i++) { $land = new Land(); if (!LandService::initNewFarmDataAndSave($land, $farmDbData->id, $i)) throw new StatusException(ResultStatusServices::RS_SAVE_DB_ERROR); } return true; } }