Slide 6
Slide 6 text
ニュースは「データ」、ロジックは小さく
ニュース定義(JSON)
ターン終了処理(簡略化)
{
setGameState((draft) => {
draft.turn += 1;
for (const news of [draft.firstNews,
draft.secondNews]) {
for (const { stockId, diff } of news.impact) {
const s = draft.stocks[stockId];
s.price = clamp(s.price + diff,
minPrice, maxPrice);
}
}
});
為替レートが円安傾向
"article": "
",
"impact": [
{ "stockId": 0, "diff": -2000,
"reason": "
…" },
{ "stockId": 1, "diff": 2000,
"reason": "
…" }
]
輸入品価格が上昇
訪日外国人が増加
}
ニュースの追加はJSONを足すだけ。 reason は「なぜ上がった?」の解説に使う
エコノクエスト | https://econo.quest/
6