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.

40 lines
832B

  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. if (
  24. fieldName == "MemoryContext.playfieldItems" and
  25. len(c.playfieldItems) == 4 and
  26. c.playfieldItems[0] == 0 and
  27. c.playfieldItems[1] == 0 and
  28. c.playfieldItems[2] == 1 and
  29. c.playfieldItems[3] == 1
  30. ):
  31. return "OK: memory_generateConstPlayfield"
  32. #}
  33. return "ERR: memory_generateConstPlayfield"
  34. #}