My IDE says my game class has too many instance variables. I'm curious as to how it 'should' be? I could re-implement it into a hash or maybe a struct object. But I'm not sure that makes it any better. The variables are specific state that belong to the game. Would refactoring lead to some being memoized? Maybe some variables moved into a "rule-set" struct? What patterns apply to initializing multiple variables handling state?
class TonkGame
def initialize
@max_players = 5
@min_players = 2
@players = []
@bet = 1
@tonk = Game.new
@face_up = []
@turn = nil
@over = false
@round = 0
end
# ...
end
Just thinking out loud... I could have a GameTable object which contains no rules but would be a sensible object to hold players seated and cards in the center of the table.
A Player object could hold a default bet. Player already hold cards in hand.
turn, round , and over are specific game states. Possibly leave these alone?
min and max players could possibly go into a simple rule-set struct.
I seem to just be shuffling things around. Is that good? Many things to consider.