def DeleteRoulete(id): for i in range(0, db.llen('Rouletes')): tempJSON = db.lindex('Rouletes', i) loadroulet = json.loads(tempJSON) if loadroulet['id'] == id: db.lrem('Rouletes', 0, tempJSON) break
def RouleteCommit(newRouleta): for i in range(0, db.llen('Rouletes')): tempJSON = db.lindex('Rouletes', i) loadroulet = json.loads(tempJSON) if loadroulet['id'] == newRouleta.id: newrouleteJson = json.dumps(newRouleta.__dict__) db.lset('Rouletes', i, newrouleteJson) return newRouleta
def RouletefindById(FindId): newRouleta = None for i in range(0, db.llen('Rouletes')): tempJSON = db.lindex('Rouletes', i) loadroulet = json.loads(tempJSON) if loadroulet['id'] == FindId: newRouleta = roulete.Roulete(loadroulet['id']) newRouleta.state = loadroulet['state'] return newRouleta
def FindIdxFree(): newindex = db.llen('Rouletes') for j in range(0, db.llen('Rouletes')): conuntEqual = 0 for i in range(0, db.llen('Rouletes')): tempJSON = db.lindex('Rouletes', i) loadroulet = json.loads(tempJSON) if loadroulet['id'] == j: conuntEqual = conuntEqual + 1 break if conuntEqual == 0 and not newindex == j: newindex = j break return newindex
def AllRouletes(): Rouletes = [] for i in range(0, db.llen('Rouletes')): tempJSON = db.lindex('Rouletes', i) loadroulet = json.loads(tempJSON) newroulute = roulete.Roulete(loadroulet['id']) newroulute.BetsTable = loadroulet['BetsTable'] newroulute.state = loadroulet['state'] newroulute.ListAllBets() RouleteData = { 'id': loadroulet['id'], 'roulete': newroulute, 'message': newroulute.StateToString() } Rouletes.append(RouleteData) return Rouletes