Completed
Branch docs (a64d16)
by Kyle
01:29
created

Dice.__getattr__()   A

Complexity

Conditions 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
1
"""This module handles backward compatibility with the ctypes libtcodpy module.
2
"""
3
4
from __future__ import absolute_import as _
5
6
import threading as _threading
7
8
from tcod.libtcod import *
0 ignored issues
show
Coding Style introduced by
The usage of wildcard imports like tcod.libtcod should generally be avoided.
Loading history...
Unused Code introduced by
BKGND_ALPHA was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
FOV_PERMISSIVE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
BKGND_ADDALPHA was imported with wildcard, but is not used.
Loading history...
9
10
from tcod.tcod import _int, _cdata, _bytes, _unicode, _unpack_char_p
11
from tcod.tcod import _CDataWrapper
12
from tcod.tcod import _PropagateException
13
from tcod.tcod import BSP as Bsp
14
from tcod.tcod import Color, Key, Mouse, HeightMap
15
16
class ConsoleBuffer(object):
17
    """Simple console that allows direct (fast) access to cells. simplifies
18
    use of the "fill" functions.
19
    """
20
    def __init__(self, width, height, back_r=0, back_g=0, back_b=0, fore_r=0, fore_g=0, fore_b=0, char=' '):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (108/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
21
        """initialize with given width and height. values to fill the buffer
22
        are optional, defaults to black with no characters.
23
        """
24
        n = width * height
0 ignored issues
show
Unused Code introduced by
The variable n seems to be unused.
Loading history...
25
        self.width = width
26
        self.height = height
27
        self.clear(back_r, back_g, back_b, fore_r, fore_g, fore_b, char)
28
29
    def clear(self, back_r=0, back_g=0, back_b=0, fore_r=0, fore_g=0, fore_b=0, char=' '):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (90/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
30
        """clears the console. values to fill it with are optional, defaults
31
        to black with no characters.
32
        """
33
        n = self.width * self.height
34
        self.back_r = [back_r] * n
35
        self.back_g = [back_g] * n
36
        self.back_b = [back_b] * n
37
        self.fore_r = [fore_r] * n
38
        self.fore_g = [fore_g] * n
39
        self.fore_b = [fore_b] * n
40
        self.char = [ord(char)] * n
41
42
    def copy(self):
43
        """returns a copy of this ConsoleBuffer."""
44
        other = ConsoleBuffer(0, 0)
45
        other.width = self.width
46
        other.height = self.height
47
        other.back_r = list(self.back_r)  # make explicit copies of all lists
0 ignored issues
show
Coding Style introduced by
The attribute back_r was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
48
        other.back_g = list(self.back_g)
0 ignored issues
show
Coding Style introduced by
The attribute back_g was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
49
        other.back_b = list(self.back_b)
0 ignored issues
show
Coding Style introduced by
The attribute back_b was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
50
        other.fore_r = list(self.fore_r)
0 ignored issues
show
Coding Style introduced by
The attribute fore_r was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
51
        other.fore_g = list(self.fore_g)
0 ignored issues
show
Coding Style introduced by
The attribute fore_g was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
52
        other.fore_b = list(self.fore_b)
0 ignored issues
show
Coding Style introduced by
The attribute fore_b was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
53
        other.char = list(self.char)
0 ignored issues
show
Coding Style introduced by
The attribute char was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
54
        return other
55
56
    def set_fore(self, x, y, r, g, b, char):
57
        """set the character and foreground color of one cell."""
58
        i = self.width * y + x
59
        self.fore_r[i] = r
60
        self.fore_g[i] = g
61
        self.fore_b[i] = b
62
        self.char[i] = ord(char)
63
64
    def set_back(self, x, y, r, g, b):
65
        """set the background color of one cell."""
66
        i = self.width * y + x
67
        self.back_r[i] = r
68
        self.back_g[i] = g
69
        self.back_b[i] = b
70
71
    def set(self, x, y, back_r, back_g, back_b, fore_r, fore_g, fore_b, char):
72
        """set the background color, foreground color and character of one cell."""
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (83/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
73
        i = self.width * y + x
74
        self.back_r[i] = back_r
75
        self.back_g[i] = back_g
76
        self.back_b[i] = back_b
77
        self.fore_r[i] = fore_r
78
        self.fore_g[i] = fore_g
79
        self.fore_b[i] = fore_b
80
        self.char[i] = ord(char)
81
82
    def blit(self, dest, fill_fore=True, fill_back=True):
83
        """use libtcod's "fill" functions to write the buffer to a console."""
84
        if (console_get_width(dest) != self.width or
85
            console_get_height(dest) != self.height):
86
            raise ValueError('ConsoleBuffer.blit: Destination console has an incorrect size.')
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (94/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
87
88
        if fill_back:
89
            lib.TCOD_console_fill_background(dest or ffi.NULL,
90
                                              ffi.new('int[]', self.back_r),
91
                                              ffi.new('int[]', self.back_g),
92
                                              ffi.new('int[]', self.back_b))
93
        if fill_fore:
94
            lib.TCOD_console_fill_foreground(dest or ffi.NULL,
95
                                              ffi.new('int[]', self.fore_r),
96
                                              ffi.new('int[]', self.fore_g),
97
                                              ffi.new('int[]', self.fore_b))
98
            lib.TCOD_console_fill_char(dest or ffi.NULL,
99
                                        ffi.new('int[]', self.char))
100
101
class Dice(_CDataWrapper):
102
    """
103
    
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
104
    .. versionchanged:: 2.0
105
       This class has been standardized to behave like other CData wrapped
106
       classes.  This claas no longer acts like a list.
107
    """
108
109
    def __init__(self, *args, **kargs):
110
        super(Dice, self).__init__(*args, **kargs)
111
        if self.cdata == ffi.NULL:
112
            self._init(*args, **kargs)
113
114
    def _init(self, nb_dices, nb_faces, multiplier, addsub):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
115
        self.cdata = ffi.new('TCOD_dice_t*')
116
        self.nb_dices = nb_dices
117
        self.nb_faces = nb_faces
118
        self.multiplier = multiplier
119
        self.addsub = addsub
120
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
121
    def __getattr__(self, attr):
122
        if attr == 'nb_dices':
123
            attr = 'nb_faces'
124
        return super(Dice, self).__getattr__(attr)
125
        
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
126
    def __setattr__(self, attr, value):
127
        if attr == 'nb_dices':
128
            attr = 'nb_faces'
129
        return super(Dice, self).__setattr__(attr, value)
130
131
    def __repr__(self):
132
        return "<%s(%id%ix%s+(%s))>" % (self.__class__.__name__,
133
                                        self.nb_dices, self.nb_faces,
134
                                        self.multiplier, self.addsub)
135
136
def bsp_new_with_size(x, y, w, h):
137
    """Create a new :any:`BSP` instance with the given rectangle.
138
139
    :param int x: rectangle left coordinate
140
    :param int y: rectangle top coordinate
141
    :param int w: rectangle width
142
    :param int h: rectangle height
143
    :rtype: BSP
144
145
    .. deprecated:: 2.0
146
       Calling the :any:`BSP` class instead.
147
    """
148
    return Bsp(x, y, w, h)
149
150
def bsp_split_once(node, horizontal, position):
151
    """
152
    .. deprecated:: 2.0
153
       Use :any:`BSP.split_once` instead.
154
    """
155
    node.split_once('h' if horizontal else 'v', position)
156
157
def bsp_split_recursive(node, randomizer, nb, minHSize, minVSize, maxHRatio,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
158
                        maxVRatio):
159
    node.split_recursive(nb, minHSize, minVSize,
160
                         maxHRatio, maxVRatio, randomizer)
161
162
def bsp_resize(node, x, y, w, h):
163
    """
164
    .. deprecated:: 2.0
165
       Use :any:`BSP.resize` instead.
166
    """
167
    node.resize(x, y, w, h)
168
169
def bsp_left(node):
170
    """
171
    .. deprecated:: 2.0
172
       Use :any:`BSP.get_left` instead.
173
    """
174
    return node.get_left()
175
176
def bsp_right(node):
177
    """
178
    .. deprecated:: 2.0
179
       Use :any:`BSP.get_right` instead.
180
    """
181
    return node.get_right()
182
183
def bsp_father(node):
184
    """
185
    .. deprecated:: 2.0
186
       Use :any:`BSP.get_parent` instead.
187
    """
188
    return node.get_parent()
189
190
def bsp_is_leaf(node):
191
    """
192
    .. deprecated:: 2.0
193
       Use :any:`BSP.is_leaf` instead.
194
    """
195
    return node.is_leaf()
196
197
def bsp_contains(node, cx, cy):
198
    """
199
    .. deprecated:: 2.0
200
       Use :any:`BSP.contains` instead.
201
    """
202
    return node.contains(cx, cy)
203
204
def bsp_find_node(node, cx, cy):
205
    """
206
    .. deprecated:: 2.0
207
       Use :any:`BSP.find_node` instead.
208
    """
209
    return node.find_node(cx, cy)
210
211
def _bsp_traverse(node, func, callback, userData):
212
    """pack callback into a handle for use with the callback
213
    _pycall_bsp_callback
214
    """
215
    with _PropagateException() as propagate:
216
        handle = ffi.new_handle((callback, userData, propagate))
217
        func(node.cdata, lib._pycall_bsp_callback, handle)
218
219
def bsp_traverse_pre_order(node, callback, userData=0):
220
    """Traverse this nodes hierarchy with a callback.
221
222
    .. deprecated:: 2.0
223
       Use :any:`BSP.walk` instead.
224
    """
225
    _bsp_traverse(node, lib.TCOD_bsp_traverse_pre_order, callback, userData)
226
227
def bsp_traverse_in_order(node, callback, userData=0):
228
    """Traverse this nodes hierarchy with a callback.
229
230
    .. deprecated:: 2.0
231
       Use :any:`BSP.walk` instead.
232
    """
233
    _bsp_traverse(node, lib.TCOD_bsp_traverse_in_order, callback, userData)
234
235
def bsp_traverse_post_order(node, callback, userData=0):
236
    """Traverse this nodes hierarchy with a callback.
237
238
    .. deprecated:: 2.0
239
       Use :any:`BSP.walk` instead.
240
    """
241
    _bsp_traverse(node, lib.TCOD_bsp_traverse_post_order, callback, userData)
242
243
def bsp_traverse_level_order(node, callback, userData=0):
244
    """Traverse this nodes hierarchy with a callback.
245
246
    .. deprecated:: 2.0
247
       Use :any:`BSP.walk` instead.
248
    """
249
    _bsp_traverse(node, lib.TCOD_bsp_traverse_level_order, callback, userData)
250
251
def bsp_traverse_inverted_level_order(node, callback, userData=0):
252
    """Traverse this nodes hierarchy with a callback.
253
254
    .. deprecated:: 2.0
255
       Use :any:`BSP.walk` instead.
256
    """
257
    _bsp_traverse(node, lib.TCOD_bsp_traverse_inverted_level_order,
258
                  callback, userData)
259
260
def bsp_remove_sons(node):
261
    """Delete all children of a given node.  Not recommended.
262
263
    .. note::
264
       This function will add unnecessary complexity to your code.
265
       Don't use it.
266
267
    .. deprecated:: 2.0
268
       BSP deletion is automatic.
269
    """
270
    node._invalidate_children()
271
    lib.TCOD_bsp_remove_sons(node.cdata)
272
273
def bsp_delete(node):
0 ignored issues
show
Unused Code introduced by
The argument node seems to be unused.
Loading history...
274
    """Exists for backward compatibility.  Does nothing.
275
276
    BSP's created by this library are automatically garbage collected once
277
    there are no references to the tree.
278
    This function exists for backwards compatibility.
279
280
    .. deprecated:: 2.0
281
       BSP deletion is automatic.
282
    """
283
    pass
284
285
def color_lerp(c1, c2, a):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
286
    return Color.from_cdata(lib.TCOD_color_lerp(c1, c2, a))
287
288
def color_set_hsv(c, h, s, v):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
289
    tcod_color = ffi.new('TCOD_color_t *', c)
290
    lib.TCOD_color_set_HSV(tcod_color, h, s, v)
291
    c[0:3] = tcod_color.r, tcod_color.g, tcod_color.b
292
293
def color_get_hsv(c):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
294
    h = ffi.new('float *')
295
    s = ffi.new('float *')
296
    v = ffi.new('float *')
297
    lib.TCOD_color_get_HSV(c, h, s, v)
298
    return h[0], s[0], v[0]
299
300
def color_scale_HSV(c, scoef, vcoef):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
301
    tcod_color = ffi.new('TCOD_color_t *', c)
302
    lib.TCOD_color_scale_HSV(tcod_color, scoef, vcoef)
303
    c[0:3] = tcod_color.r, tcod_color.g, tcod_color.b
304
305
def color_gen_map(colors, indexes):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
306
    ccolors = ffi.new('TCOD_color_t[]', colors)
307
    cindexes = ffi.new('int[]', indexes)
308
    cres = ffi.new('TCOD_color_t[]', max(indexes) + 1)
309
    lib.TCOD_color_gen_map(cres, len(colors), ccolors, cindexes)
310
    return [Color.from_cdata(cdata) for cdata in cres]
311
312
_numpy = None
313
314
def _numpy_available():
315
    'check if numpy is available and lazily load it when needed'
316
    global _numpy
317
    if _numpy is None:
318
        try:
319
            import numpy as _numpy
0 ignored issues
show
Comprehensibility Bug introduced by
_numpy is re-defining a name which is already available in the outer-scope (previously defined on line 312).

It is generally a bad practice to shadow variables from the outer-scope. In most cases, this is done unintentionally and might lead to unexpected behavior:

param = 5

class Foo:
    def __init__(self, param):   # "param" would be flagged here
        self.param = param
Loading history...
320
        except ImportError:
321
            _numpy = False
322
    return _numpy
323
324
# initializing the console
325
def console_init_root(w, h, title, fullscreen=False,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
326
                      renderer=RENDERER_SDL):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'RENDERER_SDL'
Loading history...
327
    lib.TCOD_console_init_root(w, h, _bytes(title), fullscreen, renderer)
328
    return None # root console is None
329
330
331
def console_set_custom_font(fontFile, flags=FONT_LAYOUT_ASCII_INCOL,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'FONT_LAYOUT_ASCII_INCOL'
Loading history...
332
                            nb_char_horiz=0, nb_char_vertic=0):
333
    lib.TCOD_console_set_custom_font(_bytes(fontFile), flags,
334
                                     nb_char_horiz, nb_char_vertic)
335
336
337
def console_get_width(con):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
338
    return lib.TCOD_console_get_width(con or ffi.NULL)
339
340
def console_get_height(con):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
341
    return lib.TCOD_console_get_height(con or ffi.NULL)
342
343
def console_map_ascii_code_to_font(asciiCode, fontCharX, fontCharY):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
344
    lib.TCOD_console_map_ascii_code_to_font(_int(asciiCode), fontCharX,
345
                                                              fontCharY)
346
347
def console_map_ascii_codes_to_font(firstAsciiCode, nbCodes, fontCharX,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
348
                                    fontCharY):
349
    lib.TCOD_console_map_ascii_codes_to_font(_int(firstAsciiCode), nbCodes,
350
                                              fontCharX, fontCharY)
351
352
def console_map_string_to_font(s, fontCharX, fontCharY):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
353
    lib.TCOD_console_map_string_to_font_utf(_unicode(s), fontCharX, fontCharY)
354
355
def console_is_fullscreen():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
356
    return lib.TCOD_console_is_fullscreen()
357
358
def console_set_fullscreen(fullscreen):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
359
    lib.TCOD_console_set_fullscreen(fullscreen)
360
361
def console_is_window_closed():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
362
    return lib.TCOD_console_is_window_closed()
363
364
def console_set_window_title(title):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
365
    lib.TCOD_console_set_window_title(_bytes(title))
366
367
def console_credits():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
368
    lib.TCOD_console_credits()
369
370
def console_credits_reset():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
371
    lib.TCOD_console_credits_reset()
372
373
def console_credits_render(x, y, alpha):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
374
    return lib.TCOD_console_credits_render(x, y, alpha)
375
376
def console_flush():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
377
    lib.TCOD_console_flush()
378
379
# drawing on a console
380
def console_set_default_background(con, col):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
381
    lib.TCOD_console_set_default_background(con or ffi.NULL, col)
382
383
def console_set_default_foreground(con, col):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
384
    lib.TCOD_console_set_default_foreground(con or ffi.NULL, col)
385
386
def console_clear(con):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
387
    return lib.TCOD_console_clear(con or ffi.NULL)
388
389
def console_put_char(con, x, y, c, flag=BKGND_DEFAULT):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
390
    lib.TCOD_console_put_char(con or ffi.NULL, x, y, _int(c), flag)
391
392
def console_put_char_ex(con, x, y, c, fore, back):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
393
    lib.TCOD_console_put_char_ex(con or ffi.NULL, x, y, _int(c), fore, back)
394
395
def console_set_char_background(con, x, y, col, flag=BKGND_SET):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_SET'
Loading history...
396
    lib.TCOD_console_set_char_background(con or ffi.NULL, x, y, col, flag)
397
398
def console_set_char_foreground(con, x, y, col):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
399
    lib.TCOD_console_set_char_foreground(con or ffi.NULL, x, y, col)
400
401
def console_set_char(con, x, y, c):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
402
    lib.TCOD_console_set_char(con or ffi.NULL, x, y, _int(c))
403
404
def console_set_background_flag(con, flag):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
405
    lib.TCOD_console_set_background_flag(con or ffi.NULL, flag)
406
407
def console_get_background_flag(con):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
408
    return lib.TCOD_console_get_background_flag(con or ffi.NULL)
409
410
def console_set_alignment(con, alignment):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
411
    lib.TCOD_console_set_alignment(con or ffi.NULL, alignment)
412
413
def console_get_alignment(con):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
414
    return lib.TCOD_console_get_alignment(con or ffi.NULL)
415
416
def console_print(con, x, y, fmt):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
417
    lib.TCOD_console_print_utf(con or ffi.NULL, x, y, _unicode(fmt))
418
419
def console_print_ex(con, x, y, flag, alignment, fmt):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
420
    lib.TCOD_console_print_ex_utf(con or ffi.NULL, x, y,
421
                                   flag, alignment, _unicode(fmt))
422
423
def console_print_rect(con, x, y, w, h, fmt):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
424
    return lib.TCOD_console_print_rect_utf(con or ffi.NULL, x, y, w, h,
425
                                            _unicode(fmt))
426
427
def console_print_rect_ex(con, x, y, w, h, flag, alignment, fmt):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
428
    return lib.TCOD_console_print_rect_ex_utf(con or ffi.NULL, x, y, w, h,
429
                                               flag, alignment, _unicode(fmt))
430
431
def console_get_height_rect(con, x, y, w, h, fmt):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
432
    return lib.TCOD_console_get_height_rect_utf(con or ffi.NULL, x, y, w, h,
433
                                                 _unicode(fmt))
434
435
def console_rect(con, x, y, w, h, clr, flag=BKGND_DEFAULT):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
436
    lib.TCOD_console_rect(con or ffi.NULL, x, y, w, h, clr, flag)
437
438
def console_hline(con, x, y, l, flag=BKGND_DEFAULT):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
439
    lib.TCOD_console_hline(con or ffi.NULL, x, y, l, flag)
440
441
def console_vline(con, x, y, l, flag=BKGND_DEFAULT):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
442
    lib.TCOD_console_vline(con or ffi.NULL, x, y, l, flag)
443
444
def console_print_frame(con, x, y, w, h, clear=True, flag=BKGND_DEFAULT, fmt=b''):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (82/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
445
    lib.TCOD_console_print_frame(con or ffi.NULL, x, y, w, h, clear, flag,
446
                                  _bytes(fmt))
447
448
def console_set_color_control(con, fore, back):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
449
    lib.TCOD_console_set_color_control(con or ffi.NULL, fore, back)
450
451
def console_get_default_background(con):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
452
    return Color.from_cdata(lib.TCOD_console_get_default_background(con or ffi.NULL))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (85/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
453
454
def console_get_default_foreground(con):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
455
    return Color.from_cdata(lib.TCOD_console_get_default_foreground(con or ffi.NULL))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (85/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
456
457
def console_get_char_background(con, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
458
    return Color.from_cdata(lib.TCOD_console_get_char_background(con or ffi.NULL, x, y))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (88/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
459
460
def console_get_char_foreground(con, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
461
    return Color.from_cdata(lib.TCOD_console_get_char_foreground(con or ffi.NULL, x, y))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (88/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
462
463
def console_get_char(con, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
464
    return lib.TCOD_console_get_char(con or ffi.NULL, x, y)
465
466
def console_set_fade(fade, fadingColor):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
467
    lib.TCOD_console_set_fade(fade, fadingColor)
468
469
def console_get_fade():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
470
    return lib.TCOD_console_get_fade()
471
472
def console_get_fading_color():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
473
    return Color.from_cdata(lib.TCOD_console_get_fading_color())
474
475
# handling keyboard input
476
def console_wait_for_keypress(flush):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
477
    k=Key()
0 ignored issues
show
Coding Style introduced by
Exactly one space required around assignment
k=Key()
^
Loading history...
478
    lib.TCOD_console_wait_for_keypress_wrapper(k.cdata, flush)
479
    return k
480
481
def console_check_for_keypress(flags=KEY_RELEASED):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'KEY_RELEASED'
Loading history...
482
    k=Key()
0 ignored issues
show
Coding Style introduced by
Exactly one space required around assignment
k=Key()
^
Loading history...
483
    lib.TCOD_console_check_for_keypress_wrapper(k.cdata, flags)
484
    return k
485
486
def console_is_key_pressed(key):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
487
    return lib.TCOD_console_is_key_pressed(key)
488
489
def console_set_keyboard_repeat(initial_delay, interval):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
490
    lib.TCOD_console_set_keyboard_repeat(initial_delay, interval)
491
492
def console_disable_keyboard_repeat():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
493
    lib.TCOD_console_disable_keyboard_repeat()
494
495
# using offscreen consoles
496
def console_new(w, h):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
497
    return ffi.gc(lib.TCOD_console_new(w, h), lib.TCOD_console_delete)
498
def console_from_file(filename):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
499
    return lib.TCOD_console_from_file(_bytes(filename))
500
501
def console_blit(src, x, y, w, h, dst, xdst, ydst, ffade=1.0,bfade=1.0):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def console_blit(src, x, y, w, h, dst, xdst, ydst, ffade=1.0,bfade=1.0):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
502
    lib.TCOD_console_blit(src or ffi.NULL, x, y, w, h, dst or ffi.NULL,
503
                           xdst, ydst, ffade, bfade)
504
505
def console_set_key_color(con, col):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
506
    lib.TCOD_console_set_key_color(con or ffi.NULL, col)
507
508
def console_delete(con):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
509
    con = con or ffi.NULL
510
    if con == ffi.NULL:
511
        lib.TCOD_console_delete(con)
512
513
# fast color filling
514
def console_fill_foreground(con,r,g,b):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def console_fill_foreground(con,r,g,b):
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
def console_fill_foreground(con,r,g,b):
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
def console_fill_foreground(con,r,g,b):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
515
    if len(r) != len(g) or len(r) != len(b):
516
        raise TypeError('R, G and B must all have the same size.')
517 View Code Duplication
    if (_numpy_available() and isinstance(r, _numpy.ndarray) and
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named ndarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
518
        isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)):
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ndarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
519
        #numpy arrays, use numpy's ctypes functions
520
        r = _numpy.ascontiguousarray(r, dtype=_numpy.intc)
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ascontiguousarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named intc.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
521
        g = _numpy.ascontiguousarray(g, dtype=_numpy.intc)
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ascontiguousarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named intc.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
522
        b = _numpy.ascontiguousarray(b, dtype=_numpy.intc)
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ascontiguousarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named intc.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
523
        cr = ffi.cast('int *', r.ctypes.data)
524
        cg = ffi.cast('int *', g.ctypes.data)
525
        cb = ffi.cast('int *', b.ctypes.data)
526
    else:
527
        # otherwise convert using ffi arrays
528
        cr = ffi.new('int[]', r)
529
        cg = ffi.new('int[]', g)
530
        cb = ffi.new('int[]', b)
531
532
    lib.TCOD_console_fill_foreground(con or ffi.NULL, cr, cg, cb)
533
534
def console_fill_background(con,r,g,b):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def console_fill_background(con,r,g,b):
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
def console_fill_background(con,r,g,b):
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
def console_fill_background(con,r,g,b):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
535
    if len(r) != len(g) or len(r) != len(b):
536
        raise TypeError('R, G and B must all have the same size.')
537 View Code Duplication
    if (_numpy_available() and isinstance(r, _numpy.ndarray) and
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named ndarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
538
        isinstance(g, _numpy.ndarray) and isinstance(b, _numpy.ndarray)):
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ndarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
539
        #numpy arrays, use numpy's ctypes functions
540
        r = _numpy.ascontiguousarray(r, dtype=_numpy.intc)
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ascontiguousarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named intc.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
541
        g = _numpy.ascontiguousarray(g, dtype=_numpy.intc)
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ascontiguousarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named intc.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
542
        b = _numpy.ascontiguousarray(b, dtype=_numpy.intc)
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ascontiguousarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named intc.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
543
        cr = ffi.cast('int *', r.ctypes.data)
544
        cg = ffi.cast('int *', g.ctypes.data)
545
        cb = ffi.cast('int *', b.ctypes.data)
546
    else:
547
        # otherwise convert using ffi arrays
548
        cr = ffi.new('int[]', r)
549
        cg = ffi.new('int[]', g)
550
        cb = ffi.new('int[]', b)
551
552
    lib.TCOD_console_fill_background(con or ffi.NULL, cr, cg, cb)
553
554
def console_fill_char(con,arr):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def console_fill_char(con,arr):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
555
    if (_numpy_available() and isinstance(arr, _numpy.ndarray) ):
0 ignored issues
show
Unused Code Coding Style introduced by
There is an unnecessary parenthesis after if.
Loading history...
Coding Style introduced by
No space allowed before bracket
if (_numpy_available() and isinstance(arr, _numpy.ndarray) ):
^
Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named ndarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
556
        #numpy arrays, use numpy's ctypes functions
557
        arr = _numpy.ascontiguousarray(arr, dtype=_numpy.intc)
0 ignored issues
show
Bug introduced by
The Instance of bool does not seem to have a member named ascontiguousarray.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named intc.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
558
        carr = ffi.cast('int *', arr.ctypes.data)
559
    else:
560
        #otherwise convert using the ffi module
561
        carr = ffi.new('int[]', arr)
562
563
    lib.TCOD_console_fill_char(con or ffi.NULL, carr)
564
565
def console_load_asc(con, filename):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
566
    return lib.TCOD_console_load_asc(con or ffi.NULL, _bytes(filename))
567
568
def console_save_asc(con, filename):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
569
    lib.TCOD_console_save_asc(con or ffi.NULL,_bytes(filename))
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_console_save_asc(con or ffi.NULL,_bytes(filename))
^
Loading history...
570
571
def console_load_apf(con, filename):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
572
    return lib.TCOD_console_load_apf(con or ffi.NULL,_bytes(filename))
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return lib.TCOD_console_load_apf(con or ffi.NULL,_bytes(filename))
^
Loading history...
573
574
def console_save_apf(con, filename):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
575
    lib.TCOD_console_save_apf(con or ffi.NULL,_bytes(filename))
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_console_save_apf(con or ffi.NULL,_bytes(filename))
^
Loading history...
576
577
def dijkstra_new(m, dcost=1.41):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
578
    return (ffi.gc(lib.TCOD_dijkstra_new(m, dcost),
579
                    lib.TCOD_dijkstra_delete), _PropagateException())
580
581
def dijkstra_new_using_function(w, h, func, userData=0, dcost=1.41):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
582
    propagator = _PropagateException()
583
    handle = ffi.new_handle((func, propagator, (userData,)))
584
    return (ffi.gc(lib.TCOD_dijkstra_new_using_function(w, h,
585
                    lib._pycall_path_func, handle, dcost),
586
                    lib.TCOD_dijkstra_delete), propagator, handle)
587
588
def dijkstra_compute(p, ox, oy):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
589
    with p[1]:
590
        lib.TCOD_dijkstra_compute(p[0], ox, oy)
591
592
def dijkstra_path_set(p, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
593
    return lib.TCOD_dijkstra_path_set(p[0], x, y)
594
595
def dijkstra_get_distance(p, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
596
    return lib.TCOD_dijkstra_get_distance(p[0], x, y)
597
598
def dijkstra_size(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
599
    return lib.TCOD_dijkstra_size(p[0])
600
601
def dijkstra_reverse(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
602
    lib.TCOD_dijkstra_reverse(p[0])
603
604
def dijkstra_get(p, idx):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
605
    x = ffi.new('int *')
606
    y = ffi.new('int *')
607
    lib.TCOD_dijkstra_get(p[0], idx, x, y)
608
    return x[0], y[0]
609
610
def dijkstra_is_empty(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
611
    return lib.TCOD_dijkstra_is_empty(p[0])
612
613
def dijkstra_path_walk(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
614
    x = ffi.new('int *')
615
    y = ffi.new('int *')
616
    if lib.TCOD_dijkstra_path_walk(p[0], x, y):
617
        return x[0], y[0]
618
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
619
620
def dijkstra_delete(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument p seems to be unused.
Loading history...
621
    pass
622
623
@ffi.def_extern()
624
def _pycall_path_func(x1, y1, x2, y2, handle):
625
    '''static float _pycall_path_func( int xFrom, int yFrom, int xTo, int yTo, void *user_data );
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (97/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
626
    '''
627
    func, propagate_manager, user_data = ffi.from_handle(handle)
628
    try:
629
        return func(x1, y1, x2, y2, *user_data)
630
    except BaseException:
631
        propagate_manager.propagate(*_sys.exc_info())
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable '_sys'
Loading history...
632
        return None
633
634
def path_new_using_map(m, dcost=1.41):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
635
    return (ffi.gc(lib.TCOD_path_new_using_map(m, dcost),
636
                    lib.TCOD_path_delete), _PropagateException())
637
638
def path_new_using_function(w, h, func, userData=0, dcost=1.41):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
639
    propagator = _PropagateException()
640
    handle = ffi.new_handle((func, propagator, (userData,)))
641
    return (ffi.gc(lib.TCOD_path_new_using_function(w, h, lib._pycall_path_func,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (80/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
642
            handle, dcost), lib.TCOD_path_delete), propagator, handle)
643
644
def path_compute(p, ox, oy, dx, dy):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
645
    with p[1]:
646
        return lib.TCOD_path_compute(p[0], ox, oy, dx, dy)
647
648
def path_get_origin(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
649
    x = ffi.new('int *')
650
    y = ffi.new('int *')
651
    lib.TCOD_path_get_origin(p[0], x, y)
652
    return x[0], y[0]
653
654
def path_get_destination(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
655
    x = ffi.new('int *')
656
    y = ffi.new('int *')
657
    lib.TCOD_path_get_destination(p[0], x, y)
658
    return x[0], y[0]
659
660
def path_size(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
661
    return lib.TCOD_path_size(p[0])
662
663
def path_reverse(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
664
    lib.TCOD_path_reverse(p[0])
665
666
def path_get(p, idx):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
667
    x = ffi.new('int *')
668
    y = ffi.new('int *')
669
    lib.TCOD_path_get(p[0], idx, x, y)
670
    return x[0], y[0]
671
672
def path_is_empty(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
673
    return lib.TCOD_path_is_empty(p[0])
674
675
def path_walk(p, recompute):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
676
    x = ffi.new('int *')
677
    y = ffi.new('int *')
678
    with p[1]:
679
        if lib.TCOD_path_walk(p[0], x, y, recompute):
680
            return x[0], y[0]
681
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
682
683
def path_delete(p):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument p seems to be unused.
Loading history...
684
    pass
685
686
def heightmap_new(w, h):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
687
    return HeightMap(w, h)
688
689
def heightmap_set_value(hm, x, y, value):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
690
    lib.TCOD_heightmap_set_value(hm.cdata, x, y, value)
691
692
def heightmap_add(hm, value):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
693
    lib.TCOD_heightmap_add(hm.cdata, value)
694
695
def heightmap_scale(hm, value):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
696
    lib.TCOD_heightmap_scale(hm.cdata, value)
697
698
def heightmap_clear(hm):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
699
    lib.TCOD_heightmap_clear(hm.cdata)
700
701
def heightmap_clamp(hm, mi, ma):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
702
    lib.TCOD_heightmap_clamp(hm.cdata, mi, ma)
703
704
def heightmap_copy(hm1, hm2):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
705
    lib.TCOD_heightmap_copy(hm1.cdata, hm2.cdata)
706
707
def heightmap_normalize(hm,  mi=0.0, ma=1.0):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def heightmap_normalize(hm, mi=0.0, ma=1.0):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
708
    lib.TCOD_heightmap_normalize(hm.cdata, mi, ma)
709
710
def heightmap_lerp_hm(hm1, hm2, hm3, coef):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
711
    lib.TCOD_heightmap_lerp_hm(hm1.cdata, hm2.cdata, hm3.cdata, coef)
712
713
def heightmap_add_hm(hm1, hm2, hm3):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
714
    lib.TCOD_heightmap_add_hm(hm1.cdata, hm2.cdata, hm3.cdata)
715
716
def heightmap_multiply_hm(hm1, hm2, hm3):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
717
    lib.TCOD_heightmap_multiply_hm(hm1.cdata, hm2.cdata, hm3.cdata)
718
719
def heightmap_add_hill(hm, x, y, radius, height):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
720
    lib.TCOD_heightmap_add_hill(hm.cdata, x, y, radius, height)
721
722
def heightmap_dig_hill(hm, x, y, radius, height):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
723
    lib.TCOD_heightmap_dig_hill(hm.cdata, x, y, radius, height)
724
725
def heightmap_rain_erosion(hm, nbDrops, erosionCoef, sedimentationCoef, rnd=None):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (82/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
726
    lib.TCOD_heightmap_rain_erosion(hm.cdata, nbDrops, erosionCoef,
727
                                     sedimentationCoef, rnd or ffi.NULL)
728
729
def heightmap_kernel_transform(hm, kernelsize, dx, dy, weight, minLevel,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
730
                               maxLevel):
731
    cdx = ffi.new('int[]', dx)
732
    cdy = ffi.new('int[]', dy)
733
    cweight = ffi.new('float[]', weight)
734
    lib.TCOD_heightmap_kernel_transform(hm.cdata, kernelsize, cdx, cdy, cweight,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (80/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
735
                                         minLevel, maxLevel)
736
737
def heightmap_add_voronoi(hm, nbPoints, nbCoef, coef, rnd=None):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
738
    ccoef = ffi.new('float[]', coef)
739
    lib.TCOD_heightmap_add_voronoi(hm.cdata, nbPoints, nbCoef, ccoef, rnd or ffi.NULL)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (86/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
740
741
def heightmap_add_fbm(hm, noise, mulx, muly, addx, addy, octaves, delta, scale):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (80/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
742
    lib.TCOD_heightmap_add_fbm(hm.cdata, noise, mulx, muly, addx, addy,
743
                                octaves, delta, scale)
744
def heightmap_scale_fbm(hm, noise, mulx, muly, addx, addy, octaves, delta,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
745
                        scale):
746
    lib.TCOD_heightmap_scale_fbm(hm.cdata, noise, mulx, muly, addx, addy,
747
                                  octaves, delta, scale)
748
749
def heightmap_dig_bezier(hm, px, py, startRadius, startDepth, endRadius,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
750
                         endDepth):
751
    #IARRAY = c_int * 4
752
    cpx = ffi.new('int[4]', px)
753
    cpy = ffi.new('int[4]', py)
754
    lib.TCOD_heightmap_dig_bezier(hm.cdata, cpx, cpy, startRadius,
755
                                   startDepth, endRadius,
756
                                   endDepth)
757
758
def heightmap_get_value(hm, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
759
    return lib.TCOD_heightmap_get_value(hm.cdata, x, y)
760
761
def heightmap_get_interpolated_value(hm, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
762
    return lib.TCOD_heightmap_get_interpolated_value(hm.cdata, x, y)
763
764
def heightmap_get_slope(hm, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
765
    return lib.TCOD_heightmap_get_slope(hm.cdata, x, y)
766
767
def heightmap_get_normal(hm, x, y, waterLevel):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
768
    #FARRAY = c_float * 3
769
    cn = ffi.new('float[3]')
770
    lib.TCOD_heightmap_get_normal(hm.cdata, x, y, cn, waterLevel)
771
    return tuple(cn)
772
773
def heightmap_count_cells(hm, mi, ma):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
774
    return lib.TCOD_heightmap_count_cells(hm.cdata, mi, ma)
775
776
def heightmap_has_land_on_border(hm, waterlevel):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
777
    return lib.TCOD_heightmap_has_land_on_border(hm.cdata, waterlevel)
778
779
def heightmap_get_minmax(hm):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
780
    mi = ffi.new('float *')
781
    ma = ffi.new('float *')
782
    lib.TCOD_heightmap_get_minmax(hm.cdata, mi, ma)
783
    return mi[0], ma[0]
784
785
def heightmap_delete(hm):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument hm seems to be unused.
Loading history...
786
    pass
787
788
def image_new(width, height):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
789
    return ffi.gc(lib.TCOD_image_new(width, height), lib.TCOD_image_delete)
790
791
def image_clear(image,col):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def image_clear(image,col):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
792
    lib.TCOD_image_clear(image,col)
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_clear(image,col)
^
Loading history...
793
794
def image_invert(image):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
795
    lib.TCOD_image_invert(image)
796
797
def image_hflip(image):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
798
    lib.TCOD_image_hflip(image)
799
800
def image_rotate90(image, num=1):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
801
    lib.TCOD_image_rotate90(image,num)
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_rotate90(image,num)
^
Loading history...
802
803
def image_vflip(image):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
804
    lib.TCOD_image_vflip(image)
805
806
def image_scale(image, neww, newh):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
807
    lib.TCOD_image_scale(image, neww, newh)
808
809
def image_set_key_color(image,col):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def image_set_key_color(image,col):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
810
    lib.TCOD_image_set_key_color(image,col)
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_set_key_color(image,col)
^
Loading history...
811
812
def image_get_alpha(image,x,y):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def image_get_alpha(image,x,y):
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
def image_get_alpha(image,x,y):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
813
    return lib.TCOD_image_get_alpha(image, x, y)
814
815
def image_is_pixel_transparent(image,x,y):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def image_is_pixel_transparent(image,x,y):
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
def image_is_pixel_transparent(image,x,y):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
816
    return lib.TCOD_image_is_pixel_transparent(image, x, y)
817
818
def image_load(filename):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
819
    return ffi.gc(lib.TCOD_image_load(_bytes(filename)),
820
                   lib.TCOD_image_delete)
821
822
def image_from_console(console):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
823
    return ffi.gc(lib.TCOD_image_from_console(console or ffi.NULL),
824
                   lib.TCOD_image_delete)
825
826
def image_refresh_console(image, console):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
827
    lib.TCOD_image_refresh_console(image, console or ffi.NULL)
828
829
def image_get_size(image):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
830
    w = ffi.new('int *')
831
    h = ffi.new('int *')
832
    lib.TCOD_image_get_size(image, w, h)
833
    return w[0], h[0]
834
835
def image_get_pixel(image, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
836
    return lib.TCOD_image_get_pixel(image, x, y)
837
838
def image_get_mipmap_pixel(image, x0, y0, x1, y1):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
839
    return lib.TCOD_image_get_mipmap_pixel(image, x0, y0, x1, y1)
840
841
def image_put_pixel(image, x, y, col):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
842
    lib.TCOD_image_put_pixel(image, x, y, col)
843
    ##lib.TCOD_image_put_pixel_wrapper(image, x, y, col)
844
845
def image_blit(image, console, x, y, bkgnd_flag, scalex, scaley, angle):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
846
    lib.TCOD_image_blit(image, console or ffi.NULL, x, y, bkgnd_flag,
847
                         scalex, scaley, angle)
848
849
def image_blit_rect(image, console, x, y, w, h, bkgnd_flag):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
850
    lib.TCOD_image_blit_rect(image, console or ffi.NULL, x, y, w, h, bkgnd_flag)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (80/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
851
852
def image_blit_2x(image, console, dx, dy, sx=0, sy=0, w=-1, h=-1):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
853
    lib.TCOD_image_blit_2x(image, console or ffi.NULL, dx,dy,sx,sy,w,h)
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(image, console or ffi.NULL, dx,dy,sx,sy,w,h)
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(image, console or ffi.NULL, dx,dy,sx,sy,w,h)
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(image, console or ffi.NULL, dx,dy,sx,sy,w,h)
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(image, console or ffi.NULL, dx,dy,sx,sy,w,h)
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(image, console or ffi.NULL, dx,dy,sx,sy,w,h)
^
Loading history...
854
855
def image_save(image, filename):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
856
    lib.TCOD_image_save(image, _bytes(filename))
857
858
def image_delete(image):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument image seems to be unused.
Loading history...
859
    pass
860
def line_init(xo, yo, xd, yd):
861
    """Initilize a line whose points will be returned by `line_step`.
862
863
    This function does not return anything on its own.
864
865
    Does not include the origin point.
866
867
    :param int xo: x origin
868
    :param int yo: y origin
869
    :param int xd: x destination
870
    :param int yd: y destination
871
872
    .. deprecated:: 2.0
873
       Use `line_iter` instead.
874
    """
875
    lib.TCOD_line_init(xo, yo, xd, yd)
876
877
def line_step():
878
    """After calling `line_init` returns (x, y) points of the line.
879
880
    Once all points are exhausted this function will return (None, None)
881
882
    :return: next (x, y) point of the line setup by `line_init`,
883
             or (None, None) if there are no more points.
884
    :rtype: tuple(x, y)
885
886
    .. deprecated:: 2.0
887
       Use `line_iter` instead
888
    """
889
    x = ffi.new('int *')
890
    y = ffi.new('int *')
891
    ret = lib.TCOD_line_step(x, y)
892
    if not ret:
893
        return x[0], y[0]
894
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
895
896
_line_listener_lock = _threading.Lock()
897
898
def line(xo, yo, xd, yd, py_callback):
899
    """ Iterate over a line using a callback function.
900
901
    Your callback function will take x and y parameters and return True to
902
    continue iteration or False to stop iteration and return.
903
904
    This function includes both the start and end points.
905
906
    :param int xo: x origin
907
    :param int yo: y origin
908
    :param int xd: x destination
909
    :param int yd: y destination
910
    :param function py_callback: Callback that takes x and y parameters and
911
                                 returns bool.
912
    :return: Returns False if the callback cancels the line interation by
913
             returning False or None, otherwise True.
914
    :rtype: bool
915
916
    .. deprecated:: 2.0
917
       Use `line_iter` instead.
918
    """
919
    with _PropagateException() as propagate:
920
        with _line_listener_lock:
921
            @ffi.def_extern(onerror=propagate)
922
            def _pycall_line_listener(x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable _pycall_line_listener seems to be unused.
Loading history...
923
                return py_callback(x, y)
924
            return bool(lib.TCOD_line(xo, yo, xd, yd,
925
                                       lib._pycall_line_listener))
926
927
def line_iter(xo, yo, xd, yd):
928
    """ returns an iterator
929
930
    This iterator does not include the origin point.
931
932
    :param int xo: x origin
933
    :param int yo: y origin
934
    :param int xd: x destination
935
    :param int yd: y destination
936
937
    :return: iterator of (x,y) points
938
    """
939
    data = ffi.new('TCOD_bresenham_data_t *')
940
    lib.TCOD_line_init_mt(xo, yo, xd, yd, data)
941
    x = ffi.new('int *')
942
    y = ffi.new('int *')
943
    done = False
0 ignored issues
show
Unused Code introduced by
The variable done seems to be unused.
Loading history...
944
    while not lib.TCOD_line_step_mt(x, y, data):
945
        yield (x[0], y[0])
946
947
FOV_BASIC = 0
948
FOV_DIAMOND = 1
949
FOV_SHADOW = 2
950
FOV_PERMISSIVE_0 = 3
951
FOV_PERMISSIVE_1 = 4
952
FOV_PERMISSIVE_2 = 5
953
FOV_PERMISSIVE_3 = 6
954
FOV_PERMISSIVE_4 = 7
955
FOV_PERMISSIVE_5 = 8
956
FOV_PERMISSIVE_6 = 9
957
FOV_PERMISSIVE_7 = 10
958
FOV_PERMISSIVE_8 = 11
959
FOV_RESTRICTIVE = 12
960
NB_FOV_ALGORITHMS = 13
961
962
def map_new(w, h):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
963
    return ffi.gc(lib.TCOD_map_new(w, h), lib.TCOD_map_delete)
964
965
def map_copy(source, dest):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
966
    return lib.TCOD_map_copy(source, dest)
967
968
def map_set_properties(m, x, y, isTrans, isWalk):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
969
    lib.TCOD_map_set_properties(m, x, y, isTrans, isWalk)
970
971
def map_clear(m,walkable=False,transparent=False):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def map_clear(m,walkable=False,transparent=False):
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
def map_clear(m,walkable=False,transparent=False):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
972
    lib.TCOD_map_clear(m, walkable, transparent)
973
974
def map_compute_fov(m, x, y, radius=0, light_walls=True, algo=FOV_RESTRICTIVE ):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (80/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
Coding Style introduced by
No space allowed before bracket
def map_compute_fov(m, x, y, radius=0, light_walls=True, algo=FOV_RESTRICTIVE ):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
975
    lib.TCOD_map_compute_fov(m, x, y, radius, light_walls, algo)
976
977
def map_is_in_fov(m, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
978
    return lib.TCOD_map_is_in_fov(m, x, y)
979
980
def map_is_transparent(m, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
981
    return lib.TCOD_map_is_transparent(m, x, y)
982
983
def map_is_walkable(m, x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
984
    return lib.TCOD_map_is_walkable(m, x, y)
985
986
def map_delete(m):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument m seems to be unused.
Loading history...
987
    pass
988
989
def map_get_width(map):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in map.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
990
    return lib.TCOD_map_get_width(map)
991
992
def map_get_height(map):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in map.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
993
    return lib.TCOD_map_get_height(map)
994
995
def mouse_show_cursor(visible):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
996
    lib.TCOD_mouse_show_cursor(visible)
997
998
def mouse_is_cursor_visible():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
999
    return lib.TCOD_mouse_is_cursor_visible()
1000
1001
def mouse_move(x, y):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1002
    lib.TCOD_mouse_move(x, y)
1003
1004
def mouse_get_status():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1005
    return Mouse(lib.TCOD_mouse_get_status())
1006
1007
def namegen_parse(filename,random=None):
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
def namegen_parse(filename,random=None):
^
Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1008
    lib.TCOD_namegen_parse(_bytes(filename), random or ffi.NULL)
1009
1010
def namegen_generate(name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1011
    return _unpack_char_p(lib.TCOD_namegen_generate(_bytes(name), False))
1012
1013
def namegen_generate_custom(name, rule):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1014
    return _unpack_char_p(lib.TCOD_namegen_generate(_bytes(name),
1015
                                                     _bytes(rule), False))
1016
1017
def namegen_get_sets():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1018
    sets = lib.TCOD_namegen_get_sets()
1019
    try:
1020
        lst = []
1021
        while not lib.TCOD_list_is_empty(sets):
1022
            lst.append(_unpack_char_p(ffi.cast('char *', lib.TCOD_list_pop(sets))))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (83/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
1023
    finally:
1024
        lib.TCOD_list_delete(sets)
1025
    return lst
1026
1027
def namegen_destroy():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1028
    lib.TCOD_namegen_destroy()
1029
1030
def noise_new(dim, h=NOISE_DEFAULT_HURST, l=NOISE_DEFAULT_LACUNARITY,
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1031
        random=None):
1032
    return ffi.gc(lib.TCOD_noise_new(dim, h, l, random or ffi.NULL),
1033
                   lib.TCOD_noise_delete)
1034
1035
def noise_set_type(n, typ):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1036
    lib.TCOD_noise_set_type(n,typ)
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_noise_set_type(n,typ)
^
Loading history...
1037
1038
def noise_get(n, f, typ=NOISE_DEFAULT):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'NOISE_DEFAULT'
Loading history...
1039
    return lib.TCOD_noise_get_ex(n, ffi.new('float[]', f), typ)
1040
1041
def noise_get_fbm(n, f, oc, typ=NOISE_DEFAULT):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'NOISE_DEFAULT'
Loading history...
1042
    return lib.TCOD_noise_get_fbm_ex(n, ffi.new('float[]', f), oc, typ)
1043
1044
def noise_get_turbulence(n, f, oc, typ=NOISE_DEFAULT):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'NOISE_DEFAULT'
Loading history...
1045
    return lib.TCOD_noise_get_turbulence_ex(n, ffi.new('float[]', f), oc, typ)
1046
1047
def noise_delete(n):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument n seems to be unused.
Loading history...
1048
    pass
1049
1050
_chr = chr
1051
try:
1052
    _chr = unichr # Python 2
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'unichr'
Loading history...
1053
except NameError:
0 ignored issues
show
Unused Code introduced by
This except handler seems to be unused and could be removed.

Except handlers which only contain pass and do not have an else clause can usually simply be removed:

try:
    raises_exception()
except:  # Could be removed
    pass
Loading history...
1054
    pass
1055
1056
def _unpack_union(type, union):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
1057
    '''
1058
        unpack items from parser new_property (value_converter)
1059
    '''
1060
    if type == lib.TCOD_TYPE_BOOL:
1061
        return bool(union.b)
1062
    elif type == lib.TCOD_TYPE_CHAR:
1063
        return _unicode(union.c)
1064
    elif type == lib.TCOD_TYPE_INT:
1065
        return union.i
1066
    elif type == lib.TCOD_TYPE_FLOAT:
1067
        return union.f
1068
    elif (type == lib.TCOD_TYPE_STRING or
1069
         lib.TCOD_TYPE_VALUELIST15 >= type >= lib.TCOD_TYPE_VALUELIST00):
1070
         return _unpack_char_p(union.s)
0 ignored issues
show
Coding Style introduced by
The indentation here looks off. 8 spaces were expected, but 9 were found.
Loading history...
1071
    elif type == lib.TCOD_TYPE_COLOR:
1072
        return Color.from_cdata(union.col)
1073
    elif type == lib.TCOD_TYPE_DICE:
1074
        return Dice(union.dice)
1075
    elif type & lib.TCOD_TYPE_LIST:
1076
        return _convert_TCODList(union.list, type & 0xFF)
1077
    else:
1078
        raise RuntimeError('Unknown libtcod type: %i' % type)
1079
1080
def _convert_TCODList(clist, type):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
1081
    return [_unpack_union(type, lib.TDL_list_get_union(clist, i))
1082
            for i in range(lib.TCOD_list_size(clist))]
1083
1084
def parser_new():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1085
    return ffi.gc(lib.TCOD_parser_new(), lib.TCOD_parser_delete)
1086
1087
def parser_new_struct(parser, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1088
    return lib.TCOD_parser_new_struct(parser, name)
1089
1090
# prevent multiple threads from messing with def_extern callbacks
1091
_parser_callback_lock = _threading.Lock()
1092
1093
def parser_run(parser, filename, listener=None):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1094
    if not listener:
1095
        lib.TCOD_parser_run(parser, _bytes(filename), ffi.NULL)
1096
        return
1097
1098
    propagate_manager = _PropagateException()
1099
    propagate = propagate_manager.propagate
1100
1101
    with _parser_callback_lock:
1102
        clistener = ffi.new('TCOD_parser_listener_t *')
1103
1104
        @ffi.def_extern(onerror=propagate)
1105
        def pycall_parser_new_struct(struct, name):
1 ignored issue
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable pycall_parser_new_struct seems to be unused.
Loading history...
1106
            return listener.end_struct(struct, _unpack_char_p(name))
1107
1108
        @ffi.def_extern(onerror=propagate)
1109
        def pycall_parser_new_flag(name):
1 ignored issue
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable pycall_parser_new_flag seems to be unused.
Loading history...
1110
            return listener.new_flag(_unpack_char_p(name))
1111
1112
        @ffi.def_extern(onerror=propagate)
1113
        def pycall_parser_new_property(propname, type, value):
1 ignored issue
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
Unused Code introduced by
The variable pycall_parser_new_property seems to be unused.
Loading history...
1114
            return listener.new_property(_unpack_char_p(propname), type,
1115
                                         _unpack_union(type, value))
1116
1117
        @ffi.def_extern(onerror=propagate)
1118
        def pycall_parser_end_struct(struct, name):
1 ignored issue
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable pycall_parser_end_struct seems to be unused.
Loading history...
1119
            return listener.end_struct(struct, _unpack_char_p(name))
1120
1121
        @ffi.def_extern(onerror=propagate)
1122
        def pycall_parser_error(msg):
1 ignored issue
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable pycall_parser_error seems to be unused.
Loading history...
1123
            listener.error(_unpack_char_p(msg))
1124
1125
        clistener.new_struct = lib.pycall_parser_new_struct
1126
        clistener.new_flag = lib.pycall_parser_new_flag
1127
        clistener.new_property = lib.pycall_parser_new_property
1128
        clistener.end_struct = lib.pycall_parser_end_struct
1129
        clistener.error = lib.pycall_parser_error
1130
1131
        with propagate_manager:
1132
            lib.TCOD_parser_run(parser, _bytes(filename), clistener)
1133
1134
def parser_delete(parser):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument parser seems to be unused.
Loading history...
1135
    pass
1136
1137
def parser_get_bool_property(parser, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1138
    return bool(lib.TCOD_parser_get_bool_property(parser, _bytes(name)))
1139
1140
def parser_get_int_property(parser, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1141
    return lib.TCOD_parser_get_int_property(parser, _bytes(name))
1142
1143
def parser_get_char_property(parser, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1144
    return _chr(lib.TCOD_parser_get_char_property(parser, _bytes(name)))
1145
1146
def parser_get_float_property(parser, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1147
    return lib.TCOD_parser_get_float_property(parser, _bytes(name))
1148
1149
def parser_get_string_property(parser, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1150
    return _unpack_char_p(lib.TCOD_parser_get_string_property(parser, _bytes(name)))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (84/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
1151
1152
def parser_get_color_property(parser, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1153
    return Color.from_cdata(lib.TCOD_parser_get_color_property(parser, _bytes(name)))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (85/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
1154
1155
def parser_get_dice_property(parser, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1156
    d = ffi.new('TCOD_dice_t *')
1157
    lib.TCOD_parser_get_dice_property_py(parser, _bytes(name), d)
1158
    return Dice(d)
1159
1160
def parser_get_list_property(parser, name, type):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in type.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
1161
    clist = lib.TCOD_parser_get_list_property(parser, _bytes(name), type)
1162
    return _convert_TCODList(clist, type)
1163
1164
RNG_MT = 0
1165
RNG_CMWC = 1
1166
1167
DISTRIBUTION_LINEAR = 0
1168
DISTRIBUTION_GAUSSIAN = 1
1169
DISTRIBUTION_GAUSSIAN_RANGE = 2
1170
DISTRIBUTION_GAUSSIAN_INVERSE = 3
1171
DISTRIBUTION_GAUSSIAN_RANGE_INVERSE = 4
1172
1173
def random_get_instance():
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1174
    return lib.TCOD_random_get_instance()
1175
1176
def random_new(algo=RNG_CMWC):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1177
    return ffi.gc(lib.TCOD_random_new(algo), lib.TCOD_random_delete)
1178
1179
def random_new_from_seed(seed, algo=RNG_CMWC):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1180
    return ffi.gc(lib.TCOD_random_new_from_seed(algo, seed),
1181
                   lib.TCOD_random_delete)
1182
1183
def random_set_distribution(rnd, dist):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1184
	lib.TCOD_random_set_distribution(rnd or ffi.NULL, dist)
0 ignored issues
show
Coding Style introduced by
Found indentation with tabs instead of spaces
Loading history...
1185
1186
def random_get_int(rnd, mi, ma):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1187
    return lib.TCOD_random_get_int(rnd or ffi.NULL, mi, ma)
1188
1189
def random_get_float(rnd, mi, ma):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1190
    return lib.TCOD_random_get_float(rnd or ffi.NULL, mi, ma)
1191
1192
def random_get_double(rnd, mi, ma):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1193
    return lib.TCOD_random_get_double(rnd or ffi.NULL, mi, ma)
1194
1195
def random_get_int_mean(rnd, mi, ma, mean):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1196
    return lib.TCOD_random_get_int_mean(rnd or ffi.NULL, mi, ma, mean)
1197
1198
def random_get_float_mean(rnd, mi, ma, mean):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1199
    return lib.TCOD_random_get_float_mean(rnd or ffi.NULL, mi, ma, mean)
1200
1201
def random_get_double_mean(rnd, mi, ma, mean):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1202
    return lib.TCOD_random_get_double_mean(rnd or ffi.NULL, mi, ma, mean)
1203
1204
def random_save(rnd):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1205
    return ffi.gc(lib.TCOD_random_save(rnd or ffi.NULL),
1206
                   lib.TCOD_random_delete)
1207
1208
def random_restore(rnd, backup):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1209
    lib.TCOD_random_restore(rnd or ffi.NULL, backup)
1210
1211
def random_delete(rnd):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The argument rnd seems to be unused.
Loading history...
1212
    pass
1213
1214
def struct_add_flag(struct, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1215
    lib.TCOD_struct_add_flag(struct, name)
1216
1217
def struct_add_property(struct, name, typ, mandatory):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1218
    lib.TCOD_struct_add_property(struct, name, typ, mandatory)
1219
1220
def struct_add_value_list(struct, name, value_list, mandatory):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1221
    CARRAY = c_char_p * (len(value_list) + 1)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'c_char_p'
Loading history...
1222
    cvalue_list = CARRAY()
1223
    for i in range(len(value_list)):
1224
        cvalue_list[i] = cast(value_list[i], c_char_p)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'cast'
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'c_char_p'
Loading history...
1225
    cvalue_list[len(value_list)] = 0
1226
    lib.TCOD_struct_add_value_list(struct, name, cvalue_list, mandatory)
1227
1228
def struct_add_list_property(struct, name, typ, mandatory):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1229
    lib.TCOD_struct_add_list_property(struct, name, typ, mandatory)
1230
1231
def struct_add_structure(struct, sub_struct):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1232
    lib.TCOD_struct_add_structure(struct, sub_struct)
1233
1234
def struct_get_name(struct):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1235
    return _unpack_char_p(lib.TCOD_struct_get_name(struct))
1236
1237
def struct_is_mandatory(struct, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1238
    return lib.TCOD_struct_is_mandatory(struct, name)
1239
1240
def struct_get_type(struct, name):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
1241
    return lib.TCOD_struct_get_type(struct, name)
1242
1243
# high precision time functions
1244
def sys_set_fps(fps):
1245
    """Set the maximum frame rate.
1246
1247
    You can disable the frame limit again by setting fps to 0.
1248
1249
    :param int fps: A frame rate limit (i.e. 60)
1250
    """
1251
    lib.TCOD_sys_set_fps(fps)
1252
1253
def sys_get_fps():
1254
    """Return the current frames per second.
1255
1256
    This the actual frame rate, not the frame limit set by
1257
    :any:`tcod.sys_set_fps`.
1258
1259
    This number is updated every second.
1260
1261
    :rtype: int
1262
    """
1263
    return lib.TCOD_sys_get_fps()
1264
1265
def sys_get_last_frame_length():
1266
    """Return the delta time of the last rendered frame in seconds.
1267
1268
    :rtype: float
1269
    """
1270
    return lib.TCOD_sys_get_last_frame_length()
1271
1272
def sys_sleep_milli(val):
1273
    """Sleep for 'val' milliseconds.
1274
1275
    :param int val: Time to sleep for in milliseconds.
1276
1277
    .. deprecated:: 2.0
1278
       Use :any:`time.sleep` instead.
1279
    """
1280
    lib.TCOD_sys_sleep_milli(val)
1281
1282
def sys_elapsed_milli():
1283
    """Get number of milliseconds since the start of the program.
1284
1285
    :rtype: int
1286
1287
    .. deprecated:: 2.0
1288
       Use :any:`time.clock` instead.
1289
    """
1290
    return lib.TCOD_sys_elapsed_milli()
1291
1292
def sys_elapsed_seconds():
1293
    """Get number of seconds since the start of the program.
1294
1295
    :rtype: float
1296
1297
    .. deprecated:: 2.0
1298
       Use :any:`time.clock` instead.
1299
    """
1300
    return lib.TCOD_sys_elapsed_seconds()
1301
1302
def sys_set_renderer(renderer):
1303
    """Change the current rendering mode to renderer.
1304
1305
    .. deprecated:: 2.0
1306
       RENDERER_GLSL and RENDERER_OPENGL are not currently available.
1307
    """
1308
    lib.TCOD_sys_set_renderer(renderer)
1309
1310
def sys_get_renderer():
1311
    """Return the current rendering mode.
1312
1313
    """
1314
    return lib.TCOD_sys_get_renderer()
1315
1316
# easy screenshots
1317
def sys_save_screenshot(name=None):
1318
    """Save a screenshot to a file.
1319
1320
    By default this will automatically save screenshots in the working
1321
    directory.
1322
1323
    The automatic names are formatted as screenshotNNN.png.  For example:
1324
    screenshot000.png, screenshot001.png, etc.  Whichever is available first.
1325
1326
    :param str file: File path to save screenshot.
1327
1328
    """
1329
    if name is not None:
1330
        name = _bytes(name)
1331
    lib.TCOD_sys_save_screenshot(name or ffi.NULL)
1332
1333
# custom fullscreen resolution
1334
def sys_force_fullscreen_resolution(width, height):
1335
    """Force a specific resolution in fullscreen.
1336
1337
    Will use the smallest available resolution so that:
1338
1339
    * resolution width >= width and
1340
      resolution width >= root console width * font char width
1341
    * resolution height >= height and
1342
      resolution height >= root console height * font char height
1343
    """
1344
    lib.TCOD_sys_force_fullscreen_resolution(width, height)
1345
1346
def sys_get_current_resolution():
1347
    """Return the current resolution as (width, height)"""
1348
    w = ffi.new('int *')
1349
    h = ffi.new('int *')
1350
    lib.TCOD_sys_get_current_resolution(w, h)
1351
    return w[0], h[0]
1352
1353
def sys_get_char_size():
1354
    """Return the current fonts character size as (width, height)"""
1355
    w = ffi.new('int *')
1356
    h = ffi.new('int *')
1357
    lib.TCOD_sys_get_char_size(w, h)
1358
    return w[0], h[0]
1359
1360
# update font bitmap
1361
def sys_update_char(asciiCode, fontx, fonty, img, x, y):
1362
    """Dynamically update the current frot with img.
1363
1364
    All cells using this asciiCode will be updated
1365
    at the next call to :any:`tcod.console_flush`.
1366
1367
    :param int asciiCode: Ascii code corresponding to the character to update.
1368
    :param int fontx: Left coordinate of the character
1369
                      in the bitmap font (in tiles)
1370
    :param int fonty: Top coordinate of the character
1371
                      in the bitmap font (in tiles)
1372
    :param img: An image containing the new character bitmap.
1373
    :param int x: Left pixel of the character in the image.
1374
    :param int y: Top pixel of the character in the image.
1375
    """
1376
    lib.TCOD_sys_update_char(_int(asciiCode), fontx, fonty, img, x, y)
1377
1378
def sys_register_SDL_renderer(callback):
1379
    """Register a custom randering function with libtcod.
1380
1381
    The callack will receive a :any:`CData <ffi-cdata>` void* to an
1382
    SDL_Surface* struct.
1383
1384
    The callback is called on every call to :any:`tcod.console_flush`.
1385
1386
    :param callable callback: A function which takes a single argument.
1387
    """
1388
    with _PropagateException() as propagate:
1389
        @ffi.def_extern(onerror=propagate)
1390
        def _pycall_sdl_hook(sdl_surface):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable _pycall_sdl_hook seems to be unused.
Loading history...
1391
            callback(sdl_surface)
1392
        lib.TCOD_sys_register_SDL_renderer(lib._pycall_sdl_hook)
1393
1394
def sys_check_for_event(mask, k, m):
1395
    """Check for events.
1396
1397
    mask can be any of the following:
1398
1399
    * tcod.EVENT_NONE
1400
    * tcod.EVENT_KEY_PRESS
1401
    * tcod.EVENT_KEY_RELEASE
1402
    * tcod.EVENT_KEY
1403
    * tcod.EVENT_MOUSE_MOVE
1404
    * tcod.EVENT_MOUSE_PRESS
1405
    * tcod.EVENT_MOUSE_RELEASE
1406
    * tcod.EVENT_MOUSE
1407
    * tcod.EVENT_FINGER_MOVE
1408
    * tcod.EVENT_FINGER_PRESS
1409
    * tcod.EVENT_FINGER_RELEASE
1410
    * tcod.EVENT_FINGER
1411
    * tcod.EVENT_ANY
1412
1413
    :param mask: Event types to wait for.
1414
    :param Key k: :any:`tcod.Key` instance which might be updated with
1415
                  an event.  Can be None.
1416
1417
    :param Mouse m: :any:`tcod.Mouse` instance which might be updated
1418
                    with an event.  Can be None.
1419
    """
1420
    return lib.TCOD_sys_check_for_event(mask, _cdata(k), _cdata(m))
1421
1422
def sys_wait_for_event(mask, k, m, flush):
1423
    """Wait for events.
1424
1425
    mask can be any of the following:
1426
1427
    * tcod.EVENT_NONE
1428
    * tcod.EVENT_KEY_PRESS
1429
    * tcod.EVENT_KEY_RELEASE
1430
    * tcod.EVENT_KEY
1431
    * tcod.EVENT_MOUSE_MOVE
1432
    * tcod.EVENT_MOUSE_PRESS
1433
    * tcod.EVENT_MOUSE_RELEASE
1434
    * tcod.EVENT_MOUSE
1435
    * tcod.EVENT_FINGER_MOVE
1436
    * tcod.EVENT_FINGER_PRESS
1437
    * tcod.EVENT_FINGER_RELEASE
1438
    * tcod.EVENT_FINGER
1439
    * tcod.EVENT_ANY
1440
1441
    If flush is True then the buffer will be cleared before waiting. Otherwise
1442
    each available event will be returned in the order they're recieved.
1443
1444
    :param mask: Event types to wait for.
1445
    :param Key k: :any:`tcod.Key` instance which might be updated with
1446
                  an event.  Can be None.
1447
1448
    :param Mouse m: :any:`tcod.Mouse` instance which might be updated
1449
                    with an event.  Can be None.
1450
1451
    :param bool flush: Clear the buffer before waiting.
1452
    """
1453
    return lib.TCOD_sys_wait_for_event(mask, _cdata(k), _cdata(m), flush)
1454
1455
__all__ = [_name for _name in list(globals()) if _name[0] != '_']
1456