| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- package mapUnion
- import (
- capp "f1-game/internal/cherry_app"
- "f1-game/internal/code"
- "f1-game/internal/enum"
- nameActor "f1-game/internal/name/actor"
- nameLocal "f1-game/internal/name/local"
- nameRemote "f1-game/internal/name/remote"
- "f1-game/internal/pb"
- "f1-game/internal/sessions"
- cfacade "github.com/cherry-game/cherry/facade"
- "github.com/cherry-game/cherry/net/parser/pomelo"
- cproto "github.com/cherry-game/cherry/net/proto"
- )
- type (
- actor struct {
- pomelo.ActorBase
- }
- )
- func NewActor() *actor {
- return &actor{}
- }
- func (p *actor) AliasID() string {
- return nameActor.Map_Union
- }
- func Init(app cfacade.IApplication) {
- actor := NewActor()
- app.ActorSystem().CreateActor(actor.AliasID(), actor)
- }
- func (p *actor) OnInit() {
- p.Local().Register(nameLocal.MapUnion_ApplyOption, p.applyOption)
- p.Local().Register(nameLocal.MapUnion_UmengRelieve, p.umengRelieve)
- p.Local().Register(nameLocal.MapUnion_UnionRelieve, p.unionRelieve)
- }
- // 联盟外交邀请处理
- func (p *actor) applyOption(session *cproto.Session, req *pb.UnionApplyOp) {
- var (
- curLeagueID = sessions.GetLeagueID(session)
- playerID = sessions.GetPlayerID(session)
- sendApplyLeagueID = req.LeagueID
- applyType = req.ApplyType
- agree = req.Agree
- )
- // 未加入联盟
- if curLeagueID <= 0 {
- p.ResponseCode(session, code.LeagueNotJoin)
- return
- }
- // 参数错误
- if sendApplyLeagueID <= 0 || enum.IsNotLeagueDiplomacyType(applyType) {
- p.ResponseCode(session, code.IllegalArgument)
- return
- }
- // 发送到当前执行的联盟actor处理
- var (
- handleReq = &pb.LeagueDiplomacyHandle{
- PlayerID: playerID,
- HandleLeagueID: sendApplyLeagueID,
- ApplyType: applyType,
- Agree: agree,
- }
- path = cfacade.NewChildPath("", nameActor.League, curLeagueID)
- )
- errCode := capp.CallWait(path, nameRemote.MapLeague_DiplomacyApplyHandle, handleReq, nil)
- p.ResponseCode(session, errCode)
- }
- // 解除友盟外交关系
- func (p *actor) umengRelieve(session *cproto.Session, req *pb.I64) {
- var (
- curLeagueID = sessions.GetLeagueID(session)
- playerID = sessions.GetPlayerID(session)
- relieveLeagueID = req.Value
- )
- // 未加入联盟
- if curLeagueID <= 0 {
- p.ResponseCode(session, code.LeagueNotJoin)
- return
- }
- // 参数错误
- if relieveLeagueID <= 0 {
- p.ResponseCode(session, code.IllegalArgument)
- return
- }
- // 发送到当前执行的联盟actor处理
- var (
- handleReq = &pb.I64I64{
- Key: playerID,
- Value: relieveLeagueID,
- }
- resp = &pb.I64{}
- path = cfacade.NewChildPath("", nameActor.League, curLeagueID)
- )
- errCode := capp.CallWait(path, nameRemote.MapLeague_UmengRelieve, handleReq, resp)
- if code.IsFail(errCode) {
- p.ResponseCode(session, errCode)
- return
- }
- p.Response(session, resp)
- }
- // 解除联邦外交关系
- func (p *actor) unionRelieve(session *cproto.Session, _ *pb.None) {
- var (
- curLeagueID = sessions.GetLeagueID(session)
- playerID = sessions.GetPlayerID(session)
- )
- // 未加入联盟
- if curLeagueID <= 0 {
- p.ResponseCode(session, code.LeagueNotJoin)
- return
- }
- // 发送到当前执行的联盟actor处理
- var (
- handleReq = &pb.I64{
- Value: playerID,
- }
- resp = &pb.I64{}
- path = cfacade.NewChildPath("", nameActor.League, curLeagueID)
- )
- errCode := capp.CallWait(path, nameRemote.MapLeague_UnionRelieve, handleReq, resp)
- if code.IsFail(errCode) {
- p.ResponseCode(session, errCode)
- return
- }
- p.Response(session, resp)
- }
|