mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 10:16:14 +00:00
简单的升星
This commit is contained in:
@@ -1,24 +1,21 @@
|
||||
package cn.jisol.game.controller.game;
|
||||
|
||||
import cn.jisol.game.controller.argsresolver.CurrentPlayer;
|
||||
import cn.jisol.game.controller.argsresolver.CurrentUser;
|
||||
import cn.jisol.game.entity.User;
|
||||
import cn.jisol.game.entity.game.Player;
|
||||
import cn.jisol.game.entity.game.PlayerPet;
|
||||
import cn.jisol.game.service.PlayerPetService;
|
||||
import cn.jisol.game.service.impl.PlayerServiceImpl;
|
||||
import cn.jisol.game.vo.pet.PetUpStarOV;
|
||||
import cn.jisol.ngame.util.NewsContext;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 玩家宠物
|
||||
@@ -46,4 +43,54 @@ public class GPlayerPetController {
|
||||
|
||||
}
|
||||
|
||||
//提升宠物星
|
||||
@ApiImplicitParams({})
|
||||
@ApiOperation(value = "提升宠物星")
|
||||
@PostMapping("/up/star")
|
||||
public NewsContext<PlayerPet> onUpStar(@RequestBody PetUpStarOV info,@CurrentPlayer Player player){
|
||||
|
||||
//判断参数
|
||||
if(info.getPets().size() <= 0 || Objects.isNull(info.getPetId())){
|
||||
return NewsContext.onFail("参数错误");
|
||||
}
|
||||
|
||||
//查询被合成的宠物列表
|
||||
//合成数量
|
||||
long petCount = playerPetService.count(
|
||||
Wrappers.lambdaQuery(PlayerPet.class)
|
||||
.eq(PlayerPet::getPetPlayerId, player.getPlayerId())
|
||||
.and(qr -> {
|
||||
//遍历被合成的宠物
|
||||
info.getPets().forEach(petId -> {
|
||||
qr.eq(PlayerPet::getPetId, petId);
|
||||
qr.or();
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
if(info.getPets().size() != petCount){
|
||||
return NewsContext.onFail("合成宠物信息错误");
|
||||
}
|
||||
|
||||
//查询被升级的宠物
|
||||
PlayerPet pet = playerPetService.getById(info.getPetId());
|
||||
|
||||
//判断宠物是否是自己的
|
||||
if(!Objects.equals(pet.getPetPlayerId(), player.getPlayerId())){
|
||||
return NewsContext.onFail("宠物不是自己的");
|
||||
}
|
||||
|
||||
//升级星
|
||||
pet.setPetStarExp(pet.getPetStarExp() + info.getPets().size());
|
||||
|
||||
//保存宠物信息
|
||||
playerPetService.updateById(pet);
|
||||
|
||||
//删除被合成的宠物
|
||||
playerPetService.removeByIds(info.getPets());
|
||||
|
||||
return NewsContext.onSuccess("升星成功",pet);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -18,4 +18,6 @@ public class PlayerPet {
|
||||
private Long petPlayerId; //宠物的玩家Id
|
||||
private Integer petTbId; //宠物配置表Id
|
||||
private Integer petGrade; //宠物等级
|
||||
private Integer petStar; //宠物星级
|
||||
private Integer petStarExp; //宠物星级经验
|
||||
}
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package cn.jisol.game.vo.pet;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ApiModel(value = "升星请求体")
|
||||
@Builder
|
||||
@Data
|
||||
public class PetUpStarOV {
|
||||
|
||||
@ApiModelProperty(value = "需要升级的宠物Id", required = true)
|
||||
private Integer petId;
|
||||
|
||||
@ApiModelProperty(value = "被吸收的宠物列表", required = true)
|
||||
ArrayList<Integer> pets;
|
||||
|
||||
}
|
Reference in New Issue
Block a user