This commit is contained in:
Yohann D'ANELLO 2021-01-11 01:21:52 +01:00
parent 03c45a970c
commit 7b019ce149
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 11 additions and 13 deletions

View File

@ -24,9 +24,9 @@ DEFAULT_PARAMS = {
"loop_max": 5,
"loop_threshold": 15,
"spawn_per_region": [1, 2],
"room_chances" : {
"circular" : 5,
"chunks" : 1,
"room_chances": {
"circular": 5,
"chunks": 1,
},
}
@ -269,19 +269,19 @@ class Generator:
nb_chunks, r = 6, 3
h_sup, w_sup, h_off, w_off = self.corr_meta_info()
room = [[Tile.EMPTY] * (width + w_sup) \
room = [[Tile.EMPTY] * (width + w_sup)
for _dummy in range(height + h_sup)]
def draw_chunk(room, y, x):
def draw_chunk(room: List[List[Tile]], y: int, x: int) -> None:
for i in range(y - r, y + r + 1):
d = (y - i)**2
for j in range(x - r, x + r + 1):
if d + (x - j)**2 < r**2:
if d + (x - j) ** 2 < r ** 2:
room[i][j] = Tile.FLOOR
draw_chunk(room, h_off + height//2 + 1, w_off + width//2 + 1)
draw_chunk(room, h_off + height // 2 + 1, w_off + width // 2 + 1)
min_w, max_w = w_off + r + 1, width + w_off - r -1
min_w, max_w = w_off + r + 1, width + w_off - r - 1
min_h, max_h = h_off + r + 1, height + h_off - r - 1
for i in range(nb_chunks):
y, x = randint(min_h, max_h), randint(min_w, max_w)
@ -359,9 +359,9 @@ class Generator:
break
if key == "circular":
return self.create_circular_room(spawnable = spawnable)
return self.create_circular_room(spawnable=spawnable)
elif key == "chunks":
return self.create_chunk_room(spawnable = spawnable)
return self.create_chunk_room(spawnable=spawnable)
def register_spawn_area(self, area: List[List[Tile]]) -> None:
"""

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import curses
import os
import unittest
from ..bootstrap import Bootstrap
@ -101,7 +100,6 @@ class TestGame(unittest.TestCase):
Yeah, that's only for coverage.
"""
self.assertRaises(Exception, Bootstrap.run_game)
self.assertEqual(os.getenv("TERM", "unknown"), "unknown")
def test_key_translation(self) -> None:
"""