Exemplo n.º 1
0
 def edge_to_condition(self):
     condition = Condition(False)
     condition.set_first_object(self._from_node)
     condition.set_second_object(self._to_node)
     condition.set_key(self.get_key())
     condition.set_value(self.get_value())
     return condition
Exemplo n.º 2
0
	def edge_to_condition(self):
		condition = Condition(False)
		condition.set_first_object(self._from_node)
		condition.set_second_object(self._to_node)
		condition.set_key(self.get_key())
		condition.set_value(self.get_value())
		return condition
Exemplo n.º 3
0
	def new_owner(self, input_array):
		if not self._condition_only:
			new_owner = input_array[0]
			status = input_array[1]
			own_reason = input_array[2]
			
			#Make the changes
			self._attributes['status'] = status
			edge  = Edge({'Owns' : own_reason}, new_owner, self)
			
			#Set up our return arrays
			to_add = [edge]
			to_remove = self.remove_all_edges(True)
			
			#Add the new edges to their respective node
			new_owner.add_outgoing_edge(edge)
			self.add_incoming_edge(edge)
			
			return to_remove, to_add
		else:
			new_owner = input_array[0]
			status = input_array[1]
			own_reason = input_array[2]
			
			pre_conditions = []
			new_conditions = []
			lost_conditions = []
			
			precondition = Condition(False)
			precondition.set_first_object(self)
			who = self.get_from_node_from_incoming_edge_name({"Owns" : "N/A"})
			where = who.get_to_node_from_outgoing_edge_name({"Lives" : "N/A"})
			precondition.set_second_object(where)
			precondition.set_key("Currently_In")
			precondition.set_value("N/A")
			pre_conditions.append(precondition)

			lost_conditions.append(self.attribute_to_condition('status'))
			lost_conditions.extend(self.convert_all_edges_to_condition(True))
			
			condition = Condition(True)
			condition.set_first_object(self)
			condition.set_key('status')
			condition.set_value(status)			
			new_conditions.append(condition)
			
			condition2 = Condition(False)
			condition2.set_first_object(new_owner)
			condition2.set_second_object(self)
			condition2.set_key('Owns')
			condition2.set_value(own_reason)	
			new_conditions.append(condition2)
			
			return pre_conditions, new_conditions, lost_conditions
Exemplo n.º 4
0
    def new_owner(self, input_array):
        if not self._condition_only:
            new_owner = input_array[0]
            status = input_array[1]
            own_reason = input_array[2]

            #Make the changes
            self._attributes['status'] = status
            edge = Edge({'Owns': own_reason}, new_owner, self)

            #Set up our return arrays
            to_add = [edge]
            to_remove = self.remove_all_edges(True)

            #Add the new edges to their respective node
            new_owner.add_outgoing_edge(edge)
            self.add_incoming_edge(edge)

            return to_remove, to_add
        else:
            new_owner = input_array[0]
            status = input_array[1]
            own_reason = input_array[2]

            pre_conditions = []
            new_conditions = []
            lost_conditions = []

            precondition = Condition(False)
            precondition.set_first_object(self)
            who = self.get_from_node_from_incoming_edge_name({"Owns": "N/A"})
            where = who.get_to_node_from_outgoing_edge_name({"Lives": "N/A"})
            precondition.set_second_object(where)
            precondition.set_key("Currently_In")
            precondition.set_value("N/A")
            pre_conditions.append(precondition)

            lost_conditions.append(self.attribute_to_condition('status'))
            lost_conditions.extend(self.convert_all_edges_to_condition(True))

            condition = Condition(True)
            condition.set_first_object(self)
            condition.set_key('status')
            condition.set_value(status)
            new_conditions.append(condition)

            condition2 = Condition(False)
            condition2.set_first_object(new_owner)
            condition2.set_second_object(self)
            condition2.set_key('Owns')
            condition2.set_value(own_reason)
            new_conditions.append(condition2)

            return pre_conditions, new_conditions, lost_conditions
Exemplo n.º 5
0
	def talk(self, input_array):
		if not self._condition_only:
			return [], []
		else:
			other_person = input_array[0]
			where = other_person.get_to_node_from_outgoing_edge_name({"Lives" : "N/A"})
						
			condition = Condition(False)
			condition.set_first_object(self)
			condition.set_second_object(where)
			condition.set_key("Currently_In")
			condition.set_value("N/A")
			
			print [condition], [], []
Exemplo n.º 6
0
	def move_player(self, where):
		if not self._condition_only:
			self.get_outgoing_edges()[0].set_to_node(where)
			
			return [], []
		else:
			lost_condition = self.get_outgoing_edges()[0].edge_to_condition()
			
			condition = Condition(False)
			condition.set_first_object(self)
			condition.set_second_object(where)
			condition.set_key(self.get_outgoing_edges()[0].get_key())
			condition.set_value(self.get_outgoing_edges()[0].get_value())
			
			return [], [condition], [lost_condition]
Exemplo n.º 7
0
    def talk(self, input_array):
        if not self._condition_only:
            return [], []
        else:
            other_person = input_array[0]
            where = other_person.get_to_node_from_outgoing_edge_name(
                {"Lives": "N/A"})

            condition = Condition(False)
            condition.set_first_object(self)
            condition.set_second_object(where)
            condition.set_key("Currently_In")
            condition.set_value("N/A")

            print[condition], [], []
Exemplo n.º 8
0
    def move_player(self, where):
        if not self._condition_only:
            self.get_outgoing_edges()[0].set_to_node(where)

            return [], []
        else:
            lost_condition = self.get_outgoing_edges()[0].edge_to_condition()

            condition = Condition(False)
            condition.set_first_object(self)
            condition.set_second_object(where)
            condition.set_key(self.get_outgoing_edges()[0].get_key())
            condition.set_value(self.get_outgoing_edges()[0].get_value())

            return [], [condition], [lost_condition]
Exemplo n.º 9
0
    def take_Item(self, input_array):
        if not self._condition_only:
            print "Receive or take an item"
            old_owner = input_array[0]
            item = input_array[1]
            own_reason = input_array[2]

            #Make the changes
            edge = Edge({'Owns': own_reason}, self, item)

            #Set up our return arrays
            to_add = [edge]
            to_remove = item.remove_all_edges(True)

            #Add the new edges to their respective node
            self.add_outgoing_edge(edge)
            item.add_incoming_edge(edge)

            return to_remove, to_add
        else:
            print "Receive"
            old_owner = input_array[0]
            item = input_array[1]
            own_reason = input_array[2]

            pre_conditions = []
            new_conditions = []
            lost_conditions = []

            precondition = Condition(False)
            precondition.set_first_object(self)
            where = old_owner.get_to_node_from_outgoing_edge_name(
                {"Lives": "N/A"})
            precondition.set_second_object(where)
            precondition.set_key("Currently_In")
            precondition.set_value("N/A")
            pre_conditions.append(precondition)

            lost_conditions.extend(item.convert_all_edges_to_condition(True))

            condition2 = Condition(False)
            condition2.set_first_object(self)
            condition2.set_second_object(item)
            condition2.set_key('Owns')
            condition2.set_value(own_reason)
            new_conditions.append(condition2)

            return pre_conditions, new_conditions, lost_conditions
Exemplo n.º 10
0
	def take_Item(self, input_array):
		if not self._condition_only:
			print "Receive or take an item"
			old_owner = input_array[0]
			item = input_array[1]
			own_reason = input_array[2]
			
			#Make the changes
			edge  = Edge({'Owns' : own_reason}, self, item)
			
			#Set up our return arrays
			to_add = [edge]
			to_remove = item.remove_all_edges(True)
			
			#Add the new edges to their respective node
			self.add_outgoing_edge(edge)
			item.add_incoming_edge(edge)
			
			return to_remove, to_add
		else:
			print "Receive"
			old_owner = input_array[0]
			item = input_array[1]
			own_reason = input_array[2]
			
			pre_conditions = []
			new_conditions = []
			lost_conditions = []
			
			precondition = Condition(False)
			precondition.set_first_object(self)
			where = old_owner.get_to_node_from_outgoing_edge_name({"Lives" : "N/A"})
			precondition.set_second_object(where)
			precondition.set_key("Currently_In")
			precondition.set_value("N/A")
			pre_conditions.append(precondition)

			lost_conditions.extend(item.convert_all_edges_to_condition(True))
			
			condition2 = Condition(False)
			condition2.set_first_object(self)
			condition2.set_second_object(item)
			condition2.set_key('Owns')
			condition2.set_value(own_reason)	
			new_conditions.append(condition2)
			
			return pre_conditions, new_conditions, lost_conditions
Exemplo n.º 11
0
	def add_edge(self, method_array):
			
		to_node = method_array[0]
		key = method_array[1]
		value = method_array[2]

		if not self._condition_only:
			new_edge = Edge({key : value}, self, to_node)
			self.add_edge_special(new_edge, to_node)
			return [], [new_edge]
		
		else:
			condition = Condition(False)
			condition.set_first_object(self)
			condition.set_second_object(to_node)
			condition.set_key(key)
			condition.set_value(value)
			
			return [], [condition], []
Exemplo n.º 12
0
    def add_edge(self, method_array):

        to_node = method_array[0]
        key = method_array[1]
        value = method_array[2]

        if not self._condition_only:
            new_edge = Edge({key: value}, self, to_node)
            self.add_edge_special(new_edge, to_node)
            return [], [new_edge]

        else:
            condition = Condition(False)
            condition.set_first_object(self)
            condition.set_second_object(to_node)
            condition.set_key(key)
            condition.set_value(value)

            return [], [condition], []
Exemplo n.º 13
0
	def move_player_to_node(self, who):
		if not self._condition_only:
			who = who[0]
		
			where = who.get_to_node_from_outgoing_edge_name({"Lives" : "N/A"})
			self.get_outgoing_edges()[0].set_to_node(where)
		
			return [], []	
		else:
			who = who[0]
			where = who.get_to_node_from_outgoing_edge_name({"Lives" : "N/A"})
			
			lost_condition = self.get_outgoing_edges()[0].edge_to_condition()
			
			condition = Condition(False)
			condition.set_first_object(self)
			condition.set_second_object(where)
			condition.set_key(self.get_outgoing_edges()[0].get_key())
			condition.set_value(self.get_outgoing_edges()[0].get_value())
			
			return [], [condition], [lost_condition]
Exemplo n.º 14
0
    def move_player_to_node(self, who):
        if not self._condition_only:
            who = who[0]

            where = who.get_to_node_from_outgoing_edge_name({"Lives": "N/A"})
            self.get_outgoing_edges()[0].set_to_node(where)

            return [], []
        else:
            who = who[0]
            where = who.get_to_node_from_outgoing_edge_name({"Lives": "N/A"})

            lost_condition = self.get_outgoing_edges()[0].edge_to_condition()

            condition = Condition(False)
            condition.set_first_object(self)
            condition.set_second_object(where)
            condition.set_key(self.get_outgoing_edges()[0].get_key())
            condition.set_value(self.get_outgoing_edges()[0].get_value())

            return [], [condition], [lost_condition]
Exemplo n.º 15
0
    def get_node_relations(self, relation_input, other_node, new_relation,
                           reason, incoming):

        cause = reason + self._name

        if incoming:
            edges = self._incoming_edges
        else:
            edges = self._outgoing_edges

        Postconditions = []
        Preconditions = []
        #Update all the edges
        for edge in edges:
            attribute = edge.get_name()

            #If the other player liked or loved this character
            #	they should hate the murderer
            if attribute.keys()[0] in relation_input:

                if incoming:
                    from_node = edge.get_from_node()
                else:
                    from_node = edge.get_to_node()

                if not (from_node == other_node):
                    precondition = Condition(False)
                    precondition.set_first_object(from_node)
                    precondition.set_second_object(self)
                    precondition.set_key(edge.get_key())
                    precondition.set_value(edge.get_value())
                    Preconditions.append(precondition)

                    new_condition = Condition(False)
                    new_condition.set_first_object(from_node)
                    new_condition.set_second_object(other_node)
                    new_condition.set_key(new_relation)
                    new_condition.set_value(cause)
                    Postconditions.append(new_condition)
        return Preconditions, Postconditions
Exemplo n.º 16
0
	def get_node_relations(self, relation_input, other_node, new_relation, reason, incoming):
		
		cause = reason + self._name
		
		if incoming:
			edges = self._incoming_edges
		else:  
			edges = self._outgoing_edges
		
		Postconditions = []
		Preconditions = []
		#Update all the edges
		for edge in edges:
			attribute = edge.get_name()
			
			#If the other player liked or loved this character
			#	they should hate the murderer
			if attribute.keys()[0] in relation_input:
				
				if incoming:
					from_node = edge.get_from_node()
				else:
					from_node = edge.get_to_node()
				
				if not (from_node == other_node):
					precondition = Condition(False)
					precondition.set_first_object(from_node)
					precondition.set_second_object(self)
					precondition.set_key(edge.get_key())
					precondition.set_value(edge.get_value())
					Preconditions.append(precondition)

					new_condition = Condition(False)
					new_condition.set_first_object(from_node)
					new_condition.set_second_object(other_node)
					new_condition.set_key(new_relation)
					new_condition.set_value(cause)
					Postconditions.append(new_condition)		
		return Preconditions, Postconditions