File tree Expand file tree Collapse file tree 2 files changed +26
-27
lines changed
Expand file tree Collapse file tree 2 files changed +26
-27
lines changed Original file line number Diff line number Diff line change 1+ import lifespan from "$lib/assets/life-game-rules/lifespan.js?raw" ;
2+ import probabilistics from "$lib/assets/life-game-rules/probabilistics.js?raw" ;
3+
4+ export type RuleExplanation = {
5+ code : string ;
6+ ja : string ;
7+ en : string ;
8+ } ;
9+
10+ export const rulesExplanation = {
11+ lifespan : {
12+ code : lifespan ,
13+ ja : "それぞれのいのちに寿命を設定できます" ,
14+ en : "Set lifespan for each cell" ,
15+ } ,
16+ probabilistics : {
17+ code : probabilistics ,
18+ ja : "生死に確率を導入できます" ,
19+ en : "Introduce probability to life and death" ,
20+ } ,
21+ } ;
Original file line number Diff line number Diff line change 33 import event from " @/iframe/event.js?raw" ;
44 import lifeGameHTML from " @/iframe/life-game.html?raw" ;
55 import lifeGameJS from " @/iframe/life-game.js?raw" ;
6- import lifespan from " $lib/assets/life-game-rules/lifespan.js?raw" ;
7- import probabilistics from " $lib/assets/life-game-rules/probabilistics.js?raw" ;
6+ import { rulesExplanation , type RuleExplanation } from " $lib/rules-explanation" ;
87 import patterns from " $lib/board-templates" ;
98 import * as icons from " $lib/icons/index.ts" ;
109 import { BoardManager } from " $lib/models/BoardManager.svelte" ;
142141 },
143142 });
144143
145- const rulesExplanation = {
146- lifespan: {
147- code: lifespan ,
148- ja: " それぞれのいのちに寿命を設定できます" ,
149- en: " Set lifespan for each cell" ,
150- },
151- probabilistics: {
152- code: probabilistics ,
153- ja: " 生死に確率を導入できます" ,
154- en: " Introduce probability to life and death" ,
155- },
156- };
157-
158- type RuleExplanation = {
159- code: string ;
160- ja: string ;
161- en: string ;
162- };
163-
164- function selectRule(ruleName : keyof typeof rulesExplanation ) {
165- console .log (` Selected rule: ${ruleName } ` );
166- const rule = rulesExplanation [ruleName ] as RuleExplanation ;
144+ function selectRule(rule : RuleExplanation ) {
167145 editingCode = rule .code ;
168146 appliedCode = rule .code ;
169147 }
258236 <button
259237 class =" card bg-base-100 shadow-md hover:shadow-lg transition-shadow cursor-pointer text-left flex-shrink-0 w-64"
260238 onclick ={() => {
261- selectRule (ruleName as keyof typeof rulesExplanation );
239+ selectRule (description as RuleExplanation );
262240 ruleDrawerOpen = false ;
263241 }}
264242 >
522500 {#if ruleDrawerOpen }
523501 ▼
524502 {:else if isJapanese }
525- ▲ 追加ルール
503+ ▲ ルール選択
526504 {:else }
527- ▲ Additional Rules
505+ ▲ Select Rule
528506 {/if }
529507 </button >
530508 </div >
You can’t perform that action at this time.
0 commit comments