From 374b21d68e16643d43b3d61356e85904a49689c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Thu, 11 Apr 2024 16:19:02 +0300 Subject: [PATCH] d --- v2/entities.py | 6 ++++++ v2/functions.py | 40 ++++++++++++++++++++++++++++++++++++++++ v2/main.py | 4 ++++ 3 files changed, 50 insertions(+) create mode 100644 v2/entities.py create mode 100644 v2/functions.py create mode 100644 v2/main.py diff --git a/v2/entities.py b/v2/entities.py new file mode 100644 index 0000000..f23babe --- /dev/null +++ b/v2/entities.py @@ -0,0 +1,6 @@ +class MemoryContext: + playfieldSize = 0 + playfieldItems = {} + +def memory_createEmptyContext(): + return MemoryContext() diff --git a/v2/functions.py b/v2/functions.py new file mode 100644 index 0000000..abcba66 --- /dev/null +++ b/v2/functions.py @@ -0,0 +1,40 @@ +from entities import * + + +# L4: Function. + +def memory_generateConstPlayfield( + c: MemoryContext +) -> str: + idGroups: dict[int, int] = { } + id = 0 + for gid in range(0, c.playfieldSize): + idGroups[id] = gid + id += 1 + idGroups[id] = gid + id += 1 + #} + c.playfieldItems = idGroups + return "MemoryContext.playfieldItems" +#} + +# L20: Test. + +def test_memory_generateConstPlayfield( +) -> str: + c = memory_createEmptyContext() + c.playfieldSize = 2 + fieldName = memory_generateConstPlayfield(c) + idGroups = c.playfieldItems + if ( + fieldName == "MemoryContext.playfieldItems" and + len(idGroups) == 4 and + idGroups[0] == 0 and + idGroups[1] == 0 and + idGroups[2] == 1 and + idGroups[3] == 1 + ): + return "OK: memory_generateConstPlayfield" + #} + return "ERR: memory_generateConstPlayfield" +#} diff --git a/v2/main.py b/v2/main.py new file mode 100644 index 0000000..01ff942 --- /dev/null +++ b/v2/main.py @@ -0,0 +1,4 @@ +from entities import * +from functions import * + +print(test_memory_generateConstPlayfield())