2025-06-04 18:17:39 +08:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"ecs/proto/pb"
|
2025-06-09 18:33:52 +08:00
|
|
|
"github.com/oylshe1314/framework/util"
|
2025-06-04 18:17:39 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func (this *Player) checkCorrect(firstLogin bool, cur *GameTime) {
|
|
|
|
if firstLogin {
|
|
|
|
this.checkCorrectFirstLogin(cur)
|
|
|
|
}
|
|
|
|
this.checkCorrectModules(cur)
|
|
|
|
this.checkCorrectMemoryData(cur)
|
|
|
|
//this.checkWechatUserInfo(cur)
|
|
|
|
this.checkCorrectPower(cur)
|
|
|
|
//this.checkCorrectBattlePass(cur)
|
|
|
|
//this.checkEnterArena(cur)
|
|
|
|
//this.checkStorePoolChange(cur)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Player) checkCorrectModules(cur *GameTime) {
|
2025-06-04 18:31:07 +08:00
|
|
|
if this.Artifact == nil {
|
|
|
|
this.Artifact = make(map[uint64]*PlayerArtifact)
|
|
|
|
this.SaveField("achievement", this.Artifact)
|
|
|
|
}
|
2025-06-04 18:17:39 +08:00
|
|
|
//if this.Achievement == nil {
|
|
|
|
// this.Achievement = make(map[uint64]*PlayerAchievement)
|
|
|
|
// this.SaveField("achievement", this.Achievement)
|
|
|
|
//}
|
|
|
|
//if this.BattlePass == nil {
|
|
|
|
// this.BattlePass = make(map[uint32]*PlayerBattlePass)
|
|
|
|
// this.SaveField("battle_pass", this.BattlePass)
|
|
|
|
//}
|
|
|
|
//if this.Cdkey == nil {
|
|
|
|
// this.Cdkey = make(map[string]*PlayerCdkey)
|
|
|
|
// this.SaveField("cdkey", this.Cdkey)
|
|
|
|
//}
|
|
|
|
//if this.CopyPassed == nil {
|
|
|
|
// this.CopyPassed = make(map[uint32]*PlayerCopyPassed)
|
|
|
|
// this.SaveField("copy_passed", this.CopyPassed)
|
|
|
|
//}
|
|
|
|
//if this.CopySpeed == nil {
|
|
|
|
// this.CopySpeed = make(map[uint32]*PlayerCopySpeed)
|
|
|
|
// this.SaveField("copy_speed", this.CopySpeed)
|
|
|
|
//}
|
|
|
|
//if this.CopyStatus == nil {
|
|
|
|
// this.CopyStatus = make(map[uint64]*PlayerCopyStatus)
|
|
|
|
// this.SaveField("copy_status", this.CopyStatus)
|
|
|
|
//}
|
|
|
|
if this.Counter == nil {
|
|
|
|
this.Counter = make(map[uint32]map[uint64]*PlayerCounter)
|
|
|
|
this.SaveField("counter", this.Counter)
|
|
|
|
}
|
|
|
|
if this.Hero == nil {
|
2025-06-05 17:47:59 +08:00
|
|
|
this.Hero = make(map[uint64]*PlayerHero)
|
|
|
|
this.SaveField("hero", this.Hero)
|
|
|
|
}
|
|
|
|
if this.Hero == nil {
|
|
|
|
this.HeroBook = make(map[uint32]*PlayerHeroBook)
|
2025-06-04 18:17:39 +08:00
|
|
|
this.SaveField("hero", this.Hero)
|
|
|
|
}
|
|
|
|
if this.Item == nil {
|
|
|
|
this.Item = make(map[uint32]*PlayerItem)
|
|
|
|
this.SaveField("item", this.Item)
|
|
|
|
}
|
|
|
|
if this.Equip == nil {
|
|
|
|
this.Equip = make(map[uint64]*PlayerEquip)
|
|
|
|
this.SaveField("item", this.Equip)
|
|
|
|
}
|
|
|
|
//if this.GiftPack == nil {
|
|
|
|
// this.GiftPack = make(map[uint32]*PlayerGiftPack)
|
|
|
|
// this.SaveField("gift_pack", this.GiftPack)
|
|
|
|
//}
|
2025-06-07 18:31:00 +08:00
|
|
|
if this.Lineup == nil {
|
|
|
|
this.Lineup = make(map[uint64]*PlayerLineup)
|
|
|
|
this.SaveField("money", this.Lineup)
|
|
|
|
}
|
2025-06-04 18:17:39 +08:00
|
|
|
//if this.Mail == nil {
|
|
|
|
// this.Mail = make(map[uint64]*PlayerMail)
|
|
|
|
// this.SaveField("mail", this.Mail)
|
|
|
|
//}
|
|
|
|
if this.Money == nil {
|
|
|
|
this.Money = make(map[uint32]*PlayerMoney)
|
|
|
|
this.SaveField("money", this.Money)
|
|
|
|
}
|
|
|
|
//if this.MonthlyCard == nil {
|
|
|
|
// this.MonthlyCard = make(map[uint32]*PlayerMonthlyCard)
|
|
|
|
// this.SaveField("monthly_card", this.MonthlyCard)
|
|
|
|
//}
|
|
|
|
//if this.Planet == nil {
|
|
|
|
// this.Planet = make(map[uint32]*PlayerPlanet)
|
|
|
|
// this.SaveField("planet", this.Planet)
|
|
|
|
//}
|
|
|
|
//if this.RawStone == nil {
|
|
|
|
// this.RawStone = make(map[uint32]*PlayerRawStone)
|
|
|
|
// this.SaveField("raw_stone", this.RawStone)
|
|
|
|
//}
|
|
|
|
//if this.RigCharacter == nil {
|
|
|
|
// this.RigCharacter = make(map[uint32]*PlayerRigCharacter)
|
|
|
|
// this.SaveField("rig_character", this.RigCharacter)
|
|
|
|
//}
|
|
|
|
//if this.RigComponent == nil {
|
|
|
|
// this.RigComponent = make(map[uint32]*PlayerRigComponent)
|
|
|
|
// this.SaveField("rig_component", this.RigComponent)
|
|
|
|
//}
|
|
|
|
//if this.RigCore == nil {
|
|
|
|
// this.RigCore = make(map[uint32]*PlayerRigCore)
|
|
|
|
// this.SaveField("rig_core", this.RigCore)
|
|
|
|
//}
|
|
|
|
//if this.RigEquip == nil {
|
|
|
|
// this.RigEquip = make(map[uint32]*PlayerRigEquip)
|
|
|
|
// this.SaveField("rig_equip", this.RigEquip)
|
|
|
|
//}
|
|
|
|
//if this.RigPendant == nil {
|
|
|
|
// this.RigPendant = make(map[uint32]*PlayerRigPendant)
|
|
|
|
// this.SaveField("rig_pendant", this.RigPendant)
|
|
|
|
//}
|
|
|
|
//if this.RigRemains == nil {
|
|
|
|
// this.RigRemains = make(map[uint32]*PlayerRigRemains)
|
|
|
|
// this.SaveField("rig_remains", this.RigRemains)
|
|
|
|
//}
|
|
|
|
//if this.RigSmelter == nil {
|
|
|
|
// this.RigSmelter = make(map[uint32]*PlayerRigSmelter)
|
|
|
|
// this.SaveField("rig_smelter", this.RigSmelter)
|
|
|
|
//}
|
|
|
|
//if this.RigTrammels == nil {
|
|
|
|
// this.RigTrammels = make(map[uint32]*PlayerRigTrammels)
|
|
|
|
// this.SaveField("rig_trammels", this.RigTrammels)
|
|
|
|
//}
|
|
|
|
//if this.RigWarship == nil {
|
|
|
|
// this.RigWarship = make(map[uint32]*PlayerRigWarship)
|
|
|
|
// this.SaveField("rig_warship", this.RigWarship)
|
|
|
|
//}
|
|
|
|
//if this.RoleTalent == nil {
|
|
|
|
// this.RoleTalent = make(map[uint32]*PlayerRoleTalent)
|
|
|
|
// this.SaveField("role_talent", this.RoleTalent)
|
|
|
|
//}
|
|
|
|
//if this.StorePool == nil {
|
|
|
|
// this.StorePool = make(map[uint32]*PlayerStorePool)
|
|
|
|
// this.SaveField("store_pool", this.StorePool)
|
|
|
|
//}
|
|
|
|
//if this.Task == nil {
|
|
|
|
// this.Task = make(map[uint32]*PlayerTask)
|
|
|
|
// this.SaveField("task", this.Task)
|
|
|
|
//}
|
|
|
|
//if this.TaskActive == nil {
|
|
|
|
// this.TaskActive = make(map[uint32]*PlayerTaskActive)
|
|
|
|
// this.SaveField("task_active", this.TaskActive)
|
|
|
|
//}
|
2025-06-04 18:31:07 +08:00
|
|
|
if this.Treasure == nil {
|
|
|
|
this.Treasure = make(map[uint64]*PlayerTreasure)
|
|
|
|
this.SaveField("achievement", this.Treasure)
|
|
|
|
}
|
2025-06-04 18:17:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Player) initRole(cur *GameTime) {
|
|
|
|
var roleHeroId = this.manager.tables.ServerConfig.GetInitRole(int(this.RoleGender))
|
|
|
|
if roleHeroId == 0 {
|
|
|
|
this.manager.logger.Error("get main hero id failed, roleHeroId: 0, roleGender: ", this.RoleGender)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var heroTable = this.manager.tables.Hero.Find(roleHeroId)
|
|
|
|
if heroTable == nil {
|
|
|
|
this.manager.logger.Error("find hero table failed, roleHeroId: ", roleHeroId)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-06-09 18:33:52 +08:00
|
|
|
var roleHero = this.newHero(heroTable)
|
|
|
|
if roleHero == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.RoleHero = roleHero
|
|
|
|
this.SaveField("role_hero", this.RoleHero)
|
2025-06-04 18:17:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Player) initHeroes(cur *GameTime) {
|
|
|
|
var initHeroIds = this.manager.tables.ServerConfig.GetInitHeroes()
|
|
|
|
for _, initHeroId := range initHeroIds {
|
2025-06-09 18:33:52 +08:00
|
|
|
this.AddHero(uint32(initHeroId))
|
2025-06-04 18:17:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Player) initItems(cur *GameTime) {
|
|
|
|
var itemIds, itemNums = this.manager.tables.ServerConfig.GetInitItems()
|
|
|
|
for i, itemId := range itemIds {
|
|
|
|
var itemNum = itemNums[i]
|
|
|
|
|
|
|
|
var itemTable = this.manager.tables.Item.Find1(itemId)
|
|
|
|
if itemTable == nil {
|
|
|
|
this.manager.logger.Error("find item table failed, itemId: ", itemId)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
_ = this.addItem(itemTable, uint32(itemNum), 0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-06-09 18:33:52 +08:00
|
|
|
func (this *Player) initLineup(cur *GameTime) {
|
|
|
|
var roleHero = this.RoleHero
|
|
|
|
if roleHero == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var lineup = &PlayerLineup{
|
|
|
|
Uid: util.RandomUid(),
|
|
|
|
Name: "阵容1",
|
|
|
|
Active: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
var roleLineupHero = &PlayerLineupHero{
|
|
|
|
HeroUid: roleHero.Uid,
|
|
|
|
Position: 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateHeroAttrs(roleHero, lineup, roleLineupHero)
|
|
|
|
this.UpdateBattleHeroCapacity(roleLineupHero)
|
|
|
|
|
|
|
|
lineup.Heroes[0] = roleLineupHero
|
|
|
|
|
|
|
|
var i = uint32(1)
|
|
|
|
for _, hero := range this.Hero {
|
|
|
|
var lineupHero = &PlayerLineupHero{
|
|
|
|
HeroUid: hero.Uid,
|
|
|
|
Position: i + 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateHeroAttrs(hero, lineup, lineupHero)
|
|
|
|
this.UpdateBattleHeroCapacity(lineupHero)
|
|
|
|
|
|
|
|
lineup.Heroes[i] = lineupHero
|
|
|
|
}
|
|
|
|
|
|
|
|
this.Lineup[lineup.Uid] = lineup
|
|
|
|
this.SaveModel(lineup)
|
|
|
|
}
|
|
|
|
|
2025-06-04 18:17:39 +08:00
|
|
|
// func (this *Player) initMails(cur *GameTime) {
|
|
|
|
// var cfgTable = this.manager.tables.ServerCfg.Get("init_mails")
|
|
|
|
// if cfgTable == nil {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// itemIds, itemNums, err := util.SplitItemNums(cfgTable.Value1, cfgTable.Value2, 1)
|
|
|
|
// if err != nil {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// this.AddMail(proto.MailTypeNormal, proto.MailTitleSystem, proto.MailContentSystem, nil, itemIds, itemNums, cur.Timestamp)
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func (this *Player) initTasks(cur *GameTime) {
|
|
|
|
// var cfgTable = this.manager.tables.ServerCfg.Get("init_tasks")
|
|
|
|
// if cfgTable == nil {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// var taskIds []uint32
|
|
|
|
// err := util.SplitToIntegers2(cfgTable.Value1, ",", &taskIds)
|
|
|
|
// if err != nil {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// for _, taskId := range taskIds {
|
|
|
|
// var taskTable = this.manager.tables.Task.Get(int(taskId))
|
|
|
|
// if taskTable != nil {
|
|
|
|
// this.addTask(taskTable)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
func (this *Player) initPower(cur *GameTime) {
|
|
|
|
var money = &PlayerMoney{Type: uint32(pb.MoneyType_Power), Value: RolePowerMax}
|
|
|
|
this.Money[money.Type] = money
|
|
|
|
this.SaveModel(money)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Player) checkCorrectFirstLogin(cur *GameTime) {
|
|
|
|
this.initRole(cur)
|
|
|
|
this.initHeroes(cur)
|
|
|
|
//this.initItems(cur)
|
2025-06-09 18:33:52 +08:00
|
|
|
this.initLineup(cur)
|
2025-06-04 18:17:39 +08:00
|
|
|
//this.initMails(cur)
|
|
|
|
//this.initTasks(cur)
|
|
|
|
this.initPower(cur)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *Player) checkCorrectMemoryData(cur *GameTime) {
|
|
|
|
this.initTemp()
|
|
|
|
for _, hero := range this.Hero {
|
2025-06-09 18:33:52 +08:00
|
|
|
this.UpdateHeroAttrs(hero)
|
2025-06-04 18:17:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//func (this *Player) checkWechatUserInfo(cur *GameTime) {
|
|
|
|
// switch data_old.Channel(this.Channel) {
|
|
|
|
// case data_old.ChannelWechatMiniGame, data_old.ChannelTapTap:
|
|
|
|
// if this.Temp.ThirdData != nil {
|
|
|
|
// if this.RoleName != this.Temp.ThirdData.NickName {
|
|
|
|
// this.RoleName = this.Temp.ThirdData.NickName
|
|
|
|
// this.SaveField("role_name", this.RoleName)
|
|
|
|
// }
|
|
|
|
// if this.Avatar != this.Temp.ThirdData.AvatarUrl {
|
|
|
|
// this.Avatar = this.Temp.ThirdData.AvatarUrl
|
|
|
|
// this.SaveField("avatar", this.Avatar)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
func (this *Player) checkCorrectPower(cur *GameTime) {
|
|
|
|
var money = this.GetMoney(pb.MoneyType_Power)
|
|
|
|
if money.Value >= uint32(RolePowerMax) || this.PowerNextTime > cur.Timestamp {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
for {
|
|
|
|
money.Value += uint32(RolePowerRegain)
|
|
|
|
this.PowerNextTime += int64(RolePowerCycle)
|
|
|
|
|
|
|
|
if money.Value >= uint32(RolePowerMax) {
|
|
|
|
this.PowerNextTime = 0
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
if this.PowerNextTime > cur.Timestamp {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.SaveModel(money)
|
|
|
|
this.SaveField("power_next_time", this.PowerNextTime)
|
|
|
|
}
|
|
|
|
|
|
|
|
//func (this *Player) checkCorrectBattlePass(cur *GameTime) {
|
|
|
|
// var seasonTable = this.manager.tables.BattlePassSeasonExtend.Get(cur.Timestamp)
|
|
|
|
// if seasonTable == nil {
|
|
|
|
// this.Role.BattlePassSeason = 0
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if this.Role.BattlePassSeason != uint32(seasonTable.Id) || this.BattlePass[this.Role.BattlePassSeason] == nil {
|
|
|
|
// this.Role.BattlePassSeason = uint32(seasonTable.Id)
|
|
|
|
// this.SaveField("role.battle_pass_season", this.Role.BattlePassSeason)
|
|
|
|
//
|
|
|
|
// var battlePass = &PlayerBattlePass{
|
|
|
|
// Season: this.Role.BattlePassSeason,
|
|
|
|
// Advanced: false,
|
|
|
|
// }
|
|
|
|
// this.BattlePass[this.Role.BattlePassSeason] = battlePass
|
|
|
|
// this.SaveModel(battlePass)
|
|
|
|
//
|
|
|
|
// var levels = seasonTable.MaxLevel
|
|
|
|
// var rewardTables = this.manager.tables.BattlePassRewardExtend.List(int(battlePass.Season))
|
|
|
|
// if levels > len(rewardTables) {
|
|
|
|
// levels = len(rewardTables)
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// this.BattlePassReward = make([]*PlayerBattlePassRewrad, levels)
|
|
|
|
// for i, rewardTable := range rewardTables {
|
|
|
|
// this.BattlePassReward[i] = &PlayerBattlePassRewrad{Id: uint32(rewardTable.Id), Ordinary: uint32(proto.RewardStatusUnable), Advanced: uint32(proto.RewardStatusUnable)}
|
|
|
|
// }
|
|
|
|
// this.SaveField("battle_pass_reward", this.BattlePassReward)
|
|
|
|
//
|
|
|
|
// this.checkTaskReset(proto.TaskTypeBattlePass)
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//func (this *Player) checkEnterArena(cur *GameTime) {
|
|
|
|
// var copyArenaTable = this.manager.tables.CopyArena.Get(1)
|
|
|
|
// if copyArenaTable == nil {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// var season = this.manager.arenaManager.CopyArenaSeason()
|
|
|
|
// if season == nil {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// this.EnterArena(season, copyArenaTable)
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//func (this *Player) checkStorePoolChange(cur *GameTime) {
|
2025-06-05 17:47:59 +08:00
|
|
|
// this.copyStorePoolUnlock(this.Role.CopyMainSceneId, cur.Timestamp)
|
2025-06-04 18:17:39 +08:00
|
|
|
//}
|