@tora-editor/tora 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -58
- package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
- package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
- package/assets/kenney-food-starter/License.txt +28 -0
- package/assets/kenney-food-starter/burger.glb +0 -0
- package/assets/kenney-food-starter/frying-pan.glb +0 -0
- package/assets/kenney-food-starter/plan.json +61 -0
- package/assets/kenney-food-starter/plate.glb +0 -0
- package/assets/kenney-food-starter/pot.glb +0 -0
- package/assets/kenney-harvest/audio/victory.wav +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
- package/bin/tora.mjs +322 -28
- package/crates/packer/trusted/native-3d-meta.json +4 -3
- package/crates/packer/trusted/native-3d.js +181 -181
- package/crates/packer/trusted/native-meta.json +3 -3
- package/crates/packer/trusted/native.js +5 -5
- package/crates/packer/trusted/release-manifest.json +17 -17
- package/crates/packer/trusted/review-runtime-meta.json +4 -3
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/MIGRATION_0_3.md +39 -0
- package/docs/NATIVE_AGENT_TOOLS.md +12 -363
- package/docs/TORA_AGENT_SETUP.md +24 -95
- package/docs/TORA_CREATION_API.md +63 -348
- package/docs/reference/CORE_AUTHORING.md +10 -3
- package/docs/reference/PLAYABLE_STARTERS.md +20 -0
- package/docs/reference/packs/3d.md +11 -3
- package/network-rules/mintegral-appgrowth-single-html.json +10 -10
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +372 -9
- package/scripts/lean/editor/entry.js +11 -6
- package/scripts/lean/editor/project-launcher.js +116 -0
- package/scripts/lean/editor/quick-edit-panel.js +479 -0
- package/scripts/lean/editor/review-editor.css +256 -68
- package/scripts/lean/editor/review-editor.js +1834 -1086
- package/scripts/lean/editor-state.mjs +6 -0
- package/scripts/lean/editor.mjs +6 -3
- package/scripts/lean/matrix.mjs +5 -0
- package/scripts/lean/native/agent-tools.mjs +39 -62
- package/scripts/lean/native/api.mjs +161 -136
- package/scripts/lean/native/asset-catalog.mjs +7 -6
- package/scripts/lean/native/asset-lineage.mjs +54 -0
- package/scripts/lean/native/asset-prep.mjs +173 -40
- package/scripts/lean/native/assets.mjs +107 -11
- package/scripts/lean/native/audio-assets.mjs +30 -0
- package/scripts/lean/native/browser-pool.mjs +34 -0
- package/scripts/lean/native/build-cache.mjs +38 -7
- package/scripts/lean/native/cc0-inputs.mjs +24 -0
- package/scripts/lean/native/cc0-staging.mjs +28 -8
- package/scripts/lean/native/compiler.mjs +9 -3
- package/scripts/lean/native/contracts.mjs +16 -11
- package/scripts/lean/native/creative-qa.mjs +365 -128
- package/scripts/lean/native/demos.mjs +53 -18
- package/scripts/lean/native/document.mjs +50 -12
- package/scripts/lean/native/export-budget.mjs +75 -0
- package/scripts/lean/native/local-bundle.mjs +7 -3
- package/scripts/lean/native/mcp-server.mjs +42 -74
- package/scripts/lean/native/media-validate.mjs +124 -0
- package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
- package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
- package/scripts/lean/native/modules/star-salvage.mjs +3 -368
- package/scripts/lean/native/native-bin.mjs +3 -3
- package/scripts/lean/native/outcome-playthrough.mjs +97 -0
- package/scripts/lean/native/project-bundle.mjs +6 -5
- package/scripts/lean/native/project-index.mjs +0 -2
- package/scripts/lean/native/qa-adapters.mjs +10 -0
- package/scripts/lean/native/quick-edit.mjs +328 -0
- package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
- package/scripts/lean/native/review.mjs +205 -571
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +7 -5
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +378 -79
- package/scripts/lean/native/starters.mjs +563 -0
- package/scripts/lean/native/variant-adapters.mjs +8 -0
- package/scripts/lean/native/variants-core.mjs +186 -0
- package/scripts/lean/native/variants.mjs +63 -0
- package/scripts/lean/native/win-cues.mjs +96 -0
- package/skills/tora-playables/SKILL.md +1 -1
- package/scripts/lean/editor/review-intake.js +0 -837
- package/scripts/lean/model-client.mjs +0 -119
- package/scripts/lean/native/author-expansion-proofs.mjs +0 -240
- package/scripts/lean/native/author-games.mjs +0 -160
- package/scripts/lean/native/author-harvest.mjs +0 -74
- package/scripts/lean/native/author-primitive-proofs.mjs +0 -874
- package/scripts/lean/native/author-salvage.mjs +0 -71
- package/scripts/lean/native/chat-compose.mjs +0 -287
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -191
- package/scripts/lean/native/check-salvage.mjs +0 -197
- package/scripts/lean/native/compatibility.mjs +0 -34
- package/scripts/lean/native/concept.mjs +0 -633
- package/scripts/lean/native/draw-stroke.mjs +0 -26
- package/scripts/lean/native/erase-mask.mjs +0 -18
- package/scripts/lean/native/harvest-recipe.mjs +0 -21
- package/scripts/lean/native/instance-steering.mjs +0 -24
- package/scripts/lean/native/intake-creator-agent.mjs +0 -98
- package/scripts/lean/native/intake-creator-tools.mjs +0 -165
- package/scripts/lean/native/interaction-gestures.mjs +0 -45
- package/scripts/lean/native/match-board.mjs +0 -138
- package/scripts/lean/native/modules/index.mjs +0 -54
- package/scripts/lean/native/modules/tap-collect.mjs +0 -54
- package/scripts/lean/native/path-network.mjs +0 -132
- package/scripts/lean/native/physics-2d.mjs +0 -154
- package/scripts/lean/native/physics-3d.mjs +0 -259
- package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
- package/scripts/lean/native/prepare-game-audio.mjs +0 -372
- package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
- package/scripts/lean/native/prepare-golf-assets.py +0 -211
- package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
- package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
- package/scripts/lean/native/prepare-primitive-images.py +0 -25
- package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
- package/scripts/lean/native/prepare-traffic-assets.py +0 -329
- package/scripts/lean/native/presentation.mjs +0 -335
- package/scripts/lean/native/review-agent-tools.mjs +0 -561
- package/scripts/lean/native/review-connection.mjs +0 -303
- package/scripts/lean/native/review-fields.mjs +0 -24
- package/scripts/lean/native/review-intake.mjs +0 -385
- package/scripts/lean/native/review-intents.mjs +0 -217
- package/scripts/lean/native/review-provider.mjs +0 -580
- package/scripts/lean/native/review-receipts.mjs +0 -76
- package/scripts/lean/native/review-resolver.mjs +0 -429
- package/scripts/lean/native/review-targets.mjs +0 -35
- package/scripts/lean/native/runtime.mjs +0 -1623
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -818
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
|
@@ -1,255 +1,3 @@
|
|
|
1
|
-
import {isDeepStrictEqual} from 'node:util';
|
|
2
|
-
import {component} from '../document.mjs';
|
|
3
|
-
import {assertValue,fieldLimits,layout,record,standardText} from '../review-fields.mjs';
|
|
4
|
-
import {isAudioMime} from '../media-validate.mjs';
|
|
5
|
-
|
|
6
|
-
const moments=[
|
|
7
|
-
{id:'opening',label:'Opening'},
|
|
8
|
-
{id:'first-harvest',label:'First harvest'},
|
|
9
|
-
{id:'end-card',label:'End card'},
|
|
10
|
-
{id:'timeout',label:'Timeout'},
|
|
11
|
-
];
|
|
12
|
-
const targetDefinitions=[
|
|
13
|
-
{id:'opening',label:'Opening instruction',moment:'opening',componentIds:['harvest.instruction'],
|
|
14
|
-
fields:[['instruction','Instruction'],['hint-delay','Time before opening hint (s)']]},
|
|
15
|
-
{id:'first-harvest',label:'First orchard restoration',moment:'first-harvest',componentIds:['harvest.world.stage.1','harvest.instruction'],
|
|
16
|
-
fields:[['reveal-duration','Reveal duration (s)'],['message','Reward message']]},
|
|
17
|
-
{id:'cta',label:'Install button',moment:'end-card',componentIds:['harvest.cta'],
|
|
18
|
-
fields:[['text','Button wording'],['payoff-hold','Time to enjoy the farm before showing the button (s)']]},
|
|
19
|
-
{id:'ending',label:'Final payoff',moment:'end-card',componentIds:['harvest.reward.title','harvest.reward.detail'],
|
|
20
|
-
fields:[['payoff-hold','Hold before install button (s)']]},
|
|
21
|
-
];
|
|
22
|
-
const message=binding=>binding?.actions.find(action=>action.kind==='set'&&action.variableId==='harvest.message');
|
|
23
|
-
const payoff=binding=>binding?.condition?.all?.find(part=>part.variableId==='harvest.payoff'&&part.op==='gte');
|
|
24
|
-
const timeoutCaptionId='harvest.timeout.caption';
|
|
25
|
-
const timeoutLayoutId='harvest.timeout.layout';
|
|
26
|
-
const timeoutBindingId='harvest.timeout.caption.show';
|
|
27
|
-
const endingCues={match:'short clear confirmation cue',repair:'short restoration cue',complete:'current completion cue'};
|
|
28
|
-
const openingHint=condition=>condition?.any?.[0]?.all?.find(part=>part.variableId==='harvest.idle')??condition;
|
|
29
|
-
|
|
30
|
-
function condition(binding,variableId,op,value){
|
|
31
|
-
const parts=[binding.condition,...binding.condition?.all??[],...binding.condition?.any??[]].filter(Boolean);
|
|
32
|
-
return parts.some(part=>part.variableId===variableId&&part.op===op&&part.value===value)||
|
|
33
|
-
binding.condition?.all?.some(group=>group.all?.some(part=>part.variableId===variableId&&part.op===op&&part.value===value));
|
|
34
|
-
}
|
|
35
|
-
function setsPhase(binding,value){
|
|
36
|
-
return binding?.actions.some(action=>action.kind==='set'&&action.variableId==='harvest.phase'&&action.value===value);
|
|
37
|
-
}
|
|
38
|
-
function audioCue(index,binding){
|
|
39
|
-
const actions=binding?.actions.filter(action=>action.kind==='playAudio')??[];
|
|
40
|
-
if(actions.length!==1)return {unresolved:actions.length?'multiple-cues':'missing-cue'};
|
|
41
|
-
const behavior=index.behavior(actions[0].behaviorId),component=behavior&&index.component(behavior.componentId);
|
|
42
|
-
const assetId=component?.assetSlots[0]?.assetId,asset=assetId&&index.asset(assetId);
|
|
43
|
-
if(behavior?.kind!=='audio'||!component||!isAudioMime(asset?.mime))return {unresolved:'invalid-cue'};
|
|
44
|
-
return {behaviorId:behavior.id,componentId:component.id,assetId,assetHash:asset.hash};
|
|
45
|
-
}
|
|
46
|
-
function outcome(index,{bindingId,eventKind,eventReference,phase}){
|
|
47
|
-
const binding=index.binding(bindingId),event=binding&&index.event(binding.eventId);
|
|
48
|
-
if(!binding||event?.kind!==eventKind||event[eventReference.key]!==eventReference.value||!setsPhase(binding,phase))return {unresolved:'invalid-binding'};
|
|
49
|
-
const duplicate=index.bindingsForEvent(event.id).filter(other=>other.id!==binding.id&&
|
|
50
|
-
isDeepStrictEqual(other.condition,binding.condition)&&setsPhase(other,phase));
|
|
51
|
-
if(duplicate.length)return {unresolved:'ambiguous-binding'};
|
|
52
|
-
return {bindingId,eventId:event.id,cue:audioCue(index,binding)};
|
|
53
|
-
}
|
|
54
|
-
export function resolveHarvestRoles(index){
|
|
55
|
-
const unresolved=[];
|
|
56
|
-
const board=index.behavior('harvest.rules');
|
|
57
|
-
if(board?.kind!=='match-board'||board.componentId!=='harvest.board')return {status:'unsupported',module:null,unresolved:['module']};
|
|
58
|
-
const win=outcome(index,{bindingId:'harvest.restore.3',eventKind:'variableChange',eventReference:{key:'variableId',value:'harvest.moves'},phase:'payoff'});
|
|
59
|
-
if(!condition(index.binding('harvest.restore.3')??{},'harvest.moves','eq',3))win.unresolved??='invalid-condition';
|
|
60
|
-
const loss=outcome(index,{bindingId:'harvest.deadline.cta',eventKind:'timer',eventReference:{key:'behaviorId',value:'harvest.deadline'},phase:'cta'});
|
|
61
|
-
const cta=index.component('harvest.cta'),ctaLabel=index.component('harvest.cta.label'),ctaBinding=index.binding('harvest.cta.click');
|
|
62
|
-
const ctaEvent=ctaBinding&&index.event(ctaBinding.eventId);
|
|
63
|
-
const primaryCta=cta?.contract==='native.button.v1'&&ctaLabel?.parentId===cta.id&&ctaLabel.contract==='native.text.v1'&&
|
|
64
|
-
ctaEvent?.kind==='click'&&ctaEvent.componentId===cta.id&&ctaBinding.actions.some(action=>action.kind==='store')
|
|
65
|
-
?{componentId:cta.id,labelId:ctaLabel.id,bindingId:ctaBinding.id}:{unresolved:'invalid-cta'};
|
|
66
|
-
const panel=index.component('harvest.board.lock');
|
|
67
|
-
const outcomePanel=panel?{componentId:panel.id}:{unresolved:'missing-panel'};
|
|
68
|
-
const roles={winEvent:win,timeoutEvent:loss,primaryCta,outcomePanel,rewardCue:win.cue??{unresolved:win.unresolved??'invalid-cue'}};
|
|
69
|
-
for(const [role,value] of Object.entries(roles))if(value.unresolved)unresolved.push(role+':'+value.unresolved);
|
|
70
|
-
if(index.component(timeoutCaptionId))roles.timeoutCaption={componentId:timeoutCaptionId};
|
|
71
|
-
if(win.bindingId&&win.bindingId===loss.bindingId)unresolved.push('outcomes:shared-binding');
|
|
72
|
-
return {status:unresolved.length?'unresolved':'resolved',module:'harvest-restore',version:1,roles,unresolved};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function endingFields(project,resolution){
|
|
76
|
-
const puzzle=layout(project,'harvest.puzzle.layout');
|
|
77
|
-
const panel=record(project,'components','harvest.board.lock');
|
|
78
|
-
const cta=record(project,'components','harvest.cta');
|
|
79
|
-
const winAudio=record(project,'components',resolution.roles?.rewardCue?.componentId);
|
|
80
|
-
if(!puzzle||!panel||!cta||!layout(project,'harvest.cta.layout')||!layout(project,'harvest.instruction.layout')||!record(project,'eventBindings','harvest.cta.show'))return [];
|
|
81
|
-
const descriptions={};
|
|
82
|
-
for(const [role,description] of Object.entries(endingCues)){
|
|
83
|
-
const assetId=record(project,'components','harvest.audio.'+role)?.assetSlots[0]?.assetId;
|
|
84
|
-
if(assetId&&project.assets.some(asset=>asset.id===assetId&&isAudioMime(asset.mime)))descriptions[assetId]=description;
|
|
85
|
-
}
|
|
86
|
-
const windowWidth=Math.max(project.base.width,project.base.height);
|
|
87
|
-
const rightEdge=puzzle.parameters.x+puzzle.parameters.scaleX*(panel.transform[4]+panel.parameters.width);
|
|
88
|
-
return [
|
|
89
|
-
{id:'landscape-inset',label:'Right margin around the landscape end card (px)',value:windowWidth-rightEdge,...fieldLimits['landscape-inset'],viewportWidth:windowWidth,panelRight:rightEdge},
|
|
90
|
-
{id:'timeout-caption',label:'Centered text on the timeout end card',value:record(project,'components',timeoutCaptionId)?.parameters?.text??'',...standardText},
|
|
91
|
-
...(winAudio?[{id:'win-cue',label:'Sound played when the last harvest completes',value:winAudio.assetSlots[0]?.assetId,
|
|
92
|
-
choices:Object.keys(descriptions),descriptions}]:[]),
|
|
93
|
-
];
|
|
94
|
-
}
|
|
95
|
-
function values(project){
|
|
96
|
-
const binding=id=>record(project,'eventBindings',id);
|
|
97
|
-
return {
|
|
98
|
-
instruction:record(project,'variables','harvest.message')?.initial,
|
|
99
|
-
'hint-delay':openingHint(binding('harvest.hint.show')?.condition)?.value,
|
|
100
|
-
'reveal-duration':record(project,'gameplay','harvest.world.stage.1.reveal')?.parameters.seconds,
|
|
101
|
-
message:message(binding('harvest.restore.1'))?.value,
|
|
102
|
-
text:record(project,'components','harvest.cta.label')?.parameters.text,
|
|
103
|
-
'payoff-hold':payoff(binding('harvest.payoff.finish'))?.value,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function sharedCropTargets(project){
|
|
107
|
-
const crops=new Map();
|
|
108
|
-
for(const behavior of project.gameplay){
|
|
109
|
-
if(behavior.kind!=='match-tile')continue;
|
|
110
|
-
const component=record(project,'components',behavior.componentId);
|
|
111
|
-
if(component?.parentId!=='harvest.board')continue;
|
|
112
|
-
const artwork=project.components.find(item=>item.parentId===component.id&&item.contract==='native.image.v1');
|
|
113
|
-
if(!artwork?.assetSlots[0])continue;
|
|
114
|
-
const group=behavior.parameters.group;
|
|
115
|
-
const crop=crops.get(group)??{cells:[],assets:new Set()};
|
|
116
|
-
crop.cells.push(component.id);crop.assets.add(artwork.assetSlots[0].assetId);crops.set(group,crop);
|
|
117
|
-
}
|
|
118
|
-
const usedForOtherCrops=new Set([...crops.values()].flatMap(crop=>[...crop.assets]));
|
|
119
|
-
return [...crops].flatMap(([group,crop])=>{
|
|
120
|
-
if(crop.assets.size!==1)return [];
|
|
121
|
-
const [assetId]=crop.assets;
|
|
122
|
-
if([...crops.values()].filter(item=>item.assets.has(assetId)).length!==1)return [];
|
|
123
|
-
const uses=project.components.filter(item=>item.assetSlots.some(slot=>slot.assetId===assetId));
|
|
124
|
-
if(uses.some(item=>item.assetSlots.length!==1||item.assetSlots[0].slotId!=='source'))return [];
|
|
125
|
-
const imageChoices=project.assets.filter(asset=>asset.mime.startsWith('image/')&&!usedForOtherCrops.has(asset.id)).map(asset=>asset.id);
|
|
126
|
-
if(!imageChoices.length)return [];
|
|
127
|
-
return [{id:'crop-'+group,label:group[0].toUpperCase()+group.slice(1)+' artwork',cropGroup:group,moment:'opening',
|
|
128
|
-
componentIds:crop.cells,uses:uses.map(item=>item.id),imageChoices,
|
|
129
|
-
fields:[{id:'shared-art',label:'Replace all '+uses.length+' uses of this source asset',confirm:true,value:assetId}]}];
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function reviewTargets(project,resolution){
|
|
133
|
-
const current=values(project);
|
|
134
|
-
if(!record(project,'gameplay','harvest.rules')||!message(record(project,'eventBindings','harvest.music.start'))||
|
|
135
|
-
Object.values(current).some(value=>value===undefined)||targetDefinitions.some(target=>target.componentIds.some(id=>!record(project,'components',id))))
|
|
136
|
-
return {module:'harvest-restore',moments:[],targets:[]};
|
|
137
|
-
const targets=targetDefinitions.map(target=>({...target,fields:target.fields.map(([id,label])=>({id,label,value:current[id],...fieldLimits[id]}))}));
|
|
138
|
-
const ending=endingFields(project,resolution);
|
|
139
|
-
targets.find(target=>target.id==='ending').fields.push(...ending);
|
|
140
|
-
if(ending.length)targets.push({id:'timeout-card',label:'Timeout end card',moment:'timeout',
|
|
141
|
-
componentIds:['harvest.board.lock',timeoutCaptionId],fields:[
|
|
142
|
-
...ending.filter(field=>field.id!=='win-cue'),
|
|
143
|
-
...(record(project,'components',timeoutCaptionId)?[{id:'caption-alignment',label:'Caption alignment within the panel',choices:['center']}]:[]),
|
|
144
|
-
]});
|
|
145
|
-
return {module:'harvest-restore',moments,targets:[...targets,...sharedCropTargets(project)],
|
|
146
|
-
momentRules:{phaseVariable:'harvest.phase',progressVariable:'harvest.moves',goal:3,progressMoment:'first-harvest'},
|
|
147
|
-
picker:{cropGroups:true}};
|
|
148
|
-
}
|
|
149
|
-
function reviewOperations(project,targetId,fields,changes,baseline,resolution){
|
|
150
|
-
if(!changes||typeof changes!=='object'||Array.isArray(changes))throw Error('E_REVIEW_ARGUMENT');
|
|
151
|
-
const keys=Object.keys(changes);
|
|
152
|
-
if(!keys.length||keys.some(key=>!fields.includes(key)))throw Error('E_REVIEW_SCOPE');
|
|
153
|
-
const operations=[],expected=globalThis.structuredClone(project);
|
|
154
|
-
function update(collection,id,kind,key,change){
|
|
155
|
-
const next=record(expected,collection,id);change(next);operations.push({kind,[key]:globalThis.structuredClone(next)});
|
|
156
|
-
}
|
|
157
|
-
const binding=(id,change)=>update('eventBindings',id,'putBinding','binding',change);
|
|
158
|
-
for(const field of keys){
|
|
159
|
-
const value=changes[field];
|
|
160
|
-
if(field==='shared-art'){
|
|
161
|
-
const target=sharedCropTargets(baseline).find(item=>item.id===targetId);
|
|
162
|
-
if(!target?.imageChoices.includes(value))throw Error('E_REVIEW_ASSET_CHOICE');
|
|
163
|
-
for(const id of target.uses){
|
|
164
|
-
record(expected,'components',id).assetSlots=[{slotId:'source',assetId:value}];
|
|
165
|
-
operations.push({kind:'replaceAsset',id,assetId:value});
|
|
166
|
-
}
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
if(field==='win-cue'){
|
|
170
|
-
const cue=endingFields(baseline,resolution).find(item=>item.id===field);
|
|
171
|
-
if(!cue?.choices.includes(value))throw Error('E_REVIEW_ASSET_CHOICE');
|
|
172
|
-
const id=resolution.roles?.rewardCue?.componentId;
|
|
173
|
-
if(!id)throw Error('E_REVIEW_ROLE_UNRESOLVED');
|
|
174
|
-
record(expected,'components',id).assetSlots=[{slotId:'source',assetId:value}];
|
|
175
|
-
operations.push({kind:'replaceAsset',id,assetId:value});continue;
|
|
176
|
-
}
|
|
177
|
-
assertValue(field,value);
|
|
178
|
-
switch(field){
|
|
179
|
-
case 'landscape-inset':{
|
|
180
|
-
const panel=record(expected,'components','harvest.board.lock'),stageWidth=Math.max(expected.base.width,expected.base.height);
|
|
181
|
-
const puzzle=layout(expected,'harvest.puzzle.layout');
|
|
182
|
-
const insetDelta=stageWidth-value-puzzle.parameters.x-puzzle.parameters.scaleX*(panel.transform[4]+panel.parameters.width);
|
|
183
|
-
for(const id of ['harvest.puzzle.layout','harvest.cta.layout','harvest.instruction.layout'])update('gameplay',id+'.responsive','putBehavior','behavior',entry=>{entry.parameters.x+=insetDelta;});
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
case 'timeout-caption':{
|
|
187
|
-
const existing=record(expected,'components',timeoutCaptionId);
|
|
188
|
-
if(existing){existing.parameters.text=value;operations.push({kind:'setParameter',id:timeoutCaptionId,key:'text',value});break;}
|
|
189
|
-
const title=record(expected,'components','harvest.reward.title'),panel=record(expected,'components','harvest.board.lock');
|
|
190
|
-
const button=record(expected,'components','harvest.cta'),puzzleLayout=layout(expected,'harvest.puzzle.layout').parameters;
|
|
191
|
-
const buttonLayout=layout(expected,'harvest.cta.layout').parameters;
|
|
192
|
-
const landscapeButtonTop=buttonLayout.y+buttonLayout.scaleY*button.transform[5];
|
|
193
|
-
const landscapeOffset=((landscapeButtonTop-puzzleLayout.y)/puzzleLayout.scaleY-button.transform[5])/2;
|
|
194
|
-
const group=component({id:timeoutLayoutId,label:'Timeout caption layout',contract:'native.group.v1',parentId:title.parentId,sceneId:title.sceneId,order:title.order});
|
|
195
|
-
const responsive={id:timeoutLayoutId+'.responsive',componentId:timeoutLayoutId,kind:'responsive-layout',parameters:{x:0,y:landscapeOffset,scaleX:1,scaleY:1}};
|
|
196
|
-
const caption=component({...title,id:timeoutCaptionId,label:'Timeout caption',parentId:group.id,
|
|
197
|
-
transform:[1,0,0,1,title.transform[4],(panel.transform[5]+button.transform[5]-title.parameters.height)/2],
|
|
198
|
-
parameters:{...title.parameters,text:value,visible:false,fontSize:22}});
|
|
199
|
-
const show={id:timeoutBindingId,eventId:record(expected,'eventBindings','harvest.cta.show').eventId,
|
|
200
|
-
condition:{all:[{variableId:'harvest.phase',op:'eq',value:'cta'},{variableId:'harvest.moves',op:'lt',value:3}]},
|
|
201
|
-
actions:[
|
|
202
|
-
{kind:'setComponent',componentId:'harvest.reward.title',key:'visible',value:false},
|
|
203
|
-
{kind:'setComponent',componentId:'harvest.reward.detail',key:'visible',value:false},
|
|
204
|
-
{kind:'setComponent',componentId:timeoutCaptionId,key:'visible',value:true},
|
|
205
|
-
]};
|
|
206
|
-
expected.components.push(group,caption);expected.gameplay.push(responsive);expected.eventBindings.push(show);
|
|
207
|
-
operations.push({kind:'createComponent',component:group},{kind:'createComponent',component:caption},{kind:'putBehavior',behavior:responsive},{kind:'putBinding',binding:show});
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
case 'caption-alignment':{
|
|
211
|
-
const caption=record(expected,'components',timeoutCaptionId),panel=record(expected,'components','harvest.board.lock');
|
|
212
|
-
const button=record(expected,'components','harvest.cta'),group=caption&&record(expected,'components',caption.parentId);
|
|
213
|
-
const alternate=group&&layout(expected,group.id),panelLayout=panel&&layout(expected,panel.parentId),buttonLayout=button&&layout(expected,button.parentId);
|
|
214
|
-
const isTranslation=object=>object.transform.slice(0,4).join(',')==='1,0,0,1';
|
|
215
|
-
if(targetId!=='timeout-card'||!caption||!panel||!group||!button||!panelLayout||!buttonLayout||
|
|
216
|
-
group.parentId!==panel.parentId||panel.parentId!=='harvest.puzzle.layout'||button.parentId!=='harvest.cta.layout'||
|
|
217
|
-
![caption,panel,group,button].every(isTranslation)||alternate?.parameters.x!==group.transform[4]||
|
|
218
|
-
alternate.parameters.scaleX!==1||alternate.parameters.scaleY!==1)throw Error('E_REVIEW_ROLE_UNRESOLVED');
|
|
219
|
-
const x=panel.transform[4]+(panel.parameters.width-caption.parameters.width)/2-group.transform[4];
|
|
220
|
-
const y=(panel.transform[5]+button.transform[5]-caption.parameters.height)/2-group.transform[5];
|
|
221
|
-
const landscapeButtonTop=buttonLayout.parameters.y+buttonLayout.parameters.scaleY*button.transform[5];
|
|
222
|
-
const landscapeButtonY=(landscapeButtonTop-panelLayout.parameters.y)/panelLayout.parameters.scaleY;
|
|
223
|
-
const landscapeOffset=(panel.transform[5]+landscapeButtonY-caption.parameters.height)/2-y;
|
|
224
|
-
const transform=[...caption.transform];transform[4]=x;transform[5]=y;
|
|
225
|
-
if(Math.abs(x-caption.transform[4])>.001||Math.abs(y-caption.transform[5])>.001)operations.push({kind:'setTransform',id:caption.id,transform});
|
|
226
|
-
if(caption.parameters.align!=='center')operations.push({kind:'setParameter',id:caption.id,key:'align',value:'center'});
|
|
227
|
-
if(Math.abs(landscapeOffset-alternate.parameters.y)>.001)update('gameplay',alternate.id,'putBehavior','behavior',entry=>{entry.parameters.y=landscapeOffset;});
|
|
228
|
-
caption.transform=transform;caption.parameters.align='center';break;
|
|
229
|
-
}
|
|
230
|
-
case 'text':{
|
|
231
|
-
const label=record(expected,'components',resolution.roles?.primaryCta?.labelId);
|
|
232
|
-
if(!label)throw Error('E_REVIEW_ROLE_UNRESOLVED');
|
|
233
|
-
label.parameters.text=value;operations.push({kind:'setParameter',id:label.id,key:'text',value});break;
|
|
234
|
-
}
|
|
235
|
-
case 'instruction':
|
|
236
|
-
update('variables','harvest.message','putVariable','variable',entry=>{entry.initial=value;});
|
|
237
|
-
binding('harvest.music.start',entry=>{message(entry).value=value;});break;
|
|
238
|
-
case 'hint-delay':
|
|
239
|
-
binding('harvest.hint.show',entry=>{
|
|
240
|
-
if(entry.condition.any){openingHint(entry.condition).value=value;return;}
|
|
241
|
-
const previous=entry.condition;
|
|
242
|
-
entry.condition={any:[{all:[{variableId:'harvest.moves',op:'eq',value:0},{...previous,value}]},{all:[{variableId:'harvest.moves',op:'gt',value:0},previous]}]};
|
|
243
|
-
});break;
|
|
244
|
-
case 'reveal-duration':update('gameplay','harvest.world.stage.1.reveal','putBehavior','behavior',entry=>{entry.parameters.seconds=value;});break;
|
|
245
|
-
case 'message':binding('harvest.restore.1',entry=>{message(entry).value=value;});break;
|
|
246
|
-
case 'payoff-hold':binding('harvest.payoff.finish',entry=>{payoff(entry).value=value;});break;
|
|
247
|
-
default:throw Error('E_REVIEW_SCOPE');
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return {operations,expected};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
1
|
async function playToEndCard(page,project){
|
|
254
2
|
const boardBehavior=(project.gameplay??[]).find(behavior=>behavior.kind==='match-board');
|
|
255
3
|
if(!boardBehavior)return {available:false};
|
|
@@ -293,37 +41,8 @@ async function playToEndCard(page,project){
|
|
|
293
41
|
return {available:finalPhase==='cta',mode:'real-play'};
|
|
294
42
|
}
|
|
295
43
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
matches:index=>Boolean(index.behavior('harvest.rules')),
|
|
300
|
-
resolveRoles:resolveHarvestRoles,reviewTargets,reviewOperations,
|
|
301
|
-
canTransferOutcomeCue:(index,resolution)=>resolution.status==='resolved'&&resolution.roles.timeoutEvent.cue?.unresolved==='missing-cue'&&!index.asset('harvest.audio.victory.source'),
|
|
302
|
-
timingFields:()=>({
|
|
303
|
-
'hint-delay':{target:'opening',targets:['opening'],moment:'opening',label:'opening hint delay'},
|
|
304
|
-
'reveal-duration':{target:'first-harvest',targets:['first-harvest'],moment:'first-harvest',label:'reveal duration'},
|
|
305
|
-
'payoff-hold':{target:'ending',targets:['ending','cta'],moment:'end-card',label:'payoff hold'},
|
|
306
|
-
}),
|
|
307
|
-
intake:{
|
|
308
|
-
validateMedia(assets,concept){
|
|
309
|
-
const images=new Set(assets.filter(asset=>asset.mime.startsWith('image/')).map(asset=>asset.hash));
|
|
310
|
-
if(images.size<5||!assets.some(asset=>isAudioMime(asset.mime)))throw Error('E_INTAKE_HARVEST_MEDIA');
|
|
311
|
-
if(concept){
|
|
312
|
-
const tiles=Object.values(concept.harvest.tiles).map(id=>assets.find(asset=>asset.id===id));
|
|
313
|
-
if(tiles.length!==5||tiles.some(asset=>!asset?.mime.startsWith('image/'))||new Set(tiles.map(asset=>asset.hash)).size!==5)throw Error('E_INTAKE_HARVEST_MEDIA');
|
|
314
|
-
}
|
|
315
|
-
},
|
|
316
|
-
validateConcept(concept){
|
|
317
|
-
const audio=concept?.harvest?.audio;
|
|
318
|
-
const supportedAudio=JSON.stringify(Object.keys(audio??{}).sort())===JSON.stringify(['ambient','complete','loss','match','reject'])||
|
|
319
|
-
JSON.stringify(Object.keys(audio??{}).sort())===JSON.stringify(['ambient','complete','match','reject','repair']);
|
|
320
|
-
if(concept?.experience?.mechanic!=='harvest-restore'||!concept.harvest||
|
|
321
|
-
JSON.stringify(Object.keys(concept.harvest).sort())!==JSON.stringify(['audio','firstHintSeconds','seed','tiles','world'])||
|
|
322
|
-
JSON.stringify(Object.keys(concept.harvest.tiles??{}).sort())!==JSON.stringify(['carrot','corn','eggplant','pumpkin','tomato'])||
|
|
323
|
-
!supportedAudio||!Array.isArray(concept.harvest.world)||concept.harvest.world.length>64)throw Error('E_INTAKE_ARGUMENT');
|
|
324
|
-
return [...Object.values(concept.harvest.tiles),...Object.values(audio),...concept.harvest.world.map(object=>object?.assetId)];
|
|
325
|
-
},
|
|
326
|
-
hydrateConcept(concept,assets){return {...concept,harvest:{...concept.harvest,assets}};},
|
|
327
|
-
},
|
|
44
|
+
|
|
45
|
+
export const harvestQaAdapter=Object.freeze({
|
|
46
|
+
id:'harvest-restore',matches:index=>Boolean(index.behavior('harvest.rules')),
|
|
328
47
|
qa:{phaseVariable:'harvest.phase',progressVariable:'harvest.moves',goalValue:3,deadlineBehaviorId:'harvest.deadline',playToEndCard},
|
|
329
48
|
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const crops=['carrot','corn','tomato'];
|
|
2
|
+
const cropId=crop=>'sort.crop.'+crop;
|
|
3
|
+
const zoneId=crop=>'sort.crate.'+crop;
|
|
4
|
+
|
|
5
|
+
async function dragPoints(page,from,to){
|
|
6
|
+
return page.evaluate(({from,to})=>{
|
|
7
|
+
const runtime=globalThis.toraRuntime,canvas=globalThis.document.querySelector('canvas');
|
|
8
|
+
if(!runtime||!canvas)return null;
|
|
9
|
+
const audit=runtime.auditSceneLayout({ids:[from,to],interactiveIds:[from,to],minTouchPx:1}),rect=canvas.getBoundingClientRect(),stage=audit.viewport,scale=stage.scale;
|
|
10
|
+
const point=id=>{const row=audit.interactive.find(item=>item.id===id);if(!row)return null;const b=row.bounds;return {x:rect.left+(rect.width-stage.width*scale)/2+(b.left+b.right)/2*scale,y:rect.top+(rect.height-stage.height*scale)/2+(b.top+b.bottom)/2*scale};};
|
|
11
|
+
return {from:point(from),to:point(to)};
|
|
12
|
+
},{from,to});
|
|
13
|
+
}
|
|
14
|
+
async function realDrag(page,from,to){
|
|
15
|
+
const points=await dragPoints(page,from,to);if(!points?.from||!points?.to)throw Error('E_SORT_QA_TARGET');
|
|
16
|
+
await page.mouse.move(points.from.x,points.from.y);await page.mouse.down();await page.mouse.move(points.to.x,points.to.y,{steps:8});await page.mouse.up();
|
|
17
|
+
}
|
|
18
|
+
async function playToEndCard(page){
|
|
19
|
+
for(const [index,crop] of crops.entries()){
|
|
20
|
+
const phase=await page.evaluate(()=>globalThis.toraRuntime?.state?.()?.variables?.['sort.phase']);
|
|
21
|
+
if(phase==='payoff')break;
|
|
22
|
+
await realDrag(page,cropId(crop),zoneId(crop));
|
|
23
|
+
await page.waitForFunction(value=>globalThis.toraRuntime?.state?.()?.variables?.['sort.sorted']>=value,index+1,{timeout:2500});
|
|
24
|
+
}
|
|
25
|
+
try{await page.waitForFunction(()=>globalThis.toraRuntime?.state?.()?.scene==='scene.win',undefined,{timeout:6000});}catch{return {available:false};}
|
|
26
|
+
return {available:true,mode:'real-play'};
|
|
27
|
+
}
|
|
28
|
+
async function prepareTimeout(page){
|
|
29
|
+
await realDrag(page,cropId('carrot'),zoneId('corn'));
|
|
30
|
+
const sorted=await page.evaluate(()=>globalThis.toraRuntime?.state?.()?.variables?.['sort.sorted']);
|
|
31
|
+
if(sorted!==0)throw Error('E_SORT_TIMEOUT_INPUT');
|
|
32
|
+
}
|
|
33
|
+
function validateTimeout(state){
|
|
34
|
+
return state?.scene==='scene.timeout'&&state.variables?.['sort.phase']==='cta'&&state.variables['sort.sorted']<3;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export function variantPreset(id){
|
|
39
|
+
const overlay={id,label:id,preset:id};
|
|
40
|
+
if(id==='shorter-hook')return {...overlay,texts:{'sort.instruction':{text:'SORT THE CROPS'}}};
|
|
41
|
+
if(id==='easier-win')return {...overlay,variables:{'sort.time':30},behaviors:{'sort.deadline':{seconds:30},'sort.time.meter':{max:30}}};
|
|
42
|
+
if(id==='high-contrast-cta')return {...overlay,colors:Object.fromEntries(['sort.cta','sort.timeout.cta'].map(componentId=>[componentId,{fill:'#ffd23f',hoverFill:'#ffe784',pressedFill:'#d99a2b',stroke:'#3c2933'}]))};
|
|
43
|
+
if(id==='custom')return overlay;
|
|
44
|
+
throw Error('E_VARIANT_PRESET');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export const sortPuzzleCompatibility=Object.freeze({
|
|
49
|
+
id:'sort-puzzle',matches:index=>Boolean(index.behavior('sort.rules')),variantPreset,
|
|
50
|
+
qa:{phaseVariable:'sort.phase',progressVariable:'sort.sorted',goalValue:3,deadlineBehaviorId:'sort.deadline',playToEndCard,prepareTimeout,validateTimeout},
|
|
51
|
+
});
|