New Page
flowchart TD API[/POST /api/service/game/:id/end-round/] --> S1[GameService.endRound] S1 --> S2[Engine loop: set gameState=CALCULATING] S2 --> S3[prepareNextRound(game)]
subgraph PrepareNextRound S3 --> A1[setCurrentRoundSolutions] A1 --> A1n[Inject 'Доля_софинанс_ПР' for projects started at current step into solutions.values]
S3 --> B1{game.currentStep != 0?}
B1 -- yes --> B2[RoundResultCalculator.run]
B2 --> B2a[Calculator.process(calculatedParameters)]
B2a --> B2b[Save GRCP for world and regions]
B2b --> B2c[Update SolutionsDraft.results for current step]
S3 --> P1[[Parallel tasks]]
P1 --> P2[createNextRoundDefaultSolutions]
P1 --> P3[updateGameRegionStatistic(step+1 money=0, gamePoints=0)]
P1 --> P4[updateGameRegionsProjects]
subgraph Projects
P4 --> C1[Fetch realising + mega stats]
C1 --> C2{remainStepBeforeRealize == 0?}
C2 -- no (building) --> D1[Decrement remain steps]
D1 --> D2[GRProjectCalcParams: create soinvestedOnStepSum at step+1]
D2 --> D3[GRCalculatedParams: increment 'КБ_Расходы_ИТОГО' at step+1]
C2 -- yes (completing) --> E1{project.megaProjectId?}
E1 -- no --> E2[Mark REALIZED]
E2 --> E3[buildGRCalculatedParams(project replaceable params) for step+1]
E3 --> E4[batchUpsertGRCP]
E1 -- yes --> F1[Collect realized parts by MegaProject]
F1 --> F2{awaiting + realized >= totalNum?}
F2 -- yes --> F3[Mark all awaiting+realized REALIZED]
F3 --> F4[buildGRCalculatedParams for each; step+1]
F4 --> F5[batchUpsertGRCP]
F2 -- no --> F6[Mark realized parts AWAITING]
end
S3 --> G1[startNextRound: ++currentStep, set WAITSTEP]
G1 --> G2[UpdateRating (try)]
G1 --> G3[InitUserStatistics (try)]
G1 --> G4[InitStepTasks (try)]
end
No comments to display
No comments to display