예제 #1
0
 def create_river_map(self):
     mappy = Map()
     for x in range(10):
         row = Row()
         for y in range(10):
             if x < 2 and y < 2:
                 cell = Cell()
                 cell.x_pos = x
                 cell.y_pos = y
                 cell.terrain = RIVER
                 row.cells.extend([cell])
             else:
                 cell = Cell()
                 cell.x_pos = x
                 cell.y_pos = y
                 cell.terrain = SEA
                 row.cells.extend([cell])
         mappy.rows.extend([row])
     return self.store_new_map(mappy)
예제 #2
0
 def create_random_map_data(self, size):
     mappy = Map()
     for x in range(size):
         row = Row()
         for y in range(size):
             cell = Cell()
             cell.x_pos = x
             cell.y_pos = y
             cell.terrain = self.choose_random_terrain()
             row.cells.extend([cell])
         mappy.rows.extend([row])
     return mappy
예제 #3
0
 def get_fragment(self, update: UpdatedPosition):
     terrain = self.conn.get("map:{0}:x:{1}:y:{2}".format(str(update.p_id), str(update.x_pos), str(update.y_pos)))
     print(terrain)
     if terrain is None:
         terrain = self.choose_random_terrain()
         self.conn.set("map:{0}:x:{1}:y:{2}".format(str(update.p_id), str(update.x_pos), str(update.y_pos)), terrain)
     else:
         terrain = int(terrain)
     print(terrain)
     cell = Cell()
     cell.x_pos = update.x_pos
     cell.y_pos = update.y_pos
     cell.terrain = terrain
     fragment = MapFragment()
     fragment.id = update.p_id
     fragment.cells.extend([cell])
     return fragment