Next: , Previous: , Up: Top   [Contents][Index]


7 Module field

This chapter describes the field module in detail, but most of the time you don’t have to know much more than that you can access theyr contents like lists.

7.1 Field class

The Field class is one field at the Map. It holds all objects that are on one position on a Map. It inherits from list and you can access t just like a list. A field has a __str__ and a color method that returns the values of the Obj on top of the Field.

7.1.1 methods

Here are all methods defined in Field. Note that Field inherits from list and has alle the methods from list.

7.1.1.1 __init__/constructor

This method takes two needed and one optional argument. The two needed are the coordinates this Field represents. The optional is a str that is returned by __str__ if there is no Obj on the Field.

7.1.1.2 uppest

This method returns the Obj on top of the Field or None, if the Field is empty.

7.1.1.3 __str__

This returns the str of the Obj on top of the Field. So the field looks like the Obj on top of it. If there is no Obj on the Field it returns self.defstr. See Field.defstr.

7.1.1.4 color

THis method returns the color of the Obj on top of the Field. So the field looks like the Obj on top of it. If there is no Obj on the Field it returns cursgame.color.WHITE. See colors.

7.1.1.5 __repr__

This returns the representation in the form Field([contents of field...]).

7.1.2 attributes

Here are all the important attributes of Field

7.1.2.1 x/y

These are the coordinates where the Field is.

7.1.2.2 defstr

This is the string that is used for the Field if it’s empty. You can change it at runtime.


Next: , Previous: , Up: Top   [Contents][Index]