增加积分显示

This commit is contained in:
meixiongfeng 2023-11-08 11:00:23 +08:00
parent 3b549fe732
commit 0ca938652b
7 changed files with 96 additions and 46 deletions

View File

@ -63,8 +63,9 @@ func (this *apiComp) CreateRoom(session comm.IUserSession, req *pb.EntertainCrea
return
}
p1 := &pb.PlayerData{
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Consumeexp: user.Consumeexp,
}
if room, err = this.module.gameMgr.CreateMasterRoom(p1); err != nil {
errdata = &pb.ErrorData{

View File

@ -61,8 +61,9 @@ func (this *apiComp) JoinRoom(session comm.IUserSession, req *pb.EntertainJoinRo
return
}
p := &pb.PlayerData{
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Consumeexp: user.Consumeexp,
}
if _, err = this.module.gameMgr.JoinMasterRoom(req.Roomid, p); err != nil {

View File

@ -58,8 +58,9 @@ func (this *apiComp) Match(session comm.IUserSession, req *pb.EntertainMatchReq)
}
this.module.match.MatchReq(&pb.DBXXLMatch{
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Consumeexp: user.Consumeexp,
})
session.SendMsg(string(this.module.GetType()), "match", &pb.EntertainMatchResp{

View File

@ -68,13 +68,15 @@ func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) {
for pos, v := range playerSlice {
if pos == 0 {
p1 = &pb.PlayerData{
Userinfo: v.Userinfo,
Cardid: v.Cardid,
Userinfo: v.Userinfo,
Cardid: v.Cardid,
Consumeexp: v.Consumeexp,
}
} else if pos == 1 {
p2 = &pb.PlayerData{
Userinfo: v.Userinfo,
Cardid: v.Cardid,
Userinfo: v.Userinfo,
Cardid: v.Cardid,
Consumeexp: v.Consumeexp,
}
} else {
break

View File

@ -55,7 +55,7 @@ func (this *Room) RandomPlayType() (itype int32) {
weight = append(weight, v.Weight)
}
itype = list[comm.GetRandW(weight)].Key
//itype = 4
return
}
@ -139,13 +139,13 @@ func (this *Room) AiOperator() {
ChangeType: 1,
})
}
for _, v := range szMap { //
curScore += v.CurSocre
this.player2.Score += v.CurSocre
v.CurSocre = this.player2.Score
this.player2.Energy += v.CurEnergy
v.CurEnergy = this.player2.Energy
}
// for _, v := range szMap { //
// curScore += v.CurSocre
// this.player2.Score += v.CurSocre
// v.CurSocre = this.player2.Score
// this.player2.Energy += v.CurEnergy
// v.CurEnergy = this.player2.Energy
// }
// 广播消息
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
Mpadata: szMap,
@ -381,6 +381,18 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
this.round++
}
for _, v := range szMap { //
fmt.Printf("================\n")
var v1 int
for index := Width - 1; index >= 0; index-- {
for j := 0; j < Height; j++ {
v1 = index + j*7
fmt.Printf("%d ", v.Data[v1].Cid)
}
fmt.Printf("\n")
}
}
// 广播消息
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
Mpadata: szMap,
@ -568,7 +580,15 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) {
if conf, err := this.module.configure.GetGameConsumeintegral(user.Consumeexp); err == nil {
//res = append(res, conf.Onereward...) 这奖励手动领取
res = append(res, conf.Rewards...)
for _, v := range res {
if v.A == "attr" && v.T == "consumeexp" {
if winner == this.player1 {
this.player1.Score += v.N
} else {
this.player2.Score += v.N
}
}
}
if errdata, atno = this.module.DispenseAtno(this.szSession[winindex], res, true); errdata != nil {
return
}

View File

@ -117,7 +117,7 @@ func (this *MapData) InitMap(module *Entertainment, iType int32) {
this.SetIndelibilityPlat()
this.Plat = this.GetPalatData()
// this.SetMap() // 方便测试固定地图
//this.SetMap() // 方便测试固定地图
}
// 交换之前先判断是不是特殊元素的交换
@ -740,26 +740,29 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32,
func (this *MapData) SetMap() {
sz2 := []int32{
3, 3, 2, 2, 1, 3, 1,
5, 1, 3, 3, 1, 2, 2,
3, 2, 1, 4, 3, 1, 6,
1, 4, 3, 4, 2, 3, 6,
3, 1, 2, 2, 1, 3, 1,
5, 1, 2, 3, 1, 2, 2,
2, 42, 3, 4, 3, 1, 6,
1, 3, 3, 4, 2, 3, 6,
1, 5, 6, 5, 6, 1, 4,
6, 6, 3, 6, 3, 1, 3,
3, 3, 1, 3, 3, 2, 5,
// 1, 4, 2, 5, 4, 5, 2,
// 3, 2, 3, 5, 2, 1, 4,
// 2, 5, 5, 4, 5, 4, 1,
// 3, 1, 3, 5, 2, 6, 3,
// 4, 5, 4, 2, 4, 1, 1,
// 5, 3, 1, 5, 3, 3, 4,
// 4, 2, 4, 1, 2, 3, 4,
6, 6, 3, 6, 3, 48, 3,
3, 3, 1, 3, 5, 2, 5,
}
var pos int
for index := Width - 1; index >= 0; index-- {
for j := 0; j < Height; j++ {
this.Plat[index+j*Height].Color = sz2[pos]
this.Plat[index+j*Height].Cid = sz2[pos]
Color := sz2[pos]
Cid := sz2[pos]
if sz2[pos] > 6 {
conf, err := this.module.configure.GetGameBlockByKey(sz2[pos])
if err == nil {
Color = conf.Color
Cid = conf.Key
this.Plat[index+j*Height].Special = conf.Type
}
}
this.Plat[index+j*Height].Color = Color
this.Plat[index+j*Height].Cid = Cid
pos++
}
}
@ -1128,7 +1131,9 @@ func (this *MapData) GetBoomElem(pos int) (elem []int) {
func (this *MapData) GetFireBoom(pos int, itype int32) (elem []int) {
x := int(pos / Width)
y := int(pos % Height)
if itype == FireUp || itype == FireDown || itype == FireLeft || itype == FireRight {
elem = append(elem, pos)
}
switch itype {
case FireUp: //上烟火
for i := 0; i < Height; i++ {

View File

@ -177,11 +177,12 @@ type PlayerData struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Userinfo *BaseUserInfo `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo"`
Score int32 `protobuf:"varint,2,opt,name=score,proto3" json:"score"` // 积分
Ps int32 `protobuf:"varint,3,opt,name=ps,proto3" json:"ps"` // 体力
Cardid string `protobuf:"bytes,4,opt,name=cardid,proto3" json:"cardid"` // 出战的英雄卡
Energy int32 `protobuf:"varint,5,opt,name=energy,proto3" json:"energy"` // 能量进度
Userinfo *BaseUserInfo `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo"`
Score int32 `protobuf:"varint,2,opt,name=score,proto3" json:"score"` // 本局战斗得分
Ps int32 `protobuf:"varint,3,opt,name=ps,proto3" json:"ps"` // 体力
Cardid string `protobuf:"bytes,4,opt,name=cardid,proto3" json:"cardid"` // 出战的英雄卡
Energy int32 `protobuf:"varint,5,opt,name=energy,proto3" json:"energy"` // 能量进度
Consumeexp int32 `protobuf:"varint,6,opt,name=consumeexp,proto3" json:"consumeexp"` // 消消乐积分
}
func (x *PlayerData) Reset() {
@ -251,14 +252,22 @@ func (x *PlayerData) GetEnergy() int32 {
return 0
}
func (x *PlayerData) GetConsumeexp() int32 {
if x != nil {
return x.Consumeexp
}
return 0
}
// 消消乐匹配数据
type DBXXLMatch struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Userinfo *BaseUserInfo `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo"`
Cardid string `protobuf:"bytes,2,opt,name=cardid,proto3" json:"cardid"` // 选择的卡片ID
Userinfo *BaseUserInfo `protobuf:"bytes,1,opt,name=userinfo,proto3" json:"userinfo"`
Cardid string `protobuf:"bytes,2,opt,name=cardid,proto3" json:"cardid"` // 选择的卡片ID
Consumeexp int32 `protobuf:"varint,3,opt,name=consumeexp,proto3" json:"consumeexp"` // 消消乐积分
}
func (x *DBXXLMatch) Reset() {
@ -307,6 +316,13 @@ func (x *DBXXLMatch) GetCardid() string {
return ""
}
func (x *DBXXLMatch) GetConsumeexp() int32 {
if x != nil {
return x.Consumeexp
}
return 0
}
type BoxData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -495,7 +511,7 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{
0x28, 0x05, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65,
0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x18, 0x0a,
0x07, 0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07,
0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x22, 0x8d, 0x01, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79,
0x73, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x22, 0xad, 0x01, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79,
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x29, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x69, 0x6e,
0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x55,
0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x69, 0x6e, 0x66,
@ -504,12 +520,16 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{
0x01, 0x28, 0x05, 0x52, 0x02, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69,
0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x12,
0x16, 0x0a, 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52,
0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x22, 0x4f, 0x0a, 0x0a, 0x44, 0x42, 0x58, 0x58, 0x4c,
0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x73, 0x75,
0x6d, 0x65, 0x65, 0x78, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f, 0x6e,
0x73, 0x75, 0x6d, 0x65, 0x65, 0x78, 0x70, 0x22, 0x6f, 0x0a, 0x0a, 0x44, 0x42, 0x58, 0x58, 0x4c,
0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x69, 0x6e, 0x66,
0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x55, 0x73,
0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x69, 0x6e, 0x66, 0x6f,
0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x22, 0x3b, 0x0a, 0x07, 0x42, 0x6f, 0x78, 0x44,
0x52, 0x06, 0x63, 0x61, 0x72, 0x64, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x73,
0x75, 0x6d, 0x65, 0x65, 0x78, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f,
0x6e, 0x73, 0x75, 0x6d, 0x65, 0x65, 0x78, 0x70, 0x22, 0x3b, 0x0a, 0x07, 0x42, 0x6f, 0x78, 0x44,
0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6f, 0x78, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x05, 0x62, 0x6f, 0x78, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65,
0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6f, 0x70, 0x65,