Skip to content

Commit

Permalink
Merge pull request #285 from KComrade53/kc/pets-getter
Browse files Browse the repository at this point in the history
Change PetCollection.pets to be a getter
  • Loading branch information
tonybaloney authored Oct 21, 2022
2 parents 7e19282 + bbd115b commit 0a589f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/panel/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function calculateFloor(size: PetSize, theme: Theme): number {

function handleMouseOver(e: MouseEvent) {
var el = e.currentTarget as HTMLDivElement;
allPets.pets().forEach((element) => {
allPets.pets.forEach((element) => {
if (element.collision === el) {
if (!element.pet.canSwipe()) {
return;
Expand Down Expand Up @@ -185,7 +185,7 @@ export function saveState(stateApi?: VscodeStateApi) {
var state = new PetPanelState();
state.petStates = new Array();

allPets.pets().forEach((petItem) => {
allPets.pets.forEach((petItem) => {
state.petStates?.push({
petName: petItem.pet.name(),
petColor: petItem.color,
Expand Down Expand Up @@ -420,7 +420,7 @@ export function petPanelApp(
case 'throw-ball':
resetBall();
throwBall();
allPets.pets().forEach((petEl) => {
allPets.pets.forEach((petEl) => {
if (petEl.pet.canChase()) {
petEl.pet.chase(ballState, canvas);
}
Expand All @@ -444,7 +444,7 @@ export function petPanelApp(
break;

case 'list-pets':
var pets = allPets.pets();
var pets = allPets.pets;
stateApi?.postMessage({
command: 'list-pets',
text: pets
Expand All @@ -457,7 +457,7 @@ export function petPanelApp(
break;

case 'roll-call':
var pets = allPets.pets();
var pets = allPets.pets;
// go through every single
// pet and then print out their name
pets.forEach((pet) => {
Expand Down
4 changes: 2 additions & 2 deletions src/panel/pets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class PetElement {
}

export interface IPetCollection {
pets(): Array<PetElement>;
pets: Array<PetElement>;
push(pet: PetElement): void;
reset(): void;
seekNewFriends(): string[];
Expand All @@ -62,7 +62,7 @@ export class PetCollection implements IPetCollection {
this._pets = new Array(0);
}

pets() {
public get pets() {
return this._pets;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/panel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ suite('Pets Test Suite', () => {
assert.equal(firstPet.petType, petType);
assert.equal(firstPet.petColor, PetColor.black);

const createdPets = panel.allPets.pets();
const createdPets = panel.allPets.pets;
assert.notEqual(createdPets.at(0), undefined);

assert.equal(createdPets.at(0)?.color, PetColor.black);
Expand Down

0 comments on commit 0a589f1

Please sign in to comment.