Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/thread-self/root/lib64/python2.7/Demo/tkinter/guido/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/lib64/python2.7/Demo/tkinter/guido/solitaire.pyc

�
Afc@sCdZddlZddlZddlTddlmZmZmZmZdefd��YZdZ	dZ
d	Ze	d
eZe
deZ
dZd
ZdZdZdZdZdZdZiZxeefD]Zeee<q�WxeefD]Zeee<q�Wej�Zee�ZdZdZdZdZe dd�Z!ee!�Z"ddge#e$e d
d��dddgZ%dZ&dd0d ��YZ'd!d1d"��YZ(d#e(fd$��YZ)d%�Z*d&e(fd'��YZ+d(e+fd)��YZ,d*e+fd+��YZ-d,d2d-��YZ.d.�Z/e0d/kr?e/�ndS(3s�Solitaire game, much like the one that comes with MS Windows.

Limitations:

- No cute graphical images for the playing cards faces or backs.
- No scoring or timer.
- No undo.
- No option to turn 3 cards at a time.
- No keyboard shortcuts.
- Less fancy animation when you win.
- The determination of which stack you drag to is more relaxed.

Apology:

I'm not much of a card player, so my terminology in these comments may
at times be a little unusual.  If you have suggestions, please let me
know!

i����N(t*(t	Rectanglet
CanvasTexttGrouptWindowRcBseZddd�ZRS(cCs|jj|j||�S(N(tcanvasttag_bindtid(tselftsequencetcommand((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytbind%sN(t__name__t
__module__tNoneR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR$sidi�i
iiis#070tHearttDiamondtClubtSpadetredtblackiiii
ittAtJtQtKitCardcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(s�A playing card.

    A card doesn't record to which stack it belongs; only the stack
    records this (it turns out that we always know this from the
    context, and this saves a ``double update'' with potential for
    inconsistencies).

    Public methods:

    moveto(x, y) -- move the card to an absolute position
    moveby(dx, dy) -- move the card by a relative offset
    tkraise() -- raise the card to the top of its stack
    showface(), showback() -- turn the card face up or down & raise it

    Public read-only instance variables:

    suit, value, color -- the card's suit, value and color
    face_shown -- true when the card is shown face up, else false

    Semi-public read-only instance variables (XXX should be made
    private):

    group -- the Canvas.Group representing the card
    x, y -- the position of the card's top left corner

    Private instance variables:

    __back, __rect, __text -- the canvas items making up the card

    (To show the card face up, the text item is placed in front of
    rect and the back is placed behind it.  To show it face down, this
    is reversed.  The card is created face down.)

    c
Cs||_||_t||_d|_d|_|_t|�|_dt	||f}t
|tdddtd|jd|�|_
|jj|j
�t|ddttdddd	�|_|jj|j�t|ttttttdddd
�|_|jj|j�dS(sCard constructor.

        Arguments are the card's suit and value, and the canvas widget.

        The card is created at position (0, 0), with its face down
        (adding it to a stack will position it according to that
        stack's rules).

        is%s  %sitanchortfillttexttoutlineRtwhitetblueN(tsuittvaluetCOLORtcolort
face_showntxtyRtgrouptVALNAMESRt	CARDWIDTHtNt_Card__texttaddtag_withtagRt
CARDHEIGHTt_Card__recttMARGINt_Card__back(RR!R"RR((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyt__init__�s"
		
	cCsd|j|jfS(s+Return a string for debug print statements.sCard(%r, %r)(R!R"(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyt__repr__�scCs"|j||j||j�dS(s*Move the card to absolute position (x, y).N(tmovebyR&R'(RR&R'((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytmoveto�scCs7|j||_|j||_|jj||�dS(sMove the card by (dx, dy).N(R&R'R(tmove(Rtdxtdy((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR4�scCs|jj�dS(s5Raise the card above all other objects in its canvas.N(R(ttkraise(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR9�scCs1|j�|jj�|jj�d|_dS(sTurn the card's face up.iN(R9R/R,R%(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytshowface�s


cCs1|j�|jj�|jj�d|_dS(sTurn the card's face down.iN(R9R/R1R%(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytshowback�s


(
RR
t__doc__R2R3R5R4R9R:R;(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRss#	 					tStackcBs�eZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�ZdZd�Zd�Zd�ZRS(s�A generic stack of cards.

    This is used as a base class for all other stacks (e.g. the deck,
    the suit stacks, and the row stacks).

    Public methods:

    add(card) -- add a card to the stack
    delete(card) -- delete a card from the stack
    showtop() -- show the top card (if any) face up
    deal() -- delete and return the top card, or None if empty

    Method that subclasses may override:

    position(card) -- move the card to its proper (x, y) position

        The default position() method places all cards at the stack's
        own (x, y) position.

    userclickhandler(), userdoubleclickhandler() -- called to do
    subclass specific things on single and double clicks

        The default user (single) click handler shows the top card
        face up.  The default user double click handler calls the user
        single click handler.

    usermovehandler(cards) -- called to complete a subpile move

        The default user move handler moves all moved cards back to
        their original position (by calling the position() method).

    Private methods:

    clickhandler(event), doubleclickhandler(event),
    motionhandler(event), releasehandler(event) -- event handlers

        The default event handlers turn the top card of the stack with
        its face up on a (single or double) click, and also support
        moving a subpile around.

    startmoving(event) -- begin a move operation
    finishmoving() -- finish a move operation

    cCs�||_||_||_g|_t|jj�|_|jjd|j�|jjd|j	�|jjd|j
�|jjd|j�|j�dS(sStack constructor.

        Arguments are the stack's nominal x and y position (the top
        left corner of the first card placed in the stack), and the
        game object (which is used to get the canvas; subclasses use
        the game object to find other stacks).

        s<1>s
<Double-1>s<B1-Motion>s<ButtonRelease-1>N(
R&R'tgametcardsRRR(Rtclickhandlertdoubleclickhandlert
motionhandlertreleasehandlert
makebottom(RR&R'R>((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR2s					cCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRDscCsd|jj|j|jfS(s+Return a string for debug print statements.s
%s(%d, %d)(t	__class__RR&R'(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR3scCs>|jj|�|j�|j|�|jj|j�dS(N(R?tappendR9tpositionR(R-(Rtcard((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytadd%s

cCs'|jj|�|jj|j�dS(N(R?tremoveR(tdtag(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytdelete+scCs!|jr|jdj�ndS(Ni����(R?R:(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytshowtop/s	cCs+|js
dS|jd}|j|�|S(Ni����(R?RRL(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytdeal3s
	

cCs|j|j|j�dS(N(R5R&R'(RRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRG<scCs|j�dS(N(RM(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytuserclickhandler?scCs|j�dS(N(RO(R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytuserdoubleclickhandlerBscCs"x|D]}|j|�qWdS(N(RG(RR?RH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytusermovehandlerEs
cCs%|j�|j�|j|�dS(N(tfinishmovingROtstartmoving(Rtevent((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR@Ks

cCs|j|�dS(N(t
keepmoving(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRBPscCs|j|�|j�dS(N(RURR(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRCSs
cCs%|j�|j�|j|�dS(N(RRRPRS(RRT((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRAWs

cCs�d|_|jjjd�}xDtt|j��D])}|j|}|jj	|kr4Pq4q4WdS|j
srdS|j||_|j|_|j
|_x|jD]}|j�q�WdS(Ntcurrent(RtmovingR>RtgettagstrangetlenR?R(ttagR%R&tlastxR'tlastyR9(RRTttagstiRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRS`s	
	cCs||js
dS|j|j}|j|j}|j|_|j|_|sQ|rxx$|jD]}|j||�q[WndS(N(RWR&R\R'R]R4(RRTR7R8RH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRUqs	cCs,|j}d|_|r(|j|�ndS(N(RWRRQ(RR?((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRR|s		N(RR
R<RR2RDR3RIRLRMRNRGRORPRQR@RBRCRARWRSRURR(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR=�s(-																	tDeckcBs2eZdZd�Zd�Zd�Zd�ZRS(s7The deck is a stack with support for shuffling.

    New methods:

    fill() -- create the playing cards
    shuffle() -- shuffle the playing cards

    A single click moves the top card to the game's open deck and
    moves it face up; if we're out of cards, it moves the open deck
    back to the deck.

    c
CsRt|jj|j|j|jt|jtdddt�}|jj	|�dS(NRRR(
RR>RR&R'R*R.t
BACKGROUNDR(R-(Rtbottom((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRD�s
cCsEx>tD]6}x-tD]%}|jt|||jj��qWqWdS(N(tALLSUITSt	ALLVALUESRIRR>R(RR!R"((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR�s

cCsMt|j�}g}x(t|�D]}|j|j|�q"W||_dS(N(RZR?trandpermRF(RtntnewcardsR_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytshuffle�s
cCsv|jj}|j�}|sUxQ|j�}|s7Pn|j|�|j�q!Wn|jjj|�|j�dS(N(R>topendeckRNRIR;R:(RRiRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRO�s
(RR
R<RDRRhRO(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR`�s

			cCsLt|�}g}x3|rGtj|�}|j|�|j|�qW|S(s4Function returning a random permutation of range(n).(RYtrandomtchoiceRFRJ(RftrR&R_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRe�s	
t	OpenStackcBs#eZd�Zd�Zd�ZRS(cCsdS(Ni((RR?((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyt
acceptable�scCs�|d}|jj|�}|s?||ks?|j|�rRtj||�n8x(|D] }|j|�|j|�qYW|jj�dS(Ni(R>tcloseststackRnR=RQRLRItwincheck(RR?RHtstack((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRQ�s
#

cCs�|js
dS|jd}|js1|j�dSxQ|jjD]C}|j|g�r>|j|�|j|�|jj�Pq>q>WdS(Ni����(	R?R%ROR>tsuitsRnRLRIRp(RRHts((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRP�s	
	



(RR
RnRQRP(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRm�s		t	SuitStackcBs,eZd�Zd�Zd�Zd�ZRS(c
CsBt|jj|j|j|jt|jtdddd�}dS(NRRRR(RR>RR&R'R*R.(RRb((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRD�scCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRO�scCsdS(N((R((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRP�scCsit|�dkrdS|d}|js6|jtkS|jd}|j|jkoh|j|jdkS(Niii����(RZR?R"tACER!(RR?RHttopcard((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRn�s
	

(RR
RDRORPRn(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRt�s			tRowStackcBseZd�Zd�ZRS(cCs`|d}|js |jtkS|jd}|js:dS|j|jko_|j|jdkS(Nii����i(R?R"tKINGR%R$(RR?RHRv((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRn�s
	

	cCsh|j}xE|jD]:}||kr)Pn|jrC|dt}q|t}qW|j|j|�dS(Ni(R'R?R%R0tOFFSETR5R&(RRHR'tc((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRGs		(RR
RnRG(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRw�s		t	SolitairecBsGeZd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs�||_t|jdtdddttddtdt�|_|jjdt	d	t
�t|jd
ddddtdd
d|j�|_
t|jtdtdd|j
dt�t}t}t|||�|_|t}t|||�|_|t}g|_x:tt�D],}|t}|jjt|||��qWt}|t}g|_x:tt�D],}|jjt|||��|t}qoW|jg|j|j|_|jj�|j�dS(Nt
backgroundthighlightthicknessitwidththeightiiRtexpandRtDealtactivebackgroundtgreenR
twindowR(tmastertCanvasRatNROWStXSPACINGtYSPACINGR0RtpacktBOTHtTRUEtButtonRNt
dealbuttonRtSWR`tdeckRmRiRrRYtNSUITSRFRttrowsRwt
openstacksR(RR�R&R'R_((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR2sD	


	
 
	
cCsEx*|jD]}t|j�tkr
dSq
W|j�|j�dS(N(RrRZR?tNVALUEStwinRN(RRs((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRp=s

cCsgg}x|jD]}||j}qWx9|rbtj|�}|j|�|j||j�q*WdS(sStupid animation when you win.N(R�R?RjRkRJtanimatedmovetoR�(RR?RsRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR�Ds	
cCsgx`tddd�D]L}|j|j||j|j|}}|j||�|jj�qWdS(Ni
ii����(RYR&R'R4R�tupdate_idletasks(RRHtdestR_R7R8((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR�Ns)cCsed}d}xR|jD]G}|j|jd|j|jd}||kr|}|}qqW|S(Ni�ɚ;i(RR�R&R'(RRHtclosesttcdistRqtdist((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRoTs&
cCs�|j�|jj�xHtt�D]:}x1|j|D]"}|jj�}|j|�q8Wq$Wx|jD]}|j�qlWdS(N(	tresetR�RhRYR�R�RNRIRM(RR_RlRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyRN`s

cCsOxH|jD]=}x4|j�}|s)Pn|jj|�|j�qWq
WdS(N(R�RNR�RIR;(RRqRH((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR�js(	RR
R2RpR�R�RoRNR�(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyR{
s	.		
			
cCs6t�}t|�}|jd|j�|j�dS(NtWM_DELETE_WINDOW(tTkR{tprotocoltquittmainloop(trootR>((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pytmainvs	t__main__((((1R<tmathRjtTkinterR�RRRRR*R.R0R�R�RyRatHEARTStDIAMONDStCLUBStSPADEStREDtBLACKR#RstkeysRcRZR�RutJACKtQUEENRxRYRdR�tmaptstrR)R�RR=R`ReRmRtRwR{R�R(((s4/usr/lib64/python2.7/Demo/tkinter/guido/solitaire.pyt<module>sX
"
/f�1	i	

Hacked By AnonymousFox1.0, Coded By AnonymousFox