Skip to content

Commit

Permalink
Unlock all cook recipes(CANNOT cook)
Browse files Browse the repository at this point in the history
GetCompoundData packet need fix
  • Loading branch information
Sycamore0 committed Oct 6, 2024
1 parent 273e302 commit 20725c5
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/kcpServer/game/gameData/data/CookData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Loader from '$/gameData/loader'
import CookDataGroup, { RecipeData, BonusData } from '@/types/gameData/CookData'

class CookDataLoader extends Loader {
declare data: CookDataGroup

constructor() {
super('CookData', [])
}

async getData(): Promise<CookDataGroup> {
return super.getData()
}

async getRecipe(id: number): Promise<RecipeData> {
return (await this.getRecipeList()).find(data => data.Id === id)
}

async getRecipeBonus(recipeId: number): Promise<BonusData[]> {
return (await this.getBonusList()).filter(data => data.RecipeId === recipeId) || []
}

async getRecipeList(): Promise<RecipeData[]> {
return (await this.getData())?.Recipe || []
}

async getBonusList(): Promise<BonusData[]> {
return (await this.getData())?.Bonus || []
}
}

let loader: CookDataLoader
export default (() => loader = loader || new CookDataLoader())()
5 changes: 5 additions & 0 deletions src/kcpServer/game/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import AllWidgetData from '#/packets/AllWidgetData'
import AvatarData from '#/packets/AvatarData'
import AvatarSatiationData from '#/packets/AvatarSatiationData'
import CombineData from '#/packets/CombineData'
import CookData from '#/packets/CookData'
import CookGradeData from '#/packets/CookGradeData'
import CoopData from '#/packets/CoopData'
import DoSetPlayerBornData from '#/packets/DoSetPlayerBornData'
import FinishedParentQuest from '#/packets/FinishedParentQuest'
Expand Down Expand Up @@ -186,6 +188,9 @@ export default class Game {
await activityManager.sendAllActivityInfo(context)

await CombineData.sendNotify(context)
await CookData.sendNotify(context)
await CookGradeData.sendNotify(context)

await PlayerData.sendNotify(context)
await OpenStateUpdate.sendNotify(context)
await StoreWeightLimit.sendNotify(context)
Expand Down
33 changes: 33 additions & 0 deletions src/kcpServer/packets/CookData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Packet, { PacketInterface, PacketContext } from '#/packet'
import { CookRecipeData } from '@/types/proto/CookRecipeData'
import CookData from '$/gameData/data/CookData'

export interface CookDataNotify {
recipeDataList: CookRecipeData[]
upgrade: number
}

class CookDataPacket extends Packet implements PacketInterface {
constructor() {
super('CookData')
}

async sendNotify(context: PacketContext): Promise<void> {
const cookRecipeList = await CookData.getRecipeList()

const recipeDataList = cookRecipeList.map(recipe => ({
recipeId: recipe.Id,
proficiency: recipe.MaxProficiency
}))

const notifyData: CookDataNotify = {
recipeDataList,
upgrade: 3 // what???
}

await super.sendNotify(context, notifyData)
}
}

let packet: CookDataPacket
export default (() => packet = packet || new CookDataPacket())()
22 changes: 22 additions & 0 deletions src/kcpServer/packets/CookGradeData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Packet, { PacketInterface, PacketContext } from '#/packet'

export interface CookGradeDataNotify {
grade: number
}

class CookGradeDataPacket extends Packet implements PacketInterface {
constructor() {
super('CookGradeData')
}

async sendNotify(context: PacketContext): Promise<void> {
const notifyData: CookGradeDataNotify = {
grade: 3 // what???
}

await super.sendNotify(context, notifyData)
}
}

let packet: CookGradeDataPacket
export default (() => packet = packet || new CookGradeDataPacket())()
28 changes: 28 additions & 0 deletions src/kcpServer/packets/GetCompoundData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Packet, { PacketInterface, PacketContext } from '#/packet'
import { CompoundQueueData } from '@/types/proto/CompoundQueueData'
import { RetcodeEnum } from '@/types/proto/enum'

export interface GetCompoundDataReq { }

export interface GetCompoundDataRsp {
retcode: RetcodeEnum
unlockCompoundList?: number[]
compoundQueDataList?: CompoundQueueData[]
}

class GetCompoundDataPacket extends Packet implements PacketInterface {
constructor() {
super('GetCompoundData')
}

async request(context: PacketContext, data: GetCompoundDataReq): Promise<void> {
await this.response(context, { retcode: RetcodeEnum.RET_UNKNOWN_ERROR })
}

async response(context: PacketContext, data: GetCompoundDataRsp): Promise<void> {
await super.response(context, data)
}
}

let packet: GetCompoundDataPacket
export default (() => packet = packet || new GetCompoundDataPacket())()
3 changes: 3 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AbilityData from '$/gameData/data/AbilityData'
import AvatarData from '$/gameData/data/AvatarData'
import CombineData from '$/gameData/data/CombineData'
import CookData from '$/gameData/data/CookData'
import DungeonData from '$/gameData/data/DungeonData'
import GadgetData from '$/gameData/data/GadgetData'
import GrowCurveData from '$/gameData/data/GrowCurveData'
Expand Down Expand Up @@ -348,6 +349,8 @@ export default class Server {
logger.debug('message.cache.debug.ability')
await AvatarData.getData()
logger.debug('message.cache.debug.avatar')
await CookData.getData()
logger.debug('message.cache.debug.cook')
await CombineData.getData()
logger.debug('message.cache.debug.combine')
await DungeonData.getData()
Expand Down
36 changes: 36 additions & 0 deletions src/types/gameData/CookData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export interface RecipeData {
Id: number // RecipeId
FoodType: string
CookMethod: string
IsDefaultUnlocked: boolean
MaxProficiency: number
QualityOutputVec: {
id?: number
count?: number
}[]
InputVec: {
id?: number
count?: number
}[]

RankLevel?: number
Icon?: string
NameTextMapHash?: number
DescTextMapHash?: number
EffectDesc?: number[]
QteParam?: string
QteQualityWeightVec?: number[]
}

export interface BonusData {
RecipeId: number
AvatarId: number
BonusType: string
ParamVec: number[]
ComplexParamVec: number[]
}

export default interface CookDataGroup {
Recipe: RecipeData[]
Bonus: BonusData[]
}
6 changes: 6 additions & 0 deletions src/types/proto/CompoundQueueData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface CompoundQueueData {
outputCount: number
compoundId: number
outputTime: number
waitCount: number
}
4 changes: 4 additions & 0 deletions src/types/proto/CookRecipeData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface CookRecipeData {
proficiency: number
recipeId: number
}

0 comments on commit 20725c5

Please sign in to comment.