Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xml.etree.cElementTree as ET
- class XMLSituation:
- def __init__(self):
- XMLSituation.root = ET.Element("historia")
- XMLSituation.history = ET.SubElement(XMLSituation.root, "pojedyncza_historia")
- XMLSituation.gameover = 0
- x = 1
- y = 1
- while XMLSituation.gameover < 15:
- XMLSituation.gimiStep(str('x: ' + str(x) + ", y:" + str(y)), str('x: ' + str(x + 1) + ", y:" + str(y + 1)),
- str('x: ' + str(x + 2) + ", y:" + str(y + 2)), str('x: ' + str(x + 3) + ", y:" + str(y + 3)),
- XMLSituation.gameover)
- x += 1
- y += 1
- XMLSituation.gameover += 1
- tree = ET.ElementTree(XMLSituation.root)
- tree.write("history.xml")
- def gimiStep(playerPositions1, playerPositions2, playerPositions3, playerPositions4, stepCounter):
- step = ET.SubElement(XMLSituation.history, "step", name=str(stepCounter))
- playerStep1 = ET.SubElement(step, "stepPlayer1")
- playerStep2 = ET.SubElement(step, "stepPlayer2")
- playerStep3 = ET.SubElement(step, "stepPlayer3")
- playerStep4 = ET.SubElement(step, "stepPlayer4")
- playerStep1.text = str(playerPositions1)
- playerStep2.text = str(playerPositions2)
- playerStep3.text = str(playerPositions3)
- playerStep4.text = str(playerPositions4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement