mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 18:26:23 +00:00
宠物升星
This commit is contained in:
@@ -14,14 +14,14 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
|
||||
public final class TbGRoleCUp extends AbstractBean {
|
||||
public TbGRoleCUp(JsonObject _buf) {
|
||||
public final class TbGRoleUpLevel extends AbstractBean {
|
||||
public TbGRoleUpLevel(JsonObject _buf) {
|
||||
grade = _buf.get("grade").getAsInt();
|
||||
{ com.google.gson.JsonArray _json0_ = _buf.get("materials").getAsJsonArray(); int __n0 = _json0_.size(); materials = new cfg.TbGEntity.Resource[__n0]; int __index0=0; for(JsonElement __e0 : _json0_) { cfg.TbGEntity.Resource __v0; __v0 = cfg.TbGEntity.Resource.deserialize(__e0.getAsJsonObject()); materials[__index0++] = __v0; } }
|
||||
}
|
||||
|
||||
public static TbGRoleCUp deserialize(JsonObject _buf) {
|
||||
return new cfg.TB.TbGRoleCUp(_buf);
|
||||
public static TbGRoleUpLevel deserialize(JsonObject _buf) {
|
||||
return new cfg.TB.TbGRoleUpLevel(_buf);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ public final class TbGRoleCUp extends AbstractBean {
|
||||
*/
|
||||
public final cfg.TbGEntity.Resource[] materials;
|
||||
|
||||
public static final int __ID__ = 1860940751;
|
||||
public static final int __ID__ = -877225318;
|
||||
|
||||
@Override
|
||||
public int getTypeId() { return __ID__; }
|
@@ -14,14 +14,14 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
|
||||
public final class TbGRoleCStar extends AbstractBean {
|
||||
public TbGRoleCStar(JsonObject _buf) {
|
||||
public final class TbGRoleUpStar extends AbstractBean {
|
||||
public TbGRoleUpStar(JsonObject _buf) {
|
||||
grade = _buf.get("grade").getAsInt();
|
||||
merge = _buf.get("merge").getAsInt();
|
||||
}
|
||||
|
||||
public static TbGRoleCStar deserialize(JsonObject _buf) {
|
||||
return new cfg.TB.TbGRoleCStar(_buf);
|
||||
public static TbGRoleUpStar deserialize(JsonObject _buf) {
|
||||
return new cfg.TB.TbGRoleUpStar(_buf);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ public final class TbGRoleCStar extends AbstractBean {
|
||||
*/
|
||||
public final int merge;
|
||||
|
||||
public static final int __ID__ = 1657613958;
|
||||
public static final int __ID__ = 387566716;
|
||||
|
||||
@Override
|
||||
public int getTypeId() { return __ID__; }
|
@@ -35,10 +35,10 @@ public final class Tables
|
||||
public cfg.TbGOnHookGlobal getTbGOnHookGlobal() { return _tbgonhookglobal; }
|
||||
private final cfg.TbGResource _tbgresource;
|
||||
public cfg.TbGResource getTbGResource() { return _tbgresource; }
|
||||
private final cfg.TbGRoleCUp _tbgrolecup;
|
||||
public cfg.TbGRoleCUp getTbGRoleCUp() { return _tbgrolecup; }
|
||||
private final cfg.TbGRoleCStar _tbgrolecstar;
|
||||
public cfg.TbGRoleCStar getTbGRoleCStar() { return _tbgrolecstar; }
|
||||
private final cfg.TbGRoleUpLevel _tbgroleuplevel;
|
||||
public cfg.TbGRoleUpLevel getTbGRoleUpLevel() { return _tbgroleuplevel; }
|
||||
private final cfg.TbGRoleUpStar _tbgroleupstar;
|
||||
public cfg.TbGRoleUpStar getTbGRoleUpStar() { return _tbgroleupstar; }
|
||||
private final cfg.TbSServerInfo _tbsserverinfo;
|
||||
public cfg.TbSServerInfo getTbSServerInfo() { return _tbsserverinfo; }
|
||||
|
||||
@@ -51,8 +51,8 @@ public final class Tables
|
||||
_tbgmap = new cfg.TbGMap(loader.load("tbgmap"));
|
||||
_tbgonhookglobal = new cfg.TbGOnHookGlobal(loader.load("tbgonhookglobal"));
|
||||
_tbgresource = new cfg.TbGResource(loader.load("tbgresource"));
|
||||
_tbgrolecup = new cfg.TbGRoleCUp(loader.load("tbgrolecup"));
|
||||
_tbgrolecstar = new cfg.TbGRoleCStar(loader.load("tbgrolecstar"));
|
||||
_tbgroleuplevel = new cfg.TbGRoleUpLevel(loader.load("tbgroleuplevel"));
|
||||
_tbgroleupstar = new cfg.TbGRoleUpStar(loader.load("tbgroleupstar"));
|
||||
_tbsserverinfo = new cfg.TbSServerInfo(loader.load("tbsserverinfo"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,37 +0,0 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package cfg;
|
||||
|
||||
import luban.*;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
|
||||
public final class TbGRoleCStar {
|
||||
private final java.util.HashMap<Integer, cfg.TB.TbGRoleCStar> _dataMap;
|
||||
private final java.util.ArrayList<cfg.TB.TbGRoleCStar> _dataList;
|
||||
|
||||
public TbGRoleCStar(JsonElement _buf) {
|
||||
_dataMap = new java.util.HashMap<Integer, cfg.TB.TbGRoleCStar>();
|
||||
_dataList = new java.util.ArrayList<cfg.TB.TbGRoleCStar>();
|
||||
|
||||
for (com.google.gson.JsonElement _e_ : _buf.getAsJsonArray()) {
|
||||
cfg.TB.TbGRoleCStar _v;
|
||||
_v = cfg.TB.TbGRoleCStar.deserialize(_e_.getAsJsonObject());
|
||||
_dataList.add(_v);
|
||||
_dataMap.put(_v.grade, _v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.HashMap<Integer, cfg.TB.TbGRoleCStar> getDataMap() { return _dataMap; }
|
||||
public java.util.ArrayList<cfg.TB.TbGRoleCStar> getDataList() { return _dataList; }
|
||||
|
||||
public cfg.TB.TbGRoleCStar get(int key) { return _dataMap.get(key); }
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package cfg;
|
||||
|
||||
import luban.*;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
|
||||
public final class TbGRoleCUp {
|
||||
private final java.util.HashMap<Integer, cfg.TB.TbGRoleCUp> _dataMap;
|
||||
private final java.util.ArrayList<cfg.TB.TbGRoleCUp> _dataList;
|
||||
|
||||
public TbGRoleCUp(JsonElement _buf) {
|
||||
_dataMap = new java.util.HashMap<Integer, cfg.TB.TbGRoleCUp>();
|
||||
_dataList = new java.util.ArrayList<cfg.TB.TbGRoleCUp>();
|
||||
|
||||
for (com.google.gson.JsonElement _e_ : _buf.getAsJsonArray()) {
|
||||
cfg.TB.TbGRoleCUp _v;
|
||||
_v = cfg.TB.TbGRoleCUp.deserialize(_e_.getAsJsonObject());
|
||||
_dataList.add(_v);
|
||||
_dataMap.put(_v.grade, _v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.HashMap<Integer, cfg.TB.TbGRoleCUp> getDataMap() { return _dataMap; }
|
||||
public java.util.ArrayList<cfg.TB.TbGRoleCUp> getDataList() { return _dataList; }
|
||||
|
||||
public cfg.TB.TbGRoleCUp get(int key) { return _dataMap.get(key); }
|
||||
|
||||
}
|
37
JisolGameServer/Main/src/main/java/cfg/TbGRoleUpLevel.java
Normal file
37
JisolGameServer/Main/src/main/java/cfg/TbGRoleUpLevel.java
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package cfg;
|
||||
|
||||
import luban.*;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
|
||||
public final class TbGRoleUpLevel {
|
||||
private final java.util.HashMap<Integer, cfg.TB.TbGRoleUpLevel> _dataMap;
|
||||
private final java.util.ArrayList<cfg.TB.TbGRoleUpLevel> _dataList;
|
||||
|
||||
public TbGRoleUpLevel(JsonElement _buf) {
|
||||
_dataMap = new java.util.HashMap<Integer, cfg.TB.TbGRoleUpLevel>();
|
||||
_dataList = new java.util.ArrayList<cfg.TB.TbGRoleUpLevel>();
|
||||
|
||||
for (com.google.gson.JsonElement _e_ : _buf.getAsJsonArray()) {
|
||||
cfg.TB.TbGRoleUpLevel _v;
|
||||
_v = cfg.TB.TbGRoleUpLevel.deserialize(_e_.getAsJsonObject());
|
||||
_dataList.add(_v);
|
||||
_dataMap.put(_v.grade, _v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.HashMap<Integer, cfg.TB.TbGRoleUpLevel> getDataMap() { return _dataMap; }
|
||||
public java.util.ArrayList<cfg.TB.TbGRoleUpLevel> getDataList() { return _dataList; }
|
||||
|
||||
public cfg.TB.TbGRoleUpLevel get(int key) { return _dataMap.get(key); }
|
||||
|
||||
}
|
37
JisolGameServer/Main/src/main/java/cfg/TbGRoleUpStar.java
Normal file
37
JisolGameServer/Main/src/main/java/cfg/TbGRoleUpStar.java
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package cfg;
|
||||
|
||||
import luban.*;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
|
||||
public final class TbGRoleUpStar {
|
||||
private final java.util.HashMap<Integer, cfg.TB.TbGRoleUpStar> _dataMap;
|
||||
private final java.util.ArrayList<cfg.TB.TbGRoleUpStar> _dataList;
|
||||
|
||||
public TbGRoleUpStar(JsonElement _buf) {
|
||||
_dataMap = new java.util.HashMap<Integer, cfg.TB.TbGRoleUpStar>();
|
||||
_dataList = new java.util.ArrayList<cfg.TB.TbGRoleUpStar>();
|
||||
|
||||
for (com.google.gson.JsonElement _e_ : _buf.getAsJsonArray()) {
|
||||
cfg.TB.TbGRoleUpStar _v;
|
||||
_v = cfg.TB.TbGRoleUpStar.deserialize(_e_.getAsJsonObject());
|
||||
_dataList.add(_v);
|
||||
_dataMap.put(_v.grade, _v);
|
||||
}
|
||||
}
|
||||
|
||||
public java.util.HashMap<Integer, cfg.TB.TbGRoleUpStar> getDataMap() { return _dataMap; }
|
||||
public java.util.ArrayList<cfg.TB.TbGRoleUpStar> getDataList() { return _dataList; }
|
||||
|
||||
public cfg.TB.TbGRoleUpStar get(int key) { return _dataMap.get(key); }
|
||||
|
||||
}
|
@@ -1,9 +1,12 @@
|
||||
package cn.jisol.game.controller.game;
|
||||
|
||||
import cn.jisol.game.controller.argsresolver.CurrentPlayer;
|
||||
import cn.jisol.game.data.TD;
|
||||
import cn.jisol.game.entity.game.Player;
|
||||
import cn.jisol.game.entity.game.PlayerPet;
|
||||
import cn.jisol.game.service.PlayerPetService;
|
||||
import cn.jisol.game.vo.news.NewsResource;
|
||||
import cn.jisol.game.vo.news.ov.ResourceUpdateOV;
|
||||
import cn.jisol.game.vo.pet.PetUpStarOV;
|
||||
import cn.jisol.ngame.util.NewsContext;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -14,6 +17,8 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -47,11 +52,11 @@ public class GPlayerPetController {
|
||||
@ApiImplicitParams({})
|
||||
@ApiOperation(value = "提升宠物星")
|
||||
@PostMapping("/up/star")
|
||||
public NewsContext<PlayerPet> onUpStar(@RequestBody PetUpStarOV info,@CurrentPlayer Player player){
|
||||
public NewsResource<PlayerPet> onUpStar(@RequestBody PetUpStarOV info, @CurrentPlayer Player player){
|
||||
|
||||
//判断参数
|
||||
if(info.getPets().size() <= 0 || Objects.isNull(info.getPetId())){
|
||||
return NewsContext.onFail("参数错误");
|
||||
return NewsResource.onFail("参数错误");
|
||||
}
|
||||
|
||||
//查询被合成的宠物列表
|
||||
@@ -69,7 +74,7 @@ public class GPlayerPetController {
|
||||
);
|
||||
|
||||
if(info.getPets().size() != petCount){
|
||||
return NewsContext.onFail("合成宠物信息错误");
|
||||
return NewsResource.onFail("合成宠物信息错误");
|
||||
}
|
||||
|
||||
//查询被升级的宠物
|
||||
@@ -77,19 +82,37 @@ public class GPlayerPetController {
|
||||
|
||||
//判断宠物是否是自己的
|
||||
if(!Objects.equals(pet.getPetPlayerId(), player.getPlayerId())){
|
||||
return NewsContext.onFail("宠物不是自己的");
|
||||
return NewsResource.onFail("宠物不是自己的");
|
||||
}
|
||||
|
||||
//升级星
|
||||
pet.setPetStarExp(pet.getPetStarExp() + info.getPets().size());
|
||||
|
||||
//判断是否可以升下一星 如果可以则 升
|
||||
int upStarExp;
|
||||
while (pet.getPetStarExp() >= (upStarExp = TD.DATA.getTbGRoleUpStar().get(pet.getPetStar() + 1).merge)){
|
||||
//消耗经验
|
||||
pet.setPetStarExp(pet.getPetStarExp() - upStarExp);
|
||||
//升星
|
||||
pet.setPetStar(pet.getPetStar() + 1);
|
||||
}
|
||||
|
||||
//保存宠物信息
|
||||
playerPetService.updateById(pet);
|
||||
|
||||
//删除被合成的宠物
|
||||
playerPetService.removeByIds(info.getPets());
|
||||
|
||||
return NewsContext.onSuccess("升星成功",pet);
|
||||
//整理刷新数据
|
||||
ArrayList<ResourceUpdateOV> resources = new ArrayList<>();
|
||||
//刷新宠物
|
||||
resources.add(ResourceUpdateOV.onPet(ResourceUpdateOV.ResourceUpdateType.UPDATE,pet));
|
||||
//删除被合成的宠物
|
||||
info.getPets().forEach(item -> {
|
||||
resources.add(ResourceUpdateOV.onPet(ResourceUpdateOV.ResourceUpdateType.MINUS,PlayerPet.builder().petId(new Long(item)).build()));
|
||||
});
|
||||
|
||||
return NewsResource.onSuccess("升星成功",null, resources.toArray(new ResourceUpdateOV[0]));
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cn.jisol.game.vo.news.ov;
|
||||
|
||||
import cn.jisol.game.entity.game.PlayerPet;
|
||||
import cn.jisol.game.entity.game.Resource;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -9,7 +10,8 @@ import lombok.Data;
|
||||
@Data
|
||||
public class ResourceUpdateOV {
|
||||
|
||||
Resource resource;
|
||||
Resource resource; //资源
|
||||
PlayerPet pet; //宠物
|
||||
|
||||
//操作
|
||||
int operation = 0;
|
||||
@@ -26,4 +28,9 @@ public class ResourceUpdateOV {
|
||||
return ResourceUpdateOV.builder().operation(ResourceUpdateType.UPDATE).resource(resource).build();
|
||||
}
|
||||
|
||||
//返回宠物
|
||||
public static ResourceUpdateOV onPet(int type,PlayerPet pet){
|
||||
return ResourceUpdateOV.builder().operation(type).pet(pet).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user