Completed
Push — master ( b15329...013701 )
by Kyle
01:03
created

Dice.__setattr__()   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, _color, _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
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
121
    def __getattr__(self, attr):
122
        if attr == 'nb_dices':
123
            attr = 'nb_faces'
124
        return super(Dice, self).__getattr__(attr)
125
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):
286
    """Return the linear interpolation between two colors.
287
288
    :param c1: The first color like object.
289
    :param c2: The second color like object.
290
    :param float a: The interpolation value,
291
                    with 0 returing c1, 1 returning c2, and 0.5 returing a
292
                    color halfway between both.
293
    """
294
    return Color.from_cdata(lib.TCOD_color_lerp(c1, c2, a))
295
296
def color_set_hsv(c, h, s, v):
297
    """Set a color using: hue, saturation, and value parameters.
298
299
    :param Color c: Must be a :any:`Color` instance.
300
    """
301
    # TODO: this may not work as expected, need to fix colors in general
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
302
    lib.TCOD_color_set_HSV(_cdata(c), h, s, v)
303
304
def color_get_hsv(c):
305
    """Return the (hue, saturation, value) of a color.
306
307
    :param c: Can be any color like object.
308
    :returns: Returns 3-item tuple of :any:float (hue, saturation, value)
309
    """
310
    h = ffi.new('float *')
311
    s = ffi.new('float *')
312
    v = ffi.new('float *')
313
    lib.TCOD_color_get_HSV(_color(c), h, s, v)
314
    return h[0], s[0], v[0]
315
316
def color_scale_HSV(c, scoef, vcoef):
317
    """Scale a color's saturation and value.
318
319
    :param c: Must be a :any:`Color` instance.
320
    :param float scoef: saturation multiplier, use 1 to keep current saturation
321
    :param float vcoef: value multiplier, use 1 to keep current value
322
    """
323
    lib.TCOD_color_scale_HSV(_cdata(c), scoef, vcoef)
324
325
def color_gen_map(colors, indexes):
326
    """Return a smoothly defined scale of colors.
327
328
    For example::
329
330
        tcod.color_gen_map([(0, 0, 0), (255, 255, 255)], [0, 8])
331
332
    Will return a smooth grey-scale, from black to white, with a length of 8.
333
334
    :param colors: Array of colors to be sampled.
335
    :param indexes:
336
337
    """
338
    ccolors = ffi.new('TCOD_color_t[]', colors)
339
    cindexes = ffi.new('int[]', indexes)
340
    cres = ffi.new('TCOD_color_t[]', max(indexes) + 1)
341
    lib.TCOD_color_gen_map(cres, len(colors), ccolors, cindexes)
342
    return [Color.from_cdata(cdata) for cdata in cres]
343
344
_numpy = None
345
346
def _numpy_available():
347
    'check if numpy is available and lazily load it when needed'
348
    global _numpy
349
    if _numpy is None:
350
        try:
351
            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 344).

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...
352
        except ImportError:
353
            _numpy = False
354
    return _numpy
355
356
# initializing the console
357
def console_init_root(w, h, title, fullscreen=False,
358
                      renderer=RENDERER_SDL):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'RENDERER_SDL'
Loading history...
359
    """Set up the primary display and return the root console.
360
361
    .. note:: Currently only the SDL renderer is supported at the moment.
362
              Do not attempt to change it.
363
364
    :param int w: Width in character tiles for the root console.
365
    :param int h: Height in character tiles for the root console.
366
    :param unicode title: A Unicode or system encoded string.
367
                          This string will be displayed on the created windows
368
                          title bar.
369
    :param renderer: Rendering mode for libtcod to use.
370
    """
371
    lib.TCOD_console_init_root(w, h, _bytes(title), fullscreen, renderer)
372
    return None # root console is None
373
374
375
def console_set_custom_font(fontFile, flags=FONT_LAYOUT_ASCII_INCOL,
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'FONT_LAYOUT_ASCII_INCOL'
Loading history...
376
                            nb_char_horiz=0, nb_char_vertic=0):
377
    """Load a custom font file.
378
379
    Call this before function before calling :any:`tcod.console_init_root`.
380
381
    Flags can be a mix of the following:
382
383
    * tcod.FONT_LAYOUT_ASCII_INCOL
384
    * tcod.FONT_LAYOUT_ASCII_INROW
385
    * tcod.FONT_TYPE_GREYSCALE
386
    * tcod.FONT_TYPE_GRAYSCALE
387
    * tcod.FONT_LAYOUT_TCOD
388
389
    :param str fontFile: Path to a font file.
390
    :param flags:
391
    :param int nb_char_horiz:
392
    :param int nb_char_vertic:
393
394
    """
395
    lib.TCOD_console_set_custom_font(_bytes(fontFile), flags,
396
                                     nb_char_horiz, nb_char_vertic)
397
398
399
def console_get_width(con):
400
    """Return the width of a console."""
401
    return lib.TCOD_console_get_width(_cdata(con))
402
403
def console_get_height(con):
404
    """Return the height of a console."""
405
    return lib.TCOD_console_get_height(_cdata(con))
406
407
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...
408
    lib.TCOD_console_map_ascii_code_to_font(_int(asciiCode), fontCharX,
409
                                                              fontCharY)
410
411
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...
412
                                    fontCharY):
413
    lib.TCOD_console_map_ascii_codes_to_font(_int(firstAsciiCode), nbCodes,
414
                                              fontCharX, fontCharY)
415
416
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...
417
    lib.TCOD_console_map_string_to_font_utf(_unicode(s), fontCharX, fontCharY)
418
419
def console_is_fullscreen():
420
    """Returns True if the display is fullscreen, otherwise False."""
421
    return lib.TCOD_console_is_fullscreen()
422
423
def console_set_fullscreen(fullscreen):
424
    """Change the display to be fullscreen or windowed."""
425
    lib.TCOD_console_set_fullscreen(fullscreen)
426
427
def console_is_window_closed():
428
    """Returns True if the window has received and exit event."""
429
    return lib.TCOD_console_is_window_closed()
430
431
def console_set_window_title(title):
432
    """Change the current title bar string."""
433
    lib.TCOD_console_set_window_title(_bytes(title))
434
435
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...
436
    lib.TCOD_console_credits()
437
438
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...
439
    lib.TCOD_console_credits_reset()
440
441
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...
442
    return lib.TCOD_console_credits_render(x, y, alpha)
443
444
def console_flush():
445
    """Update the display to represent the root consoles current state."""
446
    lib.TCOD_console_flush()
447
448
# drawing on a console
449
def console_set_default_background(con, col):
450
    """Change the default background color for this console."""
451
    lib.TCOD_console_set_default_background(_cdata(con), _color(col))
452
453
def console_set_default_foreground(con, col):
454
    """Change the default foreround color for this console."""
455
    lib.TCOD_console_set_default_foreground(_cdata(con), _color(col))
456
457
def console_clear(con):
458
    """Reset this console to its default colors and the space character."""
459
    return lib.TCOD_console_clear(_cdata(con))
460
461
def console_put_char(con, x, y, c, flag=BKGND_DEFAULT):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
462
    """Draw the character c at x,y using the default colors and a blend mode.
463
464
    :param int x: Character position from the left.
465
    :param int y: Character position from the top.
466
    :param c: Character to draw, can be an integer or string.
467
    :param flag: Blending mode to use.
468
469
    .. seealso::
470
       :any:`console_set_default_background`
471
       :any:`console_set_default_foreground`
472
    """
473
    lib.TCOD_console_put_char(_cdata(con), x, y, _int(c), flag)
474
475
def console_put_char_ex(con, x, y, c, fore, back):
476
    """Draw the character c at x,y using the colors fore and back."""
477
    lib.TCOD_console_put_char_ex(_cdata(con), x, y,
478
                                 _int(c), _color(fore), _color(back))
479
480
def console_set_char_background(con, x, y, col, flag=BKGND_SET):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_SET'
Loading history...
481
    """Change the background color of x,y to col using a blend mode."""
482
    lib.TCOD_console_set_char_background(_cdata(con), x, y, _color(col), flag)
483
484
def console_set_char_foreground(con, x, y, col):
485
    """Change the foreground color of x,y to col."""
486
    lib.TCOD_console_set_char_foreground(_cdata(con), x, y, _color(col))
487
488
def console_set_char(con, x, y, c):
489
    """Change the character at x,y to c, keeping the current colors."""
490
    lib.TCOD_console_set_char(_cdata(con), x, y, _int(c))
491
492
def console_set_background_flag(con, flag):
493
    """Change the default blend mode for this console."""
494
    lib.TCOD_console_set_background_flag(_cdata(con), flag)
495
496
def console_get_background_flag(con):
497
    """Return this consoles current blend mode."""
498
    return lib.TCOD_console_get_background_flag(_cdata(con))
499
500
def console_set_alignment(con, alignment):
501
    """Change this consoles current alignment mode.
502
503
    * tcod.LEFT
504
    * tcod.CENTER
505
    * tcod.RIGHT
506
    """
507
    lib.TCOD_console_set_alignment(_cdata(con), alignment)
508
509
def console_get_alignment(con):
510
    """Return this consoles current alignment mode."""
511
    return lib.TCOD_console_get_alignment(_cdata(con))
512
513
def console_print(con, x, y, fmt):
514
    """Print a string on a console."""
515
    lib.TCOD_console_print_utf(_cdata(con), x, y, _unicode(fmt))
516
517
def console_print_ex(con, x, y, flag, alignment, fmt):
518
    """Print a string on a console using a blend mode and alignment mode."""
519
    lib.TCOD_console_print_ex_utf(_cdata(con), x, y,
520
                                   flag, alignment, _unicode(fmt))
521
522
def console_print_rect(con, x, y, w, h, fmt):
523
    """Print a string constrained to a rectangle.
524
525
    If h > 0 and the bottom of the rectangle is reached,
526
    the string is truncated. If h = 0,
527
    the string is only truncated if it reaches the bottom of the console.
528
529
    :returns: Returns the number of lines of the text once word-wrapped.
530
    :rtype: int
531
    """
532
    return lib.TCOD_console_print_rect_utf(_cdata(con), x, y, w, h,
533
                                            _unicode(fmt))
534
535
def console_print_rect_ex(con, x, y, w, h, flag, alignment, fmt):
536
    """Print a string constrained to a rectangle with blend and alignment.
537
538
    :returns: Returns the number of lines of the text once word-wrapped.
539
    :rtype: int
540
    """
541
    return lib.TCOD_console_print_rect_ex_utf(_cdata(con), x, y, w, h,
542
                                               flag, alignment, _unicode(fmt))
543
544
def console_get_height_rect(con, x, y, w, h, fmt):
545
    """Return the height of this text once word-wrapped into this rectangle.
546
547
    :returns: Returns the number of lines of the text once word-wrapped.
548
    :rtype: int
549
    """
550
    return lib.TCOD_console_get_height_rect_utf(_cdata(con), x, y, w, h,
551
                                                 _unicode(fmt))
552
553
def console_rect(con, x, y, w, h, clr, flag=BKGND_DEFAULT):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
554
    """Draw a the background color on a rect optionally clearing the text.
555
556
    If clr is True the affected tiles are changed to space character.
557
    """
558
    lib.TCOD_console_rect(_cdata(con), x, y, w, h, clr, flag)
559
560
def console_hline(con, x, y, l, flag=BKGND_DEFAULT):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
561
    """Draw a horizontal line on the console.
562
563
    This always uses the character 196, the horizontal line character.
564
    """
565
    lib.TCOD_console_hline(_cdata(con), x, y, l, flag)
566
567
def console_vline(con, x, y, l, flag=BKGND_DEFAULT):
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
568
    """Draw a vertical line on the console.
569
570
    This always uses the character 179, the vertical line character.
571
    """
572
    lib.TCOD_console_vline(_cdata(con), x, y, l, flag)
573
574
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...
Comprehensibility Best Practice introduced by
Undefined variable 'BKGND_DEFAULT'
Loading history...
575
    """Draw a framed rectangle with optinal text.
576
577
    This uses the default background color and blend mode to fill the
578
    rectangle and the default foreground to draw the outline.
579
580
    fmt will be printed on the inside of the rectangle, word-wrapped.
581
    """
582
    lib.TCOD_console_print_frame(_cdata(con), x, y, w, h, clear, flag,
583
                                  _bytes(fmt))
584
585
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...
586
    lib.TCOD_console_set_color_control(_cdata(con), fore, back)
587
588
def console_get_default_background(con):
589
    """Return this consoles default background color."""
590
    return Color.from_cdata(lib.TCOD_console_get_default_background(_cdata(con)))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (81/79).

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

Loading history...
591
592
def console_get_default_foreground(con):
593
    """Return this consoles default foreground color."""
594
    return Color.from_cdata(lib.TCOD_console_get_default_foreground(_cdata(con)))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (81/79).

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

Loading history...
595
596
def console_get_char_background(con, x, y):
597
    """Return the background color at the x,y of this console."""
598
    return Color.from_cdata(lib.TCOD_console_get_char_background(_cdata(con), x, y))
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...
599
600
def console_get_char_foreground(con, x, y):
601
    """Return the foreground color at the x,y of this console."""
602
    return Color.from_cdata(lib.TCOD_console_get_char_foreground(_cdata(con), x, y))
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...
603
604
def console_get_char(con, x, y):
605
    """Return the character at the x,y of this console."""
606
    return lib.TCOD_console_get_char(_cdata(con), x, y)
607
608
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...
609
    lib.TCOD_console_set_fade(fade, fadingColor)
610
611
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...
612
    return lib.TCOD_console_get_fade()
613
614
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...
615
    return Color.from_cdata(lib.TCOD_console_get_fading_color())
616
617
# handling keyboard input
618
def console_wait_for_keypress(flush):
619
    """Block until the user presses a key, then returns a :any:Key instance.
620
621
    :param bool flush: If True then the event queue is cleared before waiting
622
                       for the next event.
623
    :rtype: Key
624
    """
625
    k=Key()
0 ignored issues
show
Coding Style introduced by
Exactly one space required around assignment
k=Key()
^
Loading history...
626
    lib.TCOD_console_wait_for_keypress_wrapper(k.cdata, flush)
627
    return k
628
629
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...
630
    k=Key()
0 ignored issues
show
Coding Style introduced by
Exactly one space required around assignment
k=Key()
^
Loading history...
631
    lib.TCOD_console_check_for_keypress_wrapper(k.cdata, flags)
632
    return k
633
634
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...
635
    return lib.TCOD_console_is_key_pressed(key)
636
637
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...
638
    lib.TCOD_console_set_keyboard_repeat(initial_delay, interval)
639
640
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...
641
    lib.TCOD_console_disable_keyboard_repeat()
642
643
# using offscreen consoles
644
def console_new(w, h):
645
    """Return an offscreen console of size: w,h."""
646
    return ffi.gc(lib.TCOD_console_new(w, h), lib.TCOD_console_delete)
647
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...
648
    return lib.TCOD_console_from_file(_bytes(filename))
649
650
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...
651
    """Blit the console src from x,y,w,h to console dst at xdst,ydst."""
652
    lib.TCOD_console_blit(_cdata(src), x, y, w, h,
653
                          _cdata(dst), xdst, ydst, ffade, bfade)
654
655
def console_set_key_color(con, col):
656
    """Set a consoles blit transparent color."""
657
    lib.TCOD_console_set_key_color(_cdata(con), _color(col))
658
659
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...
660
    con = _cdata(con)
661
    if con == ffi.NULL:
662
        lib.TCOD_console_delete(con)
663
664
# fast color filling
665 View Code Duplication
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...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
666
    if len(r) != len(g) or len(r) != len(b):
667
        raise TypeError('R, G and B must all have the same size.')
668
    if (_numpy_available() and isinstance(r, _numpy.ndarray) and
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...
669
        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...
670
        #numpy arrays, use numpy's ctypes functions
671
        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...
672
        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...
673
        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...
674
        cr = ffi.cast('int *', r.ctypes.data)
675
        cg = ffi.cast('int *', g.ctypes.data)
676
        cb = ffi.cast('int *', b.ctypes.data)
677
    else:
678
        # otherwise convert using ffi arrays
679
        cr = ffi.new('int[]', r)
680
        cg = ffi.new('int[]', g)
681
        cb = ffi.new('int[]', b)
682
683
    lib.TCOD_console_fill_foreground(_cdata(con), cr, cg, cb)
684
685 View Code Duplication
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...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
686
    if len(r) != len(g) or len(r) != len(b):
687
        raise TypeError('R, G and B must all have the same size.')
688
    if (_numpy_available() and isinstance(r, _numpy.ndarray) and
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...
689
        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...
690
        #numpy arrays, use numpy's ctypes functions
691
        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...
692
        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...
693
        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...
694
        cr = ffi.cast('int *', r.ctypes.data)
695
        cg = ffi.cast('int *', g.ctypes.data)
696
        cb = ffi.cast('int *', b.ctypes.data)
697
    else:
698
        # otherwise convert using ffi arrays
699
        cr = ffi.new('int[]', r)
700
        cg = ffi.new('int[]', g)
701
        cb = ffi.new('int[]', b)
702
703
    lib.TCOD_console_fill_background(_cdata(con), cr, cg, cb)
704
705
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...
706
    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...
707
        #numpy arrays, use numpy's ctypes functions
708
        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...
709
        carr = ffi.cast('int *', arr.ctypes.data)
710
    else:
711
        #otherwise convert using the ffi module
712
        carr = ffi.new('int[]', arr)
713
714
    lib.TCOD_console_fill_char(_cdata(con), carr)
715
716
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...
717
    return lib.TCOD_console_load_asc(_cdata(con), _bytes(filename))
718
719
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...
720
    lib.TCOD_console_save_asc(_cdata(con),_bytes(filename))
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_console_save_asc(_cdata(con),_bytes(filename))
^
Loading history...
721
722
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...
723
    return lib.TCOD_console_load_apf(_cdata(con),_bytes(filename))
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return lib.TCOD_console_load_apf(_cdata(con),_bytes(filename))
^
Loading history...
724
725
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...
726
    lib.TCOD_console_save_apf(_cdata(con),_bytes(filename))
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_console_save_apf(_cdata(con),_bytes(filename))
^
Loading history...
727
728
@ffi.def_extern()
729
def _pycall_path_func(x1, y1, x2, y2, handle):
730
    '''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...
731
    '''
732
    func, propagate_manager, user_data = ffi.from_handle(handle)
733
    try:
734
        return func(x1, y1, x2, y2, *user_data)
735
    except BaseException:
736
        propagate_manager.propagate(*_sys.exc_info())
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable '_sys'
Loading history...
737
        return None
738
739
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...
740
    return (ffi.gc(lib.TCOD_path_new_using_map(m, dcost),
741
                    lib.TCOD_path_delete), _PropagateException())
742
743
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...
744
    propagator = _PropagateException()
745
    handle = ffi.new_handle((func, propagator, (userData,)))
746
    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...
747
            handle, dcost), lib.TCOD_path_delete), propagator, handle)
748
749
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...
750
    with p[1]:
751
        return lib.TCOD_path_compute(p[0], ox, oy, dx, dy)
752
753
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...
754
    x = ffi.new('int *')
755
    y = ffi.new('int *')
756
    lib.TCOD_path_get_origin(p[0], x, y)
757
    return x[0], y[0]
758
759
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...
760
    x = ffi.new('int *')
761
    y = ffi.new('int *')
762
    lib.TCOD_path_get_destination(p[0], x, y)
763
    return x[0], y[0]
764
765
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...
766
    return lib.TCOD_path_size(p[0])
767
768
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...
769
    lib.TCOD_path_reverse(p[0])
770
771
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...
772
    x = ffi.new('int *')
773
    y = ffi.new('int *')
774
    lib.TCOD_path_get(p[0], idx, x, y)
775
    return x[0], y[0]
776
777
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...
778
    return lib.TCOD_path_is_empty(p[0])
779
780
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...
781
    x = ffi.new('int *')
782
    y = ffi.new('int *')
783
    with p[1]:
784
        if lib.TCOD_path_walk(p[0], x, y, recompute):
785
            return x[0], y[0]
786
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
787
788
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...
789
    pass
790
791
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...
792
    return (ffi.gc(lib.TCOD_dijkstra_new(m, dcost),
793
                    lib.TCOD_dijkstra_delete), _PropagateException())
794
795
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...
796
    propagator = _PropagateException()
797
    handle = ffi.new_handle((func, propagator, (userData,)))
798
    return (ffi.gc(lib.TCOD_dijkstra_new_using_function(w, h,
799
                    lib._pycall_path_func, handle, dcost),
800
                    lib.TCOD_dijkstra_delete), propagator, handle)
801
802
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...
803
    with p[1]:
804
        lib.TCOD_dijkstra_compute(p[0], ox, oy)
805
806
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...
807
    return lib.TCOD_dijkstra_path_set(p[0], x, y)
808
809
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...
810
    return lib.TCOD_dijkstra_get_distance(p[0], x, y)
811
812
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...
813
    return lib.TCOD_dijkstra_size(p[0])
814
815
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...
816
    lib.TCOD_dijkstra_reverse(p[0])
817
818
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...
819
    x = ffi.new('int *')
820
    y = ffi.new('int *')
821
    lib.TCOD_dijkstra_get(p[0], idx, x, y)
822
    return x[0], y[0]
823
824
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...
825
    return lib.TCOD_dijkstra_is_empty(p[0])
826
827
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...
828
    x = ffi.new('int *')
829
    y = ffi.new('int *')
830
    if lib.TCOD_dijkstra_path_walk(p[0], x, y):
831
        return x[0], y[0]
832
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
833
834
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...
835
    pass
836
837
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...
838
    return HeightMap(w, h)
839
840
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...
841
    lib.TCOD_heightmap_set_value(hm.cdata, x, y, value)
842
843
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...
844
    lib.TCOD_heightmap_add(hm.cdata, value)
845
846
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...
847
    lib.TCOD_heightmap_scale(hm.cdata, value)
848
849
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...
850
    lib.TCOD_heightmap_clear(hm.cdata)
851
852
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...
853
    lib.TCOD_heightmap_clamp(hm.cdata, mi, ma)
854
855
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...
856
    lib.TCOD_heightmap_copy(hm1.cdata, hm2.cdata)
857
858
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...
859
    lib.TCOD_heightmap_normalize(hm.cdata, mi, ma)
860
861
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...
862
    lib.TCOD_heightmap_lerp_hm(hm1.cdata, hm2.cdata, hm3.cdata, coef)
863
864
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...
865
    lib.TCOD_heightmap_add_hm(hm1.cdata, hm2.cdata, hm3.cdata)
866
867
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...
868
    lib.TCOD_heightmap_multiply_hm(hm1.cdata, hm2.cdata, hm3.cdata)
869
870
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...
871
    lib.TCOD_heightmap_add_hill(hm.cdata, x, y, radius, height)
872
873
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...
874
    lib.TCOD_heightmap_dig_hill(hm.cdata, x, y, radius, height)
875
876
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...
877
    lib.TCOD_heightmap_rain_erosion(hm.cdata, nbDrops, erosionCoef,
878
                                     sedimentationCoef, rnd or ffi.NULL)
879
880
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...
881
                               maxLevel):
882
    cdx = ffi.new('int[]', dx)
883
    cdy = ffi.new('int[]', dy)
884
    cweight = ffi.new('float[]', weight)
885
    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...
886
                                         minLevel, maxLevel)
887
888
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...
889
    ccoef = ffi.new('float[]', coef)
890
    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...
891
892
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...
893
    lib.TCOD_heightmap_add_fbm(hm.cdata, noise, mulx, muly, addx, addy,
894
                                octaves, delta, scale)
895
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...
896
                        scale):
897
    lib.TCOD_heightmap_scale_fbm(hm.cdata, noise, mulx, muly, addx, addy,
898
                                  octaves, delta, scale)
899
900
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...
901
                         endDepth):
902
    #IARRAY = c_int * 4
903
    cpx = ffi.new('int[4]', px)
904
    cpy = ffi.new('int[4]', py)
905
    lib.TCOD_heightmap_dig_bezier(hm.cdata, cpx, cpy, startRadius,
906
                                   startDepth, endRadius,
907
                                   endDepth)
908
909
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...
910
    return lib.TCOD_heightmap_get_value(hm.cdata, x, y)
911
912
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...
913
    return lib.TCOD_heightmap_get_interpolated_value(hm.cdata, x, y)
914
915
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...
916
    return lib.TCOD_heightmap_get_slope(hm.cdata, x, y)
917
918
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...
919
    #FARRAY = c_float * 3
920
    cn = ffi.new('float[3]')
921
    lib.TCOD_heightmap_get_normal(hm.cdata, x, y, cn, waterLevel)
922
    return tuple(cn)
923
924
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...
925
    return lib.TCOD_heightmap_count_cells(hm.cdata, mi, ma)
926
927
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...
928
    return lib.TCOD_heightmap_has_land_on_border(hm.cdata, waterlevel)
929
930
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...
931
    mi = ffi.new('float *')
932
    ma = ffi.new('float *')
933
    lib.TCOD_heightmap_get_minmax(hm.cdata, mi, ma)
934
    return mi[0], ma[0]
935
936
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...
937
    pass
938
939
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...
940
    return ffi.gc(lib.TCOD_image_new(width, height), lib.TCOD_image_delete)
941
942
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...
943
    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...
944
945
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...
946
    lib.TCOD_image_invert(image)
947
948
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...
949
    lib.TCOD_image_hflip(image)
950
951
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...
952
    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...
953
954
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...
955
    lib.TCOD_image_vflip(image)
956
957
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...
958
    lib.TCOD_image_scale(image, neww, newh)
959
960
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...
961
    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...
962
963
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...
964
    return lib.TCOD_image_get_alpha(image, x, y)
965
966
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...
967
    return lib.TCOD_image_is_pixel_transparent(image, x, y)
968
969
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...
970
    return ffi.gc(lib.TCOD_image_load(_bytes(filename)),
971
                   lib.TCOD_image_delete)
972
973
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...
974
    return ffi.gc(lib.TCOD_image_from_console(console or ffi.NULL),
975
                   lib.TCOD_image_delete)
976
977
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...
978
    lib.TCOD_image_refresh_console(image, console or ffi.NULL)
979
980
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...
981
    w = ffi.new('int *')
982
    h = ffi.new('int *')
983
    lib.TCOD_image_get_size(image, w, h)
984
    return w[0], h[0]
985
986
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...
987
    return lib.TCOD_image_get_pixel(image, x, y)
988
989
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...
990
    return lib.TCOD_image_get_mipmap_pixel(image, x0, y0, x1, y1)
991
992
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...
993
    lib.TCOD_image_put_pixel(image, x, y, col)
994
    ##lib.TCOD_image_put_pixel_wrapper(image, x, y, col)
995
996
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...
997
    lib.TCOD_image_blit(image, console or ffi.NULL, x, y, bkgnd_flag,
998
                         scalex, scaley, angle)
999
1000
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...
1001
    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...
1002
1003
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...
1004
    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...
1005
1006
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...
1007
    lib.TCOD_image_save(image, _bytes(filename))
1008
1009
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...
1010
    pass
1011
1012
def line_init(xo, yo, xd, yd):
1013
    """Initilize a line whose points will be returned by `line_step`.
1014
1015
    This function does not return anything on its own.
1016
1017
    Does not include the origin point.
1018
1019
    :param int xo: x origin
1020
    :param int yo: y origin
1021
    :param int xd: x destination
1022
    :param int yd: y destination
1023
1024
    .. deprecated:: 2.0
1025
       Use `line_iter` instead.
1026
    """
1027
    lib.TCOD_line_init(xo, yo, xd, yd)
1028
1029
def line_step():
1030
    """After calling `line_init` returns (x, y) points of the line.
1031
1032
    Once all points are exhausted this function will return (None, None)
1033
1034
    :return: next (x, y) point of the line setup by `line_init`,
1035
             or (None, None) if there are no more points.
1036
    :rtype: tuple(x, y)
1037
1038
    .. deprecated:: 2.0
1039
       Use `line_iter` instead.
1040
    """
1041
    x = ffi.new('int *')
1042
    y = ffi.new('int *')
1043
    ret = lib.TCOD_line_step(x, y)
1044
    if not ret:
1045
        return x[0], y[0]
1046
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
1047
1048
_line_listener_lock = _threading.Lock()
1049
1050
def line(xo, yo, xd, yd, py_callback):
1051
    """ Iterate over a line using a callback function.
1052
1053
    Your callback function will take x and y parameters and return True to
1054
    continue iteration or False to stop iteration and return.
1055
1056
    This function includes both the start and end points.
1057
1058
    :param int xo: x origin
1059
    :param int yo: y origin
1060
    :param int xd: x destination
1061
    :param int yd: y destination
1062
    :param function py_callback: Callback that takes x and y parameters and
1063
                                 returns bool.
1064
    :return: Returns False if the callback cancels the line interation by
1065
             returning False or None, otherwise True.
1066
    :rtype: bool
1067
1068
    .. deprecated:: 2.0
1069
       Use `line_iter` instead.
1070
    """
1071
    with _PropagateException() as propagate:
1072
        with _line_listener_lock:
1073
            @ffi.def_extern(onerror=propagate)
1074
            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...
1075
                return py_callback(x, y)
1076
            return bool(lib.TCOD_line(xo, yo, xd, yd,
1077
                                       lib._pycall_line_listener))
1078
1079
def line_iter(xo, yo, xd, yd):
1080
    """ returns an iterator
1081
1082
    This iterator does not include the origin point.
1083
1084
    :param int xo: x origin
1085
    :param int yo: y origin
1086
    :param int xd: x destination
1087
    :param int yd: y destination
1088
1089
    :return: iterator of (x,y) points
1090
    """
1091
    data = ffi.new('TCOD_bresenham_data_t *')
1092
    lib.TCOD_line_init_mt(xo, yo, xd, yd, data)
1093
    x = ffi.new('int *')
1094
    y = ffi.new('int *')
1095
    done = False
0 ignored issues
show
Unused Code introduced by
The variable done seems to be unused.
Loading history...
1096
    while not lib.TCOD_line_step_mt(x, y, data):
1097
        yield (x[0], y[0])
1098
1099
FOV_BASIC = 0
1100
FOV_DIAMOND = 1
1101
FOV_SHADOW = 2
1102
FOV_PERMISSIVE_0 = 3
1103
FOV_PERMISSIVE_1 = 4
1104
FOV_PERMISSIVE_2 = 5
1105
FOV_PERMISSIVE_3 = 6
1106
FOV_PERMISSIVE_4 = 7
1107
FOV_PERMISSIVE_5 = 8
1108
FOV_PERMISSIVE_6 = 9
1109
FOV_PERMISSIVE_7 = 10
1110
FOV_PERMISSIVE_8 = 11
1111
FOV_RESTRICTIVE = 12
1112
NB_FOV_ALGORITHMS = 13
1113
1114
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...
1115
    return ffi.gc(lib.TCOD_map_new(w, h), lib.TCOD_map_delete)
1116
1117
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...
1118
    return lib.TCOD_map_copy(source, dest)
1119
1120
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...
1121
    lib.TCOD_map_set_properties(m, x, y, isTrans, isWalk)
1122
1123
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...
1124
    lib.TCOD_map_clear(m, walkable, transparent)
1125
1126
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...
1127
    lib.TCOD_map_compute_fov(m, x, y, radius, light_walls, algo)
1128
1129
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...
1130
    return lib.TCOD_map_is_in_fov(m, x, y)
1131
1132
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...
1133
    return lib.TCOD_map_is_transparent(m, x, y)
1134
1135
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...
1136
    return lib.TCOD_map_is_walkable(m, x, y)
1137
1138
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...
1139
    pass
1140
1141
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...
1142
    return lib.TCOD_map_get_width(map)
1143
1144
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...
1145
    return lib.TCOD_map_get_height(map)
1146
1147
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...
1148
    lib.TCOD_mouse_show_cursor(visible)
1149
1150
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...
1151
    return lib.TCOD_mouse_is_cursor_visible()
1152
1153
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...
1154
    lib.TCOD_mouse_move(x, y)
1155
1156
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...
1157
    return Mouse(lib.TCOD_mouse_get_status())
1158
1159
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...
1160
    lib.TCOD_namegen_parse(_bytes(filename), random or ffi.NULL)
1161
1162
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...
1163
    return _unpack_char_p(lib.TCOD_namegen_generate(_bytes(name), False))
1164
1165
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...
1166
    return _unpack_char_p(lib.TCOD_namegen_generate(_bytes(name),
1167
                                                     _bytes(rule), False))
1168
1169
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...
1170
    sets = lib.TCOD_namegen_get_sets()
1171
    try:
1172
        lst = []
1173
        while not lib.TCOD_list_is_empty(sets):
1174
            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...
1175
    finally:
1176
        lib.TCOD_list_delete(sets)
1177
    return lst
1178
1179
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...
1180
    lib.TCOD_namegen_destroy()
1181
1182
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...
1183
        random=None):
1184
    return ffi.gc(lib.TCOD_noise_new(dim, h, l, random or ffi.NULL),
1185
                   lib.TCOD_noise_delete)
1186
1187
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...
1188
    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...
1189
1190
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...
1191
    return lib.TCOD_noise_get_ex(n, ffi.new('float[]', f), typ)
1192
1193
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...
1194
    return lib.TCOD_noise_get_fbm_ex(n, ffi.new('float[]', f), oc, typ)
1195
1196
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...
1197
    return lib.TCOD_noise_get_turbulence_ex(n, ffi.new('float[]', f), oc, typ)
1198
1199
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...
1200
    pass
1201
1202
_chr = chr
1203
try:
1204
    _chr = unichr # Python 2
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'unichr'
Loading history...
1205
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...
1206
    pass
1207
1208
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...
1209
    '''
1210
        unpack items from parser new_property (value_converter)
1211
    '''
1212
    if type == lib.TCOD_TYPE_BOOL:
1213
        return bool(union.b)
1214
    elif type == lib.TCOD_TYPE_CHAR:
1215
        return _unicode(union.c)
1216
    elif type == lib.TCOD_TYPE_INT:
1217
        return union.i
1218
    elif type == lib.TCOD_TYPE_FLOAT:
1219
        return union.f
1220
    elif (type == lib.TCOD_TYPE_STRING or
1221
         lib.TCOD_TYPE_VALUELIST15 >= type >= lib.TCOD_TYPE_VALUELIST00):
1222
         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...
1223
    elif type == lib.TCOD_TYPE_COLOR:
1224
        return Color.from_cdata(union.col)
1225
    elif type == lib.TCOD_TYPE_DICE:
1226
        return Dice(union.dice)
1227
    elif type & lib.TCOD_TYPE_LIST:
1228
        return _convert_TCODList(union.list, type & 0xFF)
1229
    else:
1230
        raise RuntimeError('Unknown libtcod type: %i' % type)
1231
1232
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...
1233
    return [_unpack_union(type, lib.TDL_list_get_union(clist, i))
1234
            for i in range(lib.TCOD_list_size(clist))]
1235
1236
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...
1237
    return ffi.gc(lib.TCOD_parser_new(), lib.TCOD_parser_delete)
1238
1239
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...
1240
    return lib.TCOD_parser_new_struct(parser, name)
1241
1242
# prevent multiple threads from messing with def_extern callbacks
1243
_parser_callback_lock = _threading.Lock()
1244
1245
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...
1246
    if not listener:
1247
        lib.TCOD_parser_run(parser, _bytes(filename), ffi.NULL)
1248
        return
1249
1250
    propagate_manager = _PropagateException()
1251
    propagate = propagate_manager.propagate
1252
1253
    with _parser_callback_lock:
1254
        clistener = ffi.new('TCOD_parser_listener_t *')
1255
1256
        @ffi.def_extern(onerror=propagate)
1257
        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...
1258
            return listener.end_struct(struct, _unpack_char_p(name))
1259
1260
        @ffi.def_extern(onerror=propagate)
1261
        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...
1262
            return listener.new_flag(_unpack_char_p(name))
1263
1264
        @ffi.def_extern(onerror=propagate)
1265
        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...
1266
            return listener.new_property(_unpack_char_p(propname), type,
1267
                                         _unpack_union(type, value))
1268
1269
        @ffi.def_extern(onerror=propagate)
1270
        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...
1271
            return listener.end_struct(struct, _unpack_char_p(name))
1272
1273
        @ffi.def_extern(onerror=propagate)
1274
        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...
1275
            listener.error(_unpack_char_p(msg))
1276
1277
        clistener.new_struct = lib.pycall_parser_new_struct
1278
        clistener.new_flag = lib.pycall_parser_new_flag
1279
        clistener.new_property = lib.pycall_parser_new_property
1280
        clistener.end_struct = lib.pycall_parser_end_struct
1281
        clistener.error = lib.pycall_parser_error
1282
1283
        with propagate_manager:
1284
            lib.TCOD_parser_run(parser, _bytes(filename), clistener)
1285
1286
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...
1287
    pass
1288
1289
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...
1290
    return bool(lib.TCOD_parser_get_bool_property(parser, _bytes(name)))
1291
1292
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...
1293
    return lib.TCOD_parser_get_int_property(parser, _bytes(name))
1294
1295
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...
1296
    return _chr(lib.TCOD_parser_get_char_property(parser, _bytes(name)))
1297
1298
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...
1299
    return lib.TCOD_parser_get_float_property(parser, _bytes(name))
1300
1301
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...
1302
    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...
1303
1304
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...
1305
    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...
1306
1307
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...
1308
    d = ffi.new('TCOD_dice_t *')
1309
    lib.TCOD_parser_get_dice_property_py(parser, _bytes(name), d)
1310
    return Dice(d)
1311
1312
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...
1313
    clist = lib.TCOD_parser_get_list_property(parser, _bytes(name), type)
1314
    return _convert_TCODList(clist, type)
1315
1316
RNG_MT = 0
1317
RNG_CMWC = 1
1318
1319
DISTRIBUTION_LINEAR = 0
1320
DISTRIBUTION_GAUSSIAN = 1
1321
DISTRIBUTION_GAUSSIAN_RANGE = 2
1322
DISTRIBUTION_GAUSSIAN_INVERSE = 3
1323
DISTRIBUTION_GAUSSIAN_RANGE_INVERSE = 4
1324
1325
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...
1326
    return lib.TCOD_random_get_instance()
1327
1328
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...
1329
    return ffi.gc(lib.TCOD_random_new(algo), lib.TCOD_random_delete)
1330
1331
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...
1332
    return ffi.gc(lib.TCOD_random_new_from_seed(algo, seed),
1333
                   lib.TCOD_random_delete)
1334
1335
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...
1336
	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...
1337
1338
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...
1339
    return lib.TCOD_random_get_int(rnd or ffi.NULL, mi, ma)
1340
1341
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...
1342
    return lib.TCOD_random_get_float(rnd or ffi.NULL, mi, ma)
1343
1344
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...
1345
    return lib.TCOD_random_get_double(rnd or ffi.NULL, mi, ma)
1346
1347
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...
1348
    return lib.TCOD_random_get_int_mean(rnd or ffi.NULL, mi, ma, mean)
1349
1350
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...
1351
    return lib.TCOD_random_get_float_mean(rnd or ffi.NULL, mi, ma, mean)
1352
1353
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...
1354
    return lib.TCOD_random_get_double_mean(rnd or ffi.NULL, mi, ma, mean)
1355
1356
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...
1357
    return ffi.gc(lib.TCOD_random_save(rnd or ffi.NULL),
1358
                   lib.TCOD_random_delete)
1359
1360
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...
1361
    lib.TCOD_random_restore(rnd or ffi.NULL, backup)
1362
1363
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...
1364
    pass
1365
1366
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...
1367
    lib.TCOD_struct_add_flag(struct, name)
1368
1369
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...
1370
    lib.TCOD_struct_add_property(struct, name, typ, mandatory)
1371
1372
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...
1373
    CARRAY = c_char_p * (len(value_list) + 1)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'c_char_p'
Loading history...
1374
    cvalue_list = CARRAY()
1375
    for i in range(len(value_list)):
1376
        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...
1377
    cvalue_list[len(value_list)] = 0
1378
    lib.TCOD_struct_add_value_list(struct, name, cvalue_list, mandatory)
1379
1380
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...
1381
    lib.TCOD_struct_add_list_property(struct, name, typ, mandatory)
1382
1383
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...
1384
    lib.TCOD_struct_add_structure(struct, sub_struct)
1385
1386
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...
1387
    return _unpack_char_p(lib.TCOD_struct_get_name(struct))
1388
1389
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...
1390
    return lib.TCOD_struct_is_mandatory(struct, name)
1391
1392
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...
1393
    return lib.TCOD_struct_get_type(struct, name)
1394
1395
# high precision time functions
1396
def sys_set_fps(fps):
1397
    """Set the maximum frame rate.
1398
1399
    You can disable the frame limit again by setting fps to 0.
1400
1401
    :param int fps: A frame rate limit (i.e. 60)
1402
    """
1403
    lib.TCOD_sys_set_fps(fps)
1404
1405
def sys_get_fps():
1406
    """Return the current frames per second.
1407
1408
    This the actual frame rate, not the frame limit set by
1409
    :any:`tcod.sys_set_fps`.
1410
1411
    This number is updated every second.
1412
1413
    :rtype: int
1414
    """
1415
    return lib.TCOD_sys_get_fps()
1416
1417
def sys_get_last_frame_length():
1418
    """Return the delta time of the last rendered frame in seconds.
1419
1420
    :rtype: float
1421
    """
1422
    return lib.TCOD_sys_get_last_frame_length()
1423
1424
def sys_sleep_milli(val):
1425
    """Sleep for 'val' milliseconds.
1426
1427
    :param int val: Time to sleep for in milliseconds.
1428
1429
    .. deprecated:: 2.0
1430
       Use :any:`time.sleep` instead.
1431
    """
1432
    lib.TCOD_sys_sleep_milli(val)
1433
1434
def sys_elapsed_milli():
1435
    """Get number of milliseconds since the start of the program.
1436
1437
    :rtype: int
1438
1439
    .. deprecated:: 2.0
1440
       Use :any:`time.clock` instead.
1441
    """
1442
    return lib.TCOD_sys_elapsed_milli()
1443
1444
def sys_elapsed_seconds():
1445
    """Get number of seconds since the start of the program.
1446
1447
    :rtype: float
1448
1449
    .. deprecated:: 2.0
1450
       Use :any:`time.clock` instead.
1451
    """
1452
    return lib.TCOD_sys_elapsed_seconds()
1453
1454
def sys_set_renderer(renderer):
1455
    """Change the current rendering mode to renderer.
1456
1457
    .. deprecated:: 2.0
1458
       RENDERER_GLSL and RENDERER_OPENGL are not currently available.
1459
    """
1460
    lib.TCOD_sys_set_renderer(renderer)
1461
1462
def sys_get_renderer():
1463
    """Return the current rendering mode.
1464
1465
    """
1466
    return lib.TCOD_sys_get_renderer()
1467
1468
# easy screenshots
1469
def sys_save_screenshot(name=None):
1470
    """Save a screenshot to a file.
1471
1472
    By default this will automatically save screenshots in the working
1473
    directory.
1474
1475
    The automatic names are formatted as screenshotNNN.png.  For example:
1476
    screenshot000.png, screenshot001.png, etc.  Whichever is available first.
1477
1478
    :param str file: File path to save screenshot.
1479
1480
    """
1481
    if name is not None:
1482
        name = _bytes(name)
1483
    lib.TCOD_sys_save_screenshot(name or ffi.NULL)
1484
1485
# custom fullscreen resolution
1486
def sys_force_fullscreen_resolution(width, height):
1487
    """Force a specific resolution in fullscreen.
1488
1489
    Will use the smallest available resolution so that:
1490
1491
    * resolution width >= width and
1492
      resolution width >= root console width * font char width
1493
    * resolution height >= height and
1494
      resolution height >= root console height * font char height
1495
    """
1496
    lib.TCOD_sys_force_fullscreen_resolution(width, height)
1497
1498
def sys_get_current_resolution():
1499
    """Return the current resolution as (width, height)"""
1500
    w = ffi.new('int *')
1501
    h = ffi.new('int *')
1502
    lib.TCOD_sys_get_current_resolution(w, h)
1503
    return w[0], h[0]
1504
1505
def sys_get_char_size():
1506
    """Return the current fonts character size as (width, height)"""
1507
    w = ffi.new('int *')
1508
    h = ffi.new('int *')
1509
    lib.TCOD_sys_get_char_size(w, h)
1510
    return w[0], h[0]
1511
1512
# update font bitmap
1513
def sys_update_char(asciiCode, fontx, fonty, img, x, y):
1514
    """Dynamically update the current frot with img.
1515
1516
    All cells using this asciiCode will be updated
1517
    at the next call to :any:`tcod.console_flush`.
1518
1519
    :param int asciiCode: Ascii code corresponding to the character to update.
1520
    :param int fontx: Left coordinate of the character
1521
                      in the bitmap font (in tiles)
1522
    :param int fonty: Top coordinate of the character
1523
                      in the bitmap font (in tiles)
1524
    :param img: An image containing the new character bitmap.
1525
    :param int x: Left pixel of the character in the image.
1526
    :param int y: Top pixel of the character in the image.
1527
    """
1528
    lib.TCOD_sys_update_char(_int(asciiCode), fontx, fonty, img, x, y)
1529
1530
def sys_register_SDL_renderer(callback):
1531
    """Register a custom randering function with libtcod.
1532
1533
    The callack will receive a :any:`CData <ffi-cdata>` void* to an
1534
    SDL_Surface* struct.
1535
1536
    The callback is called on every call to :any:`tcod.console_flush`.
1537
1538
    :param callable callback: A function which takes a single argument.
1539
    """
1540
    with _PropagateException() as propagate:
1541
        @ffi.def_extern(onerror=propagate)
1542
        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...
1543
            callback(sdl_surface)
1544
        lib.TCOD_sys_register_SDL_renderer(lib._pycall_sdl_hook)
1545
1546
def sys_check_for_event(mask, k, m):
1547
    """Check for events.
1548
1549
    mask can be any of the following:
1550
1551
    * tcod.EVENT_NONE
1552
    * tcod.EVENT_KEY_PRESS
1553
    * tcod.EVENT_KEY_RELEASE
1554
    * tcod.EVENT_KEY
1555
    * tcod.EVENT_MOUSE_MOVE
1556
    * tcod.EVENT_MOUSE_PRESS
1557
    * tcod.EVENT_MOUSE_RELEASE
1558
    * tcod.EVENT_MOUSE
1559
    * tcod.EVENT_FINGER_MOVE
1560
    * tcod.EVENT_FINGER_PRESS
1561
    * tcod.EVENT_FINGER_RELEASE
1562
    * tcod.EVENT_FINGER
1563
    * tcod.EVENT_ANY
1564
1565
    :param mask: Event types to wait for.
1566
    :param Key k: :any:`tcod.Key` instance which might be updated with
1567
                  an event.  Can be None.
1568
1569
    :param Mouse m: :any:`tcod.Mouse` instance which might be updated
1570
                    with an event.  Can be None.
1571
    """
1572
    return lib.TCOD_sys_check_for_event(mask, _cdata(k), _cdata(m))
1573
1574
def sys_wait_for_event(mask, k, m, flush):
1575
    """Wait for events.
1576
1577
    mask can be any of the following:
1578
1579
    * tcod.EVENT_NONE
1580
    * tcod.EVENT_KEY_PRESS
1581
    * tcod.EVENT_KEY_RELEASE
1582
    * tcod.EVENT_KEY
1583
    * tcod.EVENT_MOUSE_MOVE
1584
    * tcod.EVENT_MOUSE_PRESS
1585
    * tcod.EVENT_MOUSE_RELEASE
1586
    * tcod.EVENT_MOUSE
1587
    * tcod.EVENT_FINGER_MOVE
1588
    * tcod.EVENT_FINGER_PRESS
1589
    * tcod.EVENT_FINGER_RELEASE
1590
    * tcod.EVENT_FINGER
1591
    * tcod.EVENT_ANY
1592
1593
    If flush is True then the buffer will be cleared before waiting. Otherwise
1594
    each available event will be returned in the order they're recieved.
1595
1596
    :param mask: Event types to wait for.
1597
    :param Key k: :any:`tcod.Key` instance which might be updated with
1598
                  an event.  Can be None.
1599
1600
    :param Mouse m: :any:`tcod.Mouse` instance which might be updated
1601
                    with an event.  Can be None.
1602
1603
    :param bool flush: Clear the buffer before waiting.
1604
    """
1605
    return lib.TCOD_sys_wait_for_event(mask, _cdata(k), _cdata(m), flush)
1606
1607
__all__ = [_name for _name in list(globals()) if _name[0] != '_']
1608