mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
简单的升星
This commit is contained in:
parent
8e644c583c
commit
b33fede03e
3
.gitignore
vendored
3
.gitignore
vendored
@ -61,4 +61,5 @@ out/
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
headless/logger/
|
||||||
|
9
JisolGameCocos/assets/resources/prefab/ui/宠物.meta
Normal file
9
JisolGameCocos/assets/resources/prefab/ui/宠物.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "3cb5a3f3-8841-4b00-8fcd-44395da74514",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
3098
JisolGameCocos/assets/resources/prefab/ui/宠物/宠物升星页面.prefab
Normal file
3098
JisolGameCocos/assets/resources/prefab/ui/宠物/宠物升星页面.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.1.49",
|
||||||
|
"importer": "prefab",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "2d60896c-8804-4c99-aedf-fc88ac297c21",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"syncNodeName": "宠物升星页面"
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"__type__": "cc.Prefab",
|
"__type__": "cc.Prefab",
|
||||||
"_name": "阵法宠物ICON",
|
"_name": "列表选择宠物ICON",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"__editorExtras__": {},
|
"__editorExtras__": {},
|
||||||
"_native": "",
|
"_native": "",
|
||||||
@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Node",
|
"__type__": "cc.Node",
|
||||||
"_name": "阵法宠物ICON",
|
"_name": "列表选择宠物ICON",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"__editorExtras__": {},
|
"__editorExtras__": {},
|
||||||
"_parent": null,
|
"_parent": null,
|
||||||
@ -248,7 +248,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.CompPrefabInfo",
|
"__type__": "cc.CompPrefabInfo",
|
||||||
"fileId": "6etm75eOVF37vJbMmq4O6z"
|
"fileId": "00FKoQn91HGIewgv1t1dOE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.PrefabInfo",
|
"__type__": "cc.PrefabInfo",
|
@ -8,6 +8,6 @@
|
|||||||
],
|
],
|
||||||
"subMetas": {},
|
"subMetas": {},
|
||||||
"userData": {
|
"userData": {
|
||||||
"syncNodeName": "阵法宠物ICON"
|
"syncNodeName": "列表选择宠物ICON"
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -70,6 +70,8 @@ export interface PlayerPetOV{
|
|||||||
petPlayerId:number; //宠物的玩家Id
|
petPlayerId:number; //宠物的玩家Id
|
||||||
petTbId:number; //宠物配置表Id
|
petTbId:number; //宠物配置表Id
|
||||||
petGrade:number; //宠物等级
|
petGrade:number; //宠物等级
|
||||||
|
petStar:number; //宠物星级
|
||||||
|
petStarExp:number; //宠物星级经验
|
||||||
}
|
}
|
||||||
//玩家阵法信息
|
//玩家阵法信息
|
||||||
export interface PlayerTacticalOV{
|
export interface PlayerTacticalOV{
|
||||||
@ -96,7 +98,9 @@ export const API = {
|
|||||||
|
|
||||||
|
|
||||||
/********** 宠物接口 ******************/
|
/********** 宠物接口 ******************/
|
||||||
GetPlayerPets: async () => RData(await app.api.get(`/game/pet/list`),false) as PlayerPetOV[], //获取玩家全部宠物
|
GetPlayerPets: async () => RData(await app.api.get(`/game/pet/list`),false) as PlayerPetOV[], //获取玩家全部宠物
|
||||||
|
//petId 需合成的Id pets 被合成的Id列表
|
||||||
|
PetUpStar: async (petId:number,pets:number[]) => RData(await app.api.post(`/game/pet/up/star`,{petId,pets}),true) as PlayerPetOV, //提升宠物星
|
||||||
|
|
||||||
/********** 阵法接口 ******************/
|
/********** 阵法接口 ******************/
|
||||||
GetPlayerTactical: async () => RData(await app.api.get(`/game/tactical/get`),false) as PlayerTacticalOV, //获取玩家阵法
|
GetPlayerTactical: async () => RData(await app.api.get(`/game/tactical/get`),false) as PlayerTacticalOV, //获取玩家阵法
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
import { _decorator, Component, Node } from 'cc';
|
||||||
|
import JNScrollViewItem from '../../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
||||||
|
import { PlayerPetOV } from '../../../consts/API';
|
||||||
|
import { PetIconSelect } from './PetIconSelect';
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ccclass('PetIconSelectScroll')
|
||||||
|
export class PetIconSelectScroll extends JNScrollViewItem<PlayerPetOV> {
|
||||||
|
|
||||||
|
@property(PetIconSelect)
|
||||||
|
select:PetIconSelect;
|
||||||
|
|
||||||
|
protected start(): void {
|
||||||
|
this.select.setIcon(this.data.petTbId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
9
JisolGameCocos/assets/script/ui/Pet.meta
Normal file
9
JisolGameCocos/assets/script/ui/Pet.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "4150c714-fb58-4291-a255-deead542da48",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
114
JisolGameCocos/assets/script/ui/Pet/PetUpStarView.ts
Normal file
114
JisolGameCocos/assets/script/ui/Pet/PetUpStarView.ts
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
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 { API, PlayerPetOV } from '../../consts/API';
|
||||||
|
import { PetOV, PlayerPetOVSelect } from '../VO/PetOV';
|
||||||
|
import { PetIconSelectScroll } from '../Consts/Pet/PetIconSelectScroll';
|
||||||
|
import { NodeEventType } from 'cc';
|
||||||
|
import { Label } from 'cc';
|
||||||
|
import { app, TD } from '../../App';
|
||||||
|
import { GUI } from '../UIConfig';
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ccclass('PetUpStarView')
|
||||||
|
export class PetUpStarView extends JNLayerBase {
|
||||||
|
|
||||||
|
@property(JNScrollView)
|
||||||
|
views:JNScrollView; //宠物列表
|
||||||
|
|
||||||
|
@property(Label)
|
||||||
|
petNameLabel:Label; //宠物名称
|
||||||
|
@property(Label)
|
||||||
|
petStar:Label; //宠物星级
|
||||||
|
@property(Label)
|
||||||
|
petStarExp:Label; //宠物星级经验
|
||||||
|
|
||||||
|
//宠物数据
|
||||||
|
pets:PlayerPetOVSelect[] = [];
|
||||||
|
|
||||||
|
data:PlayerPetOV;
|
||||||
|
|
||||||
|
onJNLoad(data: PlayerPetOV): void {
|
||||||
|
|
||||||
|
super.onJNLoad(data);
|
||||||
|
this.data = data;
|
||||||
|
this.onUpdateView();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//刷新页面
|
||||||
|
onUpdateView(){
|
||||||
|
|
||||||
|
this.onUpdateInfo();
|
||||||
|
|
||||||
|
//获取所有玩家宠物
|
||||||
|
this.pets = PetOV.PlayerPetOVSelects(PlayerPetData.getIns().getData());
|
||||||
|
this.views.refreshData(this.pets);
|
||||||
|
|
||||||
|
//向子节点添加点击事件
|
||||||
|
this.views.addItemEvent(NodeEventType.TOUCH_START,this.onClickItem.bind(this));
|
||||||
|
|
||||||
|
this.onUpdateSelect();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//刷新信息
|
||||||
|
onUpdateInfo(){
|
||||||
|
|
||||||
|
//显示宠物名称
|
||||||
|
this.petNameLabel.string = TD.TbGRole.get(this.data.petTbId).roleName;
|
||||||
|
this.petStar.string = `当前星级: ${this.data.petStar} 星`;
|
||||||
|
this.petStarExp.string = `升级所需经验 / ${this.data.petStarExp}`;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//刷新选择
|
||||||
|
onUpdateSelect(){
|
||||||
|
|
||||||
|
//刷新
|
||||||
|
this.views.getItems<PetIconSelectScroll>().forEach((item) => {
|
||||||
|
let data = item.data as PlayerPetOVSelect;
|
||||||
|
item.select.isSelect = data.isSelect;
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//选择全部
|
||||||
|
onClickAll(){
|
||||||
|
//如果全部选择则全部取消
|
||||||
|
if(this.pets.filter(pet => pet.isSelect).length == this.pets.length){
|
||||||
|
this.pets.forEach(pet => pet.isSelect = false);
|
||||||
|
}else{
|
||||||
|
this.pets.forEach(pet => pet.isSelect = true);
|
||||||
|
}
|
||||||
|
this.onUpdateSelect();
|
||||||
|
}
|
||||||
|
|
||||||
|
//点击Item
|
||||||
|
onClickItem(index:number){
|
||||||
|
|
||||||
|
this.pets[index].isSelect = !this.pets[index].isSelect;
|
||||||
|
this.onUpdateSelect();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//点击合成
|
||||||
|
async onClickUp(){
|
||||||
|
//获取被合成的Id
|
||||||
|
let pets = this.pets.filter(pet => pet.isSelect).map(pet => pet.petId);
|
||||||
|
|
||||||
|
if(pets.length <= 0){
|
||||||
|
app.layer.Open(GUI.Tips,{text:"请选择需要被合成的宠物"});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await API.PetUpStar(this.data.petId,pets);
|
||||||
|
app.layer.Open(GUI.Tips,{text:"合成成功"});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "f8ba437e-6ea7-43f3-8214-2b98fe19202a",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
import { _decorator, Component, Node } from 'cc';
|
|
||||||
import { PlayerPetOV } from '../../consts/API';
|
|
||||||
import JNScrollViewItem from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollViewItem';
|
|
||||||
import { PetIconSelect } from '../Consts/Pet/PetIconSelect';
|
|
||||||
const { ccclass, property } = _decorator;
|
|
||||||
|
|
||||||
@ccclass('IntoBattlePetIcon')
|
|
||||||
export class IntoBattlePetIcon extends JNScrollViewItem<PlayerPetOV> {
|
|
||||||
|
|
||||||
@property(PetIconSelect)
|
|
||||||
select:PetIconSelect;
|
|
||||||
|
|
||||||
protected start(): void {
|
|
||||||
this.select.setIcon(this.data.petTbId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { PlayerPetOV } from '../../consts/API';
|
|||||||
import { UIPetAnim } from '../../consts/GData';
|
import { UIPetAnim } from '../../consts/GData';
|
||||||
import { GUI } from '../UIConfig';
|
import { GUI } from '../UIConfig';
|
||||||
import PlayerTacticalData from '../../data/PlayerTacticalData';
|
import PlayerTacticalData from '../../data/PlayerTacticalData';
|
||||||
import { IntoBattlePetIcon } from './IntoBattlePetIcon';
|
import { PetIconSelectScroll } from '../Consts/Pet/PetIconSelectScroll';
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
//上阵页面
|
//上阵页面
|
||||||
@ -53,7 +53,7 @@ export class IntoBattleView extends JNLayerBase {
|
|||||||
this.views.refreshData(this.pets);
|
this.views.refreshData(this.pets);
|
||||||
|
|
||||||
//设置不可选中
|
//设置不可选中
|
||||||
this.views.getItems<IntoBattlePetIcon>().forEach(item => {
|
this.views.getItems<PetIconSelectScroll>().forEach(item => {
|
||||||
if(PlayerTacticalData.getIns().getTacticalInfo().indexOf(item.data.petId) != -1)
|
if(PlayerTacticalData.getIns().getTacticalInfo().indexOf(item.data.petId) != -1)
|
||||||
item.select.isNoSelect = true; //如果在阵法里则不可选中
|
item.select.isNoSelect = true; //如果在阵法里则不可选中
|
||||||
})
|
})
|
||||||
@ -69,13 +69,13 @@ export class IntoBattleView extends JNLayerBase {
|
|||||||
onUpdateSelect(){
|
onUpdateSelect(){
|
||||||
|
|
||||||
//默认都不选中
|
//默认都不选中
|
||||||
this.views.getItems<IntoBattlePetIcon>().forEach(item => {
|
this.views.getItems<PetIconSelectScroll>().forEach(item => {
|
||||||
item.select.isSelect = false;
|
item.select.isSelect = false;
|
||||||
})
|
})
|
||||||
|
|
||||||
//设置选中
|
//设置选中
|
||||||
if(this.index != -1){
|
if(this.index != -1){
|
||||||
let current = this.views.getItems<IntoBattlePetIcon>()[this.index]
|
let current = this.views.getItems<PetIconSelectScroll>()[this.index]
|
||||||
current.select.isSelect = true;
|
current.select.isSelect = true;
|
||||||
|
|
||||||
//显示选中宠物
|
//显示选中宠物
|
||||||
@ -87,12 +87,6 @@ export class IntoBattleView extends JNLayerBase {
|
|||||||
|
|
||||||
//点击Item
|
//点击Item
|
||||||
onClickItem(index:number){
|
onClickItem(index:number){
|
||||||
|
|
||||||
//判断是否不可选中
|
|
||||||
if(this.views.getItems<IntoBattlePetIcon>()[index].select.isNoSelect) {
|
|
||||||
app.layer.Open(GUI.Tips,{text:"当前宠物已上阵"})
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置当前选中
|
//设置当前选中
|
||||||
this.index = index;
|
this.index = index;
|
||||||
@ -108,6 +102,10 @@ export class IntoBattleView extends JNLayerBase {
|
|||||||
app.layer.Open(GUI.Tips,{text:"请选择要上阵的宠物."})
|
app.layer.Open(GUI.Tips,{text:"请选择要上阵的宠物."})
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(this.views.getItems<PetIconSelectScroll>()[this.index].select.isNoSelect) {
|
||||||
|
app.layer.Open(GUI.Tips,{text:"当前宠物已上阵"})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//修改上阵信息
|
//修改上阵信息
|
||||||
await PlayerTacticalData.getIns().UpdateIndexTactical(this.tIndex,this.pets[this.index].petId);
|
await PlayerTacticalData.getIns().UpdateIndexTactical(this.tIndex,this.pets[this.index].petId);
|
||||||
@ -117,6 +115,17 @@ export class IntoBattleView extends JNLayerBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//点击升星页面
|
||||||
|
async onClickUpStar(){
|
||||||
|
|
||||||
|
if(this.index < 0){
|
||||||
|
app.layer.Open(GUI.Tips,{text:"请选择宠物."})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app.layer.Open(GUI.PetUpStarView,this.pets[this.index]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,11 @@ export enum GUI{
|
|||||||
|
|
||||||
/** 主页页面 */
|
/** 主页页面 */
|
||||||
MainChat = "MainChat", //主页聊天页面
|
MainChat = "MainChat", //主页聊天页面
|
||||||
|
|
||||||
IntoBattleView = "IntoBattleView", //上阵页面
|
IntoBattleView = "IntoBattleView", //上阵页面
|
||||||
|
|
||||||
|
PetUpStarView = "PetUpStarView", //宠物升星页面
|
||||||
|
|
||||||
/**游戏模式页面 */
|
/**游戏模式页面 */
|
||||||
PVPModeMatchView = "PVPModeMatchView", //PVP模式匹配页面
|
PVPModeMatchView = "PVPModeMatchView", //PVP模式匹配页面
|
||||||
|
|
||||||
@ -85,6 +87,16 @@ const UIMainConfig:{ [key: string]: JNLayerInfo; } = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//宠物页面
|
||||||
|
const UIPetConfig:{ [key: string]: JNLayerInfo; } = {
|
||||||
|
[GUI.PetUpStarView]:{
|
||||||
|
layer:GLayer.Popup,
|
||||||
|
uri: "prefab/ui/宠物/宠物升星页面",
|
||||||
|
anims:BackOutScale,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//新手引导页面
|
//新手引导页面
|
||||||
const UINoviceConfig:{ [key: string]: JNLayerInfo; } = {
|
const UINoviceConfig:{ [key: string]: JNLayerInfo; } = {
|
||||||
|
|
||||||
@ -146,6 +158,7 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
|||||||
...UISystemConfig, //系统页面
|
...UISystemConfig, //系统页面
|
||||||
...UINoviceConfig, //新手引导页面
|
...UINoviceConfig, //新手引导页面
|
||||||
...UIMainConfig, //主页面
|
...UIMainConfig, //主页面
|
||||||
|
...UIPetConfig, //宠物页面
|
||||||
...UIGModeConfig, //游戏模式页面
|
...UIGModeConfig, //游戏模式页面
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
JisolGameCocos/assets/script/ui/VO.meta
Normal file
9
JisolGameCocos/assets/script/ui/VO.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "3eff9bce-ded3-4764-b79e-a86c9fd30e8e",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
18
JisolGameCocos/assets/script/ui/VO/PetOV.ts
Normal file
18
JisolGameCocos/assets/script/ui/VO/PetOV.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { PlayerPetOV } from "../../consts/API";
|
||||||
|
|
||||||
|
//宠物选择
|
||||||
|
export interface PlayerPetOVSelect extends PlayerPetOV{
|
||||||
|
|
||||||
|
//是否选择
|
||||||
|
isSelect:boolean;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PetOV{
|
||||||
|
|
||||||
|
static PlayerPetOVSelects(pets:PlayerPetOV[]):PlayerPetOVSelect[]{
|
||||||
|
return pets.map(pet => ({...pet,isSelect:false}))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
9
JisolGameCocos/assets/script/ui/VO/PetOV.ts.meta
Normal file
9
JisolGameCocos/assets/script/ui/VO/PetOV.ts.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "b4cea2c3-cb9a-43b7-9b23-a0e2d5dfe9e5",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
@ -1,24 +1,21 @@
|
|||||||
package cn.jisol.game.controller.game;
|
package cn.jisol.game.controller.game;
|
||||||
|
|
||||||
import cn.jisol.game.controller.argsresolver.CurrentPlayer;
|
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.Player;
|
||||||
import cn.jisol.game.entity.game.PlayerPet;
|
import cn.jisol.game.entity.game.PlayerPet;
|
||||||
import cn.jisol.game.service.PlayerPetService;
|
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 cn.jisol.ngame.util.NewsContext;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
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 Long petPlayerId; //宠物的玩家Id
|
||||||
private Integer petTbId; //宠物配置表Id
|
private Integer petTbId; //宠物配置表Id
|
||||||
private Integer petGrade; //宠物等级
|
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;
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user