Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active July 10, 2023 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NyaGarcia/7c8db3bcee4fc168f829e9ae78698e5e to your computer and use it in GitHub Desktop.
Save NyaGarcia/7c8db3bcee4fc168f829e9ae78698e5e to your computer and use it in GitHub Desktop.
Ngbytes Standalone Pokemon Service
import { Injectable } from '@angular/core';
export interface Pokemon {
id: string;
name: string;
type: string;
imageUrl: string;
description: string;
defense: number;
attack: number;
}
@Injectable({
providedIn: 'root',
})
export class PokemonService {
constructor() {}
private pokemon: Pokemon[] = [
{
id: "1",
name: 'Charmander',
type: 'Fire',
imageUrl: 'assets/pokemon/Charmander.png',
description:
'Charmander is a small, bipedal, dinosaur like Pokémon. Most of its body is colored orange, while its underbelly is a light yellow color. Charmander, along with all of its evolved forms, has a flame that is constantly burning on the end of its tail. ',
defense: 43,
attack: 52,
},
{
id: "2",
name: 'Bulbasaur',
type: 'Grass',
imageUrl: 'assets/pokemon/Bulbasaur.png',
description:
'Known as the Seed Pokémon, Bulbasaur resembles a small, squating dinosaur that walks on four legs and has a large plant bulb on its back. It also has large red eyes and very sharp teeth. Its skin is a light turquoise color with dark green spots. Its most notable feature, however, is the aforementioned bulb on its back, which as the Pokédex states, was planted on it at birth. ',
defense: 49,
attack: 49,
},
{
id: "3",
name: 'Squirtle',
type: 'Water',
imageUrl: 'assets/pokemon/Squirtle.png',
description:
"Squirtle is a small, light-blue Pokémon with an appearance similar to a turtle. With its aerodynamic shape and grooved surface, Squirtle's shell helps it wade through the water very quickly. It also offers protection in battle. Like turtles, Squirtle has a shell that covers its body with holes that allow its limbs, tail, and head to be exposed. Unlike a turtle, Squirtle is ordinarily bipedal. ",
defense: 65,
attack: 48,
},
{
id: "4",
name: 'Pikachu',
type: 'Electric',
imageUrl: 'assets/pokemon/Pikachu.png',
description:
"Pikachu are small, and cute mouse-like Pokémon. They are almost completely covered by yellow fur. They have long yellow ears that are tipped with black. A Pikachu's back has two brown stripes, and its large tail is notable for being shaped like a lightning bolt, yet its brown tip is almost always forgotten. Pikachu have short arms with five tiny fingers on forehands and three sharp fingers on their hind legs. On its cheeks are two circle-shaped red pouches used for storing electricity.",
defense: 55,
attack: 40,
},
{
id: "5",
name: 'Vulpix',
type: 'Fire',
imageUrl: 'assets/pokemon/Vulpix.png',
description:
"Vulpix are fox-like Pokémon with reddish-brown fur. Vulpix's most distinctive feature is its six orange tails that are curled at the tips. According to the Pokédex, when it is born, Vulpix possesses one snow white tail that eventually splits into many tails as it grows older. On the top of its head, Vulpix has a tuft of bright orange fur that curls into three rolls at the top and falls over its forehead at the bottom. Its underbelly is cream-colored and slightly plump.",
defense: 41,
attack: 40,
},
];
getAll(): Pokemon[] {
return this.pokemon;
}
get(id: number): Pokemon {
return this.pokemon.find((pokemon) => pokemon.id === id) || this.pokemon[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment