浏览代码

Added Function to find Total spend to complete Crystalization

KeyMasterOfGozer 9 月之前
父节点
当前提交
aba2b6cb6f
共有 1 个文件被更改,包括 24 次插入0 次删除
  1. 24 0
      db.py

+ 24 - 0
db.py

@@ -53,8 +53,32 @@ def plot(card=None,columns=['cost','cost-min','cost-max'],maxCost=None):
     """
     df=getDF(card).plot(x='date',y=columns)
     plt.title(str(card))
+    plt.xticks(rotation=45)
     plt.xlabel("Date")
     plt.ylabel("Cost")
     plt.ylim(0,maxCost)
     plt.show()
     
+def buyout():
+    today=datetime.utcnow().strftime('%Y-%m-%d')
+    PlayerCards=PlayerDB.search(Query().fragment({'date':today}))
+    Stock=[None]*152
+    for card in PlayerCards: Stock[card['card-num']]=card['stock']
+    MarketDF = getDF(aDate=today)
+    MarketCards=MarketDF.to_dict('records')
+    total=0
+    cardCount=0
+    NeededCards=[]
+    for card in MarketCards:
+        if 'CRYSTAL' not in Stock[card['card-num']]:
+            card['stock']=int(Stock[card['card-num']])
+            card['needed']=10-card['stock']
+            card['card-num']=card['card-num']
+            card['total-cost']=card['needed']*card['cost']
+            NeededCards.append(card)
+            total+=card['total-cost']
+            cardCount+=card['needed']
+            print(f"{card['card-num']: <3} {card['name']: <20} {card['needed']: >2} {card['total-cost']}")
+    
+    print(f"  Remaining Cards: {cardCount}")
+    print(f"Total Gems Needed: {total}")