d
This commit is contained in:
6
v2/entities.py
Normal file
6
v2/entities.py
Normal file
@@ -0,0 +1,6 @@
|
||||
class MemoryContext:
|
||||
playfieldSize = 0
|
||||
playfieldItems = {}
|
||||
|
||||
def memory_createEmptyContext():
|
||||
return MemoryContext()
|
||||
40
v2/functions.py
Normal file
40
v2/functions.py
Normal file
@@ -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"
|
||||
#}
|
||||
4
v2/main.py
Normal file
4
v2/main.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from entities import *
|
||||
from functions import *
|
||||
|
||||
print(test_memory_generateConstPlayfield())
|
||||
Reference in New Issue
Block a user