Commits

Philémon Gardet committed 0cae7ae

Enregistrement des noeuds changent de salle dans la classe graph.
Ajout d'une method dans graph specifiant si un changement de salle est necessaire.

  • Participants
  • Parent commits cc1019a

Comments (0)

Files changed (2)

File game/rooms/begin/nodes.xml

 	<node id="centre" x="500" y="509" l="lit,horloge,bureau"/>
 	<node id="bureau" x="755" y="532" l="centre,out"/>
 	<node id="horloge" x="440" y="453" l="centre"/>
-	<node id="out" x="957" y="558" l="bureau"/>
+	<node id="out" x="957" y="558" l="bureau" swr="outdoor" swn="maison"/>
 </graph>
 			| Text(_) -> raise IsNotXmlElement
 			| Element(_, dict) -> try dict#get name with Not_found -> raise AttrNotFound
 		in attr data
+	method checkAttr name =
+		match data with
+			| Text(_) -> raise IsNotXmlElement
+			| Element(_, dict) -> dict#check name
 end
 ;;
 
 		val mutable aux = VoidM
 		
 		val changingRoom = new dictionary
-		
 		val mutable currentNode = ""
 		
 		initializer
 						and l = self#strParse (data#getAttr "l")
 						in 
 						links#set id ((x,y),l);
-						browser q
+						begin if (data#checkAttr "swr") then
+							let swr = data#getAttr "swr"
+							and swn = data#getAttr "swn"
+							in changingRoom#set id (swr,swn)
+						end; browser q
 				in browser (nodes#getElementsByName "node")
 			in
 			self#calculateDistances;
 		method setCurrentNode name =
 			currentNode <- name
 		
+		method needChangeRoom =
+			if changingRoom#check currentNode then
+				Some (changingRoom#get currentNode)
+			else
+				None
 	end
 
 (* Global Variables ***********************************************************)