Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
turtledemo.nim.NimView Class Reference
Inheritance diagram for turtledemo.nim.NimView:
Inheritance graph
[legend]
Collaboration diagram for turtledemo.nim.NimView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def display
def setup
def notify_move
def notify_over
def clear

Public Attributes

 game
 screen
 model
 writer
 sticks
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Definition at line 116 of file nim.py.


Constructor & Destructor Documentation

def turtledemo.nim.NimView.__init__ (   self,
  game 
)

Definition at line 117 of file nim.py.

00117 
00118     def __init__(self, game):
00119         self.game = game
00120         self.screen = game.screen
00121         self.model = game.model
00122         self.screen.colormode(255)
00123         self.screen.tracer(False)
00124         self.screen.bgcolor((240, 240, 255))
00125         self.writer = turtle.Turtle(visible=False)
00126         self.writer.pu()
00127         self.writer.speed(0)
00128         self.sticks = {}
00129         for row in range(3):
00130             for col in range(MAXSTICKS):
00131                 self.sticks[(row, col)] = Stick(row, col, game)
00132         self.display("... a moment please ...")
00133         self.screen.tracer(True)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 180 of file nim.py.

00180 
00181     def clear(self):
00182         if self.game.state == Nim.OVER:
00183             self.screen.clear()

def turtledemo.nim.NimView.display (   self,
  msg1,
  msg2 = None 
)

Definition at line 134 of file nim.py.

00134 
00135     def display(self, msg1, msg2=None):
00136         self.screen.tracer(False)
00137         self.writer.clear()
00138         if msg2 is not None:
00139             self.writer.goto(0, - SCREENHEIGHT // 2 + 48)
00140             self.writer.pencolor("red")
00141             self.writer.write(msg2, align="center", font=("Courier",18,"bold"))
00142         self.writer.goto(0, - SCREENHEIGHT // 2 + 20)
00143         self.writer.pencolor("black")
00144         self.writer.write(msg1, align="center", font=("Courier",14,"bold"))
00145         self.screen.tracer(True)
00146 

Here is the caller graph for this function:

def turtledemo.nim.NimView.notify_move (   self,
  row,
  col,
  maxspalte,
  player 
)

Definition at line 158 of file nim.py.

00158 
00159     def notify_move(self, row, col, maxspalte, player):
00160         if player == 0:
00161             farbe = HCOLOR
00162             for s in range(col, maxspalte):
00163                 self.sticks[(row, s)].color(farbe)
00164         else:
00165             self.display(" ... thinking ...         ")
00166             time.sleep(0.5)
00167             self.display(" ... thinking ... aaah ...")
00168             farbe = COLOR
00169             for s in range(maxspalte-1, col-1, -1):
00170                 time.sleep(0.2)
00171                 self.sticks[(row, s)].color(farbe)
00172             self.display("Your turn! Click leftmost stick to remove.")

Here is the call graph for this function:

Definition at line 173 of file nim.py.

00173 
00174     def notify_over(self):
00175         if self.game.model.winner == 0:
00176             msg2 = "Congrats. You're the winner!!!"
00177         else:
00178             msg2 = "Sorry, the computer is the winner."
00179         self.display("To play again press space bar. To leave press ESC.", msg2)

Here is the call graph for this function:

Definition at line 147 of file nim.py.

00147 
00148     def setup(self):
00149         self.screen.tracer(False)
00150         for row in range(3):
00151             for col in range(self.model.sticks[row]):
00152                 self.sticks[(row, col)].color(SCOLOR)
00153         for row in range(3):
00154             for col in range(self.model.sticks[row], MAXSTICKS):
00155                 self.sticks[(row, col)].color("white")
00156         self.display("Your turn! Click leftmost stick to remove.")
00157         self.screen.tracer(True)

Here is the call graph for this function:


Member Data Documentation

Definition at line 118 of file nim.py.

Definition at line 120 of file nim.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 119 of file nim.py.

Definition at line 127 of file nim.py.

Definition at line 124 of file nim.py.


The documentation for this class was generated from the following file: