Tile colors can be overwritten
This commit is contained in:
		@@ -19,8 +19,11 @@ class MapDisplay(Display):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def update_pad(self) -> None:
 | 
					    def update_pad(self) -> None:
 | 
				
			||||||
        self.pad.resize(500, 500)
 | 
					        self.pad.resize(500, 500)
 | 
				
			||||||
        self.addstr(self.pad, 0, 0, self.map.draw_string(self.pack),
 | 
					        for i in range(self.map.height):
 | 
				
			||||||
                    self.pack.tile_fg_color, self.pack.tile_bg_color)
 | 
					            for j in range(self.map.width):
 | 
				
			||||||
 | 
					                self.addstr(self.pad, i, j * self.pack.tile_width,
 | 
				
			||||||
 | 
					                            self.map.tiles[i][j].char(self.pack),
 | 
				
			||||||
 | 
					                            *self.map.tiles[i][j].color(self.pack))
 | 
				
			||||||
        for e in self.map.entities:
 | 
					        for e in self.map.entities:
 | 
				
			||||||
            self.addstr(self.pad, e.y, self.pack.tile_width * e.x,
 | 
					            self.addstr(self.pad, e.y, self.pack.tile_width * e.x,
 | 
				
			||||||
                        self.pack[e.name.upper()],
 | 
					                        self.pack[e.name.upper()],
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,7 +91,7 @@ TexturePack.SQUIRREL_PACK = TexturePack(
 | 
				
			|||||||
    EMPTY='  ',
 | 
					    EMPTY='  ',
 | 
				
			||||||
    EXPLOSION='💥',
 | 
					    EXPLOSION='💥',
 | 
				
			||||||
    FLOOR='██',
 | 
					    FLOOR='██',
 | 
				
			||||||
    LADDER='🪜',
 | 
					    LADDER=('🪜', curses.COLOR_WHITE, curses.COLOR_WHITE),
 | 
				
			||||||
    HAZELNUT='🌰',
 | 
					    HAZELNUT='🌰',
 | 
				
			||||||
    HEART='💜',
 | 
					    HEART='💜',
 | 
				
			||||||
    HEDGEHOG='🦔',
 | 
					    HEDGEHOG='🦔',
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@
 | 
				
			|||||||
from enum import Enum, auto
 | 
					from enum import Enum, auto
 | 
				
			||||||
from math import sqrt
 | 
					from math import sqrt
 | 
				
			||||||
from random import choice, randint
 | 
					from random import choice, randint
 | 
				
			||||||
from typing import List, Optional, Any
 | 
					from typing import List, Optional, Any, Tuple
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .display.texturepack import TexturePack
 | 
					from .display.texturepack import TexturePack
 | 
				
			||||||
from .translations import gettext as _
 | 
					from .translations import gettext as _
 | 
				
			||||||
@@ -218,7 +218,19 @@ class Tile(Enum):
 | 
				
			|||||||
        Translates a Tile to the corresponding character according
 | 
					        Translates a Tile to the corresponding character according
 | 
				
			||||||
        to the texture pack
 | 
					        to the texture pack
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        return getattr(pack, self.name)
 | 
					        val = getattr(pack, self.name)
 | 
				
			||||||
 | 
					        if isinstance(val, tuple):
 | 
				
			||||||
 | 
					            return val[0]
 | 
				
			||||||
 | 
					        return val
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def color(self, pack: TexturePack) -> Tuple[int, int]:
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Retrieve the tuple (fg_color, bg_color) of the current Tile.
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        val = getattr(pack, self.name)
 | 
				
			||||||
 | 
					        if isinstance(val, tuple):
 | 
				
			||||||
 | 
					            return val[1], val[2]
 | 
				
			||||||
 | 
					        return pack.tile_fg_color, pack.tile_bg_color
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def is_wall(self) -> bool:
 | 
					    def is_wall(self) -> bool:
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user