d
This commit is contained in:
parent
d074c75b6c
commit
719a1b8d34
@ -22,7 +22,7 @@
|
|||||||
| 收获 | 收获成熟作物 | |
|
| 收获 | 收获成熟作物 | |
|
||||||
| 铲除 | 铲除荒废作物 | |
|
| 铲除 | 铲除荒废作物 | |
|
||||||
| 我的作物 | | |
|
| 我的作物 | | |
|
||||||
| 出售作物 [作物名称] [数量] | 从仓库里向系统售卖作物 | 数量不填默认全部 |
|
| 出售作物 [作物名称] [数量] | 从仓库里向系统售卖作物 | 作物不填默认清空仓库 数量不填默认全部 |
|
||||||
| @美波理 偷菜 | 偷别人的菜 | 每人每天只能偷5次 |
|
| @美波理 偷菜 | 偷别人的菜 | 每人每天只能偷5次 |
|
||||||
| 购买农场币 | 将真寻金币兑换成农场币 | 兑换比例默认为1:2 手续费默认20% |
|
| 购买农场币 | 将真寻金币兑换成农场币 | 兑换比例默认为1:2 手续费默认20% |
|
||||||
|
|
||||||
|
|||||||
@ -634,8 +634,11 @@ class CSqlManager:
|
|||||||
|
|
||||||
if plant in plantsDict:
|
if plant in plantsDict:
|
||||||
plantsDict[plant] += num
|
plantsDict[plant] += num
|
||||||
|
if plantsDict[plant] <= 0:
|
||||||
|
del plantsDict[plant]
|
||||||
else:
|
else:
|
||||||
plantsDict[plant] = num
|
if num > 0:
|
||||||
|
plantsDict[plant] = num
|
||||||
|
|
||||||
updatedPlants = ','.join([f"{name}|{count}" for name, count in plantsDict.items()])
|
updatedPlants = ','.join([f"{name}|{count}" for name, count in plantsDict.items()])
|
||||||
|
|
||||||
|
|||||||
@ -679,7 +679,7 @@ class CFarmManager:
|
|||||||
logger.info(f"{level[0]}")
|
logger.info(f"{level[0]}")
|
||||||
|
|
||||||
if level[0] < levelFileter:
|
if level[0] < levelFileter:
|
||||||
return f"当前用户等级不足,升级所需等级为{levelFileter}"
|
return f"当前用户等级{level[0]},升级所需等级为{levelFileter}"
|
||||||
|
|
||||||
if userInfo['point'] < point:
|
if userInfo['point'] < point:
|
||||||
return f"当前用户农场币不足,升级所需农场币为{point}"
|
return f"当前用户农场币不足,升级所需农场币为{point}"
|
||||||
|
|||||||
21
farm/shop.py
21
farm/shop.py
@ -1,5 +1,6 @@
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
|
from Python311.Lib._pytest.mark.structures import istestfunc
|
||||||
from zhenxun.services.log import logger
|
from zhenxun.services.log import logger
|
||||||
from zhenxun.utils._build_image import BuildImage
|
from zhenxun.utils._build_image import BuildImage
|
||||||
from zhenxun.utils.image_utils import ImageTemplate
|
from zhenxun.utils.image_utils import ImageTemplate
|
||||||
@ -139,6 +140,10 @@ class CShopManager:
|
|||||||
totalSold = 0
|
totalSold = 0
|
||||||
remainingItems = []
|
remainingItems = []
|
||||||
|
|
||||||
|
isAll = False
|
||||||
|
if num == -1:
|
||||||
|
isAll = True
|
||||||
|
|
||||||
items = plant.split(',')
|
items = plant.split(',')
|
||||||
if len(name) <= 0:
|
if len(name) <= 0:
|
||||||
#出售全部
|
#出售全部
|
||||||
@ -160,20 +165,26 @@ class CShopManager:
|
|||||||
try:
|
try:
|
||||||
count = int(countStr)
|
count = int(countStr)
|
||||||
if plantName == name:
|
if plantName == name:
|
||||||
sellAmount = min(num, count)
|
|
||||||
|
if isAll:
|
||||||
|
sellAmount = count
|
||||||
|
else:
|
||||||
|
sellAmount = min(num, count)
|
||||||
|
|
||||||
totalSold += sellAmount
|
totalSold += sellAmount
|
||||||
remaining = count - sellAmount
|
remaining = count - sellAmount
|
||||||
|
|
||||||
if remaining > 0:
|
if remaining > 0:
|
||||||
remainingItems.append(f"{plantName}|{remaining}")
|
remainingItems.append(f"{plantName}|{remaining}")
|
||||||
|
|
||||||
num -= sellAmount
|
if isAll == False:
|
||||||
if num == 0:
|
num -= sellAmount
|
||||||
break
|
|
||||||
|
break
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if num > 0:
|
if num > 0 and isAll == False:
|
||||||
return f"出售作物{name}出错:数量不足"
|
return f"出售作物{name}出错:数量不足"
|
||||||
|
|
||||||
#计算收益
|
#计算收益
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user