Эх сурвалжийг харах

Added Function to find Total spend to complete Crystalization

KeyMasterOfGozer 9 сар өмнө
parent
commit
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}")