-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
242 lines (231 loc) · 10.5 KB
/
main.html
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
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>BuklakiTheGame - menu</title>
<meta name="description" content="BuklakiTheGame - gra na projekt zespolowy UWM.">
<meta name="keywords" content="Buklaki The Game">
<meta name="author" content="Kropka">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="static/css/bootstrap.min.css" rel="stylesheet">
<link href="static/custom/global.css" rel="stylesheet">
<link href="static/custom/menu.css" rel="stylesheet">
<link rel="shortcut icon" href="#">
</head>
<body>
<div id="main-div">
<div id="menu" class="menu curr-menu">
<h1>Buklaki The Game</h1>
<h3><a href="#" data-action="new-game">Nowa gra</a></h3>
<h3><a href="#" data-action="instructions">Instrukcja</a></h3>
<h3><a href="#" data-action="settings">Opcje</a></h3>
<h3><a href="#" data-action="ranking">Ranking</a></h3>
<h3><a href="#" data-action="about">O grze</a></h3>
</div>
<div id="options" class="menu">
<h1>Opcje</h1>
<div class="overflow-auto mb-1"><h3><a href="#" data-action="basket" data-arrows="no">
<span class="float-start">Ilość bukłaków</span>
<span class="float-end basket-set">5</span>
</a></h3></div>
<div class="overflow-auto mb-1"><h3><a href="#" data-action="distance" data-arrows="no">
<span class="float-start">Dystans</span>
<span class="float-end distance-set">8</span>
</a></h3></div>
<div class="overflow-auto mb-1"><h3><a href="#" data-action="music" data-arrows="no">
<span class="float-start">Muzyka</span>
<span class="float-end volume">100%</span>
</a></h3></div>
<div class="overflow-auto mb-1"><h3><a href="#" data-action="sound" data-arrows="no">
<span class="float-start">Dzwieki z gry</span>
<span class="float-end volume">100%</span>
</a></h3></div>
<div class="overflow-auto mb-1"><h3><a href="#" data-action="language" data-arrows="no">
<span class="float-start">Język / Language</span>
<span class="float-end lang">Polski</span>
</a></h3></div>
<h3 class="mt-5"><a href="#" data-action="to-menu">Powrót do menu</a></h3>
</div>
<div id="ranking" class="menu">
<h1>Ranking</h1>
<div id="ranking-list">
</div>
<h3 class="mt-5"><a href="#" data-action="to-menu">Powrót do menu</a></h3>
</div>
<div id="about" class="menu">
<div>Projekt Zespołowy Kropka Team Company</div>
<div>Patryk Szczepański</div>
<div>Mateusz Szczygłów</div>
<div>Grzegorz Choczaj</div>
<div>Dawid Zagórski</div>
<div>Krzysztof Wysocki</div>
<div>Przemysław Samsel</div>
</div>
<div id="instructions" class="menu">
<div>Celem gry jest dotarcie do celu nie umierając po drodze z pragnienia.</div>
<div>Przejście na sąsiednie pole reprezentuje 1 dzień drogi w trakcie którego zużywa się cały bukłak wody.</div>
<div>Aktualnie posiadana liczba bukłaków znajduje się u góry ekranu.</div>
<div>Przejście na sąsienie pole odbywa się za pomocą klawiszy:</div>
<div><- lub A aby przejść w lewo | -> lub D aby przejść w prawo</div>
Na każdym polu można również zakopać dowolną ilość bukłaków
Można to uczynić za pomocą klawiszy strzałki w dół lub S
Zakopaną wcześniej wodę można ponownie odkopać za pomocą strzałki w górę lub W
</div>
</div>
<script src="static/js/jquery-3.6.0.min.js"></script>
<script src="static/js/js.cookie.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/custom/global-utils.js"></script>
<script src="static/custom/trans-handler.js"></script>
<script>
let mainAudio = undefined;
$(document).ready((e) => {
LOGGER.success('BuklakiTheGame v0.001 initialized correctly!');
LOGGER.info('CURRENT STAGE: MENU');
let getBody = $('body')
getBody.on('click', (e) => {
if (!mainAudio) {
mainAudio = new Audio('static/sound/main-ost.mp3');
mainAudio.play();
mainAudio.addEventListener('ended', function () {
this.currentTime = 0;
this.play();
}, false);
}
})
const getScoresFromBackend = () => {
$.ajax({
url: '/buklakithebackend/get-records/',
type: 'POST',
success: (data) => {
let rankingList = $('#ranking-list');
rankingList.empty();
data.forEach((item) => {
let lang = Cookies.get('lang');
if(lang === 'English'){
rankingList.append(`
<h3>Name: ${item['name']} | Distance: ${item['distance']} |
Days: ${item['days']}</h3>
`)
} else {
rankingList.append(`
<h3>Nazwa: ${item['name']} | Dystans: ${item['distance']} |
Dni: ${item['days']}</h3>
`)
}
})
},
})
}
const handleChoiceSelect = () => {
let menuItem = $(jqueryGet('.curr-menu').find('h3')[getMenuPropertyIndex()]);
let action = menuItem.find('a').data('action');
switch (action) {
case 'new-game':
window.location.href = 'game.html';
break;
case 'settings':
switchMenus('#options');
break;
case 'ranking':
getScoresFromBackend();
switchMenus('#ranking');
break;
case 'about':
switchMenus('#about');
break;
case 'instructions':
switchMenus('#instructions');
break;
case 'to-menu':
switchMenus('#menu');
break;
}
}
$('[data-action=music], [data-action=sound]').click((e) => {
let target = $(e.currentTarget);
let action = $(target).data('action');
let curr = $(target).find('.volume');
const AUDIO_SWITCHES = [
'0%', '25%', '50%', '75%', '100%'
]
let getIndex = AUDIO_SWITCHES.indexOf(curr.text());
let getVolume = AUDIO_SWITCHES[(getIndex + 1) % AUDIO_SWITCHES.length];
if (action === 'music' && mainAudio) mainAudio.volume = parseInt(getVolume.replace('%', '')) * 0.01;
curr.text(getVolume);
})
const baseSettings = ['basket', 'distance']
baseSettings.forEach((item) => {
if (Cookies.get(item)) $(`.${item}-set`).text(Cookies.get(item));
})
$('[data-action=basket], [data-action=distance]').click((e) => {
let target = $(e.currentTarget);
let amountSel = `.${target.data('action')}-set`;
let value = parseInt($(amountSel).text());
let newValue = (value + 1) % 11 || 1;
$(amountSel).text(newValue);
Cookies.set(target.data('action'), newValue);
})
$('[data-action=language]').click((e) => {
let curr = $(e.currentTarget).find('.lang');
let getIndex = LANGUAGES.indexOf(curr.text());
let getLang = LANGUAGES[(getIndex + 1) % LANGUAGES.length];
curr.text(getLang);
switchLang(getLang);
})
$('.menu').find('h1, h3').each((index, entry) => {
$(entry).find('a').each((index, anotherEntry) => {
$(anotherEntry).hover((e) => {
const currEntry = $(e.currentTarget);
$('.arrows').remove();
$('.menu-selected').each((index, item) => {
$(item).removeClass('menu-selected')
})
if (currEntry.data('arrows') !== 'no') {
currEntry.prepend($(ARROW_SPAN).text('--> ')).append($(ARROW_SPAN).text(' <--'))
}
currEntry.addClass('menu-selected');
})
$(anotherEntry).click((e) => {
handleChoiceSelect();
})
})
})
getBody.keydown((e) => {
let getMenuItems = $('.curr-menu').find('h3');
if ($('#about').hasClass('curr-menu') || $('#instructions').hasClass('curr-menu')) {
switchMenus('#menu');
} else if (checkIfPressed('ENTER', e.keyCode)) {
$('.menu-selected').click();
} else {
let menuSelected = $('.menu-selected');
let getIndex = 0;
if (!menuSelected.length) {
let curr = $(getMenuItems[getIndex]);
if (curr.find('a').data('arrows') !== 'no') {
curr.find('a').prepend($(ARROW_SPAN).text('--> ')).append($(ARROW_SPAN).text(' <--'));
}
curr.addClass('menu-selected');
} else if (menuSelected.length) {
getIndex = getMenuPropertyIndex();
if (checkIfPressed('UP', e.keyCode)) getIndex = (getIndex % getMenuItems.length) - 1;
else if (checkIfPressed('DOWN', e.keyCode)) getIndex = (getIndex % getMenuItems.length) + 1;
if (getIndex < 0) getIndex = getMenuItems.length - 1;
else if (getIndex > getMenuItems.length - 1) getIndex = 0;
$('.arrows').remove();
let curr = $(getMenuItems[getIndex]);
if (curr.find('a').data('arrows') !== 'no')
$(getMenuItems[getIndex]).find('a').prepend($(ARROW_SPAN).text('--> ')).append($(ARROW_SPAN).text(' <--'))
}
menuSelected.each((index, item) => {
$(item).removeClass('menu-selected')
})
$(getMenuItems[getIndex]).find('a').addClass('menu-selected');
}
})
})
</script>
</body>
</html>