MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/580811_Uno_TextBased/recipe-580811.py:739–800  ·  view source on GitHub ↗
(self, gs)

Source from the content-addressed store, hash-verified

737
738
739 def __init__(self, gs):
740 ### Decks ###
741 self.deck = Deck(True)
742 self.pile = Deck(False)
743
744 ### Player Information ###
745 self.players = gs.players
746 self.turnList = []
747 self.handTitles = {'play1':'','play2':'','play3':'','play4':''}
748
749 ### Carry Information ###
750 self.displayEffects = gs.displayEffects
751 self.hideComputerHands = gs.hideComputerHands
752 self.zeroChange = gs.zeroChange
753 self.computerSpeed = self.speeds[gs.computerSpeed]
754 self.simulation = gs.computerSimulation
755
756 ### Data ###
757 self.handPosition = 0 # For hand displays
758 self.drawAmount = 0 # Used for force draws
759 self.passes = 0 # Keep track of consecutive passes for emergency color change
760 self.passMax = 0 # Max passes before color change
761 self.turn = '' # Current turn
762 self.event = '' # Wild, Reverse, Skip, etc
763 self.wildColorChange = '' # Specifies color to change wild card to
764 self.currentColor = '' # Current color
765 self.currentValue = '' # Current value
766 self.winnerID = '' # ID of Player who Won
767 self.reverse = False # Is turn order reversed
768 self.turnComplete = False # Is turn complete
769 self.matchComplete = False # Is the Game over?
770 self.matchAbort = False # Did the match conclude without a winner?
771 self.forcedWild = False # Force change wild
772
773 ### Initialize Names / Cards / Deck (Assuming New Game) ###
774 self.elements = dict(self.elementsInit)
775
776 keyStringName = 'P{}Name'
777 keyStringCards = 'P{}Cards'
778
779 for i in self.players:
780 self.elements[keyStringName.format(i[-1])] = self.players[i].getName()+(' '*(11-len(self.players[i].getName())))
781 self.elements[keyStringCards.format(i[-1])] = ' '+(' '*(3-len(str(self.players[i].getCardNum()))))+str(self.players[i].getCardNum())+' Cards'
782
783 self.elements['DNum'] = len(self.deck)
784
785 if len(str(len(self.deck))) < 2:
786 self.elements['PostDNum'] = '\t'
787
788 j = 8
789 for i in range(int(math.ceil(len(self.deck)/12))):
790 self.elements['Deck'][j] = '='
791 j -= 1
792
793 for key in GameSettings.playerIdentities:
794 try:
795 self.buildHandString(key)
796 self.turnList += [key]

Callers

nothing calls this directly

Calls 8

buildHandStringMethod · 0.95
strFunction · 0.85
rangeFunction · 0.85
getCardNumMethod · 0.80
DeckClass · 0.70
dictFunction · 0.50
formatMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected