mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-08 12:47:13 +08:00
fix: 限制实体字段的最大值以防止数值溢出
在FieldStore.gd中添加entityMaxValueMap定义各字段的最大值 在Feed.gd中应用clamp确保字段值不超过定义的最大值
This commit is contained in:
@@ -71,6 +71,7 @@ func apply(entity: EntityBase):
|
|||||||
var applier = FieldStore.entityApplier.get(field, null)
|
var applier = FieldStore.entityApplier.get(field, null)
|
||||||
if !applier or applier.call(entity, value):
|
if !applier or applier.call(entity, value):
|
||||||
entity.fields[field] += value
|
entity.fields[field] += value
|
||||||
|
entity.fields[field] = clamp(entity.fields[field], 0, FieldStore.entityMaxValueMap.get(field, INF))
|
||||||
hide()
|
hide()
|
||||||
selected.emit(allHave)
|
selected.emit(allHave)
|
||||||
return allHave
|
return allHave
|
||||||
|
|||||||
@@ -69,6 +69,14 @@ static var entityMapType = {
|
|||||||
Entity.MAX_ENERGY: DataType.VALUE,
|
Entity.MAX_ENERGY: DataType.VALUE,
|
||||||
Entity.LUCK_VALUE: DataType.VALUE
|
Entity.LUCK_VALUE: DataType.VALUE
|
||||||
}
|
}
|
||||||
|
static var entityMaxValueMap = {
|
||||||
|
Entity.CRIT_RATE: 1,
|
||||||
|
Entity.PENERATE: 1,
|
||||||
|
Entity.PENARATION_RESISTANCE: 1,
|
||||||
|
Entity.PRICE_REDUCTION: 0.8,
|
||||||
|
Entity.DROP_APPLE_RATE: 0.5,
|
||||||
|
Entity.FEED_COUNT_SHOW: 6
|
||||||
|
}
|
||||||
static var entityApplier = {
|
static var entityApplier = {
|
||||||
Entity.MAX_HEALTH: func(entity, value):
|
Entity.MAX_HEALTH: func(entity, value):
|
||||||
entity.health += value
|
entity.health += value
|
||||||
|
|||||||
Reference in New Issue
Block a user