Ledger Style changes
This commit is contained in:
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Current File",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -136,10 +136,10 @@ class BlackJack:
|
||||
|
||||
async def play_game(self, ID, bet, recv, send):
|
||||
gameOver = False
|
||||
playerStats = self.ledger.readLedger(ID)
|
||||
playerStats = self.ledger.read(ID)
|
||||
if playerStats is None:
|
||||
self.ledger.writeLedger(ID)
|
||||
playerStats = self.ledger.readLedger
|
||||
self.ledger.write(ID)
|
||||
playerStats = self.ledger.read
|
||||
|
||||
self.deal()
|
||||
while not gameOver:
|
||||
|
||||
20
Ledger.py
20
Ledger.py
@@ -12,18 +12,18 @@ class Ledger():
|
||||
LOSSES integer DEFAULT 0
|
||||
); """)
|
||||
|
||||
def readLedger(self, ID):
|
||||
def read(self, ID):
|
||||
self.data.execute("""SELECT USERID, MONEY, WINS, LOSSES FROM ledger WHERE USERID = ?""", (ID,))
|
||||
data = self.data.fetchone()
|
||||
return data
|
||||
|
||||
def writeLedger(self, ID):
|
||||
def write(self, ID):
|
||||
query = """ INSERT INTO ledger(USERID)
|
||||
VALUES(?) """
|
||||
self.data.execute(query, (ID,))
|
||||
self.db.commit()
|
||||
|
||||
def updateLedger(self, data, newData):
|
||||
def update(self, data, newData):
|
||||
query = """ UPDATE ledger
|
||||
SET MONEY = ?,
|
||||
WINS = ?,
|
||||
@@ -33,19 +33,7 @@ class Ledger():
|
||||
self.data.execute(query, data)
|
||||
|
||||
def main():
|
||||
ledger = Ledger()
|
||||
ledger.writeLedger(10121)
|
||||
ID = 10121
|
||||
data = ledger.readLedger(ID)
|
||||
|
||||
ID = 2
|
||||
playerStats = ledger.readLedger(ID)
|
||||
if playerStats is None:
|
||||
print("Not real")
|
||||
ledger.writeLedger(ID)
|
||||
playerStats = ledger.readLedger(ID)
|
||||
|
||||
print(playerStats)
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user