Skip to content

Instantly share code, notes, and snippets.

@HoeenCoder
Created January 6, 2020 18:33
Show Gist options
  • Save HoeenCoder/80fddec42a73532a08f2137aa7968080 to your computer and use it in GitHub Desktop.
Save HoeenCoder/80fddec42a73532a08f2137aa7968080 to your computer and use it in GitHub Desktop.
PSJS Class Day 11 Assignment
/*
* Safari Zone
*
* The goal of this assignment is to simulate encoutering and catching pokemon in a safari-zone like enviroment.
* Unlike the safari zones of gen 3-4, the player will not have bait/rocks/mud to throw, the player will simply
* throw a pokeball. When checking if the pokemon is caught, your script should be using the same forumula's found
* in the game's themselves. I have linked resources to those in the instructions below.
*
* This assignment focuses on classes and sub classes.
*
* Create a class called Pokemon that represents any pokemon. It should contain any details needed for performing
* calculations needed during an attempt to catch the pokemon. It should also have a method to be called when
* throwing a pokeball at it, and a method to log its details (Species, level, EVs, IVs, nature, shinyness) to the console.
*
* Create at least 3 subclasses of Pokemon. Each of these subclasses should represent a unique pokemon species.
* Override any details from superclass Pokemon as needed to make the pokemon have accurate information (including catch rate/ect).
*
* Run this 20 times:
* - Encounter a random wild pokemon (The possible types to encounter are the subclasses you made).
* -- Each generated pokemon's IVs, level, and nature should vary.
* - Log that the pokemon was encounted including its information (Species, level, EVs, IVs, nature, shinyness).
* - Throw a pokeball at it. (Use any kind you want but no throwing masterballs!).
* - Log the appropirate message to the console based on how many times the pokeball shook.
* -- EG for 1 shake "Aww! It appeared to be caught!"
*
* Forumulas you will need:
* Modified Catch Rate (a): https://bulbapedia.bulbagarden.net/wiki/Catch_rate#Modified_catch_rate_3
* Shake Probability (b): https://bulbapedia.bulbagarden.net/wiki/Catch_rate#Shake_probability_3
* Shake Check information: https://bulbapedia.bulbagarden.net/wiki/Catch_rate#Shake_checks_3
* Calculating Stats (you need HP specifically): https://bulbapedia.bulbagarden.net/wiki/Statistic#In_Generation_III_onward
*
* Bonuses:
* Randomly throw different kind of pokeballs, be sure to use the appropriate ball bonus for each type.
* Make it possible to encounter shiny pokemon - and throw a master ball if one appears.
* Make it possible to encounter a pokemon with a status condition, be sure to apply the appropriate status catch modifier.
*
* Hints:
* DRY (Don't repeat yourself)
* Use google if your unsure how to do something specific in Javascript eg: "How do I take the square root of a number in JS?"
* Did you know you can place class names in arrays and use them to create instances?
* new [Lotad, Lombre, Ludicolo][2](); is the same as new Ludicolo();
*
* If you have questions, feel free to ask. I'm also willing to help you work on the assignment/help you improve your code.
*/
'use strict';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment