Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Pokéconsole Trial Libraries
- /*
- Types:
- 1 = Normal
- 2 = Fighting
- 3 = Flying
- 4 = Poison
- 5 = Ground
- 6 = Rock
- 7 = Bug
- 8 = Ghost
- 9 = Steel
- 10 = Fire
- 11 = Water
- 12 = Grass
- 13 = Electric
- 14 = Psychic
- 15 = Ice
- 16 = Dragon
- 17 = Dark
- 18 = Fairy
- */
- /*
- Stat Arrays:
- 1 = hp
- 2 = attack
- 3 = defense
- 4 = special attack
- 5 = special defense
- 6 = speed
- */
- /*
- attack Kinds:
- 0 = Effect
- 1 = Physical
- 2 = Special
- */
- /*
- non-Volatile Status Conditions
- 1 = Burn
- 2 = Poison
- 3 = Frozen
- 4 = Paralysis
- 5 = Badly Poisoned
- */
- var None = 0;
- var Normal = 1;
- var Fighting = 2;
- var Flying = 3;
- var Poison = 4;
- var Ground = 5;
- var Rock = 6;
- var Bug = 7;
- var Ghost = 8;
- var Steel = 9;
- var Fire = 10;
- var Water = 11;
- var Grass = 12;
- var Electric = 13;
- var Psychic = 14;
- var Ice = 15;
- var Dragon = 16;
- var Dark = 17;
- var Fairy = 18;
- //attack Class declaration
- function attack(attackName, attackType, attackKind, power, accuracy, pp){
- this.attackName = attackName;
- this.attackType = attackType;
- this.attackKind = attackKind;
- this.power = power;
- this.accuracy = accuracy;
- this.pp = pp;
- }
- //attack Declaration
- var ember = new attack("Ember", Fire, 1, 50, 1, 35);
- var tackle = new attack("Tackle", Normal, 1, 50, 1, 35);
- //Pokémon Class declaration
- function pokemon(pokemonName, pokemonType1, pokemonType2, ability, atk, def, spAtk, spDef, spd, hp, level, nonVolStat, move_1, move_2, move_3, move_4){
- this.pokemonName = pokemonName;
- this.pokemonType = [pokemonType1, pokemonType2];
- this.ability = ability;
- this.baseStats = [hp, atk, def, spAtk, spDef, spd];
- this.affectedStats = [hp, atk, def, spAtk, spDef, spd];
- this.level = level;
- this.nonVolStat = nonVolStat;
- this.moveSet = [move_1, move_2, move_3, move_4];
- this.suffernonVolStat = function(){
- var hpLoss = undefined;
- if (this.nonVolStat === 1){
- console.log("Suffering from Burn!");
- this.affectedStats[0] = Math.round(this.affectedStats[0] - (this.baseStats[0]/8));
- hpLoss = (this.baseStats[0]/8);
- console.log("Lost " + hpLoss + "HP");
- console.log(this.pokemonName + " has " + this.affectedStats[0] + "HP remaining.");
- this.baseStats[1] = this.baseStats[1]/2;
- }
- else if (this.nonVolStat === 2){
- console.log("Suffering from Poison!");
- hpLoss = Math.round(this.baseStats[0] - (this.baseStats[0]/8));
- this.baseStats[0] = Math.round(this.baseStats[0] - (this.baseStats[0]/8));
- console.log("Lost " + hpLoss + "HP");
- console.log(this.pokemonName + " has" + this.baseStats[0] + "HP remaining.");
- }
- else if (this.nonVolStat === 3){
- }
- }
- this.useAttack = function(target, atkName){
- var attackDmg = undefined;
- if (atkName === this.moveSet[0] || this.moveSet[1] || this.moveSet[2] || this.moveSet[3]){
- if (atkName.attackKind === 1){
- attackDmg = damage(this.level, this.affectedStats[1], target.affectedStats[2], this.affectedStats[5], atkName.power, target);
- }
- else{
- attackDmg = damage(this.level, this.affectedStats[3], target.affectedStats[4], this.affectedStats[5], atkName.power);
- }
- console.log(this.pokemonName + " used " + atkName.attackName);
- var typeReading = typeEff(atkName.attackType, target.pokemonType[0], target.pokemonType[1]);
- switch (typeReading){
- case 2:
- console.log("It was very effective!");
- break;
- case .5:
- console.log("It was not very effective...");
- break;
- case 4:
- console.log("It was super effective!");
- break;
- }
- console.log(Math.round(attackDmg) + " damage dealt!");
- target.affectedStats[0] = target.affectedStats[0] - Math.round(attackDmg);
- return attackDmg;
- }
- }
- this.checkAbility = function(user){
- if (user.ability === "Blaze"){
- if (user.affectedStats[0] < (user.baseStats[0]/3) && user.moveSet[0].attackType === Fire){
- user.moveSet[0].power = user.moveSet[0].power*1.5;
- }
- }
- }
- this.checkFaint = function(){
- isAbleToBattle = undefined;
- if (this.affectedStats[0] <= 0){
- isAbleToBattle = false;
- console.log(this.pokemonName + " is no longer able to battle!");
- }
- else{
- isAbleToBattle = true;
- }
- return isAbleToBattle;
- }
- }
- //Pokemon Declaration
- var charmander = new pokemon("Charmander", 10, 0, "Blaze", 223, 81, 116, 94, 251, 400, 100, 1, ember, "None", "None", "None");
- var squirtle = new pokemon("Squirtle", 11, 0, "Torrent", 60, 251, 94, 249, 181, 198, 100, 0, tackle, "None", "None", "None");
- //Random number function
- function getRandom(min, max){
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- //Type Effectivity function
- function typeEff(mType, tType, tType2){
- var typeEffectivity = undefined;
- if (mType === Water && tType === Fire || tType2 === Fire){
- typeEffectivity = 2;
- }
- else if (mType === Fire && tType === Water || tType2 === Water){
- typeEffectivity = .5;
- }
- else if (mType === Fire && tType === Grass && tType2 === Steel){
- typeEffectivity = 4
- }
- return typeEffectivity;
- }
- //Modifier Function
- function modifier(usrSpd, atkType, trgtType1, trgtType2){
- //Type effect determinating
- var typeMod = typeEff(atkType, trgtType1, trgtType1);
- //Critical Hit determinating
- var crit = undefined;
- var randCrit = getRandom(0, 255);
- var t = usrSpd/2;
- var p = t/256;
- if (randCrit < t){
- crit = 2;
- console.log("Critical Hit!");
- }
- else{
- crit = 1;
- }
- //STAB determinating
- var stab = undefined;
- if (pokemon.pokemonType === attack.attackType){
- stab = 1.5;
- }
- else{
- stab = 1.0;
- }
- //Random Value Determinating
- var random = getRandom(85, 100) * 0.01;
- var dmgMod = stab * crit * random * typeMod;
- return dmgMod;
- }
- //Damage Function
- function damage(level, usrAtk, opDef, usrSpeed, base, targetName){
- var mod = modifier(usrSpeed, usrAtk.attackType, targetName.pokemonType[0], targetName.pokemonType[1]);
- var dmg = (((2*level+10)/250)*(usrAtk/opDef)*base+2)*mod;
- return dmg;
- }
- if(squirtle.nonVolStat != 0){
- squirtle.suffernonVolStat();
- }
- squirtle.checkAbility(squirtle);
- squirtle.useAttack(charmander, tackle);
- console.log("---------------");
- if(charmander.nonVolStat !=0){
- charmander.suffernonVolStat();
- }
- charmander.checkAbility(charmander);
- charmander.useAttack(squirtle, ember);
- console.log("---------------");
- console.log("Squirtle has " + squirtle.affectedStats[0] + "HP remaining.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement