Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c274bebb9 | |||
a28909bb70 | |||
6566f5140a | |||
|
776f8ed88c | ||
284a22c92e | |||
|
3d019d3ca8 | ||
99b749aaa2 | |||
|
d978d319bc | ||
|
87e896bd06 |
22
README.md
22
README.md
@ -14,11 +14,15 @@ Squirrel Battle is an infinite rogue-like game with randomly generated levels, i
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
#### Via PyPI :
|
#### Via PyPI :
|
||||||
``` pip install --user squirrel-battle
|
```
|
||||||
``` to install
|
$ pip install --user squirrel-battle
|
||||||
|
```
|
||||||
|
to install
|
||||||
|
|
||||||
``` pip install --user --upgrade squirrel-battle
|
```
|
||||||
``` to upgrade
|
$ pip install --user --upgrade squirrel-battle
|
||||||
|
```
|
||||||
|
to upgrade
|
||||||
|
|
||||||
#### Via ArchLinux package :
|
#### Via ArchLinux package :
|
||||||
Download one of these two packages on the AUR :
|
Download one of these two packages on the AUR :
|
||||||
@ -29,11 +33,13 @@ Download one of these two packages on the AUR :
|
|||||||
#### Via Debian package :
|
#### Via Debian package :
|
||||||
Available on our git repository, has a dependency on fonts-noto-color-emoji (to be found in the official Debian repositories).
|
Available on our git repository, has a dependency on fonts-noto-color-emoji (to be found in the official Debian repositories).
|
||||||
|
|
||||||
Run ```
|
Run
|
||||||
dpkg -i python3-squirrelbattle_23.14_all.deb
|
```
|
||||||
``` after downloading
|
$ dpkg -i python3-squirrelbattle_23.14_all.deb
|
||||||
|
```
|
||||||
|
after downloading
|
||||||
|
|
||||||
In all cases, execute via command line : ```squirrel-battle```
|
In all cases, execute via command line : `squirrel-battle`
|
||||||
|
|
||||||
## For first-time players
|
## For first-time players
|
||||||
|
|
||||||
|
@ -232,13 +232,18 @@ class Explosion(Item):
|
|||||||
"""
|
"""
|
||||||
When a bomb explodes, the explosion is displayed.
|
When a bomb explodes, the explosion is displayed.
|
||||||
"""
|
"""
|
||||||
def __init__(self, *args, **kwargs):
|
living_ticks: int
|
||||||
|
|
||||||
|
def __init__(self, living_ticks: int = 2, *args, **kwargs):
|
||||||
super().__init__(name="explosion", *args, **kwargs)
|
super().__init__(name="explosion", *args, **kwargs)
|
||||||
|
self.living_ticks = living_ticks
|
||||||
|
|
||||||
def act(self, m: Map) -> None:
|
def act(self, m: Map) -> None:
|
||||||
"""
|
"""
|
||||||
The bomb disappears after exploding.
|
The bomb disappears after exploding.
|
||||||
"""
|
"""
|
||||||
|
self.living_ticks -= 1
|
||||||
|
if self.living_ticks <= 0:
|
||||||
m.remove_entity(self)
|
m.remove_entity(self)
|
||||||
|
|
||||||
def hold(self, player: InventoryHolder) -> None:
|
def hold(self, player: InventoryHolder) -> None:
|
||||||
|
@ -192,7 +192,7 @@ class Game:
|
|||||||
|
|
||||||
# We move up on the ladder of the beginning,
|
# We move up on the ladder of the beginning,
|
||||||
# down at the end of the stage
|
# down at the end of the stage
|
||||||
move_down = y != self.map.start_y and x != self.map.start_x
|
move_down = y != self.map.start_y or x != self.map.start_x
|
||||||
old_map = self.map
|
old_map = self.map
|
||||||
self.map_index += 1 if move_down else -1
|
self.map_index += 1 if move_down else -1
|
||||||
if self.map_index == -1:
|
if self.map_index == -1:
|
||||||
|
@ -848,7 +848,6 @@ class InventoryHolder(Entity):
|
|||||||
for i in range(len(inventory)):
|
for i in range(len(inventory)):
|
||||||
if isinstance(inventory[i], dict):
|
if isinstance(inventory[i], dict):
|
||||||
inventory[i] = self.dict_to_item(inventory[i])
|
inventory[i] = self.dict_to_item(inventory[i])
|
||||||
inventory[i].held_by = self
|
|
||||||
return inventory
|
return inventory
|
||||||
|
|
||||||
def dict_to_item(self, item_dict: dict) -> Entity:
|
def dict_to_item(self, item_dict: dict) -> Entity:
|
||||||
@ -859,7 +858,9 @@ class InventoryHolder(Entity):
|
|||||||
entity_classes = self.get_all_entity_classes_in_a_dict()
|
entity_classes = self.get_all_entity_classes_in_a_dict()
|
||||||
|
|
||||||
item_class = entity_classes[item_dict["type"]]
|
item_class = entity_classes[item_dict["type"]]
|
||||||
return item_class(**item_dict)
|
item = item_class(**item_dict)
|
||||||
|
item.held_by = self
|
||||||
|
return item
|
||||||
|
|
||||||
def save_state(self) -> dict:
|
def save_state(self) -> dict:
|
||||||
"""
|
"""
|
||||||
@ -875,6 +876,7 @@ class InventoryHolder(Entity):
|
|||||||
Adds an object to the inventory.
|
Adds an object to the inventory.
|
||||||
"""
|
"""
|
||||||
if obj not in self.inventory:
|
if obj not in self.inventory:
|
||||||
|
obj.held_by = self
|
||||||
self.inventory.append(obj)
|
self.inventory.append(obj)
|
||||||
|
|
||||||
def remove_from_inventory(self, obj: Any) -> None:
|
def remove_from_inventory(self, obj: Any) -> None:
|
||||||
|
@ -209,7 +209,8 @@ class TestEntities(unittest.TestCase):
|
|||||||
self.assertNotIn(explosion, self.player.inventory)
|
self.assertNotIn(explosion, self.player.inventory)
|
||||||
self.assertIsNone(explosion.held_by)
|
self.assertIsNone(explosion.held_by)
|
||||||
|
|
||||||
# The explosion disappears after one tick
|
# The explosion disappears after two ticks
|
||||||
|
explosion.act(self.map)
|
||||||
explosion.act(self.map)
|
explosion.act(self.map)
|
||||||
self.assertNotIn(explosion, self.map.entities)
|
self.assertNotIn(explosion, self.map.entities)
|
||||||
|
|
||||||
|
@ -255,6 +255,7 @@ class TestGame(unittest.TestCase):
|
|||||||
self.game.map.add_entity(explosion)
|
self.game.map.add_entity(explosion)
|
||||||
self.assertIn(explosion, self.game.map.entities)
|
self.assertIn(explosion, self.game.map.entities)
|
||||||
self.game.handle_key_pressed(KeyValues.WAIT)
|
self.game.handle_key_pressed(KeyValues.WAIT)
|
||||||
|
self.game.handle_key_pressed(KeyValues.WAIT)
|
||||||
self.assertNotIn(explosion, self.game.map.entities)
|
self.assertNotIn(explosion, self.game.map.entities)
|
||||||
|
|
||||||
rabbit = Rabbit()
|
rabbit = Rabbit()
|
||||||
|
@ -25,6 +25,8 @@ class Translator:
|
|||||||
Loads compiled translations.
|
Loads compiled translations.
|
||||||
"""
|
"""
|
||||||
for language in cls.SUPPORTED_LOCALES:
|
for language in cls.SUPPORTED_LOCALES:
|
||||||
|
if language == "en":
|
||||||
|
continue
|
||||||
rep = Path(__file__).parent / "locale" / language / "LC_MESSAGES"
|
rep = Path(__file__).parent / "locale" / language / "LC_MESSAGES"
|
||||||
rep.mkdir(parents=True) if not rep.is_dir() else None
|
rep.mkdir(parents=True) if not rep.is_dir() else None
|
||||||
if os.path.isfile(rep / "squirrelbattle.mo"):
|
if os.path.isfile(rep / "squirrelbattle.mo"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user