Ver Fonte

Added Function to find Total spend to complete Crystalization

KeyMasterOfGozer há 9 meses atrás
pai
commit
aba2b6cb6f
1 ficheiros alterados com 24 adições e 0 exclusões
  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}")