package com.td.WaDa.game.complayersattri.controller;

import com.td.WaDa.common.pojo.Result;
import com.td.WaDa.game.complayersattri.service.ComPlayersLuckyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 工具功能模块
 */
@RequestMapping("/game/land")
@RestController
public class ComPlayersLuckyController {

    //todo 土地升级还差一个 计算收益
    @Autowired
    private ComPlayersLuckyService service;

    /**
     * 获取所有工具列表，方便用户选择使用哪种工具来获取幸运值
     *
     * @return
     */
    @GetMapping("/tools")
    public Result<?> getLandTools(String userId) {
        return Result.of(service.getLandTools(userId), true, "查询成功");
    }

    /**
     * 获取土地升级列表
     *
     * @return
     */
    @GetMapping("/level")
    public Result<?> getLandLevelUp() {
        return Result.of(service.getLandLevelUp(), true, "查询成功");
    }

    /**
     * 使用某个工具 获得幸运值
     *
     * @param userId
     * @param toolId
     * @param landId
     * @return
     */
    @PostMapping("/tools")
    public Result<?> useLuckyTools(@RequestParam(value = "userId") String userId,
                                   @RequestParam(value = "toolId") Integer toolId,
                                   @RequestParam(value = "landId") Integer landId) {
        return service.useLuckyTools(userId, toolId, landId);
    }

    /**
     * 土地升级
     *
     * @param userId
     * @param configLandId
     * @return
     */
    @PostMapping("/level")
    public Result<?> landLevelUp(@RequestParam(value = "userId") String userId,
                                 @RequestParam(value = "configLandId") Integer configLandId) {
        return service.landLevelUp(userId, configLandId);
    }

    /**
     * 兑换snb
     *
     * @param userId
     * @param luckNum
     * @return
     */
    @PostMapping("/snb")
    public Result<?> toSNB(@RequestParam(value = "userId") String userId,
                           @RequestParam(value = "luckNum") Integer luckNum) {
        return service.toSNB(userId, luckNum);
    }
}
