Save endgame progress, team presets, technique support and camera controls
This commit is contained in:
1 parent
a681affdb3
commit
639cef7d19
52 files changed
+11940
-766
No files matched your search
@@ -0,0 +1,103 @@
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"gac-hkrpg-go/internal/common"
|
||||
goproto "gac-hkrpg-go/protocol/proto"
|
||||
)
|
||||
|
||||
func presetLineup(p *common.FreesrData, index uint32) *goproto.LineupInfo {
|
||||
saved := p.TeamPreset(index)
|
||||
lineup := common.ToLineupInfo(saved.Avatars)
|
||||
tmp := *p
|
||||
tmp.Lineups = saved.Avatars
|
||||
lineup.AvatarList = common.ToLineupAvatars(&tmp)
|
||||
lineup.Index = index
|
||||
lineup.Name = saved.Name
|
||||
lineup.LeaderSlot = saved.LeaderSlot
|
||||
lineup.PlaneId = p.Scene.PlaneID
|
||||
lineup.IECKKCHJMLP = saved.Favourite && len(lineup.AvatarList) > 0
|
||||
if saved.Avatars[lineup.LeaderSlot] == 0 {
|
||||
for _, a := range lineup.AvatarList {
|
||||
lineup.LeaderSlot = a.Slot
|
||||
break
|
||||
}
|
||||
}
|
||||
return lineup
|
||||
}
|
||||
func allPresetLineups(s *Session) ([]*goproto.LineupInfo, error) {
|
||||
rules, err := common.LoadTeamPresetRules()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p := s.JSON()
|
||||
if p == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var out []*goproto.LineupInfo
|
||||
for index := uint32(0); index < rules.Count; index++ {
|
||||
out = append(out, presetLineup(p, index))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
func (s *Session) presetEditCode(index uint32, extra goproto.ExtraLineupType, virtual bool) (uint32, error) {
|
||||
rules, err := common.LoadTeamPresetRules()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if s.JSON() == nil {
|
||||
return uint32(goproto.Retcode_RET_LINEUP_NOT_EXIST), nil
|
||||
}
|
||||
if index >= rules.Count {
|
||||
return uint32(goproto.Retcode_RET_LINEUP_INVALID_INDEX), nil
|
||||
}
|
||||
if extra != goproto.ExtraLineupType_ExtraLineupType_LineupNone || virtual {
|
||||
return uint32(goproto.Retcode_RET_LINEUP_TYPE_NOT_MATCH), nil
|
||||
}
|
||||
if _, active := CURRENT_BATTLE.Load(s.Token); active {
|
||||
return uint32(goproto.Retcode_RET_LINEUP_NOT_ALLOW_EDIT), nil
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
func (s *Session) savePreset(index uint32, saved *common.TeamPreset) error {
|
||||
if err := s.JSON().SaveTeamPreset(index, saved); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.publishPreset(index, saved)
|
||||
}
|
||||
func (s *Session) publishPreset(index uint32, saved *common.TeamPreset) error {
|
||||
if index == s.JSON().ActiveTeamPreset && s.ChallengeRun == nil {
|
||||
s.leaderSlot = saved.LeaderSlot
|
||||
if err := refreshLineup(s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
lineups, err := allPresetLineups(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
SceneDebugLog("[TEAM PRESET] saved index=%d name=%q team=%v", index, saved.Name, saved.Avatars)
|
||||
return s.Send(&goproto.SyncAllPresetLineupNotify{CurIndex: s.JSON().ActiveTeamPreset, LineupList: lineups})
|
||||
}
|
||||
func validatePresetMembers(p *common.FreesrData, avatars map[uint32]uint32) uint32 {
|
||||
rules, err := common.LoadTeamPresetRules()
|
||||
if err != nil {
|
||||
return uint32(goproto.Retcode_RET_LINEUP_NOT_EXIST)
|
||||
}
|
||||
seen := map[uint32]bool{}
|
||||
for slot, id := range avatars {
|
||||
if slot >= rules.MaxMembers {
|
||||
return uint32(goproto.Retcode_RET_LINEUP_INVALID_MEMBER_POS)
|
||||
}
|
||||
if id == 0 {
|
||||
continue
|
||||
}
|
||||
if p.Avatars[id] == nil {
|
||||
return uint32(goproto.Retcode_RET_LINEUP_AVATAR_NOT_EXIST)
|
||||
}
|
||||
if seen[id] {
|
||||
return uint32(goproto.Retcode_RET_LINEUP_AVATAR_ALREADY_IN)
|
||||
}
|
||||
seen[id] = true
|
||||
}
|
||||
return 0
|
||||
}
|
||||
Reference in new issue
Block a user