-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypeData.js
More file actions
96 lines (92 loc) · 3.33 KB
/
Copy pathtypeData.js
File metadata and controls
96 lines (92 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
export const PokemonTypes = Object.freeze({
NORMAL: "normal",
FIRE: "fire",
WATER: "water",
ELECTRIC: "electric",
GRASS: "grass",
ICE: "ice",
FIGHTING: "fighting",
POISON: "poison",
GROUND: "ground",
FLYING: "flying",
PSYCHIC: "psychic",
BUG: "bug",
ROCK: "rock",
GHOST: "ghost",
DRAGON: "dragon",
DARK: "dark",
STEEL: "steel",
FAIRY: "fairy",
});
export const typesOrder = Object.freeze([
PokemonTypes.NORMAL,
PokemonTypes.FIRE,
PokemonTypes.WATER,
PokemonTypes.ELECTRIC,
PokemonTypes.GRASS,
PokemonTypes.ICE,
PokemonTypes.FIGHTING,
PokemonTypes.POISON,
PokemonTypes.GROUND,
PokemonTypes.FLYING,
PokemonTypes.PSYCHIC,
PokemonTypes.BUG,
PokemonTypes.ROCK,
PokemonTypes.GHOST,
PokemonTypes.DRAGON,
PokemonTypes.DARK,
PokemonTypes.STEEL,
PokemonTypes.FAIRY,
]);
export const typeColors = {
[PokemonTypes.NORMAL]: "#A8A878",
[PokemonTypes.FIRE]: "#F08030",
[PokemonTypes.WATER]: "#6890F0",
[PokemonTypes.ELECTRIC]: "#F8D030",
[PokemonTypes.GRASS]: "#78C850",
[PokemonTypes.ICE]: "#98D8D8",
[PokemonTypes.FIGHTING]: "#C03028",
[PokemonTypes.POISON]: "#A040A0",
[PokemonTypes.GROUND]: "#E0C068",
[PokemonTypes.FLYING]: "#A890F0",
[PokemonTypes.PSYCHIC]: "#F85888",
[PokemonTypes.BUG]: "#A8B820",
[PokemonTypes.ROCK]: "#B8A038",
[PokemonTypes.GHOST]: "#705898",
[PokemonTypes.DRAGON]: "#7038F8",
[PokemonTypes.DARK]: "#705848",
[PokemonTypes.STEEL]: "#B8B8D0",
[PokemonTypes.FAIRY]: "#EE99AC",
};
export const effectivenessMatrix = [
// normal, fire, water, electric, grass, ice, fighting, poison, ground, flying, psychic, bug, rock, ghost, dragon, dark, steel, fairy
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.5, 0, 1, 1, 0.5, 1], // normal
[1, 0.5, 0.5, 1, 2, 2, 1, 1, 1, 1, 1, 2, 0.5, 1, 0.5, 1, 2, 1], // fire
[1, 2, 0.5, 1, 0.5, 1, 1, 1, 2, 1, 1, 1, 2, 1, 0.5, 1, 1, 1], // water
[1, 1, 2, 0.5, 0.5, 1, 1, 1, 0, 2, 1, 1, 1, 1, 0.5, 1, 1, 1], // electric
[1, 0.5, 2, 1, 0.5, 1, 1, 0.5, 2, 0.5, 1, 0.5, 2, 1, 0.5, 1, 0.5, 1], // grass
[1, 0.5, 0.5, 1, 2, 0.5, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 0.5, 1], // ice
[2, 1, 1, 1, 1, 2, 1, 0.5, 1, 0.5, 0.5, 0.5, 2, 0, 1, 2, 2, 0.5], // fighting
[1, 1, 1, 1, 2, 1, 1, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1, 1, 0, 2], // poison
[1, 2, 1, 2, 0.5, 1, 1, 2, 1, 0, 1, 0.5, 2, 1, 1, 1, 2, 1], // ground
[1, 1, 1, 0.5, 2, 1, 2, 1, 1, 1, 1, 2, 0.5, 1, 1, 1, 0.5, 1], // flying
[1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 0.5, 1, 1, 1, 1, 0, 0.5, 1], // psychic
[1, 0.5, 1, 1, 2, 1, 0.5, 0.5, 1, 0.5, 2, 1, 1, 0.5, 1, 2, 0.5, 0.5], // bug
[1, 2, 1, 1, 1, 2, 0.5, 1, 0.5, 2, 1, 2, 1, 1, 1, 1, 0.5, 1], // rock
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 0.5, 1, 1], // ghost
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 0.5, 0], // dragon
[1, 1, 1, 1, 1, 1, 0.5, 1, 1, 1, 2, 1, 1, 2, 1, 0.5, 1, 0.5], // dark
[1, 0.5, 0.5, 0.5, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0.5, 2], // steel
[1, 0.5, 1, 1, 1, 1, 2, 0.5, 1, 1, 1, 1, 1, 1, 2, 2, 0.5, 1], // fairy
];
/**
*
* @param {PokemonTypes} attackingType
* @param {PokemonTypes | {PokemonTypes, PokemonTypes}} defendingType
* @returns {number}
*/
export function getEffectiveness(attackingType, defendingType) {
const attackingIndex = typesOrder.indexOf(attackingType);
const defendingIndex = typesOrder.indexOf(defendingType);
return effectivenessMatrix[attackingIndex][defendingIndex];
}