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):
|
async def play_game(self, ID, bet, recv, send):
|
||||||
gameOver = False
|
gameOver = False
|
||||||
playerStats = self.ledger.readLedger(ID)
|
playerStats = self.ledger.read(ID)
|
||||||
if playerStats is None:
|
if playerStats is None:
|
||||||
self.ledger.writeLedger(ID)
|
self.ledger.write(ID)
|
||||||
playerStats = self.ledger.readLedger
|
playerStats = self.ledger.read
|
||||||
|
|
||||||
self.deal()
|
self.deal()
|
||||||
while not gameOver:
|
while not gameOver:
|
||||||
|
|||||||
20
Ledger.py
20
Ledger.py
@@ -12,18 +12,18 @@ class Ledger():
|
|||||||
LOSSES integer DEFAULT 0
|
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,))
|
self.data.execute("""SELECT USERID, MONEY, WINS, LOSSES FROM ledger WHERE USERID = ?""", (ID,))
|
||||||
data = self.data.fetchone()
|
data = self.data.fetchone()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def writeLedger(self, ID):
|
def write(self, ID):
|
||||||
query = """ INSERT INTO ledger(USERID)
|
query = """ INSERT INTO ledger(USERID)
|
||||||
VALUES(?) """
|
VALUES(?) """
|
||||||
self.data.execute(query, (ID,))
|
self.data.execute(query, (ID,))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
|
|
||||||
def updateLedger(self, data, newData):
|
def update(self, data, newData):
|
||||||
query = """ UPDATE ledger
|
query = """ UPDATE ledger
|
||||||
SET MONEY = ?,
|
SET MONEY = ?,
|
||||||
WINS = ?,
|
WINS = ?,
|
||||||
@@ -33,19 +33,7 @@ class Ledger():
|
|||||||
self.data.execute(query, data)
|
self.data.execute(query, data)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
ledger = Ledger()
|
pass
|
||||||
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)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user