mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
update
This commit is contained in:
parent
9157e123b6
commit
620bcd3e53
BIN
DataTables/Datas/新手引导/选择宠物.xlsx
Normal file
BIN
DataTables/Datas/新手引导/选择宠物.xlsx
Normal file
Binary file not shown.
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": "6d6e0f57-5d1a-437c-9b38-c80559719a80",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.1.49",
|
||||||
|
"importer": "prefab",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "927f03cf-a5b6-4572-a362-57b33d1f69e3",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"syncNodeName": "NoviceNamingView"
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.1.49",
|
||||||
|
"importer": "prefab",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "d9bca169-7a8d-4581-90b2-487db4a4dabb",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"syncNodeName": "NoviceSelectPetView"
|
||||||
|
}
|
||||||
|
}
|
@ -23,8 +23,11 @@ import { JsonAsset } from "cc";
|
|||||||
import { GAction } from "./consts/GActionEnum";
|
import { GAction } from "./consts/GActionEnum";
|
||||||
import { StorageData, StorageEnum } from "./consts/GData";
|
import { StorageData, StorageEnum } from "./consts/GData";
|
||||||
import { JAPI, JAPIConfig } from "../../extensions/ngame/assets/ngame/util/JAPI";
|
import { JAPI, JAPIConfig } from "../../extensions/ngame/assets/ngame/util/JAPI";
|
||||||
|
import { API } from "./consts/API";
|
||||||
|
import { AppData } from "./AppData";
|
||||||
|
|
||||||
let IP = "localhost";
|
let APIPath = `https://api.pet.jisol.cn`
|
||||||
|
let WsPath = `wss://api.pet.jisol.cn/websocket`
|
||||||
|
|
||||||
//重写UI
|
//重写UI
|
||||||
class JNGLayer extends JNLayer{
|
class JNGLayer extends JNLayer{
|
||||||
@ -43,12 +46,12 @@ class JNGSocket extends JNSocket{
|
|||||||
//获取Token
|
//获取Token
|
||||||
let token = StorageData.get(StorageEnum.Token);
|
let token = StorageData.get(StorageEnum.Token);
|
||||||
if(token){
|
if(token){
|
||||||
resolve(`ws://${IP}:8080/websocket/${token}`)
|
resolve(`${WsPath}/${token}`)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const loginResolve = (token:string) => {
|
const loginResolve = (token:string) => {
|
||||||
resolve(`ws://${IP}:8080/websocket/${token}`);
|
resolve(`${WsPath}/${token}`);
|
||||||
}
|
}
|
||||||
//如果没有Token则弹出登入页面
|
//如果没有Token则弹出登入页面
|
||||||
app.layer.Open(GUI.Login,loginResolve);
|
app.layer.Open(GUI.Login,loginResolve);
|
||||||
@ -232,20 +235,22 @@ export const app = {
|
|||||||
event : EventDispatcher.getIns(), //通知
|
event : EventDispatcher.getIns(), //通知
|
||||||
proto : NGameMessage.getIns(), //消息
|
proto : NGameMessage.getIns(), //消息
|
||||||
api : JAPI.create({
|
api : JAPI.create({
|
||||||
baseURL: `http://${IP}:8080`,
|
baseURL: `${APIPath}`,
|
||||||
}), //请求
|
}), //请求
|
||||||
// api : {}, //请求
|
// api : {}, //请求
|
||||||
battle : GBattleModeManager.getIns(), //战斗
|
battle : GBattleModeManager.getIns(), //战斗
|
||||||
config : new JNGConfig(), //配置文件
|
config : new JNGConfig(), //配置文件
|
||||||
battleRes : new JLoaderBattle("battle"), //battle包
|
battleRes : new JLoaderBattle("battle"), //battle包
|
||||||
|
data : new AppData(), //游戏基础信息
|
||||||
loading: new Loading({
|
loading: new Loading({
|
||||||
[JNGConfig.loading]:{title:"加载配置文件"},
|
[JNGConfig.loading]:{title:"加载配置文件"},
|
||||||
[JLoaderBattle.loading]:{title:"加载战斗资源"},
|
[JLoaderBattle.loading]:{title:"加载战斗资源"},
|
||||||
[JLoaderBattle.loadingInit]:{title:"初始化战斗资源"},
|
[JLoaderBattle.loadingInit]:{title:"初始化战斗资源"},
|
||||||
|
[AppData.loading]:{title:"初始化信息"},
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
app.api.addInterceptor((config:JAPIConfig) => {
|
app.api.addRequestInterceptors((config:JAPIConfig) => {
|
||||||
//设置Token
|
//设置Token
|
||||||
config.headers["Token"] = StorageData.get(StorageEnum.Token);
|
config.headers["Token"] = StorageData.get(StorageEnum.Token);
|
||||||
return true;
|
return true;
|
||||||
|
42
JisolGameCocos/assets/script/AppData.ts
Normal file
42
JisolGameCocos/assets/script/AppData.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import SystemBase from "../../extensions/ngame/assets/ngame/system/SystemBase";
|
||||||
|
import { app } from "./App";
|
||||||
|
import { API, NewsContext, PlayerInfoOV } from "./consts/API";
|
||||||
|
|
||||||
|
|
||||||
|
//数据类 (用于初始化游戏信息)
|
||||||
|
export class AppData extends SystemBase{
|
||||||
|
|
||||||
|
static loading = "AppData";
|
||||||
|
|
||||||
|
//玩家信息
|
||||||
|
static PLAYER_INFO:string = "PLAYER_INFO";
|
||||||
|
|
||||||
|
get loadings():{[key:string]:Function}{
|
||||||
|
return {
|
||||||
|
[AppData.PLAYER_INFO]:API.GetPlayerInfo, //玩家信息
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data:{[key:string]:any} = {};
|
||||||
|
|
||||||
|
async onInit(): Promise<any> {
|
||||||
|
|
||||||
|
app.loading.setCurrent(AppData.loading);
|
||||||
|
|
||||||
|
//加载信息
|
||||||
|
let keys = Object.keys(this.loadings);
|
||||||
|
for (let index = 0; index < keys.length; index++) {
|
||||||
|
this.data[keys[index]] = (await this.loadings[keys[index]]());
|
||||||
|
}
|
||||||
|
|
||||||
|
app.loading.ok(AppData.loading);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取玩家信息
|
||||||
|
getPlayerInfo():PlayerInfoOV{
|
||||||
|
return this.data[AppData.PLAYER_INFO];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
9
JisolGameCocos/assets/script/AppData.ts.meta
Normal file
9
JisolGameCocos/assets/script/AppData.ts.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "edb3bebb-69b2-4a49-aaa8-3b3c53988f46",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
@ -1,15 +1,15 @@
|
|||||||
import { app } from "../App";
|
import { app } from "../App";
|
||||||
import { GUI } from "../ui/UIConfig";
|
import { GUI } from "../ui/UIConfig";
|
||||||
|
|
||||||
const http = app.api;
|
const RData = (data:any,isTips:boolean = true) => {
|
||||||
|
|
||||||
const RData = (data:any) => {
|
|
||||||
if(data.data.state == 200){
|
if(data.data.state == 200){
|
||||||
return data.data.data;
|
return data.data.data;
|
||||||
}else{
|
}else{
|
||||||
//弹出提示
|
//弹出提示
|
||||||
app.layer.Open(GUI.Tips,{text:data.data.msg});
|
if(isTips){
|
||||||
return null;
|
app.layer.Open(GUI.Tips,{text:data.data.msg});
|
||||||
|
}
|
||||||
|
return data.data.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,12 +27,22 @@ export interface UserLoginVO{
|
|||||||
token:string, //token
|
token:string, //token
|
||||||
user:UserVO, //玩家信息
|
user:UserVO, //玩家信息
|
||||||
}
|
}
|
||||||
|
export interface PlayerInfoOV{
|
||||||
|
playerId:number, //玩家Id
|
||||||
|
userId: number, //用户Id
|
||||||
|
playerName:string, //玩家名
|
||||||
|
playerCreateTime:number, //玩家创建时间
|
||||||
|
novice: false, //是否过引导
|
||||||
|
}
|
||||||
|
|
||||||
export const API = {
|
export const API = {
|
||||||
|
|
||||||
UserRegister : async () => RData(await http.post(`/user/register`)) as UserVO, //玩家注册
|
UserRegister : async () => RData(await app.api.post(`/user/register`)) as UserVO, //玩家注册
|
||||||
UserLogin : async (account:string,password:string) => RData(await http.post(`/user/login`,{userId:account,userPass:password})) as UserLoginVO, //玩家登录
|
UserLogin : async (account:string,password:string) => RData(await app.api.post(`/user/login`,{userId:account,userPass:password})) as UserLoginVO, //玩家登录
|
||||||
GetPlayerInfo : async () => (await http.get(`/game/player/info`)).data as NewsContext, //获取玩家信息
|
GetPlayerInfo : async () => RData(await app.api.get(`/game/player/info`),false) as NewsContext, //获取玩家信息
|
||||||
|
|
||||||
|
/********** 新手引导接口 *****************/
|
||||||
|
SavePlayerInfo : async (playerName:string,novice:boolean = true) => (await app.api.post(`/game/player/info/save`,{playerName,novice})).data as NewsContext, //保存玩家信息
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
export enum GAction {
|
export enum GAction {
|
||||||
|
|
||||||
TOKEN_EXPIRED = 1001, //Token过期
|
TOKEN_EXPIRED = 1001, //Token过期
|
||||||
|
NOT_CREATE_PLAYER_INFO = 2001, //没有玩家信息 - 前往引导页面
|
||||||
|
|
||||||
}
|
}
|
@ -23,6 +23,7 @@ export class StorageData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const GData = {
|
export const GData = {
|
||||||
|
//层级
|
||||||
layer: {
|
layer: {
|
||||||
World: 1,
|
World: 1,
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ import { _decorator } from "cc";
|
|||||||
import { JNGLayerBase, app } from "../../App";
|
import { JNGLayerBase, app } from "../../App";
|
||||||
import { Label } from "cc";
|
import { Label } from "cc";
|
||||||
import { GUI } from "../UIConfig";
|
import { GUI } from "../UIConfig";
|
||||||
|
import { API } from "../../consts/API";
|
||||||
|
import { GAction } from "../../consts/GActionEnum";
|
||||||
|
import NoviceManager from "../Novice/NoviceManager";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass('LoadingView')
|
@ccclass('LoadingView')
|
||||||
@ -29,9 +32,10 @@ export default class LoadingView extends JNGLayerBase {
|
|||||||
|
|
||||||
async onSuccess(){
|
async onSuccess(){
|
||||||
|
|
||||||
//打开主页
|
await NoviceManager.getIns().onStart();
|
||||||
await app.layer.Open(GUI.Home);
|
|
||||||
//关闭加载页
|
//关闭加载页
|
||||||
|
await app.layer.Open(GUI.Home);
|
||||||
app.layer.Close(GUI.Loading);
|
app.layer.Close(GUI.Loading);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
9
JisolGameCocos/assets/script/ui/Novice.meta
Normal file
9
JisolGameCocos/assets/script/ui/Novice.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "22b638a6-c17e-4935-adb5-b5309777f71c",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
20
JisolGameCocos/assets/script/ui/Novice/NoviceManager.ts
Normal file
20
JisolGameCocos/assets/script/ui/Novice/NoviceManager.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import Singleton from "../../../../extensions/ngame/assets/ngame/util/Singleton";
|
||||||
|
import { app } from "../../App";
|
||||||
|
import { GUI } from "../UIConfig";
|
||||||
|
|
||||||
|
export default class NoviceManager extends Singleton{
|
||||||
|
|
||||||
|
//新手引导执行
|
||||||
|
async onStart(){
|
||||||
|
|
||||||
|
if(!(app.data.getPlayerInfo().novice)){
|
||||||
|
//如果没有过引导则打开引导页面
|
||||||
|
await app.layer.OpenToClose(GUI.NoviceNamingView);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("新手引导结束");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "8b5cc1e0-3fa2-4ee3-b93b-2da9878f9c8c",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
24
JisolGameCocos/assets/script/ui/Novice/NoviceNamingView.ts
Normal file
24
JisolGameCocos/assets/script/ui/Novice/NoviceNamingView.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { _decorator, Component, Node } from 'cc';
|
||||||
|
import { app, JNGLayerBase } from '../../App';
|
||||||
|
import { EditBox } from 'cc';
|
||||||
|
import { API } from '../../consts/API';
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ccclass('NoviceNamingView')
|
||||||
|
export class NoviceNamingView extends JNGLayerBase {
|
||||||
|
|
||||||
|
@property(EditBox)
|
||||||
|
text:EditBox;
|
||||||
|
|
||||||
|
//保存名称
|
||||||
|
async onSave(){
|
||||||
|
if(this.text.string){
|
||||||
|
await API.SavePlayerInfo(this.text.string);
|
||||||
|
//关闭页面
|
||||||
|
app.layer.CloseNode(this.node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "ccac142a-85d0-4cc2-9f66-e71110e1d69d",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
import { _decorator, Component, Node } from 'cc';
|
||||||
|
import { JNGLayerBase } from '../../App';
|
||||||
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
|
@ccclass('NoviceSelectPetView')
|
||||||
|
export class NoviceSelectPetView extends JNGLayerBase {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "0bc93bda-24b6-4fb9-809c-d5d4ebbf22ec",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
@ -13,6 +13,10 @@ export enum GUI{
|
|||||||
Loading = "Loading", //加载页面
|
Loading = "Loading", //加载页面
|
||||||
Tips = "Tips", //提示
|
Tips = "Tips", //提示
|
||||||
|
|
||||||
|
/** 新手引导 */
|
||||||
|
NoviceNamingView = "NoviceNamingView", //新手引导页面 - 取名
|
||||||
|
NoviceSelectPetView = "NoviceSelectPetView", //新手引导页面 - 选择宠物
|
||||||
|
|
||||||
Home = "Home", //主页面
|
Home = "Home", //主页面
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +25,7 @@ export enum GUI{
|
|||||||
const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
|
const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
|
||||||
[GUI.Tips]:{
|
[GUI.Tips]:{
|
||||||
layer:GLayer.Tips,
|
layer:GLayer.Tips,
|
||||||
uri: "prefab/ui/System/Tips/TipsView",
|
uri: "prefab/ui/系统页面/Tips/TipsView",
|
||||||
anims:{
|
anims:{
|
||||||
front:JNLayerAnim.BackOutOpen,
|
front:JNLayerAnim.BackOutOpen,
|
||||||
back:JNLayerAnim.BackInClose
|
back:JNLayerAnim.BackInClose
|
||||||
@ -29,7 +33,7 @@ const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
|
|||||||
},
|
},
|
||||||
[GUI.Login]:{
|
[GUI.Login]:{
|
||||||
layer:GLayer.Popup,
|
layer:GLayer.Popup,
|
||||||
uri: "prefab/ui/System/LoginView",
|
uri: "prefab/ui/系统页面/LoginView",
|
||||||
anims:{
|
anims:{
|
||||||
front:JNLayerAnim.BackOutOpen,
|
front:JNLayerAnim.BackOutOpen,
|
||||||
back:JNLayerAnim.BackInClose
|
back:JNLayerAnim.BackInClose
|
||||||
@ -37,7 +41,7 @@ const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
|
|||||||
},
|
},
|
||||||
[GUI.Loading]:{
|
[GUI.Loading]:{
|
||||||
layer:GLayer.View,
|
layer:GLayer.View,
|
||||||
uri: "prefab/ui/Loading/LoadingView",
|
uri: "prefab/ui/加载页面/LoadingView",
|
||||||
anims:{
|
anims:{
|
||||||
back:JNLayerAnim.Smaller,
|
back:JNLayerAnim.Smaller,
|
||||||
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
|
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
|
||||||
@ -45,10 +49,32 @@ const UISystemConfig:{ [key: string]: JNLayerInfo; } = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//新手引导页面
|
||||||
|
const UINoviceConfig:{ [key: string]: JNLayerInfo; } = {
|
||||||
|
|
||||||
|
[GUI.NoviceNamingView]:{
|
||||||
|
layer:GLayer.Popup,
|
||||||
|
uri: "prefab/ui/新手引导页面/NoviceNamingView",
|
||||||
|
anims:{
|
||||||
|
front:JNLayerAnim.BackOutOpen,
|
||||||
|
back:JNLayerAnim.BackInClose
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[GUI.NoviceSelectPetView]:{
|
||||||
|
layer:GLayer.Popup,
|
||||||
|
uri: "prefab/ui/新手引导页面/NoviceSelectPetView",
|
||||||
|
anims:{
|
||||||
|
front:JNLayerAnim.BackOutOpen,
|
||||||
|
back:JNLayerAnim.BackInClose
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
||||||
[GUI.Home]:{
|
[GUI.Home]:{
|
||||||
layer:GLayer.View,
|
layer:GLayer.View,
|
||||||
uri: "prefab/ui/Home/HomeView",
|
uri: "prefab/ui/主页/HomeView",
|
||||||
anims:{
|
anims:{
|
||||||
front:JNLayerAnim.Enlarge,
|
front:JNLayerAnim.Enlarge,
|
||||||
back:JNLayerAnim.Smaller,
|
back:JNLayerAnim.Smaller,
|
||||||
@ -56,6 +82,7 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
|
|||||||
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
|
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...UISystemConfig
|
...UISystemConfig, //系统页面
|
||||||
|
...UINoviceConfig, //新手引导页面
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,17 +8,18 @@ import cn.jisol.game.service.PlayerService;
|
|||||||
import cn.jisol.game.service.impl.PlayerServiceImpl;
|
import cn.jisol.game.service.impl.PlayerServiceImpl;
|
||||||
import cn.jisol.ngame.util.NewsContext;
|
import cn.jisol.ngame.util.NewsContext;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
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.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.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新手API
|
* 新手API
|
||||||
*/
|
*/
|
||||||
|
@Api(value = "JNGameDemo - API", tags = {"PET - API"})
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/game/player")
|
@RequestMapping("/game/player")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ -28,18 +29,56 @@ public class PlayerController {
|
|||||||
PlayerServiceImpl playerService;
|
PlayerServiceImpl playerService;
|
||||||
|
|
||||||
//获取玩家信息
|
//获取玩家信息
|
||||||
|
@ApiImplicitParams({})
|
||||||
|
@ApiOperation(value = "获取玩家信息")
|
||||||
@GetMapping("/info")
|
@GetMapping("/info")
|
||||||
public NewsContext<Player> getPlayerInfo(@CurrentUser User user){
|
public NewsContext<Player> getPlayerInfo(@CurrentUser User user){
|
||||||
|
|
||||||
Player info = playerService.getOne(Wrappers.lambdaQuery(Player.class).eq(Player::getUserId,user.getUserId()));
|
Player info = playerService.getOne(Wrappers.lambdaQuery(Player.class).eq(Player::getUserId,user.getUserId()));
|
||||||
|
|
||||||
if (Objects.isNull(info)){
|
if (Objects.isNull(info)){
|
||||||
//玩家没有进入过游戏 前往 新手引导
|
try{
|
||||||
return NewsContext.onMessage("前往新手引导",null, HttpCode.NOT_CREATE_PLAYER_INFO);
|
info = Player.builder().userId(user.getUserId()).playerName("冒险者").build();
|
||||||
}else{
|
playerService.saveOrUpdate(info);
|
||||||
|
}catch (Exception ignored){}
|
||||||
|
assert playerService != null;
|
||||||
|
info = playerService.getOne(Wrappers.lambdaQuery(Player.class).eq(Player::getUserId,user.getUserId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.isNovice()){
|
||||||
return NewsContext.onSuccess("获取成功",info);
|
return NewsContext.onSuccess("获取成功",info);
|
||||||
|
}else{
|
||||||
|
//前往 新手引导
|
||||||
|
return NewsContext.onMessage("前往新手引导",info, HttpCode.NOT_CREATE_PLAYER_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置玩家信息
|
||||||
|
@ApiImplicitParams({})
|
||||||
|
@ApiOperation(value = "设置玩家信息")
|
||||||
|
@PostMapping("/info/save")
|
||||||
|
public NewsContext<Player> savePlayerInfo(@CurrentUser User user,@RequestBody Player player){
|
||||||
|
|
||||||
|
//获取玩家信息
|
||||||
|
Player info = playerService.getOne(Wrappers.lambdaQuery(Player.class).eq(Player::getUserId,user.getUserId()));
|
||||||
|
|
||||||
|
//如果没有玩家信息则初始化信息
|
||||||
|
if (Objects.isNull(info)){
|
||||||
|
info = Player.builder().userId(user.getUserId()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
info.setPlayerName(player.getPlayerName());
|
||||||
|
info.setNovice(player.isNovice());
|
||||||
|
|
||||||
|
//保存信息
|
||||||
|
if(playerService.saveOrUpdate(info)){
|
||||||
|
return NewsContext.onSuccess("保存成功",info);
|
||||||
|
}else{
|
||||||
|
return NewsContext.onFail("保存失败",info);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
package cn.jisol.game.entity.game;
|
package cn.jisol.game.entity.game;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
@Data
|
@Data
|
||||||
@TableName("`player`")
|
@TableName("`player`")
|
||||||
public class Player {
|
public class Player {
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long playerId; //游戏玩家Id
|
private Long playerId; //游戏玩家Id
|
||||||
private String userId; //玩家Id
|
private Long userId; //玩家Id
|
||||||
private String playerName; //游戏玩家名称
|
private String playerName; //游戏玩家名称
|
||||||
private Long playerCreateTime; //玩家创建时间
|
private Date playerCreateTime; //玩家创建时间
|
||||||
|
private boolean isNovice; //玩家是否过了新手引导
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ spring:
|
|||||||
password: sThsBwjfDcaw2wJR
|
password: sThsBwjfDcaw2wJR
|
||||||
url: jdbc:mysql://kyu.jisol.cn:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
|
url: jdbc:mysql://kyu.jisol.cn:3306/pet_jisol_cn?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
jackson:
|
||||||
|
serialization:
|
||||||
|
write-dates-as-timestamps: true
|
||||||
|
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
configuration:
|
configuration:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user