This file is indexed.

/usr/share/games/balazar3/dungeon.py is in balazar3-common 0.1-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- coding: utf-8 -*-
# Balazar in the Rancid Skull Dungeon
# Copyright (C) 2008 Jean-Baptiste LAMY
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os, os.path, random
import cerealizer

from balazar3.rooms            import *
from balazar3.rooms.rooms_defs import *
from balazar3.game             import *
import balazar3.globdef as globdef
import balazar3.tofu    as tofu

DUNGEON = None

def load_dungeon():
  global DUNGEON
  filename = os.path.join(globdef.SAVED_GAME_DIR, tofu.GAME, "dungeon.data")
  if os.path.exists(filename): DUNGEON = cerealizer.load(open(filename))
  else:                        DUNGEON = Dungeon()
  DUNGEON.path = os.path.join(globdef.SAVED_GAME_DIR, tofu.GAME)
  
class Dungeon(object):
  def __init__(self):
    self.path  = ""
    self.rooms = {"0_0" : "17"}
    
  def save(self):
    if self.path: cerealizer.dump(self, open(os.path.join(self.path, "dungeon.data"), "wb"))

  def delete(self):
    if self.path:
      for level_file in os.listdir(os.path.join(self.path, "levels")):
        level_file = os.path.join(self.path, "levels", level_file)
        print "* Balazar 3 * Remove level file %s..." % level_file
        os.remove(level_file)

      dungeon_filename = os.path.join(self.path, "dungeon.data")
      if os.path.exists(dungeon_filename):
        print "* Balazar 3 * Remove dungeon file %s..." % dungeon_filename
        os.remove(dungeon_filename)
        
      self.path = ""
      
  def random_level(self, level):
    I = level.I
    J = level.J
    
    rooms = set(all_rooms)
    left  = self.rooms.get("%s_%s" % (I - 1, J))
    right = self.rooms.get("%s_%s" % (I + 1, J))
    up    = self.rooms.get("%s_%s" % (I, J + 1))
    down  = self.rooms.get("%s_%s" % (I, J - 1))
    if left:
      if (Room.get(left ).blocs[6][3] == 2): rooms.intersection_update(left_open_rooms)
      else:                                  rooms.difference_update  (left_open_rooms)
    if right:
      if (Room.get(right).blocs[0][3] == 2): rooms.intersection_update(right_open_rooms)
      else:                                  rooms.difference_update  (right_open_rooms)
    if up:
      if (Room.get(up   ).blocs[3][0] == 2): rooms.intersection_update(up_open_rooms)
      else:                                  rooms.difference_update  (up_open_rooms)
    if down:
      if (Room.get(down ).blocs[3][6] == 2): rooms.intersection_update(down_open_rooms)
      else:                                  rooms.difference_update  (down_open_rooms)
      
    room_name = self.rooms[level.filename] = random.choice(list(rooms))
    level.room = Room.get(room_name)
    
    nb_monster = random.choice(level.room.nb_monster)
    
    for k in range(nb_monster):
      monster = random.choice(level.room.monster_classes)()
      i = random.randint(0, len(level.room.monster_places) - 1)
      monster.i, monster.j = level.room.monster_places.pop(i)
      monster.angle        = random.random() * 360.0
      level.add_mobile(monster)
      
    for proba, Trap, i, j in level.room.traps:
      if random.random() <= proba:
        trap = Trap()
        trap.i = i ; trap.j = j
        level.add_mobile(trap)

cerealizer.register(Dungeon)