Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 line
822B

  1. from entities import *
  2. # L4: Function.
  3. def memory_generateConstPlayfield(
  4. c: MemoryContext
  5. ) -> str:
  6. idGroups: dict[int, int] = { }
  7. id = 0
  8. for gid in range(0, c.playfieldSize):
  9. idGroups[id] = gid
  10. id += 1
  11. idGroups[id] = gid
  12. id += 1
  13. #}
  14. c.playfieldItems = idGroups
  15. return "MemoryContext.playfieldItems"
  16. #}
  17. # L20: Test.
  18. def test_memory_generateConstPlayfield(
  19. ) -> str:
  20. c = memory_createEmptyContext()
  21. c.playfieldSize = 2
  22. fieldName = memory_generateConstPlayfield(c)
  23. idGroups = c.playfieldItems
  24. if (
  25. fieldName == "MemoryContext.playfieldItems" and
  26. len(idGroups) == 4 and
  27. idGroups[0] == 0 and
  28. idGroups[1] == 0 and
  29. idGroups[2] == 1 and
  30. idGroups[3] == 1
  31. ):
  32. return "OK: memory_generateConstPlayfield"
  33. #}
  34. return "ERR: memory_generateConstPlayfield"
  35. #}