// データモデルを扱うモジュール const DataModel = { // メニュー項目データ menuItems: [ { id: 1, name: 'まぐろ', price: 130, image: 'sushi2.jpg' }, { id: 2, name: 'サーモン', price: 130, image: 'sushi1.jpg' }, { id: 3, name: 'いか', price: 110, image: 'sushi3.jpg' }, ], // キャラクターデータ characters: [ { id: 1, name: 'ぶた', image: 'c_buta.png', description: '定番キャラクター' }, { id: 2, name: 'ひつじ', image: 'c_hitsuji.png', description: 'みんな大好き' }, { id: 3, name: '犬', image: 'c_inu.png', description: 'ピリッとした性格' }, { id: 4, name: 'かば', image: 'c_kaba.png', description: '知識豊富' } ], // テーブル情報を生成する関数 getTables: function() { return Array.from({ length: 12 }, (_, i) => ({ id: i + 1, status: i < 8 ? '空席' : '使用中' })); }, // 合計金額を計算する関数 calculateTotal: function(cartItems) { return cartItems.reduce((total, item) => { return total + (item.price * item.quantity); }, 0); }, // キャラクター名を取得する関数 getCharacterName: function(characterId) { const character = this.characters.find(c => c.id === characterId); return character ? character.name : '不明'; } }; // エクスポート window.DataModel = DataModel;