Completed
Push — master ( 8f28b9...54dd4d )
by Kyle
01:14
created

heightmap_kernel_transform()   B

Complexity

Conditions 1

Size

Total Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
cc 1
c 5
b 0
f 0
dl 0
loc 43
rs 8.8571
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
import numpy as _np
0 ignored issues
show
Configuration introduced by
The import numpy could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
9
10
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
FOV_PERMISSIVE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
BKGND_ALPHA was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
NOISE_SIMPLEX 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...
11
12
from tcod.tcod import _int, _cdata, _unpack_char_p
13
from tcod.tcod import _bytes, _unicode, _fmt_bytes, _fmt_unicode
14
from tcod.tcod import _CDataWrapper
15
from tcod.tcod import _PropagateException
16
from tcod.tcod import AStar
17
from tcod.tcod import BSP as Bsp
18
from tcod.tcod import Console
19
from tcod.tcod import Dijkstra
20
from tcod.tcod import Image
21
from tcod.tcod import Key
22
from tcod.tcod import Map
23
from tcod.tcod import Mouse
24
from tcod.tcod import Noise
25
from tcod.tcod import Random
26
27
class ConsoleBuffer(object):
28
    """Simple console that allows direct (fast) access to cells. simplifies
29
    use of the "fill" functions.
30
31
    Args:
32
        width (int): Width of the new ConsoleBuffer.
33
        height (int): Height of the new ConsoleBuffer.
34
        back_r (int): Red background color, from 0 to 255.
35
        back_g (int): Green background color, from 0 to 255.
36
        back_b (int): Blue background color, from 0 to 255.
37
        fore_r (int): Red foreground color, from 0 to 255.
38
        fore_g (int): Green foreground color, from 0 to 255.
39
        fore_b (int): Blue foreground color, from 0 to 255.
40
        char (AnyStr): A single character str or bytes object.
41
    """
42
    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...
43
        """initialize with given width and height. values to fill the buffer
44
        are optional, defaults to black with no characters.
45
        """
46
        n = width * height
0 ignored issues
show
Unused Code introduced by
The variable n seems to be unused.
Loading history...
47
        self.width = width
48
        self.height = height
49
        self.clear(back_r, back_g, back_b, fore_r, fore_g, fore_b, char)
50
51
    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...
52
        """Clears the console.  Values to fill it with are optional, defaults
53
        to black with no characters.
54
55
        Args:
56
            back_r (int): Red background color, from 0 to 255.
57
            back_g (int): Green background color, from 0 to 255.
58
            back_b (int): Blue background color, from 0 to 255.
59
            fore_r (int): Red foreground color, from 0 to 255.
60
            fore_g (int): Green foreground color, from 0 to 255.
61
            fore_b (int): Blue foreground color, from 0 to 255.
62
            char (AnyStr): A single character str or bytes object.
63
        """
64
        n = self.width * self.height
65
        self.back_r = [back_r] * n
66
        self.back_g = [back_g] * n
67
        self.back_b = [back_b] * n
68
        self.fore_r = [fore_r] * n
69
        self.fore_g = [fore_g] * n
70
        self.fore_b = [fore_b] * n
71
        self.char = [ord(char)] * n
72
73
    def copy(self):
74
        """Returns a copy of this ConsoleBuffer.
75
76
        Returns:
77
            ConsoleBuffer: A new ConsoleBuffer copy.
78
        """
79
        other = ConsoleBuffer(0, 0)
80
        other.width = self.width
81
        other.height = self.height
82
        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...
83
        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...
84
        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...
85
        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...
86
        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...
87
        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...
88
        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...
89
        return other
90
91
    def set_fore(self, x, y, r, g, b, char):
92
        """Set the character and foreground color of one cell.
93
94
        Args:
95
            x (int): X position to change.
96
            y (int): Y position to change.
97
            r (int): Red foreground color, from 0 to 255.
98
            g (int): Green foreground color, from 0 to 255.
99
            b (int): Blue foreground color, from 0 to 255.
100
            char (AnyStr): A single character str or bytes object.
101
        """
102
        i = self.width * y + x
103
        self.fore_r[i] = r
104
        self.fore_g[i] = g
105
        self.fore_b[i] = b
106
        self.char[i] = ord(char)
107
108
    def set_back(self, x, y, r, g, b):
109
        """Set the background color of one cell.
110
111
        Args:
112
            x (int): X position to change.
113
            y (int): Y position to change.
114
            r (int): Red background color, from 0 to 255.
115
            g (int): Green background color, from 0 to 255.
116
            b (int): Blue background color, from 0 to 255.
117
            char (AnyStr): A single character str or bytes object.
118
        """
119
        i = self.width * y + x
120
        self.back_r[i] = r
121
        self.back_g[i] = g
122
        self.back_b[i] = b
123
124
    def set(self, x, y, back_r, back_g, back_b, fore_r, fore_g, fore_b, char):
125
        """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 (80/79).

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

Loading history...
126
127
        Args:
128
            x (int): X position to change.
129
            y (int): Y position to change.
130
            back_r (int): Red background color, from 0 to 255.
131
            back_g (int): Green background color, from 0 to 255.
132
            back_b (int): Blue background color, from 0 to 255.
133
            fore_r (int): Red foreground color, from 0 to 255.
134
            fore_g (int): Green foreground color, from 0 to 255.
135
            fore_b (int): Blue foreground color, from 0 to 255.
136
            char (AnyStr): A single character str or bytes object.
137
        """
138
        i = self.width * y + x
139
        self.back_r[i] = back_r
140
        self.back_g[i] = back_g
141
        self.back_b[i] = back_b
142
        self.fore_r[i] = fore_r
143
        self.fore_g[i] = fore_g
144
        self.fore_b[i] = fore_b
145
        self.char[i] = ord(char)
146
147
    def blit(self, dest, fill_fore=True, fill_back=True):
148
        """Use libtcod's "fill" functions to write the buffer to a console.
149
150
        Args:
151
            dest (Console): Console object to modify.
152
            fill_fore (bool):
153
                If True, fill the foreground color and characters.
154
            fill_back (bool):
155
                If True, fill the background color.
156
        """
157
        dest = _cdata(dest)
158
        if (console_get_width(dest) != self.width or
159
            console_get_height(dest) != self.height):
160
            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...
161
162
        if fill_back:
163
            lib.TCOD_console_fill_background(dest or ffi.NULL,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_fill_background.

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 _MockFFI does not seem to have a member named NULL.

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...
164
                                              ffi.new('int[]', self.back_r),
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
165
                                              ffi.new('int[]', self.back_g),
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
166
                                              ffi.new('int[]', self.back_b))
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
167
        if fill_fore:
168
            lib.TCOD_console_fill_foreground(dest or ffi.NULL,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_fill_foreground.

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 _MockFFI does not seem to have a member named NULL.

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...
169
                                              ffi.new('int[]', self.fore_r),
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
170
                                              ffi.new('int[]', self.fore_g),
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
171
                                              ffi.new('int[]', self.fore_b))
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
172
            lib.TCOD_console_fill_char(dest or ffi.NULL,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_fill_char.

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 _MockFFI does not seem to have a member named NULL.

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...
173
                                        ffi.new('int[]', self.char))
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
174
175
class Dice(_CDataWrapper):
176
    """
177
178
    Args:
179
        nb_dices (int): Number of dice.
180
        nb_faces (int): Number of sides on a die.
181
        multiplier (float): Multiplier.
182
        addsub (float): Addition.
183
184
    .. versionchanged:: 2.0
185
        This class now acts like the other CData wrapped classes
186
        and no longer acts like a list.
187
188
    .. deprecated:: 2.0
189
        You should make your own dice functions instead of using this class
190
        which is tied to a CData object.
191
    """
192
193
    def __init__(self, *args, **kargs):
194
        super(Dice, self).__init__(*args, **kargs)
195
        if self.cdata == ffi.NULL:
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named NULL.

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...
196
            self._init(*args, **kargs)
197
198
    def _init(self, nb_dices=0, nb_faces=0, multiplier=0, addsub=0):
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...
199
        self.cdata = ffi.new('TCOD_dice_t*')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
200
        self.nb_dices = nb_dices
201
        self.nb_faces = nb_faces
202
        self.multiplier = multiplier
203
        self.addsub = addsub
204
205
    def _get_nb_dices(self):
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...
206
        return self.nb_rolls
207
    def _set_nb_dices(self, value):
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...
208
        self.nb_rolls = value
0 ignored issues
show
Coding Style introduced by
The attribute nb_rolls 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...
209
    nb_dices = property(_get_nb_dices, _set_nb_dices)
210
211
    def __str__(self):
212
        add = '+(%s)' % self.addsub if self.addsub != 0 else ''
213
        return '%id%ix%s%s' % (self.nb_dices, self.nb_faces,
214
                               self.multiplier, add)
215
216
    def __repr__(self):
217
        return ('%s(nb_dices=%r,nb_faces=%r,multiplier=%r,addsub=%r)' %
218
                (self.__class__.__name__, self.nb_dices, self.nb_faces,
219
                 self.multiplier, self.addsub))
220
221
def bsp_new_with_size(x, y, w, h):
222
    """Create a new BSP instance with the given rectangle.
223
224
    Args:
225
        x (int): Rectangle left coordinate.
226
        y (int): Rectangle top coordinate.
227
        w (int): Rectangle width.
228
        h (int): Rectangle height.
229
230
    Returns:
231
        BSP: A new BSP instance.
232
233
    .. deprecated:: 2.0
234
       Call the :any:`BSP` class instead.
235
    """
236
    return Bsp(x, y, w, h)
237
238
def bsp_split_once(node, horizontal, position):
239
    """
240
    .. deprecated:: 2.0
241
       Use :any:`BSP.split_once` instead.
242
    """
243
    node.split_once(horizontal, position)
244
245
def bsp_split_recursive(node, randomizer, nb, minHSize, minVSize, maxHRatio,
246
                        maxVRatio):
247
    """
248
    .. deprecated:: 2.0
249
       Use :any:`BSP.split_recursive` instead.
250
    """
251
    node.split_recursive(nb, minHSize, minVSize,
252
                         maxHRatio, maxVRatio, randomizer)
253
254
def bsp_resize(node, x, y, w, h):
255
    """
256
    .. deprecated:: 2.0
257
        Assign directly to :any:`BSP` attributes instead.
258
    """
259
    node.x = x
260
    node.y = y
261
    node.width = w
262
    node.height = h
263
264
def bsp_left(node):
265
    """
266
    .. deprecated:: 2.0
267
       Use :any:`BSP.children` instead.
268
    """
269
    return None if not node.children else node.children[0]
270
271
def bsp_right(node):
272
    """
273
    .. deprecated:: 2.0
274
       Use :any:`BSP.children` instead.
275
    """
276
    return None if not node.children else node.children[1]
277
278
def bsp_father(node):
279
    """
280
    .. deprecated:: 2.0
281
       Use :any:`BSP.parent` instead.
282
    """
283
    return node.parent
284
285
def bsp_is_leaf(node):
286
    """
287
    .. deprecated:: 2.0
288
       Use :any:`BSP.children` instead.
289
    """
290
    return not node.children
291
292
def bsp_contains(node, cx, cy):
293
    """
294
    .. deprecated:: 2.0
295
       Use :any:`BSP.contains` instead.
296
    """
297
    return node.contains(cx, cy)
298
299
def bsp_find_node(node, cx, cy):
300
    """
301
    .. deprecated:: 2.0
302
       Use :any:`BSP.find_node` instead.
303
    """
304
    return node.find_node(cx, cy)
305
306
def _bsp_traverse(node_iter, callback, userData):
307
    """pack callback into a handle for use with the callback
308
    _pycall_bsp_callback
309
    """
310
    for node in node_iter:
311
        callback(node, userData)
312
313
def bsp_traverse_pre_order(node, callback, userData=0):
314
    """Traverse this nodes hierarchy with a callback.
315
316
    .. deprecated:: 2.0
317
       Use :any:`BSP.walk` instead.
318
    """
319
    _bsp_traverse(node._iter_pre_order(), callback, userData)
320
321
def bsp_traverse_in_order(node, callback, userData=0):
322
    """Traverse this nodes hierarchy with a callback.
323
324
    .. deprecated:: 2.0
325
       Use :any:`BSP.walk` instead.
326
    """
327
    _bsp_traverse(node._iter_in_order(), callback, userData)
328
329
def bsp_traverse_post_order(node, callback, userData=0):
330
    """Traverse this nodes hierarchy with a callback.
331
332
    .. deprecated:: 2.0
333
       Use :any:`BSP.walk` instead.
334
    """
335
    _bsp_traverse(node._iter_post_order(), callback, userData)
336
337
def bsp_traverse_level_order(node, callback, userData=0):
338
    """Traverse this nodes hierarchy with a callback.
339
340
    .. deprecated:: 2.0
341
       Use :any:`BSP.walk` instead.
342
    """
343
    _bsp_traverse(node._iter_level_order(), callback, userData)
344
345
def bsp_traverse_inverted_level_order(node, callback, userData=0):
346
    """Traverse this nodes hierarchy with a callback.
347
348
    .. deprecated:: 2.0
349
       Use :any:`BSP.walk` instead.
350
    """
351
    _bsp_traverse(node._iter_inverted_level_order(), callback, userData)
352
353
def bsp_remove_sons(node):
354
    """Delete all children of a given node.  Not recommended.
355
356
    .. note::
357
       This function will add unnecessary complexity to your code.
358
       Don't use it.
359
360
    .. deprecated:: 2.0
361
       BSP deletion is automatic.
362
    """
363
    node.children = ()
364
365
def bsp_delete(node):
0 ignored issues
show
Unused Code introduced by
The argument node seems to be unused.
Loading history...
366
    """Exists for backward compatibility.  Does nothing.
367
368
    BSP's created by this library are automatically garbage collected once
369
    there are no references to the tree.
370
    This function exists for backwards compatibility.
371
372
    .. deprecated:: 2.0
373
       BSP deletion is automatic.
374
    """
375
    pass
376
377
def color_lerp(c1, c2, a):
378
    """Return the linear interpolation between two colors.
379
380
    ``a`` is the interpolation value, with 0 returing ``c1``,
381
    1 returning ``c2``, and 0.5 returing a color halfway between both.
382
383
    Args:
384
        c1 (Union[Tuple[int, int, int], Sequence[int]]):
385
            The first color.  At a=0.
386
        c2 (Union[Tuple[int, int, int], Sequence[int]]):
387
            The second color.  At a=1.
388
        a (float): The interpolation value,
389
390
    Returns:
391
        Color: The interpolated Color.
392
    """
393
    return Color._new_from_cdata(lib.TCOD_color_lerp(c1, c2, a))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_color_lerp.

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...
394
395
def color_set_hsv(c, h, s, v):
396
    """Set a color using: hue, saturation, and value parameters.
397
398
    Does not return a new Color.  Instead the provided color is modified.
399
400
    Args:
401
        c (Color): Must be a color instance.
402
        h (float): Hue, from 0 to 1.
403
        s (float): Saturation, from 0 to 1.
404
        v (float): Value, from 0 to 1.
405
    """
406
    new_color = ffi.new('TCOD_color_t*')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
407
    lib.TCOD_color_set_HSV(new_color, h, s, v)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_color_set_HSV.

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...
408
    c.r = new_color.r
409
    c.g = new_color.g
410
    c.b = new_color.b
411
412
def color_get_hsv(c):
413
    """Return the (hue, saturation, value) of a color.
414
415
    Args:
416
        c (Union[Tuple[int, int, int], Sequence[int]]):
417
            An (r, g, b) sequence or Color instance.
418
419
    Returns:
420
        Tuple[float, float, float]:
421
            A tuple with (hue, saturation, value) values, from 0 to 1.
422
    """
423
    h = ffi.new('float *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
424
    s = ffi.new('float *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
425
    v = ffi.new('float *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
426
    lib.TCOD_color_get_HSV(c, h, s, v)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_color_get_HSV.

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...
427
    return h[0], s[0], v[0]
428
429
def color_scale_HSV(c, scoef, vcoef):
430
    """Scale a color's saturation and value.
431
432
    Does not return a new Color.  Instead the provided color is modified.
433
434
    Args:
435
        c (Color): Must be a Color instance.
436
        scoef (float): Saturation multiplier, from 0 to 1.
437
                       Use 1 to keep current saturation.
438
        vcoef (float): Value multiplier, from 0 to 1.
439
                       Use 1 to keep current value.
440
    """
441
    color_p = ffi.new('TCOD_color_t*')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
442
    color_p.r, color_p.g, color_p.b = c.r, c.g, c.b
443
    lib.TCOD_color_scale_HSV(color_p, scoef, vcoef)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_color_scale_HSV.

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...
444
    c.r, c.g, c.b = color_p.r, color_p.g, color_p.b
445
446
def color_gen_map(colors, indexes):
447
    """Return a smoothly defined scale of colors.
448
449
    If ``indexes`` is [0, 3, 9] for example, the first color from ``colors``
450
    will be returned at 0, the 2nd will be at 3, and the 3rd will be at 9.
451
    All in-betweens will be filled with a gradient.
452
453
    Args:
454
        colors (Iterable[Union[Tuple[int, int, int], Sequence[int]]]):
455
            Array of colors to be sampled.
456
        indexes (Iterable[int]): A list of indexes.
457
458
    Returns:
459
        List[Color]: A list of Color instances.
460
461
    Example:
462
        >>> tcod.color_gen_map([(0, 0, 0), (255, 128, 0)], [0, 5])
463
        [Color(0,0,0), Color(51,25,0), Color(102,51,0), Color(153,76,0), \
464
Color(204,102,0), Color(255,128,0)]
465
    """
466
    ccolors = ffi.new('TCOD_color_t[]', colors)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
467
    cindexes = ffi.new('int[]', indexes)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
468
    cres = ffi.new('TCOD_color_t[]', max(indexes) + 1)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
469
    lib.TCOD_color_gen_map(cres, len(colors), ccolors, cindexes)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_color_gen_map.

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...
470
    return [Color._new_from_cdata(cdata) for cdata in cres]
471
472
_numpy = None
473
474
def _numpy_available():
475
    'check if numpy is available and lazily load it when needed'
476
    global _numpy
477
    if _numpy is None:
478
        try:
479
            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 472).

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...
480
        except ImportError:
481
            _numpy = False
482
    return _numpy
483
484
# initializing the console
485
def console_init_root(w, h, title, fullscreen=False,
486
                      renderer=RENDERER_SDL):
487
    """Set up the primary display and return the root console.
488
489
    Note:
490
        Currently only the SDL renderer is supported at the moment.
491
        Do not attempt to change it.
492
493
    Args:
494
        w (int): Width in character tiles for the root console.
495
        h (int): Height in character tiles for the root console.
496
        title (AnyStr):
497
            This string will be displayed on the created windows title bar.
498
        renderer: Rendering mode for libtcod to use.
499
500
    Returns:
501
        Console:
502
            Returns a special Console instance representing the root console.
503
    """
504
    lib.TCOD_console_init_root(w, h, _bytes(title), fullscreen, renderer)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_init_root.

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...
505
    return Console(ffi.NULL) # root console is null
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named NULL.

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...
506
507
508
def console_set_custom_font(fontFile, flags=FONT_LAYOUT_ASCII_INCOL,
509
                            nb_char_horiz=0, nb_char_vertic=0):
510
    """Load a custom font file.
511
512
    Call this before function before calling :any:`tcod.console_init_root`.
513
514
    Flags can be a mix of the following:
515
516
    * tcod.FONT_LAYOUT_ASCII_INCOL
517
    * tcod.FONT_LAYOUT_ASCII_INROW
518
    * tcod.FONT_TYPE_GREYSCALE
519
    * tcod.FONT_TYPE_GRAYSCALE
520
    * tcod.FONT_LAYOUT_TCOD
521
522
    Args:
523
        fontFile (AnyStr): Path to a font file.
524
        flags (int):
525
        nb_char_horiz (int):
526
        nb_char_vertic (int):
527
    """
528
    lib.TCOD_console_set_custom_font(_bytes(fontFile), flags,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_custom_font.

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...
529
                                     nb_char_horiz, nb_char_vertic)
530
531
532
def console_get_width(con):
533
    """Return the width of a console.
534
535
    Args:
536
        con (Console): Any Console instance.
537
538
    Returns:
539
        int: The width of a Console.
540
541
    .. deprecated:: 2.0
542
        Use `Console.get_width` instead.
543
    """
544
    return lib.TCOD_console_get_width(_cdata(con))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_width.

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...
545
546
def console_get_height(con):
547
    """Return the height of a console.
548
549
    Args:
550
        con (Console): Any Console instance.
551
552
    Returns:
553
        int: The height of a Console.
554
555
    .. deprecated:: 2.0
556
        Use `Console.get_hright` instead.
557
    """
558
    return lib.TCOD_console_get_height(_cdata(con))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_height.

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...
559
560
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...
561
    lib.TCOD_console_map_ascii_code_to_font(_int(asciiCode), fontCharX,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_map_ascii_code_to_font.

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...
562
                                                              fontCharY)
563
564
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...
565
                                    fontCharY):
566
    lib.TCOD_console_map_ascii_codes_to_font(_int(firstAsciiCode), nbCodes,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_map_ascii_codes_to_font.

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...
567
                                              fontCharX, fontCharY)
568
569
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...
570
    lib.TCOD_console_map_string_to_font_utf(_unicode(s), fontCharX, fontCharY)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_map_string_to_font_utf.

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...
571
572
def console_is_fullscreen():
573
    """Returns True if the display is fullscreen.
574
575
    Returns:
576
        bool: True if the display is fullscreen, otherwise False.
577
    """
578
    return bool(lib.TCOD_console_is_fullscreen())
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_is_fullscreen.

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...
579
580
def console_set_fullscreen(fullscreen):
581
    """Change the display to be fullscreen or windowed.
582
583
    Args:
584
        fullscreen (bool): Use True to change to fullscreen.
585
                           Use False to change to windowed.
586
    """
587
    lib.TCOD_console_set_fullscreen(fullscreen)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_fullscreen.

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...
588
589
def console_is_window_closed():
590
    """Returns True if the window has received and exit event."""
591
    return lib.TCOD_console_is_window_closed()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_is_window_closed.

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...
592
593
def console_set_window_title(title):
594
    """Change the current title bar string.
595
596
    Args:
597
        title (AnyStr): A string to change the title bar to.
598
    """
599
    lib.TCOD_console_set_window_title(_bytes(title))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_window_title.

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...
600
601
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...
602
    lib.TCOD_console_credits()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_credits.

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...
603
604
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...
605
    lib.TCOD_console_credits_reset()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_credits_reset.

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...
606
607
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...
608
    return lib.TCOD_console_credits_render(x, y, alpha)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_credits_render.

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...
609
610
def console_flush():
611
    """Update the display to represent the root consoles current state."""
612
    lib.TCOD_console_flush()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_flush.

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...
613
614
# drawing on a console
615
def console_set_default_background(con, col):
616
    """Change the default background color for a console.
617
618
    Args:
619
        con (Console): Any Console instance.
620
        col (Union[Tuple[int, int, int], Sequence[int]]):
621
            An (r, g, b) sequence or Color instance.
622
    """
623
    lib.TCOD_console_set_default_background(_cdata(con), col)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_default_background.

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...
624
625
def console_set_default_foreground(con, col):
626
    """Change the default foreground color for a console.
627
628
    Args:
629
        con (Console): Any Console instance.
630
        col (Union[Tuple[int, int, int], Sequence[int]]):
631
            An (r, g, b) sequence or Color instance.
632
    """
633
    lib.TCOD_console_set_default_foreground(_cdata(con), col)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_default_foreground.

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...
634
635
def console_clear(con):
636
    """Reset a console to its default colors and the space character.
637
638
    Args:
639
        con (Console): Any Console instance.
640
641
    .. seealso::
642
       :any:`console_set_default_background`
643
       :any:`console_set_default_foreground`
644
    """
645
    return lib.TCOD_console_clear(_cdata(con))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_clear.

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...
646
647
def console_put_char(con, x, y, c, flag=BKGND_DEFAULT):
648
    """Draw the character c at x,y using the default colors and a blend mode.
649
650
    Args:
651
        con (Console): Any Console instance.
652
        x (int): Character x position from the left.
653
        y (int): Character y position from the top.
654
        c (Union[int, AnyStr]): Character to draw, can be an integer or string.
655
        flag (int): Blending mode to use, defaults to BKGND_DEFAULT.
656
    """
657
    lib.TCOD_console_put_char(_cdata(con), x, y, _int(c), flag)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_put_char.

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...
658
659
def console_put_char_ex(con, x, y, c, fore, back):
660
    """Draw the character c at x,y using the colors fore and back.
661
662
    Args:
663
        con (Console): Any Console instance.
664
        x (int): Character x position from the left.
665
        y (int): Character y position from the top.
666
        c (Union[int, AnyStr]): Character to draw, can be an integer or string.
667
        fore (Union[Tuple[int, int, int], Sequence[int]]):
668
            An (r, g, b) sequence or Color instance.
669
        back (Union[Tuple[int, int, int], Sequence[int]]):
670
            An (r, g, b) sequence or Color instance.
671
    """
672
    lib.TCOD_console_put_char_ex(_cdata(con), x, y,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_put_char_ex.

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
                                 _int(c), fore, back)
674
675
def console_set_char_background(con, x, y, col, flag=BKGND_SET):
676
    """Change the background color of x,y to col using a blend mode.
677
678
    Args:
679
        con (Console): Any Console instance.
680
        x (int): Character x position from the left.
681
        y (int): Character y position from the top.
682
        col (Union[Tuple[int, int, int], Sequence[int]]):
683
            An (r, g, b) sequence or Color instance.
684
        flag (int): Blending mode to use, defaults to BKGND_SET.
685
    """
686
    lib.TCOD_console_set_char_background(_cdata(con), x, y, col, flag)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_char_background.

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...
687
688
def console_set_char_foreground(con, x, y, col):
689
    """Change the foreground color of x,y to col.
690
691
    Args:
692
        con (Console): Any Console instance.
693
        x (int): Character x position from the left.
694
        y (int): Character y position from the top.
695
        col (Union[Tuple[int, int, int], Sequence[int]]):
696
            An (r, g, b) sequence or Color instance.
697
    """
698
    lib.TCOD_console_set_char_foreground(_cdata(con), x, y, col)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_char_foreground.

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...
699
700
def console_set_char(con, x, y, c):
701
    """Change the character at x,y to c, keeping the current colors.
702
703
    Args:
704
        con (Console): Any Console instance.
705
        x (int): Character x position from the left.
706
        y (int): Character y position from the top.
707
        c (Union[int, AnyStr]): Character to draw, can be an integer or string.
708
    """
709
    lib.TCOD_console_set_char(_cdata(con), x, y, _int(c))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_char.

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...
710
711
def console_set_background_flag(con, flag):
712
    """Change the default blend mode for this console.
713
714
    Args:
715
        con (Console): Any Console instance.
716
        flag (int): Blend mode to use by default.
717
    """
718
    lib.TCOD_console_set_background_flag(_cdata(con), flag)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_background_flag.

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...
719
720
def console_get_background_flag(con):
721
    """Return this consoles current blend mode.
722
723
    Args:
724
        con (Console): Any Console instance.
725
    """
726
    return lib.TCOD_console_get_background_flag(_cdata(con))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_background_flag.

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...
727
728
def console_set_alignment(con, alignment):
729
    """Change this consoles current alignment mode.
730
731
    * tcod.LEFT
732
    * tcod.CENTER
733
    * tcod.RIGHT
734
735
    Args:
736
        con (Console): Any Console instance.
737
        alignment (int):
738
    """
739
    lib.TCOD_console_set_alignment(_cdata(con), alignment)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_alignment.

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...
740
741
def console_get_alignment(con):
742
    """Return this consoles current alignment mode.
743
744
    Args:
745
        con (Console): Any Console instance.
746
    """
747
    return lib.TCOD_console_get_alignment(_cdata(con))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_alignment.

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...
748
749
def console_print(con, x, y, fmt):
750
    """Print a color formatted string on a console.
751
752
    Args:
753
        con (Console): Any Console instance.
754
        x (int): Character x position from the left.
755
        y (int): Character y position from the top.
756
        fmt (AnyStr): A unicode or bytes string optionaly using color codes.
757
    """
758
    lib.TCOD_console_print_utf(_cdata(con), x, y, _fmt_unicode(fmt))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_print_utf.

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...
759
760
def console_print_ex(con, x, y, flag, alignment, fmt):
761
    """Print a string on a console using a blend mode and alignment mode.
762
763
    Args:
764
        con (Console): Any Console instance.
765
        x (int): Character x position from the left.
766
        y (int): Character y position from the top.
767
    """
768
    lib.TCOD_console_print_ex_utf(_cdata(con), x, y,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_print_ex_utf.

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...
769
                                   flag, alignment, _fmt_unicode(fmt))
770
771
def console_print_rect(con, x, y, w, h, fmt):
772
    """Print a string constrained to a rectangle.
773
774
    If h > 0 and the bottom of the rectangle is reached,
775
    the string is truncated. If h = 0,
776
    the string is only truncated if it reaches the bottom of the console.
777
778
779
780
    Returns:
781
        int: The number of lines of text once word-wrapped.
782
    """
783
    return lib.TCOD_console_print_rect_utf(_cdata(con), x, y, w, h,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_print_rect_utf.

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...
784
                                            _fmt_unicode(fmt))
785
786
def console_print_rect_ex(con, x, y, w, h, flag, alignment, fmt):
787
    """Print a string constrained to a rectangle with blend and alignment.
788
789
    Returns:
790
        int: The number of lines of text once word-wrapped.
791
    """
792
    return lib.TCOD_console_print_rect_ex_utf(_cdata(con), x, y, w, h,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_print_rect_ex_utf.

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...
793
                                              flag, alignment,
794
                                              _fmt_unicode(fmt))
795
796
def console_get_height_rect(con, x, y, w, h, fmt):
797
    """Return the height of this text once word-wrapped into this rectangle.
798
799
    Returns:
800
        int: The number of lines of text once word-wrapped.
801
    """
802
    return lib.TCOD_console_get_height_rect_utf(_cdata(con), x, y, w, h,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_height_rect_utf.

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...
803
                                                 _fmt_unicode(fmt))
804
805
def console_rect(con, x, y, w, h, clr, flag=BKGND_DEFAULT):
806
    """Draw a the background color on a rect optionally clearing the text.
807
808
    If clr is True the affected tiles are changed to space character.
809
    """
810
    lib.TCOD_console_rect(_cdata(con), x, y, w, h, clr, flag)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_rect.

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...
811
812
def console_hline(con, x, y, l, flag=BKGND_DEFAULT):
813
    """Draw a horizontal line on the console.
814
815
    This always uses the character 196, the horizontal line character.
816
    """
817
    lib.TCOD_console_hline(_cdata(con), x, y, l, flag)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_hline.

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...
818
819
def console_vline(con, x, y, l, flag=BKGND_DEFAULT):
820
    """Draw a vertical line on the console.
821
822
    This always uses the character 179, the vertical line character.
823
    """
824
    lib.TCOD_console_vline(_cdata(con), x, y, l, flag)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_vline.

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...
825
826
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...
827
    """Draw a framed rectangle with optinal text.
828
829
    This uses the default background color and blend mode to fill the
830
    rectangle and the default foreground to draw the outline.
831
832
    fmt will be printed on the inside of the rectangle, word-wrapped.
833
    """
834
    lib.TCOD_console_print_frame(_cdata(con), x, y, w, h, clear, flag,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_print_frame.

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...
835
                                  _fmt_bytes(fmt))
836
837
def console_set_color_control(con, fore, back):
838
    """Configure :any:`color controls`.
839
840
    Args:
841
        con (int): :any:`Color control` constant to modify.
842
        fore (Union[Tuple[int, int, int], Sequence[int]]):
843
            An (r, g, b) sequence or Color instance.
844
        back (Union[Tuple[int, int, int], Sequence[int]]):
845
            An (r, g, b) sequence or Color instance.
846
    """
847
    lib.TCOD_console_set_color_control(_cdata(con), fore, back)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_color_control.

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...
848
849
def console_get_default_background(con):
850
    """Return this consoles default background color."""
851
    return Color._new_from_cdata(
852
        lib.TCOD_console_get_default_background(_cdata(con)))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_default_background.

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...
853
854
def console_get_default_foreground(con):
855
    """Return this consoles default foreground color."""
856
    return Color._new_from_cdata(
857
        lib.TCOD_console_get_default_foreground(_cdata(con)))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_default_foreground.

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...
858
859
def console_get_char_background(con, x, y):
860
    """Return the background color at the x,y of this console."""
861
    return Color._new_from_cdata(
862
        lib.TCOD_console_get_char_background(_cdata(con), x, y))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_char_background.

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...
863
864
def console_get_char_foreground(con, x, y):
865
    """Return the foreground color at the x,y of this console."""
866
    return Color._new_from_cdata(
867
        lib.TCOD_console_get_char_foreground(_cdata(con), x, y))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_char_foreground.

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...
868
869
def console_get_char(con, x, y):
870
    """Return the character at the x,y of this console."""
871
    return lib.TCOD_console_get_char(_cdata(con), x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_char.

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...
872
873
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...
874
    lib.TCOD_console_set_fade(fade, fadingColor)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_fade.

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...
875
876
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...
877
    return lib.TCOD_console_get_fade()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_fade.

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...
878
879
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...
880
    return Color._new_from_cdata(lib.TCOD_console_get_fading_color())
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_get_fading_color.

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...
881
882
# handling keyboard input
883
def console_wait_for_keypress(flush):
884
    """Block until the user presses a key, then returns a new Key.
885
886
    Args:
887
        flush bool: If True then the event queue is cleared before waiting
888
                    for the next event.
889
890
    Returns:
891
        Key: A new Key instance.
892
    """
893
    k=Key()
0 ignored issues
show
Coding Style introduced by
Exactly one space required around assignment
k=Key()
^
Loading history...
894
    lib.TCOD_console_wait_for_keypress_wrapper(k.cdata, flush)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_wait_for_keypress_wrapper.

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...
895
    return k
896
897
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...
898
    k=Key()
0 ignored issues
show
Coding Style introduced by
Exactly one space required around assignment
k=Key()
^
Loading history...
899
    lib.TCOD_console_check_for_keypress_wrapper(k.cdata, flags)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_check_for_keypress_wrapper.

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...
900
    return k
901
902
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...
903
    return lib.TCOD_console_is_key_pressed(key)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_is_key_pressed.

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...
904
905
# using offscreen consoles
906
def console_new(w, h):
907
    """Return an offscreen console of size: w,h."""
908
    return Console(ffi.gc(lib.TCOD_console_new(w, h), lib.TCOD_console_delete))
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named gc.

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 object does not seem to have a member named TCOD_console_new.

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 object does not seem to have a member named TCOD_console_delete.

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...
909
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...
910
    return Console(lib.TCOD_console_from_file(_bytes(filename)))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_from_file.

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...
911
912
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...
913
    """Blit the console src from x,y,w,h to console dst at xdst,ydst."""
914
    lib.TCOD_console_blit(_cdata(src), x, y, w, h,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_blit.

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...
915 View Code Duplication
                          _cdata(dst), xdst, ydst, ffade, bfade)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
916
917
def console_set_key_color(con, col):
918
    """Set a consoles blit transparent color."""
919
    lib.TCOD_console_set_key_color(_cdata(con), col)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_set_key_color.

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...
920
921
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...
922
    con = _cdata(con)
923
    if con == ffi.NULL:
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named NULL.

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...
924
        lib.TCOD_console_delete(con)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_delete.

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...
925
926
# fast color filling
927
def console_fill_foreground(con, r, g, b):
928
    """Fill the foregound of a console with r,g,b.
929
930
    Args:
931
        con (Console): Any Console instance.
932
        r (Sequence[int]): An array of integers with a length of width*height.
933
        g (Sequence[int]): An array of integers with a length of width*height.
934
        b (Sequence[int]): An array of integers with a length of width*height.
935
    """
936
    if len(r) != len(g) or len(r) != len(b):
937
        raise TypeError('R, G and B must all have the same size.')
938
    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...
939
        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...
940
        #numpy arrays, use numpy's ctypes functions
941
        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...
942
        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...
943 View Code Duplication
        b = _numpy.ascontiguousarray(b, dtype=_numpy.intc)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
Bug introduced by
The Instance of bool does not seem to have a member named 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...
944
        cr = ffi.cast('int *', r.ctypes.data)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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...
945
        cg = ffi.cast('int *', g.ctypes.data)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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...
946
        cb = ffi.cast('int *', b.ctypes.data)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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...
947
    else:
948
        # otherwise convert using ffi arrays
949
        cr = ffi.new('int[]', r)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
950
        cg = ffi.new('int[]', g)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
951
        cb = ffi.new('int[]', b)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
952
953
    lib.TCOD_console_fill_foreground(_cdata(con), cr, cg, cb)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_fill_foreground.

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...
954
955
def console_fill_background(con, r, g, b):
956
    """Fill the backgound of a console with r,g,b.
957
958
    Args:
959
        con (Console): Any Console instance.
960
        r (Sequence[int]): An array of integers with a length of width*height.
961
        g (Sequence[int]): An array of integers with a length of width*height.
962
        b (Sequence[int]): An array of integers with a length of width*height.
963
    """
964
    if len(r) != len(g) or len(r) != len(b):
965
        raise TypeError('R, G and B must all have the same size.')
966
    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...
967
        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...
968
        #numpy arrays, use numpy's ctypes functions
969
        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...
970
        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...
971
        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...
972
        cr = ffi.cast('int *', r.ctypes.data)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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...
973
        cg = ffi.cast('int *', g.ctypes.data)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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...
974
        cb = ffi.cast('int *', b.ctypes.data)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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...
975
    else:
976
        # otherwise convert using ffi arrays
977
        cr = ffi.new('int[]', r)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
978
        cg = ffi.new('int[]', g)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
979
        cb = ffi.new('int[]', b)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
980
981
    lib.TCOD_console_fill_background(_cdata(con), cr, cg, cb)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_fill_background.

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...
982
983
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...
984
    """Fill the character tiles of a console with an array.
985
986
    Args:
987
        con (Console): Any Console instance.
988
        arr (Sequence[int]): An array of integers with a length of width*height.
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...
989
    """
990
    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...
991
        #numpy arrays, use numpy's ctypes functions
992
        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...
993
        carr = ffi.cast('int *', arr.ctypes.data)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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...
994
    else:
995
        #otherwise convert using the ffi module
996
        carr = ffi.new('int[]', arr)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
997
998
    lib.TCOD_console_fill_char(_cdata(con), carr)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_fill_char.

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...
999
1000
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...
1001
    return lib.TCOD_console_load_asc(_cdata(con), _bytes(filename))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_load_asc.

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...
1002
1003
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...
1004
    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...
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_save_asc.

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...
1005
1006
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...
1007
    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...
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_load_apf.

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...
1008
1009
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...
1010
    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...
Bug introduced by
The Instance of object does not seem to have a member named TCOD_console_save_apf.

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...
1011
1012
@ffi.def_extern()
1013
def _pycall_path_func(x1, y1, x2, y2, handle):
1014
    '''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...
1015
    '''
1016
    pathfinder = ffi.from_handle(handle)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named from_handle.

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...
1017
    try:
1018
        return pathfinder._map_data(x1, y1, x2, y2, *pathfinder._callback_args)
1019
    except BaseException:
1020
        pathfinder._propagator.propagate(*_sys.exc_info())
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable '_sys'
Loading history...
1021
        return None
1022
1023
def path_new_using_map(m, dcost=1.41):
1024
    """Return a new AStar using the given Map.
1025
1026
    Args:
1027
        m (Map): A Map instance.
1028
        dcost (float): The path-finding cost of diagonal movement.
1029
                       Can be set to 0 to disable diagonal movement.
1030
    Returns:
1031
        AStar: A new AStar instance.
1032
    """
1033
    return AStar(m, dcost)
1034
1035
def path_new_using_function(w, h, func, userData=0, dcost=1.41):
1036
    """Return a new AStar using the given callable function.
1037
1038
    Args:
1039
        w (int): Clipping width.
1040
        h (int): Clipping height.
1041
        func (Callable[[int, int, int, int, Any], float]):
1042
        userData (Any):
1043
        dcost (float): A multiplier for the cost of diagonal movement.
1044
                       Can be set to 0 to disable diagonal movement.
1045
    Returns:
1046
        AStar: A new AStar instance.
1047
    """
1048
    pathfinder = AStar(func, dcost)
1049
    pathfinder._callback_args = (userData,)
1050
    pathfinder._height = h
1051
    pathfinder._width = w
1052
    return pathfinder
1053
1054
def path_compute(p, ox, oy, dx, dy):
1055
    """Find a path from (ox, oy) to (dx, dy).  Return True if path is found.
1056
1057
    Args:
1058
        p (AStar): An AStar instance.
1059
        ox (int): Starting x position.
1060
        oy (int): Starting y position.
1061
        dx (int): Destination x position.
1062
        dy (int): Destination y position.
1063
    Returns:
1064
        bool: True if a valid path was found.  Otherwise False.
1065
    """
1066
    with p._propagator:
1067
        return lib.TCOD_path_compute(p.cdata, ox, oy, dx, dy)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_path_compute.

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...
1068
1069
def path_get_origin(p):
1070
    """Get the current origin position.
1071
1072
    This point moves when :any:`path_walk` returns the next x,y step.
1073
1074
    Args:
1075
        p (AStar): An AStar instance.
1076
    Returns:
1077
        Tuple[int, int]: An (x, y) point.
1078
    """
1079
    x = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1080
    y = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1081
    lib.TCOD_path_get_origin(p.cdata, x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_path_get_origin.

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...
1082
    return x[0], y[0]
1083
1084
def path_get_destination(p):
1085
    """Get the current destination position.
1086
1087
    Args:
1088
        p (AStar): An AStar instance.
1089
    Returns:
1090
        Tuple[int, int]: An (x, y) point.
1091
    """
1092
    x = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1093
    y = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1094
    lib.TCOD_path_get_destination(p.cdata, x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_path_get_destination.

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...
1095
    return x[0], y[0]
1096
1097
def path_size(p):
1098
    """Return the current length of the computed path.
1099
1100
    Args:
1101
        p (AStar): An AStar instance.
1102
    Returns:
1103
        int: Length of the path.
1104
    """
1105
    return lib.TCOD_path_size(p.cdata)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_path_size.

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...
1106
1107
def path_reverse(p):
1108
    """Reverse the direction of a path.
1109
1110
    This effectively swaps the origin and destination points.
1111
1112
    Args:
1113
        p (AStar): An AStar instance.
1114
    """
1115
    lib.TCOD_path_reverse(p.cdata)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_path_reverse.

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...
1116
1117
def path_get(p, idx):
1118
    """Get a point on a path.
1119
1120
    Args:
1121
        p (AStar): An AStar instance.
1122
        idx (int): Should be in range: 0 <= inx < :any:`path_size`
1123
    """
1124
    x = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1125
    y = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1126
    lib.TCOD_path_get(p.cdata, idx, x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_path_get.

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...
1127
    return x[0], y[0]
1128
1129
def path_is_empty(p):
1130
    """Return True if a path is empty.
1131
1132
    Args:
1133
        p (AStar): An AStar instance.
1134
    Returns:
1135
        bool: True if a path is empty.  Otherwise False.
1136
    """
1137
    return lib.TCOD_path_is_empty(p.cdata)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_path_is_empty.

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...
1138
1139
def path_walk(p, recompute):
1140
    """Return the next (x, y) point in a path, or (None, None) if it's empty.
1141
1142
    When ``recompute`` is True and a previously valid path reaches a point
1143
    where it is now blocked, a new path will automatically be found.
1144
1145
    Args:
1146
        p (AStar): An AStar instance.
1147
        recompute (bool): Recompute the path automatically.
1148
    Returns:
1149
        Union[Tuple[int, int], Tuple[None, None]]:
1150
            A single (x, y) point, or (None, None)
1151
    """
1152
    x = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1153
    y = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1154
    with p._propagator:
1155
        if lib.TCOD_path_walk(p.cdata, x, y, recompute):
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_path_walk.

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...
1156
            return x[0], y[0]
1157
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
1158
1159
def path_delete(p):
0 ignored issues
show
Unused Code introduced by
The argument p seems to be unused.
Loading history...
1160
    """Does nothing."""
1161
    pass
1162
1163
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...
1164
    return Dijkstra(m, dcost)
1165
    #return (ffi.gc(lib.TCOD_dijkstra_new(_cdata(m), dcost),
1166
    #                lib.TCOD_dijkstra_delete), _PropagateException())
1167
1168
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...
1169
    pathfinder = Dijkstra(func, dcost)
1170
    pathfinder._callback_args = (userData,)
1171
    pathfinder._height = h
1172
    pathfinder._width = w
1173
    return pathfinder
1174
    #propagator = _PropagateException()
1175
    #handle = ffi.new_handle((func, propagator, (userData,)))
1176
    #return (ffi.gc(lib.TCOD_dijkstra_new_using_function(w, h,
1177
    #                lib._pycall_path_func, handle, dcost),
1178
    #                lib.TCOD_dijkstra_delete), propagator, handle)
1179
1180
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...
1181
    with p._propagator:
1182
        lib.TCOD_dijkstra_compute(p.cdata, ox, oy)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_dijkstra_compute.

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...
1183
1184
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...
1185
    return lib.TCOD_dijkstra_path_set(p.cdata, x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_dijkstra_path_set.

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...
1186
1187
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...
1188
    return lib.TCOD_dijkstra_get_distance(p.cdata, x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_dijkstra_get_distance.

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...
1189
1190
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...
1191
    return lib.TCOD_dijkstra_size(p.cdata)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_dijkstra_size.

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...
1192
1193
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...
1194
    lib.TCOD_dijkstra_reverse(p.cdata)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_dijkstra_reverse.

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...
1195
1196
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...
1197
    x = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1198
    y = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1199
    lib.TCOD_dijkstra_get(p.cdata, idx, x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_dijkstra_get.

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...
1200
    return x[0], y[0]
1201
1202
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...
1203
    return lib.TCOD_dijkstra_is_empty(p.cdata)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_dijkstra_is_empty.

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...
1204
1205
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...
1206
    x = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1207
    y = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1208
    if lib.TCOD_dijkstra_path_walk(p.cdata, x, y):
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_dijkstra_path_walk.

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...
1209
        return x[0], y[0]
1210
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
1211
1212
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...
1213
    pass
1214
1215
def _heightmap_cdata(array):
1216
    """Return a new TCOD_heightmap_t instance using an array.
1217
1218
    Formatting is verified during this function.
1219
    """
1220
    if not array.flags['C_CONTIGUOUS']:
1221
        raise ValueError('array must be a C-style contiguous segment.')
1222
    if array.dtype != _np.float32:
1223
        raise ValueError('array dtype must be float32, not %r' % array.dtype)
1224
    width, height = array.shape
1225
    pointer = ffi.cast('float *', array.ctypes.data)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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...
1226
    return ffi.new('TCOD_heightmap_t *', (width, height, pointer))
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1227
1228
def heightmap_new(w, h):
1229
    """Return a new numpy.ndarray formatted for use with heightmap functions.
1230
1231
    You can pass a numpy array to any heightmap function as long as all the
1232
    following are true::
1233
    * The array is 2 dimentional.
1234
    * The array has the C_CONTIGUOUS flag.
1235
    * The array's dtype is :any:`dtype.float32`.
1236
1237
    Args:
1238
        w (int): The width of the new HeightMap.
1239
        h (int): The height of the new HeightMap.
1240
1241
    Returns:
1242
        numpy.ndarray: A C-contiguous mapping of float32 values.
1243
    """
1244
    return _np.ndarray((h, w), _np.float32)
1245
1246
def heightmap_set_value(hm, x, y, value):
1247
    """Set the value of a point on a heightmap.
1248
1249
    Args:
1250
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1251
        x (int): The x position to change.
1252
        y (int): The y position to change.
1253
        value (float): The value to set.
1254
1255
    .. deprecated:: 2.0
1256
        Do ``hm[y, x] = value`` instead.
1257
    """
1258
    hm[y, x] = value
1259
1260
def heightmap_add(hm, value):
1261
    """Add value to all values on this heightmap.
1262
1263
    Args:
1264
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1265
        value (float): A number to add to this heightmap.
1266
1267
    .. deprecated:: 2.0
1268
        Do ``hm[:] += value`` instead.
1269
    """
1270
    hm[:] += value
1271
1272
def heightmap_scale(hm, value):
1273
    """Multiply all items on this heightmap by value.
1274
1275
    Args:
1276
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1277
        value (float): A number to scale this heightmap by.
1278
1279
    .. deprecated:: 2.0
1280
        Do ``hm[:] *= value`` instead.
1281
    """
1282
    hm[:] *= value
1283
1284
def heightmap_clear(hm):
1285
    """Add value to all values on this heightmap.
1286
1287
    Args:
1288
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1289
1290
    .. deprecated:: 2.0
1291
        Do ``hm.array[:] = 0`` instead.
1292
    """
1293
    hm[:] = 0
1294
1295
def heightmap_clamp(hm, mi, ma):
1296
    """Clamp all values on this heightmap between ``mi`` and ``ma``
1297
1298
    Args:
1299
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1300
        mi (float): The lower bound to clamp to.
1301
        ma (float): The upper bound to clamp to.
1302
1303
    .. deprecated:: 2.0
1304
        Do ``hm.clip(mi, ma)`` instead.
1305
    """
1306
    hm.clip(mi, ma)
1307
1308
def heightmap_copy(hm1, hm2):
1309
    """Copy the heightmap ``hm1`` to ``hm2``.
1310
1311
    Args:
1312
        hm1 (numpy.ndarray): The source heightmap.
1313
        hm2 (numpy.ndarray): The destination heightmap.
1314
1315
    .. deprecated:: 2.0
1316
        Do ``hm2[:] = hm1[:]`` instead.
1317
    """
1318
    hm2[:] = hm1[:]
1319
1320
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...
1321
    """Normalize heightmap values between ``mi`` and ``ma``.
1322
1323
    Args:
1324
        mi (float): The lowest value after normalization.
1325
        ma (float): The highest value after normalization.
1326
    """
1327
    lib.TCOD_heightmap_normalize(_heightmap_cdata(hm), mi, ma)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_normalize.

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...
1328
1329
def heightmap_lerp_hm(hm1, hm2, hm3, coef):
1330
    """Perform linear interpolation between two heightmaps storing the result
1331
    in ``hm3``.
1332
1333
    This is the same as doing ``hm3[:] = hm1[:] + (hm2[:] - hm1[:]) * coef``
1334
1335
    Args:
1336
        hm1 (numpy.ndarray): The first heightmap.
1337
        hm2 (numpy.ndarray): The second heightmap to add to the first.
1338
        hm3 (numpy.ndarray): A destination heightmap to store the result.
1339
        coef (float): The linear interpolation coefficient.
1340
    """
1341
    lib.TCOD_heightmap_lerp_hm(_heightmap_cdata(hm1), _heightmap_cdata(hm2),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_lerp_hm.

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...
1342
                               _heightmap_cdata(hm3), coef)
1343
1344
def heightmap_add_hm(hm1, hm2, hm3):
1345
    """Add two heightmaps together and stores the result in ``hm3``.
1346
1347
    Args:
1348
        hm1 (numpy.ndarray): The first heightmap.
1349
        hm2 (numpy.ndarray): The second heightmap to add to the first.
1350
        hm3 (numpy.ndarray): A destination heightmap to store the result.
1351
1352
    .. deprecated:: 2.0
1353
        Do ``hm3[:] = hm1[:] + hm2[:]`` instead.
1354
    """
1355
    hm3[:] = hm1[:] + hm2[:]
1356
1357
def heightmap_multiply_hm(hm1, hm2, hm3):
1358
    """Multiplies two heightmap's together and stores the result in ``hm3``.
1359
1360
    Args:
1361
        hm1 (numpy.ndarray): The first heightmap.
1362
        hm2 (numpy.ndarray): The second heightmap to multiply with the first.
1363
        hm3 (numpy.ndarray): A destination heightmap to store the result.
1364
1365
    .. deprecated:: 2.0
1366
        Do ``hm3[:] = hm1[:] * hm2[:]`` instead.
1367
        Alternatively you can do ``HeightMap(hm1.array[:] * hm2.array[:])``.
1368
    """
1369
    hm3[:] = hm1[:] * hm2[:]
1370
1371
def heightmap_add_hill(hm, x, y, radius, height):
1372
    """Add a hill (a half spheroid) at given position.
1373
1374
    If height == radius or -radius, the hill is a half-sphere.
1375
1376
    Args:
1377
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1378
        x (float): The x position at the center of the new hill.
1379
        y (float): The y position at the center of the new hill.
1380
        radius (float): The size of the new hill.
1381
        height (float): The height or depth of the new hill.
1382
    """
1383
    lib.TCOD_heightmap_add_hill(_heightmap_cdata(hm), x, y, radius, height)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_add_hill.

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...
1384
1385
def heightmap_dig_hill(hm, x, y, radius, height):
1386
    """
1387
1388
    This function takes the highest value (if height > 0) or the lowest
1389
    (if height < 0) between the map and the hill.
1390
1391
    It's main goal is to carve things in maps (like rivers) by digging hills along a curve.
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (91/79).

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

Loading history...
1392
1393
    Args:
1394
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1395
        x (float): The x position at the center of the new carving.
1396
        y (float): The y position at the center of the new carving.
1397
        radius (float): The size of the carving.
1398
        height (float): The height or depth of the hill to dig out.
1399
    """
1400
    lib.TCOD_heightmap_dig_hill(_heightmap_cdata(hm), x, y, radius, height)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_dig_hill.

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...
1401
1402
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...
1403
    """Simulate the effect of rain drops on the terrain, resulting in erosion.
1404
1405
    ``nbDrops`` should be at least hm.size.
1406
1407
    Args:
1408
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1409
        nbDrops (int): Number of rain drops to simulate.
1410
        erosionCoef (float): Amount of ground eroded on the drop's path.
1411
        sedimentationCoef (float): Amount of ground deposited when the drops
1412
                                   stops to flow.
1413
        rnd (Optional[Random]): A tcod.Random instance, or None.
1414
    """
1415
    lib.TCOD_heightmap_rain_erosion(_heightmap_cdata(hm), nbDrops, erosionCoef,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_rain_erosion.

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...
1416
                                    sedimentationCoef, _cdata(rnd))
1417
1418
def heightmap_kernel_transform(hm, kernelsize, dx, dy, weight, minLevel,
1419
                               maxLevel):
1420
    """Apply a generic transformation on the map, so that each resulting cell
1421
    value is the weighted sum of several neighbour cells.
1422
1423
    This can be used to smooth/sharpen the map.
1424
1425
    Args:
1426
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1427
        kernelsize (int): Should be set to the length of the parameters::
1428
                          dx, dy, and weight.
1429
        dx (Sequence[int]): A sequence of x coorinates.
1430
        dy (Sequence[int]): A sequence of y coorinates.
1431
        weight (Sequence[float]): A sequence of kernelSize cells weight.
1432
                                  The value of each neighbour cell is scaled by
1433
                                  its corresponding weight
1434
        minLevel (float): No transformation will apply to cells
1435
                          below this value.
1436
        maxLevel (float): No transformation will apply to cells
1437
                          above this value.
1438
1439
    See examples below for a simple horizontal smoothing kernel :
1440
    replace value(x,y) with
1441
    0.33*value(x-1,y) + 0.33*value(x,y) + 0.33*value(x+1,y).
1442
    To do this, you need a kernel of size 3
1443
    (the sum involves 3 surrounding cells).
1444
    The dx,dy array will contain
1445
    * dx=-1, dy=0 for cell (x-1, y)
1446
    * dx=1, dy=0 for cell (x+1, y)
1447
    * dx=0, dy=0 for cell (x, y)
1448
    * The weight array will contain 0.33 for each cell.
1449
1450
    Example:
1451
        >>> dx = [-1, 1, 0]
1452
        >>> dy = [0, 0, 0]
1453
        >>> weight = [0.33, 0.33, 0.33]
1454
        >>> tcod.heightMap_kernel_transform(heightmap,3,dx,dy,weight,0.0,1.0)
1455
    """
1456
    cdx = ffi.new('int[]', dx)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1457
    cdy = ffi.new('int[]', dy)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1458
    cweight = ffi.new('float[]', weight)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1459
    lib.TCOD_heightmap_kernel_transform(_heightmap_cdata(hm), kernelsize,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_kernel_transform.

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...
1460
                                        cdx, cdy, cweight, minLevel, maxLevel)
1461
1462
def heightmap_add_voronoi(hm, nbPoints, nbCoef, coef, rnd=None):
1463
    """Add values from a Voronoi diagram to the heightmap.
1464
1465
    Args:
1466
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1467
        nbPoints (Any): Number of Voronoi sites.
1468
        nbCoef (int): The diagram value is calculated from the nbCoef
1469
                      closest sites.
1470
        coef (Sequence[float]): The distance to each site is scaled by the
1471
                                corresponding coef.
1472
                                Closest site : coef[0],
1473
                                second closest site : coef[1], ...
1474
        rnd (Optional[Random]): A Random instance, or None.
1475
    """
1476
    nbPoints = len(coef)
1477
    ccoef = ffi.new('float[]', coef)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1478
    lib.TCOD_heightmap_add_voronoi(_heightmap_cdata(hm), nbPoints,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_add_voronoi.

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...
1479
                                   nbCoef, ccoef, _cdata(rnd))
1480
1481
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...
1482
    """Add FBM noise to the heightmap.
1483
1484
    The noise coordinate for each map cell is
1485
    `((x + addx) * mulx / width, (y + addy) * muly / height)`.
1486
1487
    The value added to the heightmap is `delta + noise * scale`.
1488
1489
    Args:
1490
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1491
        noise (Noise): A Noise instance.
1492
        mulx (float): Scaling of each x coordinate.
1493
        muly (float): Scaling of each y coordinate.
1494
        addx (float): Translation of each x coordinate.
1495
        addy (float): Translation of each y coordinate.
1496
        octaves (float): Number of octaves in the FBM sum.
1497
        delta (float): The value added to all heightmap cells.
1498
        scale (float): The noise value is scaled with this parameter.
1499
    """
1500
    lib.TCOD_heightmap_add_fbm(_heightmap_cdata(hm), _cdata(noise),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_add_fbm.

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...
1501
                               mulx, muly, addx, addy, octaves, delta, scale)
1502
1503
def heightmap_scale_fbm(hm, noise, mulx, muly, addx, addy, octaves, delta,
1504
                        scale):
1505
    """Multiply the heighmap values with FBM noise.
1506
1507
    Args:
1508
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1509
        noise (Noise): A Noise instance.
1510
        mulx (float): Scaling of each x coordinate.
1511
        muly (float): Scaling of each y coordinate.
1512
        addx (float): Translation of each x coordinate.
1513
        addy (float): Translation of each y coordinate.
1514
        octaves (float): Number of octaves in the FBM sum.
1515
        delta (float): The value added to all heightmap cells.
1516
        scale (float): The noise value is scaled with this parameter.
1517
    """
1518
    lib.TCOD_heightmap_scale_fbm(_heightmap_cdata(hm), _cdata(noise),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_scale_fbm.

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...
1519
                                 mulx, muly, addx, addy, octaves, delta, scale)
1520
1521
def heightmap_dig_bezier(hm, px, py, startRadius, startDepth, endRadius,
1522
                         endDepth):
1523
    """Carve a path along a cubic Bezier curve.
1524
1525
    Both radius and depth can vary linearly along the path.
1526
1527
    Args:
1528
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1529
        px (Sequence[int]): The 4 `x` coordinates of the Bezier curve.
1530
        py (Sequence[int]): The 4 `y` coordinates of the Bezier curve.
1531
        startRadius (float): The starting radius size.
1532
        startDepth (float): The starting depth.
1533
        endRadius (float): The ending radius size.
1534
        endDepth (float): The ending depth.
1535
    """
1536
    lib.TCOD_heightmap_dig_bezier(_heightmap_cdata(hm), px, py, startRadius,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_dig_bezier.

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...
1537
                                   startDepth, endRadius,
1538
                                   endDepth)
1539
1540
def heightmap_get_value(hm, x, y):
1541
    """Return the value at ``x``, ``y`` in a heightmap.
1542
1543
    Args:
1544
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1545
        x (int): The x position to pick.
1546
        y (int): The y position to pick.
1547
1548
    Returns:
1549
        float: The value at ``x``, ``y``.
1550
1551
    .. deprecated:: 2.0
1552
        Do ``value = hm[y, x]`` instead.
1553
    """
1554
    # explicit type conversion to pass test, (test should have been better.)
1555
    return float(hm[y, x])
1556
1557
def heightmap_get_interpolated_value(hm, x, y):
1558
    """Return the interpolated height at non integer coordinates.
1559
1560
    Args:
1561
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1562
        x (float): A floating point x coordinate.
1563
        y (float): A floating point y coordinate.
1564
1565
    Returns:
1566
        float: The value at ``x``, ``y``.
1567
    """
1568
    return lib.TCOD_heightmap_get_interpolated_value(_heightmap_cdata(hm),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_get_interpolated_value.

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...
1569
                                                     x, y)
1570
1571
def heightmap_get_slope(hm, x, y):
1572
    """Return the slope between 0 and (pi / 2) at given coordinates.
1573
1574
    Args:
1575
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1576
        x (int): The x coordinate.
1577
        y (int): The y coordinate.
1578
1579
    Returns:
1580
        float: The steepness at ``x``, ``y``.  From 0 to (pi / 2)
1581
    """
1582
    return lib.TCOD_heightmap_get_slope(_heightmap_cdata(hm), x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_get_slope.

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...
1583
1584
def heightmap_get_normal(hm, x, y, waterLevel):
1585
    """Return the map normal at given coordinates.
1586
1587
    Args:
1588
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1589
        x (float): The x coordinate.
1590
        y (float): The y coordinate.
1591
        waterLevel (float): The heightmap is considered flat below this value.
1592
1593
    Returns:
1594
        Tuple[float, float, float]: An (x, y, z) vector normal.
1595
    """
1596
    cn = ffi.new('float[3]')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1597
    lib.TCOD_heightmap_get_normal(_heightmap_cdata(hm), x, y, cn, waterLevel)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_get_normal.

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...
1598
    return tuple(cn)
1599
1600
def heightmap_count_cells(hm, mi, ma):
1601
    """Return the number of map cells which value is between ``mi`` and ``ma``.
1602
1603
    Args:
1604
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1605
        mi (float): The lower bound.
1606
        ma (float): The upper bound.
1607
1608
    Returns:
1609
        int: The count of values which fall between ``mi`` and ``ma``.
1610
    """
1611
    return lib.TCOD_heightmap_count_cells(_heightmap_cdata(hm), mi, ma)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_count_cells.

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...
1612
1613
def heightmap_has_land_on_border(hm, waterlevel):
1614
    """Returns True if the map edges are below ``waterlevel``, otherwise False.
1615
1616
    Args:
1617
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1618
        waterLevel (float): The water level to use.
1619
1620
    Returns:
1621
        bool: True if the map edges are below ``waterlevel``, otherwise False.
1622
    """
1623
    return lib.TCOD_heightmap_has_land_on_border(_heightmap_cdata(hm),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_has_land_on_border.

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...
1624
                                                 waterlevel)
1625
1626
def heightmap_get_minmax(hm):
1627
    """Return the min and max values of this heightmap.
1628
1629
    Args:
1630
        hm (numpy.ndarray): A numpy.ndarray formatted for heightmap functions.
1631
1632
    Returns:
1633
        Tuple[float, float]: The (min, max) values.
1634
1635
    .. deprecated:: 2.0
1636
        Do ``hm.min()`` or ``hm.max()`` instead.
1637
    """
1638
    mi = ffi.new('float *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1639
    ma = ffi.new('float *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1640
    lib.TCOD_heightmap_get_minmax(_heightmap_cdata(hm), mi, ma)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_heightmap_get_minmax.

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...
1641
    return mi[0], ma[0]
1642
1643
def heightmap_delete(hm):
0 ignored issues
show
Unused Code introduced by
The argument hm seems to be unused.
Loading history...
1644
    """Does nothing.
1645
1646
    .. deprecated:: 2.0
1647
        libtcod-cffi deletes heightmaps automatically.
1648
    """
1649
    pass
1650
1651
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...
1652
    return Image(width, height)
1653
1654
def image_clear(image, 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...
1655
    lib.TCOD_image_clear(_cdata(image), col)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_clear.

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...
1656
1657
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...
1658
    lib.TCOD_image_invert(_cdata(image))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_invert.

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...
1659
1660
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...
1661
    lib.TCOD_image_hflip(_cdata(image))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_hflip.

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...
1662
1663
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...
1664
    lib.TCOD_image_rotate90(_cdata(image), num)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_rotate90.

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...
1665
1666
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...
1667
    lib.TCOD_image_vflip(_cdata(image))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_vflip.

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...
1668
1669
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...
1670
    lib.TCOD_image_scale(_cdata(image), neww, newh)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_scale.

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...
1671
1672
def image_set_key_color(image, 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...
1673
    lib.TCOD_image_set_key_color(_cdata(image), col)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_set_key_color.

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...
1674
1675
def image_get_alpha(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...
1676
    return lib.TCOD_image_get_alpha(_cdata(image), x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_get_alpha.

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...
1677
1678
def image_is_pixel_transparent(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...
1679
    return lib.TCOD_image_is_pixel_transparent(_cdata(image), x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_is_pixel_transparent.

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...
1680
1681
def image_load(filename):
1682
    """Load an image file into an Image instance and return it.
1683
1684
    Args:
1685
        filename (AnyStr): Path to a .bmp or .png image file.
1686
    """
1687
    return Image(ffi.gc(lib.TCOD_image_load(_bytes(filename)),
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named gc.

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 object does not seem to have a member named TCOD_image_load.

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...
1688
                        lib.TCOD_image_delete))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_delete.

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...
1689
1690
def image_from_console(console):
1691
    """Return an Image with a Consoles pixel data.
1692
1693
    This effectively takes a screen-shot of the Console.
1694
1695
    Args:
1696
        console (Console): Any Console instance.
1697
    """
1698
    return Image(ffi.gc(lib.TCOD_image_from_console(_cdata(console)),
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named gc.

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 object does not seem to have a member named TCOD_image_from_console.

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...
1699
                        lib.TCOD_image_delete))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_delete.

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...
1700
1701
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...
1702
    lib.TCOD_image_refresh_console(_cdata(image), _cdata(console))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_refresh_console.

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...
1703
1704
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...
1705
    w = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1706
    h = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1707
    lib.TCOD_image_get_size(_cdata(image), w, h)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_get_size.

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...
1708
    return w[0], h[0]
1709
1710
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...
1711
    return lib.TCOD_image_get_pixel(_cdata(image), x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_get_pixel.

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...
1712
1713
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...
1714
    return lib.TCOD_image_get_mipmap_pixel(_cdata(image), x0, y0, x1, y1)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_get_mipmap_pixel.

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...
1715
1716
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...
1717
    lib.TCOD_image_put_pixel(_cdata(image), x, y, col)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_put_pixel.

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...
1718
1719
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...
1720
    lib.TCOD_image_blit(_cdata(image), _cdata(console), x, y, bkgnd_flag,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_blit.

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...
1721
                         scalex, scaley, angle)
1722
1723
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...
1724
    lib.TCOD_image_blit_rect(_cdata(image), _cdata(console),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_blit_rect.

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...
1725
                             x, y, w, h, bkgnd_flag)
1726
1727
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...
1728
    lib.TCOD_image_blit_2x(_cdata(image), _cdata(console), 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(_cdata(image), _cdata(console), dx,dy,sx,sy,w,h)
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(_cdata(image), _cdata(console), dx,dy,sx,sy,w,h)
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(_cdata(image), _cdata(console), dx,dy,sx,sy,w,h)
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(_cdata(image), _cdata(console), dx,dy,sx,sy,w,h)
^
Loading history...
Coding Style introduced by
Exactly one space required after comma
lib.TCOD_image_blit_2x(_cdata(image), _cdata(console), dx,dy,sx,sy,w,h)
^
Loading history...
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_blit_2x.

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...
1729
1730
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...
1731
    lib.TCOD_image_save(_cdata(image), _bytes(filename))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_image_save.

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...
1732
1733
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...
1734
    pass
1735
1736
def line_init(xo, yo, xd, yd):
1737
    """Initilize a line whose points will be returned by `line_step`.
1738
1739
    This function does not return anything on its own.
1740
1741
    Does not include the origin point.
1742
1743
    Args:
1744
        xo (int): X starting point.
1745
        yo (int): Y starting point.
1746
        xd (int): X destination point.
1747
        yd (int): Y destination point.
1748
1749
    .. deprecated:: 2.0
1750
       Use `line_iter` instead.
1751
    """
1752
    lib.TCOD_line_init(xo, yo, xd, yd)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_line_init.

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...
1753
1754
def line_step():
1755
    """After calling line_init returns (x, y) points of the line.
1756
1757
    Once all points are exhausted this function will return (None, None)
1758
1759
    Returns:
1760
        Union[Tuple[int, int], Tuple[None, None]]:
1761
            The next (x, y) point of the line setup by line_init,
1762
            or (None, None) if there are no more points.
1763
1764
    .. deprecated:: 2.0
1765
       Use `line_iter` instead.
1766
    """
1767
    x = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1768
    y = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1769
    ret = lib.TCOD_line_step(x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_line_step.

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...
1770
    if not ret:
1771
        return x[0], y[0]
1772
    return None,None
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
return None,None
^
Loading history...
1773
1774
_line_listener_lock = _threading.Lock()
1775
1776
def line(xo, yo, xd, yd, py_callback):
1777
    """ Iterate over a line using a callback function.
1778
1779
    Your callback function will take x and y parameters and return True to
1780
    continue iteration or False to stop iteration and return.
1781
1782
    This function includes both the start and end points.
1783
1784
    Args:
1785
        xo (int): X starting point.
1786
        yo (int): Y starting point.
1787
        xd (int): X destination point.
1788
        yd (int): Y destination point.
1789
        py_callback (Callable[[int, int], bool]):
1790
            A callback which takes x and y parameters and returns bool.
1791
1792
    Returns:
1793
        bool: False if the callback cancels the line interation by
1794
              returning False or None, otherwise True.
1795
1796
    .. deprecated:: 2.0
1797
       Use `line_iter` instead.
1798
    """
1799
    with _PropagateException() as propagate:
1800
        with _line_listener_lock:
1801
            @ffi.def_extern(onerror=propagate)
1802
            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...
1803
                return py_callback(x, y)
1804
            return bool(lib.TCOD_line(xo, yo, xd, yd,
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_line.

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...
1805
                                       lib._pycall_line_listener))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named _pycall_line_listener.

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...
1806
1807
def line_iter(xo, yo, xd, yd):
1808
    """ returns an iterator
1809
1810
    This iterator does not include the origin point.
1811
1812
    Args:
1813
        xo (int): X starting point.
1814
        yo (int): Y starting point.
1815
        xd (int): X destination point.
1816
        yd (int): Y destination point.
1817
1818
    Returns:
1819
        Iterator[Tuple[int,int]]: An iterator of (x,y) points.
1820
    """
1821
    data = ffi.new('TCOD_bresenham_data_t *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1822
    lib.TCOD_line_init_mt(xo, yo, xd, yd, data)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_line_init_mt.

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...
1823
    x = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1824
    y = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
1825
    done = False
0 ignored issues
show
Unused Code introduced by
The variable done seems to be unused.
Loading history...
1826
    while not lib.TCOD_line_step_mt(x, y, data):
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_line_step_mt.

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...
1827
        yield (x[0], y[0])
1828
1829
FOV_BASIC = 0
1830
FOV_DIAMOND = 1
1831
FOV_SHADOW = 2
1832
FOV_PERMISSIVE_0 = 3
1833
FOV_PERMISSIVE_1 = 4
1834
FOV_PERMISSIVE_2 = 5
1835
FOV_PERMISSIVE_3 = 6
1836
FOV_PERMISSIVE_4 = 7
1837
FOV_PERMISSIVE_5 = 8
1838
FOV_PERMISSIVE_6 = 9
1839
FOV_PERMISSIVE_7 = 10
1840
FOV_PERMISSIVE_8 = 11
1841
FOV_RESTRICTIVE = 12
1842
NB_FOV_ALGORITHMS = 13
1843
1844
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...
1845
    return Map(w, h)
1846
1847
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...
1848
    return lib.TCOD_map_copy(_cdata(source), _cdata(dest))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_map_copy.

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...
1849
1850
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...
1851
    lib.TCOD_map_set_properties(_cdata(m), x, y, isTrans, isWalk)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_map_set_properties.

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...
1852
1853
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...
1854
    # walkable/transparent looks incorrectly ordered here.
1855
    # TODO: needs test.
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
1856
    lib.TCOD_map_clear(_cdata(m), walkable, transparent)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_map_clear.

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...
1857
1858
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...
1859
    lib.TCOD_map_compute_fov(_cdata(m), x, y, radius, light_walls, algo)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_map_compute_fov.

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...
1860
1861
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...
1862
    return lib.TCOD_map_is_in_fov(_cdata(m), x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_map_is_in_fov.

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...
1863
1864
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...
1865
    return lib.TCOD_map_is_transparent(_cdata(m), x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_map_is_transparent.

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...
1866
1867
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...
1868
    return lib.TCOD_map_is_walkable(_cdata(m), x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_map_is_walkable.

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...
1869
1870
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...
1871
    pass
1872
1873
def map_get_width(map):
0 ignored issues
show
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...
Coding Style introduced by
This function should have a docstring.

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

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

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

Loading history...
1874
    return map.width
1875
1876
def map_get_height(map):
0 ignored issues
show
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...
Coding Style introduced by
This function should have a docstring.

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

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

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

Loading history...
1877
    return map.height
1878
1879
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...
1880
    lib.TCOD_mouse_show_cursor(visible)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_mouse_show_cursor.

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...
1881
1882
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...
1883
    return lib.TCOD_mouse_is_cursor_visible()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_mouse_is_cursor_visible.

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...
1884
1885
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...
1886
    lib.TCOD_mouse_move(x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_mouse_move.

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...
1887
1888
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...
1889
    return Mouse(lib.TCOD_mouse_get_status())
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_mouse_get_status.

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...
1890
1891
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...
1892
    lib.TCOD_namegen_parse(_bytes(filename), random or ffi.NULL)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_namegen_parse.

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 _MockFFI does not seem to have a member named NULL.

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...
1893
1894
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...
1895
    return _unpack_char_p(lib.TCOD_namegen_generate(_bytes(name), False))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_namegen_generate.

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...
1896
1897
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...
1898
    return _unpack_char_p(lib.TCOD_namegen_generate(_bytes(name),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_namegen_generate.

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...
1899
                                                     _bytes(rule), False))
1900
1901
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...
1902
    sets = lib.TCOD_namegen_get_sets()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_namegen_get_sets.

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...
1903
    try:
1904
        lst = []
1905
        while not lib.TCOD_list_is_empty(sets):
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_list_is_empty.

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...
1906
            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...
Bug introduced by
The Instance of _MockFFI does not seem to have a member named cast.

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 object does not seem to have a member named TCOD_list_pop.

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...
1907
    finally:
1908
        lib.TCOD_list_delete(sets)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_list_delete.

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...
1909
    return lst
1910
1911
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...
1912
    lib.TCOD_namegen_destroy()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_namegen_destroy.

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...
1913
1914
def noise_new(dim, h=NOISE_DEFAULT_HURST, l=NOISE_DEFAULT_LACUNARITY,
1915
        random=None):
1916
    """Return a new Noise instance.
1917
1918
    Args:
1919
        dim (int): Number of dimentions.  From 1 to 4.
1920
        h (float): The hurst exponent.  Should be in the 0.0-1.0 range.
1921
        l (float): The noise lacunarity.
1922
        random (Optional[Random]): A Random instance, or None.
1923
1924
    Returns:
1925
        Noise: The new Noise instance.
1926
    """
1927
    return Noise(dim, hurst=h, lacunarity=l, rand=random)
1928
1929
def noise_set_type(n, typ):
1930
    """Set a Noise objects default noise algorithm.
1931
1932
    Args:
1933
        typ (int): Any NOISE_* constant.
1934
    """
1935
    n.algorithm = typ
1936
1937
def noise_get(n, f, typ=NOISE_DEFAULT):
1938
    """Return the noise value sampled from the ``f`` coordinate.
1939
1940
    ``f`` should be a tuple or list with a length matching
1941
    :any:`Noise.dimentions`.
1942
    If ``f`` is shoerter than :any:`Noise.dimentions` the missing coordinates
1943
    will be filled with zeros.
1944
1945
    Args:
1946
        n (Noise): A Noise instance.
1947
        f (Sequence[float]): The point to sample the noise from.
1948
        typ (int): The noise algorithm to use.
1949
1950
    Returns:
1951
        float: The sampled noise value.
1952
    """
1953
    return lib.TCOD_noise_get_ex(_cdata(n), ffi.new('float[4]', f), typ)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_noise_get_ex.

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 _MockFFI does not seem to have a member named new.

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...
1954
1955
def noise_get_fbm(n, f, oc, typ=NOISE_DEFAULT):
1956
    """Return the fractal Brownian motion sampled from the ``f`` coordinate.
1957
1958
    Args:
1959
        n (Noise): A Noise instance.
1960
        f (Sequence[float]): The point to sample the noise from.
1961
        typ (int): The noise algorithm to use.
1962
        octaves (float): The level of level.  Should be more than 1.
1963
1964
    Returns:
1965
        float: The sampled noise value.
1966
    """
1967
    return lib.TCOD_noise_get_fbm_ex(_cdata(n), ffi.new('float[4]', f),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_noise_get_fbm_ex.

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 _MockFFI does not seem to have a member named new.

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...
1968
                                     oc, typ)
1969
1970
def noise_get_turbulence(n, f, oc, typ=NOISE_DEFAULT):
1971
    """Return the turbulence noise sampled from the ``f`` coordinate.
1972
1973
    Args:
1974
        n (Noise): A Noise instance.
1975
        f (Sequence[float]): The point to sample the noise from.
1976
        typ (int): The noise algorithm to use.
1977
        octaves (float): The level of level.  Should be more than 1.
1978
1979
    Returns:
1980
        float: The sampled noise value.
1981
    """
1982
    return lib.TCOD_noise_get_turbulence_ex(_cdata(n), ffi.new('float[4]', f),
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_noise_get_turbulence_ex.

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 _MockFFI does not seem to have a member named new.

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...
1983
                                            oc, typ)
1984
1985
def noise_delete(n):
0 ignored issues
show
Unused Code introduced by
The argument n seems to be unused.
Loading history...
1986
    """Does nothing."""
1987
    pass
1988
1989
_chr = chr
1990
try:
1991
    _chr = unichr # Python 2
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'unichr'
Loading history...
1992
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...
1993
    pass
1994
1995
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...
1996
    '''
1997
        unpack items from parser new_property (value_converter)
1998
    '''
1999
    if type == lib.TCOD_TYPE_BOOL:
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_BOOL.

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...
2000
        return bool(union.b)
2001
    elif type == lib.TCOD_TYPE_CHAR:
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_CHAR.

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...
2002
        return _unicode(union.c)
2003
    elif type == lib.TCOD_TYPE_INT:
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_INT.

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...
2004
        return union.i
2005
    elif type == lib.TCOD_TYPE_FLOAT:
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_FLOAT.

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...
2006
        return union.f
2007
    elif (type == lib.TCOD_TYPE_STRING or
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_STRING.

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...
2008
         lib.TCOD_TYPE_VALUELIST15 >= type >= lib.TCOD_TYPE_VALUELIST00):
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_VALUELIST15.

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 object does not seem to have a member named TCOD_TYPE_VALUELIST00.

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...
2009
         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...
2010
    elif type == lib.TCOD_TYPE_COLOR:
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_COLOR.

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...
2011
        return Color._new_from_cdata(union.col)
2012
    elif type == lib.TCOD_TYPE_DICE:
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_DICE.

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...
2013
        return Dice(union.dice)
2014
    elif type & lib.TCOD_TYPE_LIST:
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_TYPE_LIST.

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...
2015
        return _convert_TCODList(union.list, type & 0xFF)
2016
    else:
2017
        raise RuntimeError('Unknown libtcod type: %i' % type)
2018
2019
def _convert_TCODList(clist, type):
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...
Coding Style introduced by
This function should have a docstring.

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

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

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

Loading history...
2020
    return [_unpack_union(type, lib.TDL_list_get_union(clist, i))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TDL_list_get_union.

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...
2021
            for i in range(lib.TCOD_list_size(clist))]
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_list_size.

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...
2022
2023
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...
2024
    return ffi.gc(lib.TCOD_parser_new(), lib.TCOD_parser_delete)
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named gc.

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 object does not seem to have a member named TCOD_parser_new.

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 object does not seem to have a member named TCOD_parser_delete.

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...
2025
2026
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...
2027
    return lib.TCOD_parser_new_struct(parser, name)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_new_struct.

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...
2028
2029
# prevent multiple threads from messing with def_extern callbacks
2030
_parser_callback_lock = _threading.Lock()
2031
2032
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...
2033
    if not listener:
2034
        lib.TCOD_parser_run(parser, _bytes(filename), ffi.NULL)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_run.

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 _MockFFI does not seem to have a member named NULL.

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...
2035
        return
2036
2037
    propagate_manager = _PropagateException()
2038
    propagate = propagate_manager.propagate
2039
2040
    with _parser_callback_lock:
2041
        clistener = ffi.new('TCOD_parser_listener_t *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
2042
2043
        @ffi.def_extern(onerror=propagate)
2044
        def pycall_parser_new_struct(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...
2045
            return listener.end_struct(struct, _unpack_char_p(name))
2046
2047
        @ffi.def_extern(onerror=propagate)
2048
        def pycall_parser_new_flag(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...
2049
            return listener.new_flag(_unpack_char_p(name))
2050
2051
        @ffi.def_extern(onerror=propagate)
2052
        def pycall_parser_new_property(propname, type, value):
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...
Coding Style introduced by
This function should have a docstring.

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

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

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

Loading history...
2053
            return listener.new_property(_unpack_char_p(propname), type,
2054
                                         _unpack_union(type, value))
2055
2056
        @ffi.def_extern(onerror=propagate)
2057
        def pycall_parser_end_struct(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...
2058
            return listener.end_struct(struct, _unpack_char_p(name))
2059
2060
        @ffi.def_extern(onerror=propagate)
2061
        def pycall_parser_error(msg):
0 ignored issues
show
Coding Style introduced by
This function should have a docstring.

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

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

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

Loading history...
2062
            listener.error(_unpack_char_p(msg))
2063
2064
        clistener.new_struct = lib.pycall_parser_new_struct
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named pycall_parser_new_struct.

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...
2065
        clistener.new_flag = lib.pycall_parser_new_flag
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named pycall_parser_new_flag.

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...
2066
        clistener.new_property = lib.pycall_parser_new_property
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named pycall_parser_new_property.

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...
2067
        clistener.end_struct = lib.pycall_parser_end_struct
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named pycall_parser_end_struct.

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...
2068
        clistener.error = lib.pycall_parser_error
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named pycall_parser_error.

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...
2069
2070
        with propagate_manager:
2071
            lib.TCOD_parser_run(parser, _bytes(filename), clistener)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_run.

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...
2072
2073
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...
2074
    pass
2075
2076
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...
2077
    return bool(lib.TCOD_parser_get_bool_property(parser, _bytes(name)))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_get_bool_property.

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...
2078
2079
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...
2080
    return lib.TCOD_parser_get_int_property(parser, _bytes(name))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_get_int_property.

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...
2081
2082
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...
2083
    return _chr(lib.TCOD_parser_get_char_property(parser, _bytes(name)))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_get_char_property.

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...
2084
2085
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...
2086
    return lib.TCOD_parser_get_float_property(parser, _bytes(name))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_get_float_property.

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...
2087
2088
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...
2089
    return _unpack_char_p(
2090
        lib.TCOD_parser_get_string_property(parser, _bytes(name)))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_get_string_property.

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...
2091
2092
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...
2093
    return Color._new_from_cdata(
2094
        lib.TCOD_parser_get_color_property(parser, _bytes(name)))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_get_color_property.

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...
2095
2096
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...
2097
    d = ffi.new('TCOD_dice_t *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
2098
    lib.TCOD_parser_get_dice_property_py(parser, _bytes(name), d)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_get_dice_property_py.

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...
2099
    return Dice(d)
2100
2101
def parser_get_list_property(parser, name, type):
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...
Coding Style introduced by
This function should have a docstring.

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

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

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

Loading history...
2102
    clist = lib.TCOD_parser_get_list_property(parser, _bytes(name), type)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_parser_get_list_property.

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...
2103
    return _convert_TCODList(clist, type)
2104
2105
RNG_MT = 0
2106
RNG_CMWC = 1
2107
2108
DISTRIBUTION_LINEAR = 0
2109
DISTRIBUTION_GAUSSIAN = 1
2110
DISTRIBUTION_GAUSSIAN_RANGE = 2
2111
DISTRIBUTION_GAUSSIAN_INVERSE = 3
2112
DISTRIBUTION_GAUSSIAN_RANGE_INVERSE = 4
2113
2114
def random_get_instance():
2115
    """Return the default Random instance.
2116
2117
    Returns:
2118
        Random: A Random instance using the default random number generator.
2119
    """
2120
    return Random(lib.TCOD_random_get_instance())
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_get_instance.

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...
2121
2122
def random_new(algo=RNG_CMWC):
2123
    """Return a new Random instance.  Using ``algo``.
2124
2125
    Args:
2126
        algo (int): The random number algorithm to use.
2127
2128
    Returns:
2129
        Random: A new Random instance using the given algorithm.
2130
    """
2131
    return Random(ffi.gc(lib.TCOD_random_new(algo), lib.TCOD_random_delete))
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named gc.

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 object does not seem to have a member named TCOD_random_new.

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 object does not seem to have a member named TCOD_random_delete.

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...
2132
2133
def random_new_from_seed(seed, algo=RNG_CMWC):
2134
    """Return a new Random instance.  Using the given ``seed`` and ``algo``.
2135
2136
    Args:
2137
        seed (Hashable): The RNG seed.  Should be a 32-bit integer, but any
2138
                         hashable object is accepted.
2139
        algo (int): The random number algorithm to use.
2140
2141
    Returns:
2142
        Random: A new Random instance using the given algorithm.
2143
    """
2144
    return Random(seed, algo)
2145
2146
def random_set_distribution(rnd, dist):
2147
    """Change the distribution mode of a random number generator.
2148
2149
    Args:
2150
        rnd (Optional[Random]): A Random instance, or None to use the default.
2151
        dist (int): The distribution mode to use.  Should be DISTRIBUTION_*.
2152
    """
2153
    lib.TCOD_random_set_distribution(_cdata(rnd), dist)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_set_distribution.

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...
2154
2155
def random_get_int(rnd, mi, ma):
2156
    """Return a random integer in the range: ``mi`` <= n <= ``ma``.
2157
2158
    The result is affacted by calls to :any:`random_set_distribution`.
2159
2160
    Args:
2161
        rnd (Optional[Random]): A Random instance, or None to use the default.
2162
        low (int): The lower bound of the random range, inclusive.
2163
        high (int): The upper bound of the random range, inclusive.
2164
2165
    Returns:
2166
        int: A random integer in the range ``mi`` <= n <= ``ma``.
2167
    """
2168
    return lib.TCOD_random_get_int(_cdata(rnd), mi, ma)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_get_int.

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...
2169
2170
def random_get_float(rnd, mi, ma):
2171
    """Return a random float in the range: ``mi`` <= n <= ``ma``.
2172
2173
    The result is affacted by calls to :any:`random_set_distribution`.
2174
2175
    Args:
2176
        rnd (Optional[Random]): A Random instance, or None to use the default.
2177
        low (float): The lower bound of the random range, inclusive.
2178
        high (float): The upper bound of the random range, inclusive.
2179
2180
    Returns:
2181
        float: A random double precision float
2182
               in the range ``mi`` <= n <= ``ma``.
2183
    """
2184
    return lib.TCOD_random_get_double(_cdata(rnd), mi, ma)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_get_double.

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...
2185
2186
def random_get_double(rnd, mi, ma):
2187
    """Return a random float in the range: ``mi`` <= n <= ``ma``.
2188
2189
    .. deprecated:: 2.0
2190
        Use :any:`random_get_float` instead.
2191
        Both funtions return a double precision float.
2192
    """
2193
    return lib.TCOD_random_get_double(_cdata(rnd), mi, ma)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_get_double.

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...
2194
2195
def random_get_int_mean(rnd, mi, ma, mean):
2196
    """Return a random weighted integer in the range: ``mi`` <= n <= ``ma``.
2197
2198
    The result is affacted by calls to :any:`random_set_distribution`.
2199
2200
    Args:
2201
        rnd (Optional[Random]): A Random instance, or None to use the default.
2202
        low (int): The lower bound of the random range, inclusive.
2203
        high (int): The upper bound of the random range, inclusive.
2204
        mean (int): The mean return value.
2205
2206
    Returns:
2207
        int: A random weighted integer in the range ``mi`` <= n <= ``ma``.
2208
    """
2209
    return lib.TCOD_random_get_int_mean(_cdata(rnd), mi, ma, mean)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_get_int_mean.

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...
2210
2211
def random_get_float_mean(rnd, mi, ma, mean):
2212
    """Return a random weighted float in the range: ``mi`` <= n <= ``ma``.
2213
2214
    The result is affacted by calls to :any:`random_set_distribution`.
2215
2216
    Args:
2217
        rnd (Optional[Random]): A Random instance, or None to use the default.
2218
        low (float): The lower bound of the random range, inclusive.
2219
        high (float): The upper bound of the random range, inclusive.
2220
        mean (float): The mean return value.
2221
2222
    Returns:
2223
        float: A random weighted double precision float
2224
               in the range ``mi`` <= n <= ``ma``.
2225
    """
2226
    return lib.TCOD_random_get_double_mean(_cdata(rnd), mi, ma, mean)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_get_double_mean.

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...
2227
2228
def random_get_double_mean(rnd, mi, ma, mean):
2229
    """Return a random weighted float in the range: ``mi`` <= n <= ``ma``.
2230
2231
    .. deprecated:: 2.0
2232
        Use :any:`random_get_float_mean` instead.
2233
        Both funtions return a double precision float.
2234
    """
2235
    return lib.TCOD_random_get_double_mean(_cdata(rnd), mi, ma, mean)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_get_double_mean.

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...
2236
2237
def random_save(rnd):
2238
    """Return a copy of a random number generator.
2239
2240
    Args:
2241
        rnd (Optional[Random]): A Random instance, or None to use the default.
2242
2243
    Returns:
2244
        Random: A Random instance with a copy of the random generator.
2245
    """
2246
    return Random(ffi.gc(lib.TCOD_random_save(_cdata(rnd)),
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named gc.

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 object does not seem to have a member named TCOD_random_save.

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...
2247
                         lib.TCOD_random_delete))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_delete.

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...
2248
2249
def random_restore(rnd, backup):
2250
    """Restore a random number generator from a backed up copy.
2251
2252
    Args:
2253
        rnd (Optional[Random]): A Random instance, or None to use the default.
2254
        backup (Random): The Random instance which was used as a backup.
2255
    """
2256
    lib.TCOD_random_restore(_cdata(rnd), _cdata(backup))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_random_restore.

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...
2257
2258
def random_delete(rnd):
0 ignored issues
show
Unused Code introduced by
The argument rnd seems to be unused.
Loading history...
2259
    """Does nothing."""
2260
    pass
2261
2262
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...
2263
    lib.TCOD_struct_add_flag(struct, name)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_struct_add_flag.

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...
2264
2265
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...
2266
    lib.TCOD_struct_add_property(struct, name, typ, mandatory)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_struct_add_property.

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...
2267
2268
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...
2269
    CARRAY = c_char_p * (len(value_list) + 1)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'c_char_p'
Loading history...
2270
    cvalue_list = CARRAY()
2271
    for i in range(len(value_list)):
2272
        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...
2273
    cvalue_list[len(value_list)] = 0
2274
    lib.TCOD_struct_add_value_list(struct, name, cvalue_list, mandatory)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_struct_add_value_list.

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...
2275
2276
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...
2277
    lib.TCOD_struct_add_list_property(struct, name, typ, mandatory)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_struct_add_list_property.

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...
2278
2279
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...
2280
    lib.TCOD_struct_add_structure(struct, sub_struct)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_struct_add_structure.

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...
2281
2282
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...
2283
    return _unpack_char_p(lib.TCOD_struct_get_name(struct))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_struct_get_name.

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...
2284
2285
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...
2286
    return lib.TCOD_struct_is_mandatory(struct, name)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_struct_is_mandatory.

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...
2287
2288
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...
2289
    return lib.TCOD_struct_get_type(struct, name)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_struct_get_type.

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...
2290
2291
# high precision time functions
2292
def sys_set_fps(fps):
2293
    """Set the maximum frame rate.
2294
2295
    You can disable the frame limit again by setting fps to 0.
2296
2297
    Args:
2298
        fps (int): A frame rate limit (i.e. 60)
2299
    """
2300
    lib.TCOD_sys_set_fps(fps)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_set_fps.

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...
2301
2302
def sys_get_fps():
2303
    """Return the current frames per second.
2304
2305
    This the actual frame rate, not the frame limit set by
2306
    :any:`tcod.sys_set_fps`.
2307
2308
    This number is updated every second.
2309
2310
    Returns:
2311
        int: The currently measured frame rate.
2312
    """
2313
    return lib.TCOD_sys_get_fps()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_get_fps.

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...
2314
2315
def sys_get_last_frame_length():
2316
    """Return the delta time of the last rendered frame in seconds.
2317
2318
    Returns:
2319
        float: The delta time of the last rendered frame.
2320
    """
2321
    return lib.TCOD_sys_get_last_frame_length()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_get_last_frame_length.

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...
2322
2323
def sys_sleep_milli(val):
2324
    """Sleep for 'val' milliseconds.
2325
2326
    Args:
2327
        val (int): Time to sleep for in milliseconds.
2328
2329
    .. deprecated:: 2.0
2330
       Use :any:`time.sleep` instead.
2331
    """
2332
    lib.TCOD_sys_sleep_milli(val)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_sleep_milli.

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...
2333
2334
def sys_elapsed_milli():
2335
    """Get number of milliseconds since the start of the program.
2336
2337
    Returns:
2338
        int: Time since the progeam has started in milliseconds.
2339
2340
    .. deprecated:: 2.0
2341
       Use :any:`time.clock` instead.
2342
    """
2343
    return lib.TCOD_sys_elapsed_milli()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_elapsed_milli.

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...
2344
2345
def sys_elapsed_seconds():
2346
    """Get number of seconds since the start of the program.
2347
2348
    Returns:
2349
        float: Time since the progeam has started in seconds.
2350
2351
    .. deprecated:: 2.0
2352
       Use :any:`time.clock` instead.
2353
    """
2354
    return lib.TCOD_sys_elapsed_seconds()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_elapsed_seconds.

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...
2355
2356
def sys_set_renderer(renderer):
2357
    """Change the current rendering mode to renderer.
2358
2359
    .. deprecated:: 2.0
2360
       RENDERER_GLSL and RENDERER_OPENGL are not currently available.
2361
    """
2362
    lib.TCOD_sys_set_renderer(renderer)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_set_renderer.

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...
2363
2364
def sys_get_renderer():
2365
    """Return the current rendering mode.
2366
2367
    """
2368
    return lib.TCOD_sys_get_renderer()
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_get_renderer.

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...
2369
2370
# easy screenshots
2371
def sys_save_screenshot(name=None):
2372
    """Save a screenshot to a file.
2373
2374
    By default this will automatically save screenshots in the working
2375
    directory.
2376
2377
    The automatic names are formatted as screenshotNNN.png.  For example:
2378
    screenshot000.png, screenshot001.png, etc.  Whichever is available first.
2379
2380
    Args:
2381
        file Optional[AnyStr]: File path to save screenshot.
2382
    """
2383
    if name is not None:
2384
        name = _bytes(name)
2385
    lib.TCOD_sys_save_screenshot(name or ffi.NULL)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_save_screenshot.

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 _MockFFI does not seem to have a member named NULL.

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...
2386
2387
# custom fullscreen resolution
2388
def sys_force_fullscreen_resolution(width, height):
2389
    """Force a specific resolution in fullscreen.
2390
2391
    Will use the smallest available resolution so that:
2392
2393
    * resolution width >= width and
2394
      resolution width >= root console width * font char width
2395
    * resolution height >= height and
2396
      resolution height >= root console height * font char height
2397
2398
    Args:
2399
        width (int): The desired resolution width.
2400
        height (int): The desired resolution height.
2401
    """
2402
    lib.TCOD_sys_force_fullscreen_resolution(width, height)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_force_fullscreen_resolution.

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...
2403
2404
def sys_get_current_resolution():
2405
    """Return the current resolution as (width, height)
2406
2407
    Returns:
2408
        Tuple[int,int]: The current resolution.
2409
    """
2410
    w = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
2411
    h = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
2412
    lib.TCOD_sys_get_current_resolution(w, h)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_get_current_resolution.

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...
2413
    return w[0], h[0]
2414
2415
def sys_get_char_size():
2416
    """Return the current fonts character size as (width, height)
2417
2418
    Returns:
2419
        Tuple[int,int]: The current font glyph size in (width, height)
2420
    """
2421
    w = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
2422
    h = ffi.new('int *')
0 ignored issues
show
Bug introduced by
The Instance of _MockFFI does not seem to have a member named new.

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...
2423
    lib.TCOD_sys_get_char_size(w, h)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_get_char_size.

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...
2424
    return w[0], h[0]
2425
2426
# update font bitmap
2427
def sys_update_char(asciiCode, fontx, fonty, img, x, y):
2428
    """Dynamically update the current frot with img.
2429
2430
    All cells using this asciiCode will be updated
2431
    at the next call to :any:`tcod.console_flush`.
2432
2433
    Args:
2434
        asciiCode (int): Ascii code corresponding to the character to update.
2435
        fontx (int): Left coordinate of the character
2436
                     in the bitmap font (in tiles)
2437
        fonty (int): Top coordinate of the character
2438
                     in the bitmap font (in tiles)
2439
        img (Image): An image containing the new character bitmap.
2440
        x (int): Left pixel of the character in the image.
2441
        y (int): Top pixel of the character in the image.
2442
    """
2443
    lib.TCOD_sys_update_char(_int(asciiCode), fontx, fonty, img, x, y)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_update_char.

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...
2444
2445
def sys_register_SDL_renderer(callback):
2446
    """Register a custom randering function with libtcod.
2447
2448
    The callack will receive a :any:`CData <ffi-cdata>` void* to an
2449
    SDL_Surface* struct.
2450
2451
    The callback is called on every call to :any:`tcod.console_flush`.
2452
2453
    Args:
2454
        callback Callable[[CData], None]:
2455
            A function which takes a single argument.
2456
    """
2457
    with _PropagateException() as propagate:
2458
        @ffi.def_extern(onerror=propagate)
2459
        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...
2460
            callback(sdl_surface)
2461
        lib.TCOD_sys_register_SDL_renderer(lib._pycall_sdl_hook)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_register_SDL_renderer.

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 object does not seem to have a member named _pycall_sdl_hook.

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...
2462
2463
def sys_check_for_event(mask, k, m):
2464
    """Check for and return an event.
2465
2466
    Args:
2467
        mask (int): :any:`Event types` to wait for.
2468
        k (Optional[Key]): A tcod.Key instance which might be updated with
2469
                           an event.  Can be None.
2470
        m (Optional[Mouse]): A tcod.Mouse instance which might be updated
2471
                             with an event.  Can be None.
2472
    """
2473
    return lib.TCOD_sys_check_for_event(mask, _cdata(k), _cdata(m))
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_check_for_event.

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...
2474
2475
def sys_wait_for_event(mask, k, m, flush):
2476
    """Wait for an event then return.
2477
2478
    If flush is True then the buffer will be cleared before waiting. Otherwise
2479
    each available event will be returned in the order they're recieved.
2480
2481
    Args:
2482
        mask (int): :any:`Event types` to wait for.
2483
        k (Optional[Key]): A tcod.Key instance which might be updated with
2484
                           an event.  Can be None.
2485
        m (Optional[Mouse]): A tcod.Mouse instance which might be updated
2486
                             with an event.  Can be None.
2487
        flush (bool): Clear the event buffer before waiting.
2488
    """
2489
    return lib.TCOD_sys_wait_for_event(mask, _cdata(k), _cdata(m), flush)
0 ignored issues
show
Bug introduced by
The Instance of object does not seem to have a member named TCOD_sys_wait_for_event.

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...
2490
2491
__all__ = [_name for _name in list(globals()) if _name[0] != '_']
2492