修复偷菜后收获果实数不会减少的错误
This commit is contained in:
@@ -55,6 +55,7 @@ class WPSGardenSteal(WPSGardenBase):
|
||||
super().wake_up()
|
||||
self.register_plugin("steal")
|
||||
self.register_plugin("偷取")
|
||||
self.register_plugin("偷菜")
|
||||
|
||||
async def callback(self, message: str, chat_id: int, user_id: int) -> Optional[str]:
|
||||
payload = self.parse_message_after_at(message).strip()
|
||||
|
||||
@@ -187,7 +187,10 @@ class GardenService:
|
||||
crop = GARDEN_CROPS.get(plot["seed_id"])
|
||||
if not crop:
|
||||
raise ValueError("未知作物")
|
||||
base_yield = int(plot["base_yield"])
|
||||
initial_yield = int(plot["base_yield"])
|
||||
remaining_fruit = int(plot["remaining_fruit"])
|
||||
if remaining_fruit < 0:
|
||||
remaining_fruit = 0
|
||||
extra_reward = None
|
||||
if crop.extra_reward:
|
||||
base_rate = crop.extra_reward.base_rate
|
||||
@@ -199,7 +202,7 @@ class GardenService:
|
||||
if crop.extra_reward.kind == "points":
|
||||
data = crop.extra_reward.payload
|
||||
max_points = min(
|
||||
data.get("max", base_yield * crop.seed_price),
|
||||
data.get("max", initial_yield * crop.seed_price),
|
||||
crop.seed_price * self._config.sale_multiplier,
|
||||
)
|
||||
min_points = data.get("min", 0)
|
||||
@@ -219,9 +222,10 @@ class GardenService:
|
||||
}
|
||||
result = {
|
||||
"crop": crop,
|
||||
"base_yield": base_yield,
|
||||
"base_yield": remaining_fruit,
|
||||
"extra": extra_reward,
|
||||
}
|
||||
result["initial_yield"] = initial_yield
|
||||
cursor = self._db.conn.cursor()
|
||||
cursor.execute(
|
||||
"DELETE FROM garden_plots WHERE user_id = ? AND plot_index = ?",
|
||||
|
||||
Reference in New Issue
Block a user