This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDeploy.py
84 lines (59 loc) · 2.58 KB
/
Deploy.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
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
from DATABASE import DBclass
import random
from CONCEPT import Snippet
class content():
def __init__(self):
self.content={}
self.counter=-1
def creation(self, gxel, xel, temp, umid):
self.counter=self.counter+1
if gxel not in self.content.keys() :
self.content[gxel]={}
if xel not in self.content[gxel].keys():
animal=[]
vegetal=[]
terrain=[]
db=DBclass.ExaDB()
a=1
for i in db.terrains:
terr= DBclass.Terrain(db,a)
if temp <= terr.maxtemp and temp >= terr.mintemp and umid <= terr.maxhmd and umid >= terr.minhmd:
terrain.append(terr)
a=a+1
terrain.append(None)
indext=random.randint(0,len(terrain)-1)
if terrain[indext]!=None:
if terrain[indext].nome=="water":
self.content[gxel][xel]=(None, None, terrain[indext])
return (None, None, terrain[indext])
if self.counter%random.randint(5,20)==0:
a=1
for i in db.creatures:
creatures= DBclass.Creature(db,a)
if creatures.tipo== "vegetale":
if temp <= creatures.maxtemp and temp >= creatures.mintemp and umid <= creatures.maxhmd and umid >= creatures.minhmd:
vegetal.append(creatures)
if creatures.tipo== "animale":
if temp <= creatures.maxtemp and temp >= creatures.mintemp and umid <= creatures.maxhmd and umid >= creatures.minhmd:
animal.append(creatures)
a=a+1
vegetal.append(None)
animal.append(None)
indexa=random.randint(0,len(animal)-1)
indexv=random.randint(0,len(vegetal)-1)
self.content[gxel][xel]=(animal[indexa],vegetal[indexv],terrain[indext])
return self.content[gxel][xel]
else:
return self.content[gxel][xel]
def filedictionary(self, gxel):
if gxel not in self.content.keys() :
self.content[gxel]=Snippet.load(gxel)
if self.content[gxel]== -1 :
return "errore mappa non creata"
def dictionaryfile(self, gxel):
Snippet.save(self.content[gxel])
self.content.pop(gxel)
def getcontent (gxel, xel):
return self.content[gxel][xel]
#con=content()
#print(con.creation((0,0),(32,45,8),23,20))