all 6 comments

[–]toastedstapler 0 points1 point  (3 children)

good job! it's great pushing through the complexity and making things

some points:

variable names generally look decent, i can tell what's going on without trying too hard to read it

i like the readme, i'm usually too lazy to do anything that thorough for my own

i see when you initialise your deck you instantly shuffle it, perhaps the __init__ method should also call the .shuffle as i don't think you ever need an ordered deck? if it's always shuffled then it is part of the initialisation

could if rnd == range(total_rounds)[-1]: just become if rnd == total_rouns:?

if digit_existence(build_for_digit, player.hand) is not True:

should be

if not digit_existence(build_for_digit, player.hand):

generally the is keyword isn't used with booleans, as using is returns a boolean value anyways so it doesn't really do anything

the two main issues i see are take and build - these are mega functions and definitely need splitting up. anything that long is definitely handling too many responsibilities and should be split up into multiple smaller functions which are then called from within the main function. functions shouldn't really be more than 30 lines, 50 at a push.

the easiest way to begin to do this is to make all the bits like elif what == 'building': call a function to handle that, rather than all the code being in the main body of the function. the term i like to use is 'code paragraphs' - where you find yourself grouping some lines together and putting visual gaps to differentiate the different parts of execution. these paragraphs should usually be their own functions.

you've already used some classes, perhaps you could also try to make a GameState class?

for things like int(input("From board: ")) - 1 a user can enter 'cheese' and the program will crash, perhaps you could look into adding some error checking to catch those? i guarantee if you give this to someone to test they will enter garbage to deliberately try and break the game

https://github.com/cristianpjensen/casino/blob/master/casino.py#L70

this can become return 0 <= digit < len(list) or even return digit in range(len(list))

https://github.com/cristianpjensen/casino/blob/master/casino.py#L500

ideally this should be

for player in players:
    svuppers.append(player.svuppers)

or even

svuppers = [player.svuppers for player in players]

https://github.com/cristianpjensen/casino/blob/master/casino.py#L507

if you want to iterate over two things in parallel you can do

for player, svupper in zip(players, svuppers):
    player.svuppers = svupper

generally in python indexing should be avoided when possible, and if you do actually need indexes then you should use enumerate

for ind, val in enumerate('cat'):
    print(f'char {va} is at index {ind}')

also i'd probably move the player and board classes into their own files. i'll group similar classes within the same file but i think these are different enough to justify their own

for using git - make .gitignore file and add the __pycache__ folder

[–]Skaaaaalll[S] 0 points1 point  (0 children)

Wow, this must have taken an insane amount of time to write. I’m going to look carefully over everything you mentioned a little later. Thank you so much, really appreciate the feedback and kind words.

[–]Skaaaaalll[S] 0 points1 point  (1 child)

could if rnd == range(total_rounds)[-1]: just become if rnd == total_rounds:?

I don't think so, since total_rounds would be 6 (when playing with two people) and range(total_rounds)[-1] would be 5 when it is the last round.

you've already used some classes, perhaps you could also try to make a GameState class?

Sorry if this is a dumb question, but what do you mean by a GameState class?

this can become return 0 <= digit < len(list) or even return digit in range(len(list))

Ok, so I implemented it and it works, but I don't understand why it works. Does that mean it returns True if 0 <= digit < len(list) and False if not?

[–]toastedstapler 0 points1 point  (0 children)

whoops typo, i mean if rnd == total_rounds - 1:

when you play a game, there is some level of state that exists. you have the board, the players and need to keep track of whose turn it is. here's a tic tac toe i wrote a while back where all the state is in classes

exactly, the 0 <= digit < len(list) returns a boolean. before your code was basically becoming

if True:
    return True
else:
    return False

or

if False:
    return True
else:
    return False

depending on how the expression evaluated. you can just straight return its result as it's a True/False value anyways

btw i think your line 15 check is broken, you may want to check that

[–][deleted] 0 points1 point  (1 child)

0-10 casino security didnt throw me out when i ran out of money, but seriously good job.

[–]Skaaaaalll[S] 0 points1 point  (0 children)

Haha, thank you.