Skip to content

Commit

Permalink
Merge pull request #56 from Sybit-Education/fix/error-messages
Browse files Browse the repository at this point in the history
fix: console errors
  • Loading branch information
AlexanderKugler authored Aug 4, 2023
2 parents 04bfebf + 7a6214a commit 1167a7b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 35 deletions.
10 changes: 6 additions & 4 deletions src/app/bedroom/bedroom.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ export class BedroomComponent implements OnInit{
this.store.select(selectSygotchi)
.subscribe(
syGotchi => {
this.isAsleep = syGotchi.sleeping
if(syGotchi) {
this.isAsleep = syGotchi.sleeping
}
}
)
}
left(){
if(this.isAsleep == false){
if(!this.isAsleep){
this.router.navigate(['/bathroom'])
}
}
right(){
if(this.isAsleep == false){
if(!this.isAsleep){
this.router.navigate(['/gym'])
}
}
}
}
10 changes: 6 additions & 4 deletions src/app/clean-function/clean-function.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export class CleanFunctionComponent implements OnInit {

ngOnInit(): void {
this.store.select(selectSygotchi).subscribe(SyGotchi => {
this.isDirty = SyGotchi.dirty
this.sygotchi = SyGotchi
if(SyGotchi) {
this.isDirty = SyGotchi.dirty
this.sygotchi = SyGotchi
}
})
}
clean(){
Expand All @@ -34,14 +36,14 @@ export class CleanFunctionComponent implements OnInit {
() => {
this.message.Error = true
this.message.text = "Sygotchi ist nicht dreckig genug!"
this.messageHandler()
this.messageHandler()
}

)
}else{
this.message.Error = true
this.message.text = "Sygotchi ist nicht dreckig genug!"
this.messageHandler()
this.messageHandler()
}
}
messageHandler() {
Expand Down
20 changes: 11 additions & 9 deletions src/app/gym-function/gym-function.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import { SyGotchi } from '../entities/syGotchi';
import { ActionsService } from '../services/actions.service';
import { Store } from '@ngrx/store';
Expand All @@ -10,24 +10,26 @@ import { setSygotchi } from '../store/sygotchi.actions';
templateUrl: './gym-function.component.html',
styleUrls: ['./gym-function.component.scss']
})
export class GymFunctionComponent {
export class GymFunctionComponent implements OnInit {
isTired: number = 0
isBored: number
cooldown: number
message = {text: '', error: false}
sygotchi: SyGotchi
showMessage: boolean = false
cooldown: number

constructor(private actionsService: ActionsService, private store: Store) {}

ngOnInit() {
this.store.select(selectSygotchi)
.subscribe(
syGotchi => {
this.isTired = syGotchi.tired
this.isBored = syGotchi.bored
this.cooldown = syGotchi.playCooldown
this.sygotchi = syGotchi
if(syGotchi) {
this.isTired = syGotchi.tired
this.isBored = syGotchi.bored
this.cooldown = syGotchi.playCooldown
this.sygotchi = syGotchi
}
}
)
}
Expand All @@ -51,13 +53,13 @@ export class GymFunctionComponent {
this.messageHandler()
})
}

}else{
this.message.error = true
this.message.text = 'Dein Sygotchi ist zu müde und kann nicht mehr trainieren.'
this.messageHandler()
}
}
}

messageHandler() {
this.showMessage = true
Expand Down
21 changes: 12 additions & 9 deletions src/app/kitchen-function/kitchen-function.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ export class KitchenFunctionComponent implements OnInit{
this.store.select(selectSygotchi)
.subscribe(
syGotchi => {
this.isHungry = syGotchi.hunger
this.isThirsty = syGotchi.thirst
this.feedCooldown = syGotchi.feedCooldown
this.drinkCooldown = syGotchi.drinkCooldown
this.sygotchi = syGotchi
if(syGotchi) {
this.isHungry = syGotchi.hunger
this.isThirsty = syGotchi.thirst
this.feedCooldown = syGotchi.feedCooldown
this.drinkCooldown = syGotchi.drinkCooldown
this.sygotchi = syGotchi
}
}
)
}
feed(){

if(this.isHungry <= 90){
if(this.feedCooldown > -1){
this.message.error = true
Expand All @@ -55,7 +57,7 @@ export class KitchenFunctionComponent implements OnInit{
this.messageHandler()
})
}

}else{
this.message.error = true
this.message.text = 'Sygotchi hat keinen Hunger!'
Expand All @@ -82,7 +84,7 @@ export class KitchenFunctionComponent implements OnInit{
this.messageHandler()
})
}

}else{
this.message.error = true
this.message.text = 'Sygotchi hat keinen Durst!'
Expand All @@ -92,9 +94,10 @@ export class KitchenFunctionComponent implements OnInit{
messageHandler() {
if(!this.showMessage){
this.showMessage = true
console.log(this.showMessage)
setTimeout(() => {
this.showMessage = false
}, 7000)
}
}
}
}
6 changes: 3 additions & 3 deletions src/app/needs/needs.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="center">
<div class="row w-100">
<div class="text-center h3">
<div class="text-center h3" *ngIf="sygotchi">
<a>{{sygotchi.name}}</a>
</div>
<div class="col-6 mb-3">
Expand Down Expand Up @@ -35,8 +35,8 @@
</span>
</label>
<br>
<label>
<span>Score:
<label>Score:
<span *ngIf="sygotchi">
{{ sygotchi.score}}
<i class="fa-solid fa-bank"></i>
</span>
Expand Down
4 changes: 0 additions & 4 deletions src/app/needs/needs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export class NeedsComponent {
})
}

open(content) {
this.modalService.open(content)
}

private moodIconSelector(mood: string) {
switch (mood) {
case Mood.HAPPY:
Expand Down
7 changes: 5 additions & 2 deletions src/app/sleep-scene/sleep-scene.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export class SleepSceneComponent implements OnInit {
this.store.select(selectSygotchi)
.subscribe(
syGotchi => {
this.isAsleep = syGotchi?.sleeping ? true : false
this.sygotchi = syGotchi
if(syGotchi) {
this.isAsleep = syGotchi.sleeping
this.sygotchi = syGotchi
}
}
)
}
Expand Down Expand Up @@ -65,6 +67,7 @@ export class SleepSceneComponent implements OnInit {
messageHandler() {
if(!this.showMessage){
this.showMessage = true
console.log(this.showMessage)
setTimeout(() => {
this.showMessage = false
}, 7000)
Expand Down

0 comments on commit 1167a7b

Please sign in to comment.