'integer', 'growth_time' => 'integer', 'fruit_time' => 'integer', 'mature_time' => 'integer', 'wither_time' => 'integer', ]; /** * 获取关联的果实物品 * * @return BelongsTo */ public function fruitItem(): BelongsTo { return $this->belongsTo(\App\Module\GameItems\Models\Item::class, 'fruit_item_id', 'id'); } /** * 检查果实期是否无限 * * @return bool */ public function isFruitTimeInfinite(): bool { return $this->fruit_time === 0; } /** * 检查成熟期是否无限 * * @return bool */ public function isMatureTimeInfinite(): bool { return $this->mature_time === 0; } /** * 检查枯萎期是否无限 * * @return bool */ public function isWitherTimeInfinite(): bool { return $this->wither_time === 0; } /** * 获取总生长时间(不包括无限期) * * @return int */ public function getTotalGrowthTime(): int { $total = $this->sprout_time + $this->growth_time; // 添加果实期时间(如果不是无限) if (!$this->isFruitTimeInfinite()) { $total += $this->fruit_time; } if (!$this->isMatureTimeInfinite()) { $total += $this->mature_time; } if (!$this->isWitherTimeInfinite()) { $total += $this->wither_time; } return $total; } }