diff --git a/apollo-frontend/src/app/app-routing.module.ts b/apollo-frontend/src/app/app-routing.module.ts index 4368d18..467821b 100644 --- a/apollo-frontend/src/app/app-routing.module.ts +++ b/apollo-frontend/src/app/app-routing.module.ts @@ -1,11 +1,12 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { DashboardComponent } from './dashboard/dashboard.component'; +import { MinigameBiotriviaComponent } from './minigame-biotrivia/minigame-biotrivia.component'; import { MinigameConveyorRecyclingComponent } from './minigame-conveyor-recycling/minigame-conveyor-recycling.component'; const routes: Routes = [ { path: 'minigames/conveyor-belt', component: MinigameConveyorRecyclingComponent, data: { animation: 'conveyor-belt-mg' } }, - { path: 'minigames/biotrivia', component: MinigameConveyorRecyclingComponent, data: { animation: 'biotrinia-mg' } }, + { path: 'minigames/biotrivia', component: MinigameBiotriviaComponent, data: { animation: 'biotrinia-mg' } }, { path: '', component: DashboardComponent, data: { animation: 'home' } }, ]; diff --git a/apollo-frontend/src/app/card/card.component.html b/apollo-frontend/src/app/card/card.component.html index 836f3fc..61f618d 100644 --- a/apollo-frontend/src/app/card/card.component.html +++ b/apollo-frontend/src/app/card/card.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/apollo-frontend/src/app/card/card.component.scss b/apollo-frontend/src/app/card/card.component.scss index ae6f026..24a1130 100644 --- a/apollo-frontend/src/app/card/card.component.scss +++ b/apollo-frontend/src/app/card/card.component.scss @@ -82,11 +82,6 @@ border-radius: 1em; padding: 1em; - box-shadow: #0004 3px 3px 5px; - - background-color: #f8f8f855; - backdrop-filter: blur(10px); - button { margin: 0 auto; display: block; diff --git a/apollo-frontend/src/app/dashboard-cards/dashboard-cards.component.scss b/apollo-frontend/src/app/dashboard-cards/dashboard-cards.component.scss index 70e9982..a22bb4b 100644 --- a/apollo-frontend/src/app/dashboard-cards/dashboard-cards.component.scss +++ b/apollo-frontend/src/app/dashboard-cards/dashboard-cards.component.scss @@ -10,8 +10,9 @@ flex-wrap: wrap; width: 100%; gap: 2em; - padding: 1em 0; + padding: 1em; box-sizing: border-box; + justify-content: center; } .card { scroll-snap-align: start; diff --git a/apollo-frontend/src/app/dashboard-minigames/dashboard-minigames.component.scss b/apollo-frontend/src/app/dashboard-minigames/dashboard-minigames.component.scss index 7d0d528..93ddfc2 100644 --- a/apollo-frontend/src/app/dashboard-minigames/dashboard-minigames.component.scss +++ b/apollo-frontend/src/app/dashboard-minigames/dashboard-minigames.component.scss @@ -9,7 +9,8 @@ flex-wrap: wrap; width: 100%; gap: 2em; - padding: 1em 0; + justify-content: center; + padding: 1em; scroll-snap-type: y mandatory; box-sizing: border-box; } diff --git a/apollo-frontend/src/app/db.service.ts b/apollo-frontend/src/app/db.service.ts index 9aecd75..8c26783 100644 --- a/apollo-frontend/src/app/db.service.ts +++ b/apollo-frontend/src/app/db.service.ts @@ -16,11 +16,22 @@ export interface Card { name: string; types: Array<"endangered" | "normal">; } +export interface MultipleChoiseAnswer { + type: 'multiple-choise'; + choises: string[]; + correctChoise: string; +} +export interface Question { + category: string; + question: string; + photoUrlsAbove?: string[]; + answer: MultipleChoiseAnswer; +} + export interface Saved { id: string; el: T; } - @Injectable({ providedIn: 'root' }) @@ -298,11 +309,111 @@ export class DbService { }, }, ]; + private mock_questions: Saved[] = [ + { + id: '0', + el: { + category: 'animals', + photoUrlsAbove: [ '/assets/images/questions/slon.jpg' ], + question: 'Защо бройката на слоновете в Африка намалява?', + answer: { + type: 'multiple-choise', + choises: [ + 'Убиван е от други животни', + 'Липса на храна', + 'Убивани са от бракониери', + 'Замърсяване на въздуха' + ], + correctChoise: 'Убивани са от бракониери', + } + } + }, + { + id: '1', + el: { + category: 'animals', + photoUrlsAbove: [ '/assets/images/questions/carski orel.jpg' ], + question: 'Каква е главната причина за намаляването на бройките Царски орли?', + answer: { + type: 'multiple-choise', + choises: [ + 'Бракониери', + 'Замърсяване', + 'Отсичане на горите', + 'Електрически стълбове' + ], + correctChoise: 'Електрически стълбове', + } + } + }, + { + id: '2', + el: { + category: 'animals', + photoUrlsAbove: [ '/assets/images/questions/carski orel.jpg' ], + question: 'Каква е главната причина за намаляването на бройките Царски орли?', + answer: { + type: 'multiple-choise', + choises: [ + 'Бракониери', + 'Замърсяване', + 'Отсичане на горите', + 'Електрически стълбове' + ], + correctChoise: 'Електрически стълбове', + } + } + }, + { + id: '3', + el: { + category: 'animals', + photoUrlsAbove: [ '/assets/images/questions/zlatna zhaba.png' ], + question: 'Каква е причината за изчезването на Златната жаба?', + answer: { + type: 'multiple-choise', + choises: [ + 'Глобално затопляне', + 'Замърсяване на реките', + 'Отсичане на горите', + 'Недостиг на храна' + ], + correctChoise: 'Глобално затопляне', + } + } + }, + { + id: '4', + el: { + category: 'animals', + photoUrlsAbove: [ '/assets/images/questions/shtigga.png' ], + question: 'Каква е причината за намаляването на бройките на Черният щъркел?', + answer: { + type: 'multiple-choise', + choises: [ + 'Замърсяването на блатата и езерата', + 'Недостиг на храна', + 'Глобално затопляне', + 'Естествени врагове', + ], + correctChoise: 'Замърсяването на блатата и езерата', + } + } + }, + ]; - private getRandomEl(array: T[]): T { - const index = Math.floor(Math.random() * array.length); - - return array[index]; + private getRandomEls(array: T[], n: number): T[] { + const result: T[] = new Array(n); + let len = array.length; + const taken = new Array(len); + if (n > len) + throw new RangeError("getRandom: more elements taken than available"); + while (n--) { + const x = Math.floor(Math.random() * len); + result[n] = array[x in taken ? taken[x] : x]; + taken[x] = --len in taken ? taken[len] : len; + } + return result; } getAllMinigames(): Saved[] { @@ -325,5 +436,11 @@ export class DbService { else return this.mock_card_types[index].el; } + getRandomQuestions(n: number, category: string): Question[] { + return this.getRandomEls(this.mock_questions + .filter(v => v.el.category === category) + .map(v => v.el), n); + } + constructor() { } } diff --git a/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.html b/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.html index 7fe0c07..ec04886 100644 --- a/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.html +++ b/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.html @@ -1 +1,15 @@ -

minigame-biotrivia works!

+
+
+

Пробвай познанията си за екология

+

+ В тази викторина ще има 5 въпроса, които ще тестват вашите познания по екология. + Накрая, в зависимост от познатите отговори, ще получите по-рядка карта или + по-обикновена карта

+ +
+ +
+
+

+
+
\ No newline at end of file diff --git a/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.scss b/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.scss index e69de29..06ccf6d 100644 --- a/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.scss +++ b/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.scss @@ -0,0 +1,34 @@ +.container { + height: 100vh; + width: 100vw; + display: flex; + justify-content: center; + align-items: center; + overflow: hidden; + + .start-dialog { + width: 600px; + max-width: 100%; + } + .dialog { + padding: 2em; + box-sizing: border-box; + border-radius: .5em; + button { + margin: 0 auto; + display: block; + } + h4 { + text-align: center; + margin: 0 2em; + margin-top: 0; + } + .separator { + height: .5em; + width: 100%; + } + p { + text-align: center; + } + } +} \ No newline at end of file diff --git a/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.ts b/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.ts index 8cdd6da..aba8e9d 100644 --- a/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.ts +++ b/apollo-frontend/src/app/minigame-biotrivia/minigame-biotrivia.component.ts @@ -1,15 +1,78 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, ElementRef, NgZone, OnInit, ViewChild, ViewChildren } from '@angular/core'; +import { Observable, Subject } from 'rxjs'; + @Component({ - selector: 'app-minigame-biotrivia', - templateUrl: './minigame-biotrivia.component.html', - styleUrls: ['./minigame-biotrivia.component.scss'] + selector: 'app-minigame-biotrivia', + templateUrl: './minigame-biotrivia.component.html', + styleUrls: ['./minigame-biotrivia.component.scss'] }) export class MinigameBiotriviaComponent implements OnInit { + @ViewChildren('startDialog') startingElementRef; + @ViewChildren('ongoingDialog') ongoingElementRef; - constructor() { } + guessedQuestions = 0; + stage: 'starting' | 'starting-ongoing' | 'ongoing' | 'ended' = 'starting'; - ngOnInit(): void { - } + constructor( + private zone: NgZone, + ) { } + ngOnInit(): void { + } + + animateElements(el1: HTMLElement, el2: HTMLElement): Observable { + const a = new Subject(); + el1.style.position = 'absolute'; + el1.animate([ + { + transform: 'translateX(0)', + opacity: 1, + }, + { + transform: 'translateX(-100vh)', + opacity: 0, + }, + ], { + duration: 200, + easing: 'ease-in', + }).onfinish = () => { + el1.style.opacity = '0'; + }; + el2.animate([ + { + transform: 'translateX(100vh)', + opacity: 0, + }, + { + transform: 'translateX(0)', + opacity: 1, + }, + ], { + duration: 200, + easing: 'ease-out', + }).onfinish = () => { + a.next(); + }; + return a; + } + + startGame(): void { + if (this.stage !== 'starting') return; + console.log(this.ongoingElementRef); + + const startingEl = this.startingElementRef.first.nativeElement as HTMLElement; + startingEl.style.position = 'absolute'; + + this.stage = 'starting-ongoing'; + + setTimeout(() => { + const ongoingEl = this.ongoingElementRef.first.nativeElement as HTMLElement; + + // tslint:disable-next-line: deprecation + this.animateElements(startingEl, ongoingEl).subscribe(() => { + this.stage = 'ongoing'; + }); + }, 10); + } } diff --git a/apollo-frontend/src/app/minigame-card/minigame-card.component.html b/apollo-frontend/src/app/minigame-card/minigame-card.component.html index 7cb2dde..bb89c04 100644 --- a/apollo-frontend/src/app/minigame-card/minigame-card.component.html +++ b/apollo-frontend/src/app/minigame-card/minigame-card.component.html @@ -1,14 +1,19 @@ -
+
-
{{minigame.name}}
+
{{minigame.name}} (не е готова)
-

- Вече сте играли тази игра и {{hasMedal() ? 'имате' : 'нямате'}} {{getMedalType()}} медал -

-

- Все още не сте играли тази игра +

+

+ Вече сте играли тази игра и {{hasMedal() ? 'имате' : 'нямате'}} {{getMedalType()}} медал +

+

+ Все още не сте играли тази игра +

+
+

+ Тази игра все още се разработва

- +
\ No newline at end of file diff --git a/apollo-frontend/src/app/minigame-card/minigame-card.component.scss b/apollo-frontend/src/app/minigame-card/minigame-card.component.scss index ce74c4f..ec33c35 100644 --- a/apollo-frontend/src/app/minigame-card/minigame-card.component.scss +++ b/apollo-frontend/src/app/minigame-card/minigame-card.component.scss @@ -49,11 +49,6 @@ border-radius: 1em; padding: 1em; - box-shadow: #0004 3px 3px 5px; - - background-color: #f8f8f855; - backdrop-filter: blur(10px); - button { margin: 0 auto; display: block; diff --git a/apollo-frontend/src/assets/images/questions/carski orel.jpg b/apollo-frontend/src/assets/images/questions/carski orel.jpg new file mode 100644 index 0000000..077d1fc Binary files /dev/null and b/apollo-frontend/src/assets/images/questions/carski orel.jpg differ diff --git a/apollo-frontend/src/assets/images/questions/shtigga b/apollo-frontend/src/assets/images/questions/shtigga new file mode 100644 index 0000000..ed3b4c8 Binary files /dev/null and b/apollo-frontend/src/assets/images/questions/shtigga differ diff --git a/apollo-frontend/src/assets/images/questions/slon.jpg b/apollo-frontend/src/assets/images/questions/slon.jpg new file mode 100644 index 0000000..3662495 Binary files /dev/null and b/apollo-frontend/src/assets/images/questions/slon.jpg differ diff --git a/apollo-frontend/src/assets/images/questions/zlatna zhaba.png b/apollo-frontend/src/assets/images/questions/zlatna zhaba.png new file mode 100644 index 0000000..8102e33 Binary files /dev/null and b/apollo-frontend/src/assets/images/questions/zlatna zhaba.png differ diff --git a/apollo-frontend/src/styles.scss b/apollo-frontend/src/styles.scss index 40c01d0..21cde94 100644 --- a/apollo-frontend/src/styles.scss +++ b/apollo-frontend/src/styles.scss @@ -6,6 +6,10 @@ html { width: 100%; height: 100%; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + box-sizing: border-box; +} + +html { background-image: url('/assets/images/Forest BG.png'); background-size: cover } @@ -30,3 +34,11 @@ $my-color-palette: igx-palette($primary: $company-color, .contents { display: contents; } +* { + box-sizing: border-box; +} +.dialog { + background-color: #f8f8f855; + backdrop-filter: blur(10px); + box-shadow: #0004 3px 3px 5px; +} \ No newline at end of file