Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. import xml.etree.cElementTree as ET
  2.  
  3. class XMLSituation:
  4.  
  5. def __init__(self):
  6. XMLSituation.root = ET.Element("historia")
  7. XMLSituation.history = ET.SubElement(XMLSituation.root, "pojedyncza_historia")
  8. XMLSituation.gameover = 0
  9.  
  10. x = 1
  11. y = 1
  12. while XMLSituation.gameover < 15:
  13. XMLSituation.gimiStep(str('x: ' + str(x) + ", y:" + str(y)), str('x: ' + str(x + 1) + ", y:" + str(y + 1)),
  14. str('x: ' + str(x + 2) + ", y:" + str(y + 2)), str('x: ' + str(x + 3) + ", y:" + str(y + 3)),
  15. XMLSituation.gameover)
  16.  
  17. x += 1
  18. y += 1
  19. XMLSituation.gameover += 1
  20.  
  21. tree = ET.ElementTree(XMLSituation.root)
  22. tree.write("history.xml")
  23.  
  24. def gimiStep(playerPositions1, playerPositions2, playerPositions3, playerPositions4, stepCounter):
  25.  
  26. step = ET.SubElement(XMLSituation.history, "step", name=str(stepCounter))
  27.  
  28. playerStep1 = ET.SubElement(step, "stepPlayer1")
  29. playerStep2 = ET.SubElement(step, "stepPlayer2")
  30. playerStep3 = ET.SubElement(step, "stepPlayer3")
  31. playerStep4 = ET.SubElement(step, "stepPlayer4")
  32.  
  33. playerStep1.text = str(playerPositions1)
  34. playerStep2.text = str(playerPositions2)
  35. playerStep3.text = str(playerPositions3)
  36. playerStep4.text = str(playerPositions4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement