package logic import ( "ecs/proto/pb" "github.com/oylshe1314/framework/util" ) func (this *Player) BuildMsgRolePropertyAck() *pb.RolePropertyAck { return &pb.RolePropertyAck{ UserId: this.UserId, Platform: this.Platform, Channel: this.Channel, ServerId: this.ServerId, Username: this.Username, CreateTime: this.CreateTime, Language: this.Language, RoleName: this.RoleName, RoleGender: this.RoleGender, AvatarFrame: this.AvatarFrame, ChatBubble: this.ChatBubble, NamePrefix: this.NamePrefix, NameTitle: this.NameTitle, RoleTitle: this.RoleTitle, LoginDays: this.LoginDays, PowerNextTime: this.PowerNextTime, } } func (this *Player) ChangeProperty(properties ...*util.Pair[pb.RolePropertyType, int64]) { if len(properties) == 0 { return } var ack = &pb.RolePropertyChangeAck{} for _, property := range properties { switch property.Key { case pb.RolePropertyType_AvatarFrame: this.AvatarFrame = uint32(property.Value) this.SaveField("avatar_frame", this.AvatarFrame) case pb.RolePropertyType_ChatBubble: this.ChatBubble = uint32(property.Value) this.SaveField("chat_bubble", this.ChatBubble) case pb.RolePropertyType_NamePrefix: this.NamePrefix = uint32(property.Value) this.SaveField("name_prefix", this.NamePrefix) case pb.RolePropertyType_NameTitle: this.NameTitle = uint32(property.Value) this.SaveField("name_title", this.NameTitle) case pb.RolePropertyType_RoleTitle: this.RoleTitle = uint32(property.Value) this.SaveField("role_title", this.RoleTitle) case pb.RolePropertyType_LoginDays: this.LoginDays = uint32(property.Value) this.SaveField("login_days", this.LoginDays) case pb.RolePropertyType_PowerNextTime: this.PowerNextTime = property.Value this.SaveField("power_next_time", this.PowerNextTime) default: continue } ack.PropertyList = append(ack.PropertyList, &pb.RoleProperty{Type: property.Key, Value: property.Value}) } _ = this.Send(uint16(pb.ModId_ModuleRole), uint16(pb.MsgId_ModRolePropertyChange), ack) } func (this *Player) BuildMsgRolePropertyChangeAck(types ...pb.RolePropertyType) *pb.RolePropertyChangeAck { var ack = &pb.RolePropertyChangeAck{} for _, tipe := range types { var property = &pb.RoleProperty{Type: tipe} switch tipe { case pb.RolePropertyType_AvatarFrame: property.Value = int64(this.AvatarFrame) case pb.RolePropertyType_ChatBubble: property.Value = int64(this.ChatBubble) case pb.RolePropertyType_NamePrefix: property.Value = int64(this.NamePrefix) case pb.RolePropertyType_NameTitle: property.Value = int64(this.NameTitle) case pb.RolePropertyType_RoleTitle: property.Value = int64(this.RoleTitle) case pb.RolePropertyType_LoginDays: property.Value = int64(this.LoginDays) case pb.RolePropertyType_PowerNextTime: property.Value = this.PowerNextTime } ack.PropertyList = append(ack.PropertyList, property) } return ack }