playroom优化

This commit is contained in:
hahwu 2025-02-06 19:18:44 +08:00
parent 0db815ba45
commit ca0efb53dd
2 changed files with 10 additions and 8 deletions

View File

@ -18,6 +18,8 @@ func init() {
gamedata.InitCfg(CFG_PLAYROOM_CONST)
gamedata.InitCfg(CFG_PLAYROOM_DECORATE)
gamedata.InitCfg(CFG_PLAYROOM_MOOD)
gamedata.InitCfg(CFG_PLAYROOM_PHYSIOLOGY)
gamedata.InitCfg(CFG_PLAYROOM_PHYSIOLOGY_TYPE)
}
func GetUnLockLv() int {

View File

@ -268,17 +268,17 @@ func (p *PlayroomMod) AddMood(Id, Num int) {
}
func (p *PlayroomMod) AddPhysiology(Id, Num int) {
Physiology := p.GetPhysiology(Id)
if Physiology == nil {
return
Phy := p.GetPhysiology(Id)
if Phy == nil {
Phy = &Physiology{Id: Id, Num: 0, Time: 0}
}
Max := playroomCfg.GetPhysiologyMax(Id)
Physiology.Num = max(0, min(Physiology.Num+Num, Max))
if Physiology.Num != 0 && Physiology.Time == 0 {
Physiology.Time = GoUtil.Now()
Phy.Num = max(0, min(Phy.Num+Num, Max))
if Phy.Num != 0 && Phy.Time == 0 {
Phy.Time = GoUtil.Now()
}
if Physiology.Num == 0 {
Physiology.Time = 0
if Phy.Num == 0 {
Phy.Time = 0
}
}