Update GaCy-GO
This commit is contained in:
1 parent
da8a32f60d
commit
0cbe460e49
345 files changed
+98202
-77559
No files matched your search
@@ -0,0 +1,55 @@
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gac-hkrpg-go/internal/common"
|
||||
pb "gac-hkrpg-go/protocol/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// cwCapturedSupplyLayer obtains the empty Supply node container from the
|
||||
// revision-bound native transition capture. It deliberately does not copy
|
||||
// that capture's Supply options, queue, rewards or player-specific state.
|
||||
// The current capture has an empty enemy-layer container with branch index 1;
|
||||
// this is checked against the resource rather than assumed for future clients.
|
||||
// A caller must also construct a valid Supply pending action before committing
|
||||
// a transition; this helper alone does not make a Supply round playable.
|
||||
func cwCapturedSupplyLayer(catalog *common.CurrencyWarsCatalog) (*pb.NCKOKDHNJDC, error) {
|
||||
if catalog == nil {
|
||||
return nil, fmt.Errorf("CW Supply catalog missing")
|
||||
}
|
||||
entries, err := cwNodeTransitions(catalog)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var layer *pb.NCKOKDHNJDC
|
||||
for _, entry := range entries {
|
||||
level := new(pb.AINFNFIDGFF)
|
||||
pending := new(pb.CHCHAJIANIM)
|
||||
if err := proto.Unmarshal(entry.LevelWire, level); err != nil {
|
||||
return nil, fmt.Errorf("CW captured Supply level: %w", err)
|
||||
}
|
||||
if err := proto.Unmarshal(entry.RoundWire, pending); err != nil {
|
||||
return nil, fmt.Errorf("CW captured Supply pending: %w", err)
|
||||
}
|
||||
if pending.GetFIKAGBAEOAP() == nil {
|
||||
continue
|
||||
}
|
||||
if level.IMPNAHBCADN == nil {
|
||||
return nil, fmt.Errorf("CW captured Supply layer missing")
|
||||
}
|
||||
enemy := level.IMPNAHBCADN.GetMPOBBIPMNNJ()
|
||||
if enemy == nil || enemy.MOADBALHMFD != 1 || enemy.LNDKCPBJDKH != 0 || len(enemy.BPDABHGFBFO) != 0 {
|
||||
return nil, fmt.Errorf("CW captured Supply layer contains unexpected state")
|
||||
}
|
||||
if layer != nil && !proto.Equal(layer, level.IMPNAHBCADN) {
|
||||
return nil, fmt.Errorf("CW captured Supply layers disagree")
|
||||
}
|
||||
layer = level.IMPNAHBCADN
|
||||
}
|
||||
if layer == nil {
|
||||
return nil, fmt.Errorf("CW captured Supply layer unavailable")
|
||||
}
|
||||
return proto.Clone(layer).(*pb.NCKOKDHNJDC), nil
|
||||
}
|
||||
Reference in new issue
Block a user