-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
339 lines (310 loc) · 13.5 KB
/
script.js
File metadata and controls
339 lines (310 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
// ゲームの状態を管理するオブジェクト
const gameState = {
clickCount: 0,
coinCount: 0,
collection: [],
currentCard: null
};
// AWSサービスのデータ
const awsServices = [
{
id: 1,
name: "Amazon EC2",
icon: "images/ec2-icon.svg",
description: "仮想サーバーをクラウド上で提供するサービス。様々なインスタンスタイプから選択でき、柔軟にコンピューティングリソースを利用できます。"
},
{
id: 2,
name: "Amazon S3",
icon: "images/s3-icon.svg",
description: "スケーラブルなオブジェクトストレージサービス。データの保存と取得を簡単に行え、高い耐久性と可用性を提供します。"
},
{
id: 3,
name: "Amazon RDS",
icon: "images/rds-icon.svg",
description: "リレーショナルデータベースを簡単に設定、運用、スケーリングできるマネージドサービス。複数のデータベースエンジンをサポートしています。"
},
{
id: 4,
name: "AWS Lambda",
icon: "images/lambda-icon.svg",
description: "サーバーレスコンピューティングサービス。コードを実行するためのインフラストラクチャを管理することなく、関数を実行できます。"
},
{
id: 5,
name: "Amazon DynamoDB",
icon: "images/dynamodb-icon.svg",
description: "フルマネージドのNoSQLデータベースサービス。シームレスなスケーラビリティと高速なパフォーマンスを提供します。"
},
{
id: 6,
name: "Amazon CloudFront",
icon: "images/cloudfront-icon.svg",
description: "グローバルなコンテンツ配信ネットワーク(CDN)サービス。低レイテンシーと高速な転送速度でコンテンツを配信します。"
},
{
id: 7,
name: "AWS IAM",
icon: "images/iam-icon.svg",
description: "AWSリソースへのアクセスを安全に管理するためのサービス。ユーザー、グループ、ロールを作成し、権限を細かく制御できます。"
},
{
id: 8,
name: "Amazon VPC",
icon: "images/vpc-icon.svg",
description: "仮想ネットワークを定義し、AWSリソースを論理的に分離できるサービス。セキュリティとネットワーク構成を詳細に制御できます。"
},
{
id: 9,
name: "Amazon SNS",
icon: "images/sns-icon.svg",
description: "フルマネージドのメッセージング配信サービス。アプリケーション間やユーザーへの通知を簡単に送信できます。"
},
{
id: 10,
name: "Amazon SQS",
icon: "images/sqs-icon.svg",
description: "フルマネージドのメッセージキューイングサービス。マイクロサービス、分散システム、サーバーレスアプリケーション間のメッセージ交換を可能にします。"
},
{
id: 11,
name: "Amazon ECS",
icon: "images/ecs-icon.svg",
description: "コンテナ化されたアプリケーションを簡単に実行、スケーリングできるフルマネージドコンテナオーケストレーションサービス。"
},
{
id: 12,
name: "Amazon EKS",
icon: "images/eks-icon.svg",
description: "Kubernetesを簡単に実行できるマネージドサービス。Kubernetesのコントロールプレーンとワーカーノードを自動的に管理します。"
},
{
id: 13,
name: "AWS Fargate",
icon: "images/fargate-icon.svg",
description: "サーバーやクラスターを管理することなくコンテナを実行できるサーバーレスコンピューティングエンジン。"
},
{
id: 14,
name: "Amazon Aurora",
icon: "images/aurora-icon.svg",
description: "MySQL/PostgreSQL互換のリレーショナルデータベース。従来のデータベースの5倍のスループットを提供します。"
},
{
id: 15,
name: "Amazon Redshift",
icon: "images/redshift-icon.svg",
description: "ペタバイト規模のデータウェアハウスサービス。高速なクエリパフォーマンスと大規模なデータ分析を可能にします。"
},
{
id: 16,
name: "Amazon ElastiCache",
icon: "images/elasticache-icon.svg",
description: "Redis/Memcachedと互換性のあるインメモリデータストア。高速なパフォーマンスとスケーラビリティを提供します。"
},
{
id: 17,
name: "Amazon Route 53",
icon: "images/route53-icon.svg",
description: "スケーラブルなDNSウェブサービス。ドメイン登録、DNSルーティング、ヘルスチェックを提供します。"
},
{
id: 18,
name: "AWS CloudFormation",
icon: "images/cloudformation-icon.svg",
description: "AWSリソースをテンプレートを使って作成・管理するサービス。インフラストラクチャをコードとして扱えます。"
},
{
id: 19,
name: "Amazon API Gateway",
icon: "images/apigateway-icon.svg",
description: "APIの作成、公開、維持、モニタリング、保護を行うフルマネージドサービス。"
},
{
id: 20,
name: "Amazon CloudWatch",
icon: "images/cloudwatch-icon.svg",
description: "AWSリソースとアプリケーションのモニタリングサービス。メトリクス収集、ログ管理、アラーム設定が可能です。"
},
{
id: 21,
name: "AWS Step Functions",
icon: "images/stepfunctions-icon.svg",
description: "分散アプリケーションのコンポーネントを視覚的なワークフローで調整するサービス。"
},
{
id: 22,
name: "Amazon Cognito",
icon: "images/cognito-icon.svg",
description: "ウェブ/モバイルアプリのユーザー認証、認可、ユーザー管理を提供するサービス。"
},
{
id: 23,
name: "AWS Glue",
icon: "images/glue-icon.svg",
description: "ETL(抽出、変換、ロード)ジョブを簡単に作成、実行、管理できるフルマネージドサービス。"
},
{
id: 24,
name: "Amazon Athena",
icon: "images/athena-icon.svg",
description: "標準SQLを使用してS3のデータを直接分析できるインタラクティブなクエリサービス。"
},
{
id: 25,
name: "Amazon Kinesis",
icon: "images/kinesis-icon.svg",
description: "リアルタイムのストリーミングデータを簡単に収集、処理、分析できるサービス。"
},
{
id: 26,
name: "AWS Secrets Manager",
icon: "images/secretsmanager-icon.svg",
description: "データベース認証情報、APIキー、その他のシークレットを保護するサービス。"
},
{
id: 27,
name: "Amazon SageMaker",
icon: "images/sagemaker-icon.svg",
description: "機械学習モデルを構築、トレーニング、デプロイするためのフルマネージドサービス。"
},
{
id: 28,
name: "AWS AppSync",
icon: "images/appsync-icon.svg",
description: "GraphQL APIを簡単に開発できるマネージドサービス。リアルタイムデータ同期とオフライン機能をサポート。"
},
{
id: 29,
name: "Amazon EventBridge",
icon: "images/eventbridge-icon.svg",
description: "イベント駆動型アプリケーションを簡単に構築できるサーバーレスイベントバスサービス。"
},
{
id: 30,
name: "AWS Cloud9",
icon: "images/cloud9-icon.svg",
description: "クラウドベースの統合開発環境(IDE)。コードの記述、実行、デバッグをブラウザから行えます。"
}
];
// DOM要素の参照を取得
const clickCountElement = document.getElementById('click-count');
const coinCountElement = document.getElementById('coin-count');
const clickButton = document.getElementById('click-button');
const gachaButton = document.getElementById('gacha-button');
const cardDisplay = document.getElementById('card-display');
const cardTitle = document.getElementById('card-title');
const cardIconImg = document.getElementById('card-icon-img');
const cardDescription = document.getElementById('card-description');
const collectButton = document.getElementById('collect-button');
const collectionElement = document.getElementById('collection');
const collectionCountElement = document.getElementById('collection-count');
const totalServicesElement = document.getElementById('total-services');
// 初期化関数
function initGame() {
// 合計サービス数を表示
totalServicesElement.textContent = awsServices.length;
// コレクショングリッドを初期化(未収集状態で表示)
awsServices.forEach(service => {
const collectionItem = document.createElement('div');
collectionItem.classList.add('collection-item', 'not-collected');
collectionItem.dataset.id = service.id;
collectionItem.innerHTML = `
<div class="collection-icon">
<img src="images/default-icon.svg" alt="未収集アイコン">
</div>
<div class="collection-name">???</div>
`;
collectionElement.appendChild(collectionItem);
});
// イベントリスナーを設定
clickButton.addEventListener('click', handleClick);
gachaButton.addEventListener('click', handleGacha);
collectButton.addEventListener('click', handleCollect);
// ゲーム状態を更新
updateGameState();
}
// クリックボタンのハンドラー
function handleClick() {
gameState.clickCount++;
// 50クリックごとに10コイン獲得
if (gameState.clickCount % 50 === 0) {
gameState.coinCount += 10;
}
// ゲーム状態を更新
updateGameState();
}
// ガチャボタンのハンドラー
function handleGacha() {
// コインが足りるか確認
if (gameState.coinCount < 10) return;
// コインを消費
gameState.coinCount -= 10;
// ランダムなサービスを選択
const randomIndex = Math.floor(Math.random() * awsServices.length);
gameState.currentCard = awsServices[randomIndex];
// カードを表示
cardTitle.textContent = gameState.currentCard.name;
cardIconImg.src = gameState.currentCard.icon;
cardIconImg.alt = gameState.currentCard.name + " アイコン";
cardDescription.textContent = gameState.currentCard.description;
cardDisplay.classList.remove('hidden');
// ゲーム状態を更新
updateGameState();
}
// コレクションに追加ボタンのハンドラー
function handleCollect() {
if (!gameState.currentCard) return;
// 既に収集済みかチェック
if (!gameState.collection.includes(gameState.currentCard.id)) {
gameState.collection.push(gameState.currentCard.id);
// コレクションアイテムを更新
const collectionItem = document.querySelector(`.collection-item[data-id="${gameState.currentCard.id}"]`);
collectionItem.classList.remove('not-collected');
collectionItem.innerHTML = `
<div class="collection-icon">
<img src="${gameState.currentCard.icon}" alt="${gameState.currentCard.name} アイコン">
</div>
<div class="collection-name">${gameState.currentCard.name}</div>
`;
// コレクション数を更新
collectionCountElement.textContent = gameState.collection.length;
}
// カード表示を隠す
cardDisplay.classList.add('hidden');
gameState.currentCard = null;
// ゲーム状態を更新
updateGameState();
}
// ゲーム状態の更新
function updateGameState() {
// UI要素を更新
clickCountElement.textContent = gameState.clickCount % 50;
coinCountElement.textContent = gameState.coinCount;
// ガチャボタンの有効/無効を切り替え
gachaButton.disabled = gameState.coinCount < 10;
// 進捗バーを更新
const progressPercentage = (gameState.collection.length / awsServices.length) * 100;
const progressBar = document.getElementById('progress-bar');
progressBar.style.width = progressPercentage + '%';
progressBar.textContent = Math.round(progressPercentage) + '%';
// すべてのサービスを収集した場合
if (gameState.collection.length === awsServices.length) {
alert('おめでとうございます!すべてのAWSサービスを収集しました!');
}
}
// 画像の読み込みエラー時の処理
function handleImageError(img) {
img.onerror = null; // 無限ループを防ぐ
img.src = 'images/default-icon.svg';
}
// 画像のエラーハンドリングを追加
document.addEventListener('DOMContentLoaded', function() {
// カードアイコンのエラーハンドリング
cardIconImg.onerror = function() {
handleImageError(this);
};
// 初期化
initGame();
});