How to use the hearthstone.utils.ElementTree.SubElement function in hearthstone

To help you get started, we’ve selected a few hearthstone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
for tag, value in sorted(self.referenced_tags.items()):
			e = _make_tag_element(ret, "ReferencedTag", tag, value)

		for entourage in self.entourage:
			ElementTree.SubElement(ret, "EntourageCard", cardID=entourage)

		for power in self.powers:
			ep = ElementTree.SubElement(ret, "Power", definition=power["definition"])
			reqs = power.get("requirements", {})
			for reqid, param in reqs.items():
				er = ElementTree.SubElement(ep, "PlayRequirement", reqID=str(int(reqid)))
				er.attrib["param"] = str(param or "")

		for tphi in self.triggered_power_history_info:
			e = ElementTree.SubElement(ret, "TriggeredPowerHistoryInfo")
			e.attrib["effectIndex"] = str(tphi["effectIndex"])
			e.attrib["showInHistory"] = str(tphi["showInHistory"])

		return ret
github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
def _make_tag_element(element, tagname, tag, value):
	e = ElementTree.SubElement(element, tagname, enumID=str(int(tag)))
	if not isinstance(tag, GameTag):
		try:
			tag = GameTag(tag)
			name = tag.name
			value = str(int(value))
		except ValueError:
			name = str(value)
			value = str(value)
	else:
		name = tag.name
		value = str(int(value))

	e.attrib["name"] = name
	e.attrib["type"] = "Int"
	e.attrib["value"] = value
github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
e.attrib["type"] = "String"
				e.text = value

		for tag, value in sorted(self.tags.items()):
			if value:
				e = _make_tag_element(ret, "Tag", tag, value)

				if tag == GameTag.HERO_POWER and self.hero_power:
					e.attrib["type"] = "Card"
					e.attrib["cardID"] = self.hero_power

		for tag, value in sorted(self.referenced_tags.items()):
			e = _make_tag_element(ret, "ReferencedTag", tag, value)

		for entourage in self.entourage:
			ElementTree.SubElement(ret, "EntourageCard", cardID=entourage)

		for power in self.powers:
			ep = ElementTree.SubElement(ret, "Power", definition=power["definition"])
			reqs = power.get("requirements", {})
			for reqid, param in reqs.items():
				er = ElementTree.SubElement(ep, "PlayRequirement", reqID=str(int(reqid)))
				er.attrib["param"] = str(param or "")

		for tphi in self.triggered_power_history_info:
			e = ElementTree.SubElement(ret, "TriggeredPowerHistoryInfo")
			e.attrib["effectIndex"] = str(tphi["effectIndex"])
			e.attrib["showInHistory"] = str(tphi["showInHistory"])

		return ret
github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
if tag == GameTag.HERO_POWER and self.hero_power:
					e.attrib["type"] = "Card"
					e.attrib["cardID"] = self.hero_power

		for tag, value in sorted(self.referenced_tags.items()):
			e = _make_tag_element(ret, "ReferencedTag", tag, value)

		for entourage in self.entourage:
			ElementTree.SubElement(ret, "EntourageCard", cardID=entourage)

		for power in self.powers:
			ep = ElementTree.SubElement(ret, "Power", definition=power["definition"])
			reqs = power.get("requirements", {})
			for reqid, param in reqs.items():
				er = ElementTree.SubElement(ep, "PlayRequirement", reqID=str(int(reqid)))
				er.attrib["param"] = str(param or "")

		for tphi in self.triggered_power_history_info:
			e = ElementTree.SubElement(ret, "TriggeredPowerHistoryInfo")
			e.attrib["effectIndex"] = str(tphi["effectIndex"])
			e.attrib["showInHistory"] = str(tphi["showInHistory"])

		return ret
github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
ret = ElementTree.Element("Entity", CardID=self.id, ID=str(self.dbf_id))
		if self.version:
			ret.attrib["version"] = str(self.version)

		if self.master_power:
			master_power = ElementTree.SubElement(ret, "MasterPower")
			master_power.text = self.master_power

		for tag in LOCALIZED_TAGS:
			value = self.strings[tag]
			if value:
				e = ElementTree.SubElement(ret, "Tag", enumID=str(int(tag)), name=tag.name)
				e.attrib["type"] = "LocString"
				for locale, localized_value in sorted(value.items()):
					if localized_value:
						loc_element = ElementTree.SubElement(e, locale)
						loc_element.text = str(localized_value)

		for tag in STRING_TAGS:
			value = self.strings[tag]
			if value:
				e = ElementTree.SubElement(ret, "Tag", enumID=str(int(tag)), name=tag.name)
				e.attrib["type"] = "String"
				e.text = value

		for tag, value in sorted(self.tags.items()):
			if value:
				e = _make_tag_element(ret, "Tag", tag, value)

				if tag == GameTag.HERO_POWER and self.hero_power:
					e.attrib["type"] = "Card"
					e.attrib["cardID"] = self.hero_power
github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
def to_xml(self):
		ret = ElementTree.Element("Entity", CardID=self.id, ID=str(self.dbf_id))
		if self.version:
			ret.attrib["version"] = str(self.version)

		if self.master_power:
			master_power = ElementTree.SubElement(ret, "MasterPower")
			master_power.text = self.master_power

		for tag in LOCALIZED_TAGS:
			value = self.strings[tag]
			if value:
				e = ElementTree.SubElement(ret, "Tag", enumID=str(int(tag)), name=tag.name)
				e.attrib["type"] = "LocString"
				for locale, localized_value in sorted(value.items()):
					if localized_value:
						loc_element = ElementTree.SubElement(e, locale)
						loc_element.text = str(localized_value)

		for tag in STRING_TAGS:
			value = self.strings[tag]
			if value:
				e = ElementTree.SubElement(ret, "Tag", enumID=str(int(tag)), name=tag.name)
				e.attrib["type"] = "String"
				e.text = value

		for tag, value in sorted(self.tags.items()):
			if value:
				e = _make_tag_element(ret, "Tag", tag, value)
github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
master_power.text = self.master_power

		for tag in LOCALIZED_TAGS:
			value = self.strings[tag]
			if value:
				e = ElementTree.SubElement(ret, "Tag", enumID=str(int(tag)), name=tag.name)
				e.attrib["type"] = "LocString"
				for locale, localized_value in sorted(value.items()):
					if localized_value:
						loc_element = ElementTree.SubElement(e, locale)
						loc_element.text = str(localized_value)

		for tag in STRING_TAGS:
			value = self.strings[tag]
			if value:
				e = ElementTree.SubElement(ret, "Tag", enumID=str(int(tag)), name=tag.name)
				e.attrib["type"] = "String"
				e.text = value

		for tag, value in sorted(self.tags.items()):
			if value:
				e = _make_tag_element(ret, "Tag", tag, value)

				if tag == GameTag.HERO_POWER and self.hero_power:
					e.attrib["type"] = "Card"
					e.attrib["cardID"] = self.hero_power

		for tag, value in sorted(self.referenced_tags.items()):
			e = _make_tag_element(ret, "ReferencedTag", tag, value)

		for entourage in self.entourage:
			ElementTree.SubElement(ret, "EntourageCard", cardID=entourage)
github HearthSim / python-hearthstone / hearthstone / cardxml.py View on Github external
for tag, value in sorted(self.tags.items()):
			if value:
				e = _make_tag_element(ret, "Tag", tag, value)

				if tag == GameTag.HERO_POWER and self.hero_power:
					e.attrib["type"] = "Card"
					e.attrib["cardID"] = self.hero_power

		for tag, value in sorted(self.referenced_tags.items()):
			e = _make_tag_element(ret, "ReferencedTag", tag, value)

		for entourage in self.entourage:
			ElementTree.SubElement(ret, "EntourageCard", cardID=entourage)

		for power in self.powers:
			ep = ElementTree.SubElement(ret, "Power", definition=power["definition"])
			reqs = power.get("requirements", {})
			for reqid, param in reqs.items():
				er = ElementTree.SubElement(ep, "PlayRequirement", reqID=str(int(reqid)))
				er.attrib["param"] = str(param or "")

		for tphi in self.triggered_power_history_info:
			e = ElementTree.SubElement(ret, "TriggeredPowerHistoryInfo")
			e.attrib["effectIndex"] = str(tphi["effectIndex"])
			e.attrib["showInHistory"] = str(tphi["showInHistory"])

		return ret