mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
宠物升星
This commit is contained in:
parent
b33fede03e
commit
4fea6dd030
Binary file not shown.
@ -343,7 +343,7 @@ export class TbGResource {
|
||||
|
||||
|
||||
export namespace TB {
|
||||
export class TbGRoleCUp {
|
||||
export class TbGRoleUpLevel {
|
||||
|
||||
constructor(_json_: any) {
|
||||
if (_json_.grade === undefined) { throw new Error() }
|
||||
@ -400,7 +400,7 @@ export class Resource {
|
||||
|
||||
|
||||
export namespace TB {
|
||||
export class TbGRoleCStar {
|
||||
export class TbGRoleUpStar {
|
||||
|
||||
constructor(_json_: any) {
|
||||
if (_json_.grade === undefined) { throw new Error() }
|
||||
@ -717,24 +717,24 @@ export class TbGResource{
|
||||
|
||||
|
||||
|
||||
export class TbGRoleCUp{
|
||||
private _dataMap: Map<number, TB.TbGRoleCUp>
|
||||
private _dataList: TB.TbGRoleCUp[]
|
||||
export class TbGRoleUpLevel{
|
||||
private _dataMap: Map<number, TB.TbGRoleUpLevel>
|
||||
private _dataList: TB.TbGRoleUpLevel[]
|
||||
constructor(_json_: any) {
|
||||
this._dataMap = new Map<number, TB.TbGRoleCUp>()
|
||||
this._dataMap = new Map<number, TB.TbGRoleUpLevel>()
|
||||
this._dataList = []
|
||||
for(var _json2_ of _json_) {
|
||||
let _v: TB.TbGRoleCUp
|
||||
_v = new TB.TbGRoleCUp(_json2_)
|
||||
let _v: TB.TbGRoleUpLevel
|
||||
_v = new TB.TbGRoleUpLevel(_json2_)
|
||||
this._dataList.push(_v)
|
||||
this._dataMap.set(_v.grade, _v)
|
||||
}
|
||||
}
|
||||
|
||||
getDataMap(): Map<number, TB.TbGRoleCUp> { return this._dataMap; }
|
||||
getDataList(): TB.TbGRoleCUp[] { return this._dataList; }
|
||||
getDataMap(): Map<number, TB.TbGRoleUpLevel> { return this._dataMap; }
|
||||
getDataList(): TB.TbGRoleUpLevel[] { return this._dataList; }
|
||||
|
||||
get(key: number): TB.TbGRoleCUp | undefined { return this._dataMap.get(key); }
|
||||
get(key: number): TB.TbGRoleUpLevel | undefined { return this._dataMap.get(key); }
|
||||
|
||||
resolve(tables:Tables)
|
||||
{
|
||||
@ -749,24 +749,24 @@ export class TbGRoleCUp{
|
||||
|
||||
|
||||
|
||||
export class TbGRoleCStar{
|
||||
private _dataMap: Map<number, TB.TbGRoleCStar>
|
||||
private _dataList: TB.TbGRoleCStar[]
|
||||
export class TbGRoleUpStar{
|
||||
private _dataMap: Map<number, TB.TbGRoleUpStar>
|
||||
private _dataList: TB.TbGRoleUpStar[]
|
||||
constructor(_json_: any) {
|
||||
this._dataMap = new Map<number, TB.TbGRoleCStar>()
|
||||
this._dataMap = new Map<number, TB.TbGRoleUpStar>()
|
||||
this._dataList = []
|
||||
for(var _json2_ of _json_) {
|
||||
let _v: TB.TbGRoleCStar
|
||||
_v = new TB.TbGRoleCStar(_json2_)
|
||||
let _v: TB.TbGRoleUpStar
|
||||
_v = new TB.TbGRoleUpStar(_json2_)
|
||||
this._dataList.push(_v)
|
||||
this._dataMap.set(_v.grade, _v)
|
||||
}
|
||||
}
|
||||
|
||||
getDataMap(): Map<number, TB.TbGRoleCStar> { return this._dataMap; }
|
||||
getDataList(): TB.TbGRoleCStar[] { return this._dataList; }
|
||||
getDataMap(): Map<number, TB.TbGRoleUpStar> { return this._dataMap; }
|
||||
getDataList(): TB.TbGRoleUpStar[] { return this._dataList; }
|
||||
|
||||
get(key: number): TB.TbGRoleCStar | undefined { return this._dataMap.get(key); }
|
||||
get(key: number): TB.TbGRoleUpStar | undefined { return this._dataMap.get(key); }
|
||||
|
||||
resolve(tables:Tables)
|
||||
{
|
||||
@ -832,10 +832,10 @@ export class Tables {
|
||||
get TbGOnHookGlobal(): TbGOnHookGlobal { return this._TbGOnHookGlobal;}
|
||||
private _TbGResource: TbGResource
|
||||
get TbGResource(): TbGResource { return this._TbGResource;}
|
||||
private _TbGRoleCUp: TbGRoleCUp
|
||||
get TbGRoleCUp(): TbGRoleCUp { return this._TbGRoleCUp;}
|
||||
private _TbGRoleCStar: TbGRoleCStar
|
||||
get TbGRoleCStar(): TbGRoleCStar { return this._TbGRoleCStar;}
|
||||
private _TbGRoleUpLevel: TbGRoleUpLevel
|
||||
get TbGRoleUpLevel(): TbGRoleUpLevel { return this._TbGRoleUpLevel;}
|
||||
private _TbGRoleUpStar: TbGRoleUpStar
|
||||
get TbGRoleUpStar(): TbGRoleUpStar { return this._TbGRoleUpStar;}
|
||||
private _TbSServerInfo: TbSServerInfo
|
||||
get TbSServerInfo(): TbSServerInfo { return this._TbSServerInfo;}
|
||||
|
||||
@ -848,8 +848,8 @@ export class Tables {
|
||||
this._TbGMap = new TbGMap(loader('tbgmap'))
|
||||
this._TbGOnHookGlobal = new TbGOnHookGlobal(loader('tbgonhookglobal'))
|
||||
this._TbGResource = new TbGResource(loader('tbgresource'))
|
||||
this._TbGRoleCUp = new TbGRoleCUp(loader('tbgrolecup'))
|
||||
this._TbGRoleCStar = new TbGRoleCStar(loader('tbgrolecstar'))
|
||||
this._TbGRoleUpLevel = new TbGRoleUpLevel(loader('tbgroleuplevel'))
|
||||
this._TbGRoleUpStar = new TbGRoleUpStar(loader('tbgroleupstar'))
|
||||
this._TbSServerInfo = new TbSServerInfo(loader('tbsserverinfo'))
|
||||
|
||||
this._TbGGlobal.resolve(this)
|
||||
@ -860,8 +860,8 @@ export class Tables {
|
||||
this._TbGMap.resolve(this)
|
||||
this._TbGOnHookGlobal.resolve(this)
|
||||
this._TbGResource.resolve(this)
|
||||
this._TbGRoleCUp.resolve(this)
|
||||
this._TbGRoleCStar.resolve(this)
|
||||
this._TbGRoleUpLevel.resolve(this)
|
||||
this._TbGRoleUpStar.resolve(this)
|
||||
this._TbSServerInfo.resolve(this)
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
"ver": "2.0.1",
|
||||
"importer": "json",
|
||||
"imported": true,
|
||||
"uuid": "580aaa0b-8b26-4bc6-9abe-6984e9980679",
|
||||
"uuid": "e973f307-a0ab-478d-85eb-36e1310007a7",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
@ -2,7 +2,7 @@
|
||||
"ver": "2.0.1",
|
||||
"importer": "json",
|
||||
"imported": true,
|
||||
"uuid": "dfe67d28-0f19-440b-ad19-7c1f70b3528b",
|
||||
"uuid": "02f53704-5e9c-4b95-8ef4-822a6a47882c",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
import { app } from "../App";
|
||||
import PlayerPetData from "../data/PlayerPetData";
|
||||
import ResourceData from "../data/ResourceData";
|
||||
import { GUI } from "../ui/UIConfig";
|
||||
|
||||
@ -9,7 +10,8 @@ export const RData = (data:any,isTips:boolean = true) => {
|
||||
if(data.data['resources']){
|
||||
//刷新资源
|
||||
data.data['resources'].forEach(res => {
|
||||
ResourceData.getIns().onUpdateOV(res.operation,res.resource);
|
||||
ResourceData.getIns().onUpdateOV(res.operation,res.resource); //刷新资源
|
||||
PlayerPetData.getIns().onUpdateOV(res.operation,res.pet); //刷新宠物
|
||||
})
|
||||
}
|
||||
return data.data.data;
|
||||
|
@ -1,6 +1,15 @@
|
||||
import { app } from "../App";
|
||||
import { API, PlayerInfoOV, PlayerPetOV } from "../consts/API";
|
||||
import BaseData from "./BaseData";
|
||||
import PlayerTacticalData from "./PlayerTacticalData";
|
||||
import { ResourceUpdateType } from "./ResourceData";
|
||||
|
||||
export enum PlayerPetEvent{
|
||||
UPDATE = "PlayerPetEvent_UPDATE", //刷新宠物
|
||||
UPDATE_INFO = "PlayerPetEvent_UPDATE_INFO", //刷新宠物信息
|
||||
UPDATE_ADD = "PlayerPetEvent_UPDATE_ADD", //添加宠物
|
||||
UPDATE_MINUS = "PlayerPetEvent_UPDATE_MINUS", //减少宠物
|
||||
}
|
||||
|
||||
//玩家宠物数据
|
||||
export default class PlayerPetData extends BaseData{
|
||||
@ -20,6 +29,16 @@ export default class PlayerPetData extends BaseData{
|
||||
return this.datas;
|
||||
}
|
||||
|
||||
//获取指定宠物
|
||||
getPetIdData(petTbId:number,datas:PlayerPetOV[] = this.datas):PlayerPetOV[]{
|
||||
return datas.filter(data => data.petTbId == petTbId);
|
||||
}
|
||||
|
||||
//获取未上阵的宠物
|
||||
getNoTacticalData():PlayerPetOV[]{
|
||||
return this.datas.filter(data => PlayerTacticalData.getIns().getTacticalInfo().indexOf(data.petId) < 0);
|
||||
}
|
||||
|
||||
//更新玩家宠物
|
||||
async UpdatePlayerPet(){
|
||||
//获取全部宠物
|
||||
@ -43,6 +62,54 @@ export default class PlayerPetData extends BaseData{
|
||||
this.datas.push(pet);
|
||||
}
|
||||
|
||||
//刷新返回宠物
|
||||
onUpdateOV(operation:number,resource:PlayerPetOV){
|
||||
|
||||
//如果没有刷新的宠物 则 返回
|
||||
if(!resource) return;
|
||||
|
||||
if(operation == ResourceUpdateType.UPDATE){
|
||||
//更新资源
|
||||
//找到需要被刷新的宠物 然后刷新 找不到则添加
|
||||
let pet = this.datas.filter(pet => pet.petId == resource.petId)[0];
|
||||
if(pet){
|
||||
//更新数据
|
||||
Object.assign(pet,resource);
|
||||
app.event.emit(PlayerPetEvent.UPDATE_INFO)
|
||||
}else{
|
||||
operation = ResourceUpdateType.ADD;
|
||||
this.onUpdateOV(operation,resource);
|
||||
}
|
||||
}else if(operation == ResourceUpdateType.ADD){
|
||||
//查询如果没有这个宠物则添加 负责 刷新
|
||||
let pet = this.datas.filter(pet => pet.petId != resource.petId)[0];
|
||||
if(!pet){
|
||||
//没有则添加
|
||||
this.datas.push(resource);
|
||||
app.event.emit(PlayerPetEvent.UPDATE)
|
||||
app.event.emit(PlayerPetEvent.UPDATE_ADD,pet)
|
||||
}else{
|
||||
operation = ResourceUpdateType.UPDATE;
|
||||
this.onUpdateOV(operation,resource);
|
||||
}
|
||||
}else if(operation == ResourceUpdateType.MINUS){
|
||||
|
||||
//删除的宠物
|
||||
let delPet;
|
||||
//删除指定的宠物
|
||||
this.datas = this.datas.filter(pet => {
|
||||
if(pet.petId == resource.petId){
|
||||
delPet = pet;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
app.event.emit(PlayerPetEvent.UPDATE)
|
||||
delPet && app.event.emit(PlayerPetEvent.UPDATE_MINUS,delPet)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,13 @@ export enum ResourceType{
|
||||
Gold = 90001, //金币
|
||||
}
|
||||
|
||||
//资源刷新类型
|
||||
export enum ResourceUpdateType{
|
||||
UPDATE = 0, //刷新资源数量
|
||||
MINUS = 1, //减少资源数量
|
||||
ADD = 2, //添加资源数量
|
||||
}
|
||||
|
||||
//玩家资源数据
|
||||
export default class ResourceData extends BaseData{
|
||||
|
||||
@ -43,12 +50,15 @@ export default class ResourceData extends BaseData{
|
||||
//刷新返回资源
|
||||
onUpdateOV(operation:number,resource:ResourceOV){
|
||||
|
||||
if(operation == 0){
|
||||
//如果没有刷新的资源 则 返回
|
||||
if(!resource) return;
|
||||
|
||||
if(operation == ResourceUpdateType.UPDATE){
|
||||
//更新资源
|
||||
this.data[resource.resourceTbId] = resource.resourceValue;
|
||||
app.event.emit(ResourceEvent.UPDATE)
|
||||
}
|
||||
|
||||
app.event.emit(ResourceEvent.UPDATE)
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLayerBase';
|
||||
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
|
||||
import PlayerPetData from '../../data/PlayerPetData';
|
||||
import PlayerPetData, { PlayerPetEvent } from '../../data/PlayerPetData';
|
||||
import { API, PlayerPetOV } from '../../consts/API';
|
||||
import { PetOV, PlayerPetOVSelect } from '../VO/PetOV';
|
||||
import { PetIconSelectScroll } from '../Consts/Pet/PetIconSelectScroll';
|
||||
@ -9,6 +9,8 @@ import { NodeEventType } from 'cc';
|
||||
import { Label } from 'cc';
|
||||
import { app, TD } from '../../App';
|
||||
import { GUI } from '../UIConfig';
|
||||
import { ProgressBar } from 'cc';
|
||||
import JProgressBar from '../../../../extensions/ngame/assets/ngame/util/components/Progress/JProgressBar';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('PetUpStarView')
|
||||
@ -23,9 +25,10 @@ export class PetUpStarView extends JNLayerBase {
|
||||
petStar:Label; //宠物星级
|
||||
@property(Label)
|
||||
petStarExp:Label; //宠物星级经验
|
||||
|
||||
//宠物数据
|
||||
pets:PlayerPetOVSelect[] = [];
|
||||
@property(JProgressBar)
|
||||
petExpProgress:JProgressBar; //宠物经验条
|
||||
@property(JProgressBar)
|
||||
viewPetExpProgress:JProgressBar; //预览宠物经验条
|
||||
|
||||
data:PlayerPetOV;
|
||||
|
||||
@ -35,6 +38,16 @@ export class PetUpStarView extends JNLayerBase {
|
||||
this.data = data;
|
||||
this.onUpdateView();
|
||||
|
||||
//监听
|
||||
app.event.on(PlayerPetEvent.UPDATE_INFO,this.onUpdateInfo,this); //刷新宠物信息
|
||||
app.event.on(PlayerPetEvent.UPDATE_MINUS,this.onPetMinus,this); //减少宠物
|
||||
|
||||
}
|
||||
|
||||
onJNClose(): void {
|
||||
//取消监听
|
||||
app.event.off(PlayerPetEvent.UPDATE_INFO,this.onUpdateInfo,this); //刷新宠物信息
|
||||
app.event.off(PlayerPetEvent.UPDATE_MINUS,this.onPetMinus,this); //减少宠物
|
||||
}
|
||||
|
||||
|
||||
@ -43,9 +56,14 @@ export class PetUpStarView extends JNLayerBase {
|
||||
|
||||
this.onUpdateInfo();
|
||||
|
||||
//获取所有玩家宠物
|
||||
this.pets = PetOV.PlayerPetOVSelects(PlayerPetData.getIns().getData());
|
||||
this.views.refreshData(this.pets);
|
||||
//当前需要升星的宠物并且未上阵 并且排除自己
|
||||
let pets = PetOV.PlayerPetOVSelects(
|
||||
PlayerPetData.getIns().getPetIdData(
|
||||
this.data.petTbId, //同一种宠物
|
||||
PlayerPetData.getIns().getNoTacticalData() //非上阵宠物
|
||||
).filter(pet => pet.petId != this.data.petId) //排除自己
|
||||
);
|
||||
this.views.refreshData(pets);
|
||||
|
||||
//向子节点添加点击事件
|
||||
this.views.addItemEvent(NodeEventType.TOUCH_START,this.onClickItem.bind(this));
|
||||
@ -60,10 +78,21 @@ export class PetUpStarView extends JNLayerBase {
|
||||
//显示宠物名称
|
||||
this.petNameLabel.string = TD.TbGRole.get(this.data.petTbId).roleName;
|
||||
this.petStar.string = `当前星级: ${this.data.petStar} 星`;
|
||||
this.petStarExp.string = `升级所需经验 / ${this.data.petStarExp}`;
|
||||
|
||||
let upStarExp = TD.TbGRoleUpStar.get(this.data.petStar + 1).merge;
|
||||
this.petStarExp.string = `升级进度: ${upStarExp} / ${this.data.petStarExp}`;
|
||||
this.petExpProgress.value = (this.data.petStarExp / upStarExp);
|
||||
|
||||
}
|
||||
|
||||
//减少宠物
|
||||
onPetMinus(pet:PlayerPetOV){
|
||||
this.views.getItems<PetIconSelectScroll>().forEach(item => {
|
||||
if(item.data.petId == pet.petId)
|
||||
this.views.delData(item.data);
|
||||
});
|
||||
}
|
||||
|
||||
//刷新选择
|
||||
onUpdateSelect(){
|
||||
|
||||
@ -73,31 +102,55 @@ export class PetUpStarView extends JNLayerBase {
|
||||
item.select.isSelect = data.isSelect;
|
||||
})
|
||||
|
||||
this.onUpdatePreview();
|
||||
|
||||
}
|
||||
|
||||
//更新预览进度条
|
||||
onUpdatePreview(){
|
||||
|
||||
//选择得到的经验
|
||||
let exp = this.views.getItems<PetIconSelectScroll>().filter(item => item.select.isSelect).length;
|
||||
|
||||
let upStarExp;
|
||||
let petStarExp = this.data.petStarExp + exp;
|
||||
let petStar = this.data.petStar;
|
||||
|
||||
while(petStarExp >= (upStarExp = TD.TbGRoleUpStar.get(petStar + 1).merge)){
|
||||
petStar++;
|
||||
petStarExp = Math.floor(petStarExp - upStarExp);
|
||||
}
|
||||
|
||||
this.petStar.string = `当前星级: ${petStar} 星`;
|
||||
this.petStarExp.string = `升级进度: ${upStarExp} / ${petStarExp}`;
|
||||
//预览进度
|
||||
this.viewPetExpProgress.value = (petStarExp / upStarExp);
|
||||
|
||||
}
|
||||
|
||||
//选择全部
|
||||
onClickAll(){
|
||||
let pets = this.views.getData<PlayerPetOVSelect>();
|
||||
//如果全部选择则全部取消
|
||||
if(this.pets.filter(pet => pet.isSelect).length == this.pets.length){
|
||||
this.pets.forEach(pet => pet.isSelect = false);
|
||||
if(pets.filter(pet => pet.isSelect).length == pets.length){
|
||||
pets.forEach(pet => pet.isSelect = false);
|
||||
}else{
|
||||
this.pets.forEach(pet => pet.isSelect = true);
|
||||
pets.forEach(pet => pet.isSelect = true);
|
||||
}
|
||||
this.onUpdateSelect();
|
||||
}
|
||||
|
||||
//点击Item
|
||||
onClickItem(index:number){
|
||||
|
||||
this.pets[index].isSelect = !this.pets[index].isSelect;
|
||||
let pets = this.views.getData<PlayerPetOVSelect>();
|
||||
pets[index].isSelect = !pets[index].isSelect;
|
||||
this.onUpdateSelect();
|
||||
|
||||
}
|
||||
|
||||
//点击合成
|
||||
async onClickUp(){
|
||||
//获取被合成的Id
|
||||
let pets = this.pets.filter(pet => pet.isSelect).map(pet => pet.petId);
|
||||
let pets = this.views.getData<PlayerPetOVSelect>().filter(pet => pet.isSelect).map(pet => pet.petId);
|
||||
|
||||
if(pets.length <= 0){
|
||||
app.layer.Open(GUI.Tips,{text:"请选择需要被合成的宠物"});
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 0ac0cc67b0cd8bd70fa3c9ead11fee366a6d7d68
|
||||
Subproject commit 8c270e5f8d9df4b531c5c102a43c1a66c85e2e53
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user