This server is intended for use for Academic Classwork related Git repositories only. Projects/repositories will generally be removed after 6 months following close of the semester. Inactive repositories from previous semester are now being archived when no activity for 365 days. They are renamed and marked as 'archived'. After 90 days in that state they will be removed from the system completely.

Commit 99e49c6d authored by pmdv46's avatar pmdv46

added simple upgrade to change picture of main clicker

parents a2fdf8b8 5ae9e5e3
import { Component } from '@angular/core';
import { GamePlayService } from '../game-play.service';
@Component({
selector: 'app-accumulators',
......@@ -7,24 +8,24 @@ import { Component } from '@angular/core';
})
export class AccumulatorsComponent {
// Not correct yet - need to figure out how to communicate btw click and accumulator
totalClicks = 0;
clickMulti = 1;
readonly totalClicks = this.service.pickleCount;
readonly clickMulti = this.service.incrementVal;
constructor() { }
constructor(private service: GamePlayService) { }
jarUpgrade() {
this.clickMulti += 5;
this.service.jarUpgrade().catch((err) => console.log(err));
}
barrelUpgrade() {
this.clickMulti += 50;
this.service.barrelUpgrade().catch((err) => console.log(err));
}
siloUpgrade() {
this.clickMulti += 500;
this.service.siloUpgrade().catch((err) => console.log(err));
}
reservoirUpgrade() {
this.clickMulti += 5000;
this.service.reservoirUpgrade().catch((err) => console.log(err));
}
}
......@@ -8,4 +8,4 @@
<button mat-raised-button>
<img [src]="upgradeLevel" (click)="increment()" />
</button>
<h4># of Clicks: {{ totalClicks }}</h4>
\ No newline at end of file
<h4># of Clicks: {{ totalClicks | async }}</h4>
\ No newline at end of file
import { style } from '@angular/animations';
import { Component } from '@angular/core';
import { GamePlayService } from '../game-play.service';
@Component({
selector: 'app-click',
......@@ -7,33 +8,17 @@ import { Component } from '@angular/core';
styleUrls: ['./click.component.scss'],
})
export class ClickComponent {
totalClicks = 0;
clickMulti = 1;
readonly totalClicks = this.service.pickleCount;
readonly clickMulti = this.service.incrementVal;
upgradeLevel = 'assets/Hamburger.png';
constructor() { }
constructor(private service: GamePlayService) { }
upgrade() {
this.upgradeLevel = 'assets/BabyDill.png';
}
increment() {
this.totalClicks += this.clickMulti;
}
jarUpgrade() {
this.clickMulti += 5;
}
barrelUpgrade() {
this.clickMulti += 50;
}
siloUpgrade() {
this.clickMulti += 500;
}
reservoirUpgrade() {
this.clickMulti += 5000;
this.service.increment().catch((err) => console.log(err));
}
}
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class GamePlayService {
// There are various ways to achieve an Observable that emits a
// current value on subscribe; this is one of the more common.
private readonly pickles = new BehaviorSubject<number>(0);
readonly pickleCount = this.pickles.asObservable();
private readonly increments = new BehaviorSubject<number>(1);
readonly incrementVal = this.increments.asObservable();
constructor() {
console.log('Game service activated');
}
async increment() {
this.pickles.next(this.pickles.value + this.increments.value);
}
async jarUpgrade() {
this.increments.next(this.increments.value + 5);
this.pickles.next(this.pickles.value - 5);
}
async barrelUpgrade() {
this.increments.next(this.increments.value + 50);
this.pickles.next(this.pickles.value - 50);
}
async siloUpgrade() {
this.increments.next(this.increments.value + 500);
this.pickles.next(this.pickles.value - 500);
}
async reservoirUpgrade() {
this.increments.next(this.increments.value + 5000);
this.pickles.next(this.pickles.value - 500);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment