-
Notifications
You must be signed in to change notification settings - Fork 0
/
id_sys.py
32 lines (26 loc) · 968 Bytes
/
id_sys.py
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
import random as rdm
from graph import GrapheDico
#l'objectif ici est l'attribution d'id aux differentes salles;
ROOMTYPE = ['treasure room','healing room','merchant room']
def idAttribution(graph):
entrance(graph)
sortie(graph)
#specialRoom(roomList)
def specialRoom(roomList):
roomNB = 0
while rdm.random() > 0.8:
roomNB += 1
while (roomList[roomNB].isCorridor) and (roomList[roomNB].id is not None) :
roomNB += 1
roomNB %= len(roomList)
roomList[roomNB].id = rdm.choice(ROOMTYPE)
def entrance(graph):
room = rdm.choice(graph.getRoomList())
while room.isCorridor or graph.nbNeighborOf(room) == 1:
room = rdm.choice(graph.getRoomList())
room.id = 'entrance'
def sortie(graph):
room = rdm.choice(graph.getRoomList())
while room.isCorridor or graph.nbNeighborOf(room) != 1 or room.id == 'entrance' :
room = rdm.choice(graph.getRoomList())
room.id = 'exit'