|
@@ -1,8 +1,5 @@ |
|
|
from entities import * |
|
|
from entities import * |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# L4: Function. |
|
|
|
|
|
|
|
|
|
|
|
def memory_generateConstPlayfield( |
|
|
def memory_generateConstPlayfield( |
|
|
c: MemoryContext |
|
|
c: MemoryContext |
|
|
) -> str: |
|
|
) -> str: |
|
@@ -15,10 +12,18 @@ def memory_generateConstPlayfield( |
|
|
id += 1 |
|
|
id += 1 |
|
|
#} |
|
|
#} |
|
|
c.playfieldItems = idGroups |
|
|
c.playfieldItems = idGroups |
|
|
return "MemoryContext.playfieldItems" |
|
|
|
|
|
|
|
|
return "playfieldItems" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
# L20: Test. |
|
|
|
|
|
|
|
|
def memory_selectItem( |
|
|
|
|
|
c: MemoryContext, |
|
|
|
|
|
id: int |
|
|
|
|
|
) -> str: |
|
|
|
|
|
c.selectedItems.append(id) |
|
|
|
|
|
return "selectedItems" |
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
# Test. |
|
|
|
|
|
|
|
|
def test_memory_generateConstPlayfield( |
|
|
def test_memory_generateConstPlayfield( |
|
|
) -> str: |
|
|
) -> str: |
|
@@ -26,7 +31,7 @@ def test_memory_generateConstPlayfield( |
|
|
c.playfieldSize = 2 |
|
|
c.playfieldSize = 2 |
|
|
fieldName = memory_generateConstPlayfield(c) |
|
|
fieldName = memory_generateConstPlayfield(c) |
|
|
if ( |
|
|
if ( |
|
|
fieldName == "MemoryContext.playfieldItems" and |
|
|
|
|
|
|
|
|
fieldName == "playfieldItems" and |
|
|
len(c.playfieldItems) == 4 and |
|
|
len(c.playfieldItems) == 4 and |
|
|
c.playfieldItems[0] == 0 and |
|
|
c.playfieldItems[0] == 0 and |
|
|
c.playfieldItems[1] == 0 and |
|
|
c.playfieldItems[1] == 0 and |
|
@@ -37,3 +42,22 @@ def test_memory_generateConstPlayfield( |
|
|
#} |
|
|
#} |
|
|
return "ERR: memory_generateConstPlayfield" |
|
|
return "ERR: memory_generateConstPlayfield" |
|
|
#} |
|
|
#} |
|
|
|
|
|
|
|
|
|
|
|
def test_memory_selectItem( |
|
|
|
|
|
) -> str: |
|
|
|
|
|
c = memory_createEmptyContext() |
|
|
|
|
|
c.playfieldSize = 2 |
|
|
|
|
|
memory_generateConstPlayfield(c) |
|
|
|
|
|
# Select the item with group 0. |
|
|
|
|
|
fieldName = memory_selectItem(c, 0) |
|
|
|
|
|
|
|
|
|
|
|
# See if it's in selectedItems now. |
|
|
|
|
|
if ( |
|
|
|
|
|
fieldName == "selectedItems" and |
|
|
|
|
|
len(c.selectedItems) == 1 and |
|
|
|
|
|
c.selectedItems[0] == 0 |
|
|
|
|
|
): |
|
|
|
|
|
return "OK: memory_selectItem" |
|
|
|
|
|
#} |
|
|
|
|
|
return "ERR: memory_selectItem" |
|
|
|
|
|
#} |