Prepare Capital Quest public edition and player manual
This commit is contained in:
1 parent
46f4b9cae0
commit
afa6f3c2a0
40 files changed
+1072
-106
No files matched your search
@@ -2,9 +2,10 @@ import os
|
||||
from pathlib import Path
|
||||
import sys,runpy,json,re
|
||||
sys.path.insert(0,str(Path(__file__).parent));from framebuffer import Screen,ROOT,shuffle,EVIDENCE
|
||||
from map_colors import check_map_colors
|
||||
c=runpy.run_path(str(Path(__file__).with_name('playtest_support.py')));run=json.load(open(os.environ['CAPITAL_TEST_STATE']))['run']['run_id']
|
||||
rows=[x.split('\t') for x in (ROOT/'data/states.tsv').read_text().splitlines()]
|
||||
order,_=shuffle();evidence=[];score=0;pos=[0]*4
|
||||
order,_=shuffle();evidence=[];score=0;pos=[0]*4;outcomes={};previous_correctpos=None
|
||||
c['key'](run,'1',8,600)
|
||||
for q,state in enumerate(order):
|
||||
name=f'mc-q{q+1:02d}-{rows[state][0]}'
|
||||
@@ -12,15 +13,19 @@ for q,state in enumerate(order):
|
||||
heading=scr.text(8,19,45);prompt=scr.text(8,145,50)
|
||||
assert heading==f'Question {q+1} of 50 Score {score}',(q,heading,score)
|
||||
assert prompt==f'{rows[state][1]}: what is its capital?',(q,prompt,rows[state])
|
||||
check_map_colors(scr,state,outcomes)
|
||||
opts=[scr.text(8+(i%2)*156,157+(i//2)*12,25)[2:] for i in range(4)]
|
||||
assert len(set(opts))==4 and rows[state][2] in opts,(q,opts)
|
||||
correctpos=opts.index(rows[state][2]);pos[correctpos]+=1
|
||||
assert correctpos!=previous_correctpos,(q,correctpos,previous_correctpos)
|
||||
previous_correctpos=correctpos
|
||||
# Confirm selected state's actual framebuffer mask has the expected gold fill.
|
||||
src=(ROOT/'src/map_data.c').read_text();d=list(map(int,re.search(r'national_spans\[\] = \{\s*([\d,\s]+)',src)[1].replace('\n','').split(',')));off=list(map(int,re.search(r'national_offsets\[51\] = \{([\d,]+)',src)[1].split(',')))
|
||||
points=[(6+x,33+y) for k in range(off[state],off[state+1],3) for y,x0,n in [d[k:k+3]] for x in range(x0,x0+n)]
|
||||
gold=sum(scr.guest(x,y)==(255,255,0) for x,y in points)
|
||||
assert gold>=len(points)*.8,(q,rows[state][0],gold,len(points))
|
||||
right=q%7!=0;selection=correctpos if right else (correctpos+1)%4
|
||||
outcomes[state]=right
|
||||
if right:score+=1
|
||||
# Read the feedback as soon as it appears, before its automatic timeout.
|
||||
held=[str(selection+1)] if q==0 else []
|
||||
@@ -58,7 +63,9 @@ for page in range(3):
|
||||
cap=next(x[2] for x in rows if x[0]==m['code'])
|
||||
assert s.text(8,61+i*43,48)==f'Capital: {cap}'
|
||||
if page<2:c['key'](run,'n',8,500)
|
||||
c['key'](run,'b',8,500);c['key'](run,'p',8,500);c['capture'](run,'replay-title');c['key'](run,'q',8,200);final=c['capture'](run,'mc-exit')
|
||||
c['key'](run,'b',8,500);c['key'](run,'p',8,500);c['capture'](run,'replay-title')
|
||||
check_map_colors(Screen(str(EVIDENCE)+'/replay-title.png'),None,outcomes)
|
||||
c['key'](run,'q',8,200);final=c['capture'](run,'mc-exit')
|
||||
assert 'screen_text' in final or final.get('screen_text_unavailable') is None,final
|
||||
json.dump(dict(score=score,positions=pos,questions=evidence,run_id=run,artifact=result['artifact_id'],exit=final),open(str(EVIDENCE)+'/mc-report.json','w'),indent=2)
|
||||
print('PASS complete multiple-choice quiz, all 50 masks, automatic feedback advance without Space, held-key protection, 42/50, review, replay, exit.',flush=True)
|
||||
|
||||
Reference in new issue
Block a user