refactor: 移除未使用的英雄相关数据字段

清理 SingletonModuleComp 中的英雄数组和出战英雄字段,以及相关接口定义。
同时更新 USAGE.md 中的示例代码以反映数据结构变化。
This commit is contained in:
panw
2026-04-28 16:27:15 +08:00
parent 424c9490e7
commit b7bd2c612b
2 changed files with 1 additions and 17 deletions

View File

@@ -17,16 +17,12 @@ import { gameDataSync } from "./GameDataSync";
*/ */
export interface GameDate{ export interface GameDate{
gold:number, gold:number,
heros:any,
fight_hero:number,
timestamp?: number, // 用于比对本地与云端数据的最新状态 timestamp?: number, // 用于比对本地与云端数据的最新状态
collection?: { collection?: {
talents: Partial<Record<TalentType, number>>, talents: Partial<Record<TalentType, number>>,
player_level: number, player_level: number,
player_exp: number, player_exp: number,
talent_points: number, talent_points: number,
skills?: {uuid:0,count:0},
friend?: {uuid:0,count:0},
} }
} }
export interface CloudData { export interface CloudData {
@@ -64,8 +60,6 @@ export class SingletonModuleComp extends ecs.Comp {
guides:any=[0,0,0,0,0] guides:any=[0,0,0,0,0]
current_guide:number=0 current_guide:number=0
fight_hero: number = 5001; // 单个出战英雄
heros:any= [5001]
collection: { collection: {
talents: Partial<Record<TalentType, number>>; talents: Partial<Record<TalentType, number>>;
@@ -239,14 +233,6 @@ export class SingletonModuleComp extends ecs.Comp {
if (data.gold !== undefined) { if (data.gold !== undefined) {
this.vmdata.gold = data.gold; this.vmdata.gold = data.gold;
} }
// 同步英雄
if (data.heros && Array.isArray(data.heros)) {
this.heros = data.heros;
}
// 同步出战英雄
if (data.fight_hero !== undefined) {
this.fight_hero = data.fight_hero;
}
// 恢复收集记录 // 恢复收集记录
if (data.collection) { if (data.collection) {
const remoteCol = data.collection; const remoteCol = data.collection;
@@ -267,8 +253,6 @@ export class SingletonModuleComp extends ecs.Comp {
getGameDate(){ getGameDate(){
let data: GameDate = { let data: GameDate = {
gold: this.vmdata.gold, gold: this.vmdata.gold,
heros: this.heros,
fight_hero: this.fight_hero,
collection: this.collection, collection: this.collection,
timestamp: Date.now() // 每次获取当前数据结构时都附带最新的时间戳 timestamp: Date.now() // 每次获取当前数据结构时都附带最新的时间戳
}; };

View File

@@ -20,7 +20,7 @@ if (loginResult.result.code === 200) {
const userData = loginResult.result.data; const userData = loginResult.result.data;
console.log("用户ID:", userData.user_id); console.log("用户ID:", userData.user_id);
console.log("金币:", userData.data.gold); console.log("金币:", userData.data.gold);
console.log("出战英雄:", userData.fight_heros); console.log("用户金币:", userData.gold);
} }
``` ```