Skip to content

Commit

Permalink
Add fox as spawnable pet
Browse files Browse the repository at this point in the history
  • Loading branch information
nikelasi committed Dec 10, 2022
1 parent 59d18b9 commit 46b3ce2
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 2 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@
"gray",
"purple",
"red",
"white"
"white",
"orange"
],
"default": "brown",
"description": "Pet color",
Expand All @@ -177,7 +178,8 @@
"rubber-duck",
"snake",
"totoro",
"zappy"
"zappy",
"fox"
],
"default": "cat",
"description": "Pet type",
Expand Down
2 changes: 2 additions & 0 deletions src/common/names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CLIPPY_NAMES } from '../panel/pets/clippy';
import { COCKATIEL_NAMES } from '../panel/pets/cockatiel';
import { CRAB_NAMES } from '../panel/pets/crab';
import { DOG_NAMES } from '../panel/pets/dog';
import { FOX_NAMES } from '../panel/pets/fox';
import { MOD_NAMES } from '../panel/pets/mod';
import { ROCKY_NAMES } from '../panel/pets/rocky';
import { DUCK_NAMES } from '../panel/pets/rubberduck';
Expand All @@ -28,6 +29,7 @@ export function randomName(type: PetType): string {
[PetType.zappy]: ZAPPY_NAMES,
[PetType.rocky]: ROCKY_NAMES,
[PetType.cockatiel]: COCKATIEL_NAMES,
[PetType.fox]: FOX_NAMES,
} as Record<PetType, ReadonlyArray<string>>
)[type] ?? CAT_NAMES;

Expand Down
4 changes: 4 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const enum PetColor {
purple = 'purple',
red = 'red',
white = 'white',
orange = 'orange',
null = 'null',
}

Expand All @@ -23,6 +24,7 @@ export const enum PetType {
snake = 'snake',
totoro = 'totoro',
zappy = 'zappy',
fox = 'fox',
null = 'null',
}

Expand Down Expand Up @@ -82,6 +84,7 @@ export const ALL_PETS = [
PetType.snake,
PetType.totoro,
PetType.zappy,
PetType.fox,
];
export const ALL_COLORS = [
PetColor.black,
Expand All @@ -92,6 +95,7 @@ export const ALL_COLORS = [
PetColor.purple,
PetColor.red,
PetColor.white,
PetColor.orange,
PetColor.null,
];
export const ALL_SCALES = [PetSize.nano, PetSize.medium, PetSize.large];
Expand Down
5 changes: 5 additions & 0 deletions src/panel/pets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { RubberDuck } from './pets/rubberduck';
import { Snake } from './pets/snake';
import { Totoro } from './pets/totoro';
import { Zappy } from './pets/zappy';
import { Fox } from './pets/fox';
import { IPetType } from './states';

export class PetElement {
Expand Down Expand Up @@ -195,6 +196,8 @@ export function createPet(
return new Rocky(...standardPetArguments, PetSpeed.still);
case PetType.cockatiel:
return new Cockatiel(...standardPetArguments, PetSpeed.normal);
case PetType.fox:
return new Fox(...standardPetArguments, PetSpeed.veryFast);
default:
throw new InvalidPetException("Pet type doesn't exist");
}
Expand Down Expand Up @@ -226,6 +229,8 @@ export function availableColors(petType: PetType): PetColor[] {
return Rocky.possibleColors;
case PetType.cockatiel:
return Cockatiel.possibleColors;
case PetType.fox:
return Fox.possibleColors;
default:
throw new InvalidPetException("Pet type doesn't exist");
}
Expand Down
191 changes: 191 additions & 0 deletions src/panel/pets/fox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import { PetColor } from '../../common/types';
import { BasePetType } from '../basepettype';
import { States } from '../states';

export class Fox extends BasePetType {
label = 'fox';
static possibleColors = [PetColor.orange];
sequence = {
startingState: States.sitIdle,
sequenceStates: [
{
state: States.sitIdle,
possibleNextStates: [
States.lie,
States.walkRight,
States.walkLeft,
States.runRight,
States.runLeft,
],
},
{
state: States.lie,
possibleNextStates: [
States.walkRight,
States.walkLeft,
States.runRight,
States.runLeft,
],
},
{
state: States.walkRight,
possibleNextStates: [
States.sitIdle,
States.walkLeft,
States.runLeft,
],
},
{
state: States.walkLeft,
possibleNextStates: [
States.sitIdle,
States.walkRight,
States.runRight,
],
},
{
state: States.runRight,
possibleNextStates: [
States.lie,
States.sitIdle,
States.walkLeft,
States.runLeft,
],
},
{
state: States.runLeft,
possibleNextStates: [
States.lie,
States.sitIdle,
States.walkRight,
States.runRight,
],
},
{
state: States.chase,
possibleNextStates: [States.idleWithBall],
},
{
state: States.idleWithBall,
possibleNextStates: [
States.lie,
States.walkRight,
States.walkLeft,
States.runRight,
States.runLeft,
],
},
],
};
get emoji(): string {
return '🦊';
}
get hello(): string {
return `fox says hello`;
}
}

export const FOX_NAMES: ReadonlyArray<string> = [
'Arizona',
'Frankie',
'Rosy',
'Cinnamon',
'Ginger',
'Todd',
'Rocky',
'Felix',
'Sandy',
'Archie',
'Flynn',
'Foxy',
'Elmo',
'Ember',
'Hunter',
'Otto',
'Sonic',
'Amber',
'Maroon',
'Spark',
'Sparky',
'Sly',
'Scout',
'Penny',
'Ash',
'Rose',
'Apollo',
'Chili',
'Blaze',
'Radish',
'Scarlett',
'Juliet',
'Goldie',
'Rooney',
'Paprika',
'Alpine',
'Rusty',
'Maple',
'Vixen',
'David',
'Apricot',
'Claire',
'Wilma',
'Copper',
'Pepper',
'Crimson',
'Ariel',
'Arvi',
'George',
'Eva',
'Fuzzy',
'Russell',
'Rufus',
'Mystic',
'Leopold',
'Scully',
'Ferris',
'Robin',
'Zorro',
'Scarlet',
'Comet',
'Rowan',
'Jake',
'Hope',
'Molly',
'Mars',
'Apple',
'Geneva',
'Redford',
'Chestnut',
'Evelyn',
'Red',
'Aurora',
'Agniya',
'Fitz',
'Crispin',
'Sunny',
'Autumn',
'Bridget',
'Ruby',
'Iris',
'Pumpkin',
'Rose',
'Rosie',
'Vesta',
'Adolf',
'Lava',
'Conan',
'Flame',
'Oswald',
'Tails',
'Chester',
'Jasper',
'Finch',
'Scarlet',
'Chewy',
'Finnick',
'Biscuit',
'Prince Harry',
'Loki',
'Pip',
'Pippin',
];

0 comments on commit 46b3ce2

Please sign in to comment.