1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
""" tui/static.py - Staattiset määritykset tui:ssa tarvittaville jutuille. """
from enum import Enum
from dataclasses import dataclass
class Action(Enum):
""" tominnot, joita voidaan saada palautusrvona """
QUIT = 0 # Pelin lopetus
OPEN = 1 # Ruudun avaaminen
FLAG = 2 # Ruudun liputus
HINT = 3 # Anna vihjeet
AUTO = 4 # Pelaa automaattisesti
LEFT = 5 # Liikkumiset...
RIGHT = 6
UP = 7
DOWN = 8
TOP = 9
BOTTOM = 10
BEGIN = 11
END = 12
NOOP = 13 # ei mitään - tarvitaan, ettei mätsää ansikoodeja esciin
BOMB = 14 # merkkaa pommi
SAFE = 15 # merkkaa turvallinen
# ActionKeys - Ohjelma vertaa syötteen alkua näihin ja palauttaa ekan
ActionKeys = {
"\033[A": Action.UP, "\033[D": Action.LEFT,
"\033[C": Action.RIGHT, '\033[B': Action.DOWN, "\033[5~": Action.TOP,
"\033[6~": Action.BOTTOM, "\033[7~": Action.BEGIN,"\033[8~": Action.END,
"\033[": Action.NOOP, "\033": Action.QUIT, "t": Action.SAFE,
"w": Action.UP, "a": Action.LEFT, "s": Action.DOWN,
"d": Action.RIGHT, " ": Action.OPEN, "\n": Action.OPEN,
"f": Action.FLAG, "m": Action.FLAG, "q": Action.QUIT,
"p": Action.BOMB, "x": Action.BOMB, "o": Action.SAFE,
"l": Action.QUIT, "?": Action.HINT, "b": Action.HINT
}
KEY_DESCRIPTIONS = """
Liikkuminen:
YLÖS,ALAS,VASEN,OIKEA,PGDN,PGUP,HOME,END,w,a,s,d
Merkitseminen:
m - merkitse
p,x - pommi
t,o - turvallinen
Avaaminen:
ENTER, SPACE
Vinkki:
?, b - pyydä botilta vihje
Lopetus:
l,q,ESC
"""
@dataclass
class TileType:
""" ruututyyppien tallennusmuotojen kuvaus"""
text: str # Teksti
colors: [] # Lista (väri, tausta) pareja tekstin kaunistamiseen
TileTypes = {
0: TileType( "[ ]", [(0x7,0), (0x7,0), (0x7,0)] ),
1: TileType( "[1]", [(0xA,0), (0xA,0), (0xA,0)] ),
2: TileType( "[2]", [(0xB,0), (0xB,0), (0xB,0)] ),
3: TileType( "[3]", [(0xD,0), (0xD,0), (0xD,0)] ),
4: TileType( "[4]", [(0x9,0), (0x9,0), (0x9,0)] ),
5: TileType( "[5]", [(0x9,0), (0x9,0), (0x9,0)] ),
6: TileType( "[6]", [(0x9,0), (0x9,0), (0x9,0)] ),
7: TileType( "[7]", [(0x9,0), (0x9,0), (0x9,0)] ),
8: TileType( "[8]", [(0x9,0), (0x9,0), (0x9,0)] ),
9: TileType( "[@]", [(0xF,1), (0xF,1), (0xF,1)] ),
10: TileType( "[#]", [(0x8,7), (0x8,7), (0x8,7)] ),
11: TileType( "[×]", [(0x8,7), (0x1,7), (0x8,7)] ),
12: TileType( "[•]", [(0x8,7), (0x2,7), (0x8,7)] ),
13: TileType( "[?]", [(0x8,7), (0x0,7), (0x8,7)] )
}
|