MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / getHeadStr

Method getHeadStr

src/gamesbyexample/ducklings.py:88–138  ·  view source on GitHub ↗

Returns the string of the duckling's head.

(self)

Source from the content-addressed store, hash-verified

86 self.partToDisplayNext = HEAD
87
88 def getHeadStr(self):
89 """Returns the string of the duckling's head."""
90 headStr = ''
91 if self.direction == LEFT:
92 # Get the mouth:
93 if self.mouth == OPEN:
94 headStr += '>'
95 elif self.mouth == CLOSED:
96 headStr += '='
97
98 # Get the eyes:
99 if self.eyes == BEADY and self.body == CHUBBY:
100 headStr += '"'
101 elif self.eyes == BEADY and self.body == VERY_CHUBBY:
102 headStr += '" '
103 elif self.eyes == WIDE:
104 headStr += "''"
105 elif self.eyes == HAPPY:
106 headStr += '^^'
107 elif self.eyes == ALOOF:
108 headStr += '``'
109
110 headStr += ') ' # Get the back of the head.
111
112 if self.direction == RIGHT:
113 headStr += ' (' # Get the back of the head.
114
115 # Get the eyes:
116 if self.eyes == BEADY and self.body == CHUBBY:
117 headStr += '"'
118 elif self.eyes == BEADY and self.body == VERY_CHUBBY:
119 headStr += ' "'
120 elif self.eyes == WIDE:
121 headStr += "''"
122 elif self.eyes == HAPPY:
123 headStr += '^^'
124 elif self.eyes == ALOOF:
125 headStr += '``'
126
127 # Get the mouth:
128 if self.mouth == OPEN:
129 headStr += '<'
130 elif self.mouth == CLOSED:
131 headStr += '='
132
133 if self.body == CHUBBY:
134 # Get an extra space so chubby ducklings are the same
135 # width as very chubby ducklings.
136 headStr += ' '
137
138 return headStr
139
140 def getBodyStr(self):
141 """Returns the string of the duckling's body."""

Callers 1

getNextBodyPartMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected