diff options
author | Diego Roversi <diegor@tiscali.it> | 2019-09-08 18:12:27 +0200 |
---|---|---|
committer | Diego Roversi <diegor@tiscali.it> | 2019-09-08 18:12:27 +0200 |
commit | 1d9925c287b318ec21343e2682b51ab6a36ae8db (patch) | |
tree | 17d1c0ac21eea6f291146520afa8381db4586fb4 /bubbob/boarddef.py |
initial commit from cvs 1.6.2
Diffstat (limited to 'bubbob/boarddef.py')
-rw-r--r-- | bubbob/boarddef.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/bubbob/boarddef.py b/bubbob/boarddef.py new file mode 100644 index 0000000..168a3e1 --- /dev/null +++ b/bubbob/boarddef.py @@ -0,0 +1,69 @@ +import boards, mnstrmap + +class left: + dir = 1 + def __init__(self, cls): + self.cls = cls + def build(self, x, y): + return self.cls(x=x, y=y-1, dir=self.dir) + +class right(left): + dir = 0 + +LNasty = left(mnstrmap.Nasty) +RNasty = right(mnstrmap.Nasty) + +LMonky = left(mnstrmap.Monky) +RMonky = right(mnstrmap.Monky) + +LGhosty = left(mnstrmap.Ghosty) +RGhosty = right(mnstrmap.Ghosty) + +LFlappy = left(mnstrmap.Flappy) +RFlappy = right(mnstrmap.Flappy) + +LSpringy = left(mnstrmap.Springy) +RSpringy = right(mnstrmap.Springy) + +LOrcy = left(mnstrmap.Orcy) +ROrcy = right(mnstrmap.Orcy) + +LGramy = left(mnstrmap.Gramy) +RGramy = right(mnstrmap.Gramy) + +LBlitzy = left(mnstrmap.Blitzy) +RBlitzy = right(mnstrmap.Blitzy) + + +# Sugar around the Board class +class Level(boards.Board): + + WIND_DELTA = boards.CELL + winds = None + monsters = [] + + def __init__(self, num): + walls = [line for line in self.walls.split('\n') if line] + self.monsters = list(self.monsters) + for y in range(len(walls)): + line = walls[y] + for x in range(len(line)): + c = line[x] + if c != ' ' and c != '#': + deflist = getattr(self, c) + if isinstance(deflist, left): + deflist = (deflist,) + for builder in deflist: + self.monsters.append(builder.build(x,y)) + self.walls = self.walls.replace(c, ' ') + if self.winds is None: + width = len(walls[0]) + height = len(walls) + spaces = " " * (width-6) + lbar = '>'*(width/2-2) + rbar = '<'*(width/2-2) + winds = ['>> ' + spaces + ' <<', + lbar + 'x'*(width-len(lbar)-len(rbar)) + rbar] + winds += ['>>^' + spaces + '^<<'] * (height-2) + self.winds = '\n'.join(winds) + boards.Board.__init__(self, num) |