修复空指针异常
This commit is contained in:
parent
b9c1b85193
commit
9177d20d5e
|
@ -1106,88 +1106,89 @@ func (this *TienLenSceneData) SendHandCardOdds() {
|
|||
// 前两局不能天胡,之后根据概率给一次天胡,至少天胡一次
|
||||
noviceTianHu := false
|
||||
noviceCtrl := false
|
||||
config := srvdata.PBDB_NewPlayerMgr.GetData(int32(this.GameId))
|
||||
if config != nil && config.GetTianHuRate() > 0 && len(this.testPokers) == 0 { // 启用新手天胡体验
|
||||
rand.Shuffle(len(novicePlayers), func(i, j int) {
|
||||
novicePlayers[i], novicePlayers[j] = novicePlayers[j], novicePlayers[i]
|
||||
})
|
||||
keyNovice := common.GetKeyNoviceGameId(this.GameId)
|
||||
for _, v := range novicePlayers {
|
||||
data, ok := v.GDatas[keyNovice]
|
||||
if !ok {
|
||||
data = &model.PlayerGameInfo{FirstTime: time.Now()}
|
||||
v.GDatas[keyNovice] = data
|
||||
}
|
||||
// 前两局不能天胡
|
||||
if data.Statics.GameTimes < 2 {
|
||||
continue
|
||||
}
|
||||
if int(config.GetTianHuRate()) > this.RandInt(1000) {
|
||||
var allcs []int32
|
||||
for i := 0; i < 52; i++ {
|
||||
allcs = append(allcs, int32(i))
|
||||
}
|
||||
rand.Shuffle(len(allcs), func(i, j int) {
|
||||
allcs[i], allcs[j] = allcs[j], allcs[i]
|
||||
})
|
||||
cs, _ := rule.GetTianHu()
|
||||
allcs = common.DelSliceIn32s(allcs, cs)
|
||||
for _, seat := range this.seats {
|
||||
if seat != nil && seat.IsGameing() {
|
||||
if seat != v {
|
||||
f1(seat, allcs[:13])
|
||||
allcs = allcs[13:]
|
||||
} else {
|
||||
f1(seat, cs)
|
||||
}
|
||||
}
|
||||
}
|
||||
v.TestLog = append(v.TestLog, fmt.Sprintf("新手天胡体验,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
|
||||
logger.Logger.Tracef("新手天胡体验,玩家:%d 发天胡", v.SnId)
|
||||
noviceTianHu = true
|
||||
noviceCtrl = true
|
||||
}
|
||||
}
|
||||
if !noviceTianHu {
|
||||
// 没有新手玩家天胡,随机一个非新手玩家,如果没有天胡过,给一次天胡
|
||||
rand.Shuffle(len(notNoviceRealPlayers), func(i, j int) {
|
||||
notNoviceRealPlayers[i], notNoviceRealPlayers[j] = notNoviceRealPlayers[j], notNoviceRealPlayers[i]
|
||||
})
|
||||
for _, v := range notNoviceRealPlayers {
|
||||
data, ok := v.GDatas[keyNovice]
|
||||
if !ok {
|
||||
data = &model.PlayerGameInfo{FirstTime: time.Now()}
|
||||
v.GDatas[keyNovice] = data
|
||||
}
|
||||
|
||||
if data.Statics.GetInt(rule.StaticsTianHuTimes) == 0 {
|
||||
var allcs []int32
|
||||
for i := 0; i < 52; i++ {
|
||||
allcs = append(allcs, int32(i))
|
||||
}
|
||||
rand.Shuffle(len(allcs), func(i, j int) {
|
||||
allcs[i], allcs[j] = allcs[j], allcs[i]
|
||||
})
|
||||
cs, _ := rule.GetTianHu()
|
||||
allcs = common.DelSliceIn32s(allcs, cs)
|
||||
for _, seat := range this.seats {
|
||||
if seat != nil && seat.IsGameing() {
|
||||
if seat != v {
|
||||
f1(seat, allcs[:13])
|
||||
allcs = allcs[13:]
|
||||
} else {
|
||||
f1(seat, cs)
|
||||
}
|
||||
}
|
||||
}
|
||||
v.TestLog = append(v.TestLog, fmt.Sprintf("新手阶段没有天胡过,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
|
||||
logger.Logger.Tracef("新手阶段没有天胡过,玩家:%v 发天胡", v.SnId)
|
||||
noviceCtrl = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//config := srvdata.PBDB_NewPlayerMgr.GetData(int32(this.GameId))
|
||||
//if config != nil && config.GetTianHuRate() > 0 && len(this.testPokers) == 0 { // 启用新手天胡体验
|
||||
// rand.Shuffle(len(novicePlayers), func(i, j int) {
|
||||
// novicePlayers[i], novicePlayers[j] = novicePlayers[j], novicePlayers[i]
|
||||
// })
|
||||
// keyNovice := common.GetKeyNoviceGameId(this.GameId)
|
||||
// for _, v := range novicePlayers {
|
||||
// data, ok := v.GDatas[keyNovice]
|
||||
// if !ok {
|
||||
// data = &model.PlayerGameInfo{FirstTime: time.Now()}
|
||||
// v.GDatas[keyNovice] = data
|
||||
// }
|
||||
// // 前两局不能天胡
|
||||
// if data.Statics.GameTimes < 2 {
|
||||
// continue
|
||||
// }
|
||||
// if int(config.GetTianHuRate()) > this.RandInt(1000) {
|
||||
// var allcs []int32
|
||||
// for i := 0; i < 52; i++ {
|
||||
// allcs = append(allcs, int32(i))
|
||||
// }
|
||||
// rand.Shuffle(len(allcs), func(i, j int) {
|
||||
// allcs[i], allcs[j] = allcs[j], allcs[i]
|
||||
// })
|
||||
// cs, _ := rule.GetTianHu()
|
||||
// allcs = common.DelSliceIn32s(allcs, cs)
|
||||
// for _, seat := range this.seats {
|
||||
// if seat != nil && seat.IsGameing() {
|
||||
// if seat != v {
|
||||
// f1(seat, allcs[:13])
|
||||
// allcs = allcs[13:]
|
||||
// } else {
|
||||
// f1(seat, cs)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// v.TestLog = append(v.TestLog, fmt.Sprintf("新手天胡体验,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
|
||||
// logger.Logger.Tracef("新手天胡体验,玩家:%d 发天胡", v.SnId)
|
||||
// noviceTianHu = true
|
||||
// noviceCtrl = true
|
||||
// }
|
||||
// }
|
||||
// if !noviceTianHu {
|
||||
// // 没有新手玩家天胡,随机一个非新手玩家,如果没有天胡过,给一次天胡
|
||||
// rand.Shuffle(len(notNoviceRealPlayers), func(i, j int) {
|
||||
// notNoviceRealPlayers[i], notNoviceRealPlayers[j] = notNoviceRealPlayers[j], notNoviceRealPlayers[i]
|
||||
// })
|
||||
// for _, v := range notNoviceRealPlayers {
|
||||
// data, ok := v.GDatas[keyNovice]
|
||||
// if !ok {
|
||||
// data = &model.PlayerGameInfo{FirstTime: time.Now()}
|
||||
// v.GDatas[keyNovice] = data
|
||||
// }
|
||||
//
|
||||
// if data.Statics.GetInt(rule.StaticsTianHuTimes) == 0 {
|
||||
// var allcs []int32
|
||||
// for i := 0; i < 52; i++ {
|
||||
// allcs = append(allcs, int32(i))
|
||||
// }
|
||||
// rand.Shuffle(len(allcs), func(i, j int) {
|
||||
// allcs[i], allcs[j] = allcs[j], allcs[i]
|
||||
// })
|
||||
// cs, _ := rule.GetTianHu()
|
||||
// allcs = common.DelSliceIn32s(allcs, cs)
|
||||
// for _, seat := range this.seats {
|
||||
// if seat != nil && seat.IsGameing() {
|
||||
// if seat != v {
|
||||
// f1(seat, allcs[:13])
|
||||
// allcs = allcs[13:]
|
||||
// } else {
|
||||
// f1(seat, cs)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// v.TestLog = append(v.TestLog, fmt.Sprintf("新手阶段没有天胡过,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
|
||||
// logger.Logger.Tracef("新手阶段没有天胡过,玩家:%v 发天胡", v.SnId)
|
||||
// noviceCtrl = true
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
// 全局配置
|
||||
gameConfig := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig
|
||||
|
||||
// testPokers 用于测试
|
||||
|
|
|
@ -454,7 +454,7 @@ func (this *CSPigBankGetInfoHandler) Process(s *netlib.Session, packetid int, da
|
|||
if _, ok := data.(*welfare.CSPigbankGetInfo); ok {
|
||||
p := PlayerMgrSington.GetPlayer(sid)
|
||||
if p == nil {
|
||||
logger.Logger.Warnf("CSPigBankGetInfoHandler p == nil p.SnId = %v", p.SnId)
|
||||
logger.Logger.Warnf("CSPigBankGetInfoHandler p == nil")
|
||||
return nil
|
||||
}
|
||||
WelfareMgrSington.PigbankGetInfo(p)
|
||||
|
@ -479,7 +479,7 @@ func (this *CSPigBankTakeCoinHandler) Process(s *netlib.Session, packetid int, d
|
|||
if _, ok := data.(*welfare.CSPigbankTakeCoin); ok {
|
||||
p := PlayerMgrSington.GetPlayer(sid)
|
||||
if p == nil {
|
||||
logger.Logger.Warnf("CSPigBankTakeCoinHandler p == nil p.SnId = %v", p.SnId)
|
||||
logger.Logger.Warnf("CSPigBankTakeCoinHandler p == nil")
|
||||
return nil
|
||||
}
|
||||
WelfareMgrSington.PigbankTakeCoin(p)
|
||||
|
|
Loading…
Reference in New Issue