我正在计算你是否会从一个游戏的两个项目中获利,现在我需要做"NPC购买价格-销售价格* 640",原因是你只能购买640的项目,首先我需要保证金,这就是为什么NPC购买价格-销售价格。
这是我的python的样子:
@app.route('/bresell')
def reSell():
farmingMerchantPrices = [
"5", # cocoa beans
"12", # brown mushroom
"2.33", # carrot
"8", # pumpkin
"2.33", # wheat
"12", # red mushroom
"2.33", # potato
"4", # sand
"5", # sugar cane
"2", # melon
]
farmingMerchantName = [
"Cocoa Beans",
"Brown Mushroom",
"Carrot",
"Pumpkin",
"Wheat",
"Red Mushroom",
"Potato",
"Sand",
"Sugar Cane",
"Melon"
]
sellPrice = []
f = requests.get(
'https://api.hypixel.net/skyblock/bazaar?key=[not allowed to show key]').json()
for x in farmingProducts:
sellPrice.append(f["products"][x]["sell_summary"][0]["pricePerUnit"])
profit = []
for x in farmingMerchantPrices:
profit.append(sellPrice - x)
return render_template('resell.html', farmingMerchantPrices=farmingMerchantPrices, farmingMerchantName=farmingMerchantName, sellPrice=sellPrice, profit=profit)
这是我的HTML:
<tbody>
{% for name, npcBuy,price,profit in zip(farmingMerchantName,
farmingMerchantPrices,sellPrice,profit) %}
<tr>
<td>{{ name }}</td>
<td>{{ profit will go here }}</td>
<td>{{ npcBuy }}</td>
<td>{{ price }}</td>
</tr>
{% endfor %}
</tbody>
我有点困惑,如果我应该做的数学,在金佳或烧瓶,烧瓶,对吗?而且我有点不确定该怎么做!
发布于 2020-05-27 16:09:14
要回答你的第一个问题,最好在后端执行任何计算,在那里你的计算是隐藏的和安全的。
根据您的第二个问题,我认为您的代码的唯一问题是您在farmingMerchantPrices
中将价格定义为字符串而不是数字。因此,您的问题应该只需像这样更改类型即可解决:
farmingMerchantPrices = [
5, # cocoa beans (5 instead of "5")
12, # brown mushroom
2.33, # carrot
8, # pumpkin
2.33, # wheat
12, # red mushroom
2.33, # potato
4, # sand
5, # sugar cane
2, # melon
]
https://stackoverflow.com/questions/62037994
复制相似问题