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 2832e11f authored by Hellebusch, Luke (S&T-Student)'s avatar Hellebusch, Luke (S&T-Student)
parents 6651b701 8afc2e55
<button mat-raised-button>
<img src="assets/PickleJar.png" (click)="jarUpgrade()" />
</button>
......@@ -14,6 +16,6 @@
<img src="assets/Reservoir.png" (click)="reservoirUpgrade()" />
</button>
<h4>multiplier: {{ clickMulti }}</h4>
<h4>multiplier: {{ accumulatesMulti | async }}</h4>
<!-- Add more buttons for upgrades here, with their own functions -->
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { GamePlayService } from '../game-play.service';
@Component({
selector: 'app-accumulators',
......@@ -6,25 +7,25 @@ import { Component } from '@angular/core';
styleUrls: ['./accumulator.component.scss'],
})
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.incrementsClicksVal;
readonly accumulatesMulti = this.service.accumulatesVal;
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));
}
}
<button mat-raised-button (click)="upgrade()">
<h4>
Upgrade
</h4>
</button>
<button mat-raised-button>
<img src="assets/pickle-fingers.png" (click)="increment()" />
<img [src]="upgradeLevel" (click)="increment()" />
</button>
<h4># of Clicks: {{ totalClicks }}</h4>
<h4># of Clicks: {{ totalClicks | async }}</h4>
\ No newline at end of file
......@@ -12,4 +12,4 @@ img {
h4 {
text-align: center;
}
}
\ No newline at end of file
import { Component } from '@angular/core';
import { GamePlayService } from '../game-play.service';
@Component({
selector: 'app-click',
......@@ -6,28 +7,65 @@ import { Component } from '@angular/core';
styleUrls: ['./click.component.scss'],
})
export class ClickComponent {
totalClicks = 0;
clickMulti = 1;
readonly totalClicks = this.service.pickleCount;
//readonly totalClicks = this.service.getPickles();
readonly clickMulti = this.service.incrementsClicksVal;
upgradeLevel = 'assets/Hamburger.png'
upgradeList = ['assets/Hamburger.png', 'assets/BabyDill.png', 'assets/Spear.png', 'assets/Pickle.png', 'assets/GoldenPickle.png'];
upgradePrices = [1, 5000, 50000, 500000, 5000000];
upgradeCount = 1;
constructor() {}
constructor(private service: GamePlayService) { }
increment() {
this.totalClicks += this.clickMulti;
}
upgrade() {
jarUpgrade() {
this.clickMulti += 5;
}
if (!(this.service.checkEnough(this.upgradePrices[this.upgradeCount - 1]))) {
barrelUpgrade() {
this.clickMulti += 50;
}
this.service.pickleUpgrade(this.upgradePrices[this.upgradeCount]).catch((err) => console.log(err));
// changing next upgrade picture
this.upgradeLevel = this.upgradeList[this.upgradeCount++];
/*
// buying upgrade
this.pickles.next(this.pickles.value - this.upgradePrices[this.upgradeCount]);
// changing next upgrade picture
this.upgradeLevel = this.upgradeList[this.upgradeCount++];
// upgrade taking effect
this.service.pickleUpgrade.catch((err) => console.log(err));
*/
}
/*
while (this.upgradeCount < this.upgradeList.length) {
if (this.totalClicks >= this.upgradePrices[this.upgradeCount]) {
this.service.pickleUpgrade(this.upgradePrices[this.upgradeCount]).catch((err) => console.log(err));
// changing next upgrade picture
this.upgradeLevel = this.upgradeList[this.upgradeCount++];
/*
// buying upgrade
this.pickles.next(this.pickles.value - this.upgradePrices[this.upgradeCount]);
// changing next upgrade picture
this.upgradeLevel = this.upgradeList[this.upgradeCount++];
// upgrade taking effect
this.service.pickleUpgrade.catch((err) => console.log(err));
}
}
*/
siloUpgrade() {
this.clickMulti += 500;
}
reservoirUpgrade() {
this.clickMulti += 5000;
increment() {
this.service.increment().catch((err) => console.log(err));
}
}
......@@ -10,4 +10,4 @@ const cmsRoutes: Routes = [{ path: '', component: ClickComponent }];
imports: [CommonModule, RouterModule.forChild(cmsRoutes)],
exports: [ClickComponent],
})
export class ClickModule {}
export class ClickModule { }
<!-- Need to create two columns - one with assets, one with cookie clicker stuff -->
<div class="row">
<div class="column">
<mat-card class="title">
......
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { GamePlayService } from './game-play.service';
@Component({
selector: 'app-game-play',
templateUrl: './game-play.component.html',
styleUrls: ['./game-play.component.scss'],
})
export class GamePlayComponent {}
export class GamePlayComponent implements OnInit {
constructor(private service: GamePlayService) {}
ngOnInit() {
this.service.accumulate().catch((err) => console.log(err));
}
}
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class GamePlayService {
private readonly pickles = new BehaviorSubject<number>(0);
readonly pickleCount = this.pickles.asObservable();
private readonly incrementsClicks = new BehaviorSubject<number>(1);
readonly incrementsClicksVal = this.incrementsClicks.asObservable();
private readonly accumulates = new BehaviorSubject<number>(0);
readonly accumulatesVal = this.accumulates.asObservable();
constructor() {
console.log('Game service activated');
}
async increment() {
this.pickles.next(this.pickles.value + this.incrementsClicks.value);
}
async checkEnough(price) {
if (this.pickleCount >= price) {
return true;
}
return false;
}
/*
async getPickles() {
return this.pickles.value;
}
*/
async pickleUpgrade(cost) {
this.incrementsClicks.next(this.incrementsClicks.value * 10);
// buying upgrade
this.pickles.next(this.pickles.value - cost);
}
async jarUpgrade() {
if (this.pickles.value >= 5) {
this.accumulates.next(this.accumulates.value + 5);
this.pickles.next(this.pickles.value - 5);
}
// need to add else to throw error
}
async barrelUpgrade() {
if (this.pickles.value >= 50) {
this.accumulates.next(this.accumulates.value + 50);
this.pickles.next(this.pickles.value - 50);
}
}
async siloUpgrade() {
if (this.pickles.value >= 500) {
this.accumulates.next(this.accumulates.value + 500);
this.pickles.next(this.pickles.value - 500);
}
}
async reservoirUpgrade() {
if (this.pickles.value >= 5000) {
this.accumulates.next(this.accumulates.value + 5000);
this.pickles.next(this.pickles.value - 5000);
}
}
async accumulate() {
const accumulator = setInterval(() => {
this.pickles.next(this.pickles.value + this.accumulates.value);
if (this.pickles.value >= 100000000) {
clearInterval(accumulator);
}
}, 3000);
}
}
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