<?php
defined( 'IN_WEB') or die( 'Include Error!');
class Game{
    /**
     * Notes:获取推金币游戏配置
     * User: wsc
     * Time: 2020/11/24 15:24
     * @param $param
     * @return string
     */
    public function getCDOpenInfo($param){
        $uid = oo::functions()->uint($param['uid']);
        if(empty($uid)){
            return oo::response(errorCode::REQUEST_PARAM_ERROR);
        }
        $ret =oo::commonOprModel('coindozer')->getOpenInfo($uid);
        return oo::response(1,$ret);
    }
    /**
     * Notes:开启推金币游戏
     * User: wsc
     * Time: 2020/11/20 16:56
     * @param $param
     * @return string
     */
    public function openCDGame($param){
        $uid = oo::functions()->uint($param['uid']);
        if(empty($uid)){
            return oo::response(errorCode::REQUEST_PARAM_ERROR);
        }
        $init=isset($param['init'])?intval($param['init']):0;
        $ret =oo::commonOprModel('coindozer')->openGame($uid,$init);
        return oo::response($ret['code'],$ret['data']);
    }

    /**
     * Notes:获取道具列表
     * User: wsc
     * Time: 2020/11/20 16:56
     * @param $param
     * @return string
     */
    public function getCDPropList($param){
        $uid = oo::functions()->uint($param['uid']);
        if(empty($uid)){
            return oo::response(errorCode::REQUEST_PARAM_ERROR);
        }
        $ret =array_values(oo::commonOprModel('coindozer')->getDropPropList($uid,1));
        return oo::response(1,$ret);
    }

    /**
     * Notes:购买游戏道具,次数
     * User: wsc
     * Time: 2020/11/20 17:01
     */
    public function buyCDSomeTing($param){
        $uid = oo::functions()->uint($param['uid']);
        $num = oo::functions()->uint($param['num']);
        $type = oo::functions()->uint($param['type']);
        if(empty($uid)||!isset($param['type'])||empty($num)){
            return oo::response(errorCode::REQUEST_PARAM_ERROR);
        }
        $ret =oo::commonOprModel('coindozer')->buy($uid,$num,$type);
        return oo::response($ret['code'],$ret['data']);
    }

    /**
     * Notes:使用游戏道具
     * User: wsc
     * Time: 2020/11/23 20:35
     * @param $param
     * @return string
     */
    public function useCDGameProp($param){
        $uid = oo::functions()->uint($param['uid']);
        $type = oo::functions()->uint($param['type']);
        if(empty($uid)||!isset($param['type'])){
            return oo::response(errorCode::REQUEST_PARAM_ERROR);
        }
        $ret =oo::commonOprModel('coindozer')->useProp($uid,$type);
        return oo::response($ret['code'],$ret['data']);
    }

    /**
     * Notes:上报推结果
     * User: wsc
     * Time: 2020/11/20 21:43
     * @param $param
     * @return string
     */
    public function subCD($param){
        $uid = oo::functions()->uint($param['uid']);
        $putNum = oo::functions()->uint($param['putNum']);
        $dropNum = oo::functions()->uint($param['dropNum']);
        $lostPidsStr = $param['lostPids'];
        $getPidsStr = $param['getPids'];
        if(empty($uid)){
            return oo::response(errorCode::REQUEST_PARAM_ERROR);
        }
        $ret =oo::commonOprModel('coindozer')->sub($uid,$putNum,$dropNum,$lostPidsStr,$getPidsStr);
        return $ret;
    }
}