package mapCall import ( capp "f1-game/internal/cherry_app" "f1-game/internal/code" nameActor "f1-game/internal/name/actor" nameRemote "f1-game/internal/name/remote" "f1-game/internal/pb" "f1-game/internal/types" ao "f1-game/nodes/game/player/asset/origin" cfacade "github.com/cherry-game/cherry/facade" ) var ( League = &leagueCall{} ) type leagueCall struct { } func (p *leagueCall) ForceResidenceBack(leagueID, playerID int64) { target := p.targetPath(leagueID) capp.Call(target, nameRemote.MapLeague_ForceResidenceBack, &pb.I64{Value: playerID}) } func (p *leagueCall) BuildUpdate(leagueID int64, req *pb.BuildUpdate) { target := p.targetPath(leagueID) capp.Call(target, nameRemote.MapLeague_BuildUpdate, req) } // 获取联盟列表 func (p *leagueCall) LeagueList(playerID int64) (*pb.LeagueList, int32) { var ( req = &pb.I64{ Value: playerID, } resp = &pb.LeagueList{} target = p.target() ) errCode := capp.CallWait(target, nameRemote.MapLeague_List, req, resp) if code.IsFail(errCode) { return nil, errCode } return resp, code.OK } // 联盟搜索 func (p *leagueCall) LeagueSearch(keyword string) (*pb.LeagueList, int32) { var ( req = &pb.Str{Value: keyword} resp = &pb.LeagueList{} target = p.target() ) errCode := capp.CallWait(target, nameRemote.MapLeague_Search, req, resp) if code.IsFail(errCode) { return nil, errCode } return resp, code.OK } // 创建联盟 func (p *leagueCall) LeagueCreate(playerID int64, leagueName, leagueAbbName string, flagBg, flagIcon int32) (int64, int32) { var ( target = p.target() resp = &pb.I64{} ) errCode := capp.CallWait(target, nameRemote.MapLeague_Create, &pb.CreateLeague{ PlayerID: playerID, LeagueName: leagueName, LeagueAbbName: leagueAbbName, FlagBg: flagBg, FlagIcon: flagIcon, }, resp) if code.IsFail(errCode) { return 0, errCode } return resp.Value, code.OK } // 加入联盟 func (p *leagueCall) LeagueJoin(playerID, leagueID int64, lordLevel int32) int32 { var ( target = p.targetPath(leagueID) req = &pb.I64I32{ Key: playerID, Value: lordLevel, } ) errCode := capp.Call(target, nameRemote.MapLeague_Join, req) if code.IsFail(errCode) { return errCode } return code.OK } func (p *leagueCall) LeagueOnLogin(playerID, leagueID int64) { var ( req = &pb.I64{ Value: playerID, } target = p.targetPath(leagueID) ) capp.Call(target, nameRemote.MapLeague_OnLogin, req) } func (p *leagueCall) MapLeagueAddAssets(playerID, leagueID int64, mapLeagueAssets types.Assets) { if leagueID <= 0 { return } req := &pb.AddAssets{ PlayerID: playerID, Assets: mapLeagueAssets.ToProto(), } target := p.targetPath(leagueID) capp.Call(target, nameRemote.MapLeague_AddAssets, req) } func (p *leagueCall) AddRatioAssets(playerID, leagueID int64, asset types.Assets, origin ao.Origin) { if leagueID <= 0 { return } req := &pb.AddAssets{ PlayerID: playerID, Assets: asset.ToProto(), Origin: origin.ID, } target := p.targetPath(leagueID) capp.Call(target, nameRemote.MapLeague_AddRatioAssets, req) } func (p *leagueCall) BattleReportAdd(leagueID int64, reportGroup *pb.ReportGroup) { target := p.targetPath(leagueID) capp.Call(target, nameRemote.MapLeague_ReportAdd, reportGroup) } func (p *leagueCall) AssembleAdd(leagueID int64, req *pb.NewAssemble) { target := p.targetPath(leagueID) capp.Call(target, nameRemote.MapLeague_AssembleAdd, req) } func (p *leagueCall) AssembleUpdate(leagueID int64, req *pb.AssembleUpdate) { target := p.targetPath(leagueID) capp.Call(target, nameRemote.MapLeague_AssembleUpdate, req) } func (p *leagueCall) UpdateLeagueMemberPrestige(leagueID int64, req *pb.I64I32) { target := p.targetPath(leagueID) capp.Call(target, nameRemote.MapLeague_MemberPrestigeUpdate, req) } func (p *leagueCall) targetPath(leagueID int64) string { return cfacade.NewChildPath("", nameActor.Map_League, leagueID) } func (p *leagueCall) target() string { return cfacade.NewPath("", nameActor.Map_League) }