Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nana;
- public class Java_Deck{
- // Name of the player (remains empty for tostring method unless indicated)
- private String player_name;
- // What team the player is in
- private String team;
- // Name of the card, self explanatory
- private String name_of_card;
- // Common, Uncommon, Rare, Legendary
- private String type_of_card;
- // Name of deck, we have freedom to put what we want here
- private String deck_name;
- // Elixir of card (idk why we need to have this, we don't even use this tbh)
- private double elixir;
- // health points of the CURRENT card
- private double health_points;
- // Damage of the CURRENT card
- private double damage;
- // Total hitpoints, initialized as zero
- private double t_hp = 0;
- // Total damage, initialized as zero
- private double t_dam = 0;
- // Card count, used for average calculation
- private double card_count = 1;
- // isHealth boolean used for type of toString method
- private boolean isHealth = false;
- //This is for the changing the deck by changing two cards
- // Constructor, DONT TOUCH THIS UNLESS YOU HAVE TO
- public Java_Deck(String deck_namel, String p_name, String t, String n, String ty, double eli, double he, double dam){
- deck_name = deck_namel;
- player_name = p_name;
- team = t;
- name_of_card = n;
- type_of_card = ty;
- elixir = eli;
- health_points = he;
- damage = dam;
- t_hp = he;
- t_dam = dam;
- }
- // Method to add card given parameters
- void addCard(String new_name, String new_type, double new_health, double new_elixir, double new_damage){
- name_of_card = new_name;
- type_of_card = new_type;
- t_hp = t_hp + new_health;
- t_dam = t_dam + new_damage;
- health_points = new_health;
- damage = new_damage;
- card_count += 1;
- }
- // Print Health and Damage methods, don't touch this
- String printHealth(){
- return " The average health of " + deck_name + " is: " + (t_hp/card_count);
- }
- String printDamage(){
- return " The average damage of " + deck_name + " is: " + (t_dam/card_count);
- }
- //Extra credit, since we don't really need current card health and damage, might as well add this for some extra points :)
- String recent_card_stats(Java_Deck deck){
- return ("The most recent added card has the following stats: " + health_points + " hit points, " + damage + " damage, and " + elixir + " elixir points." + "/n" + "The name of the card is " + name_of_card + " and it is of " + type_of_card + " rarity.");
- }
- // What deck Colton will play, based on the decks given in the parameter (Yes, there are better ways to do this, but spaguetti code will do the job)
- void Colton_choice(String player_namel, String team_name, Java_Deck deck1, Java_Deck deck2, Java_Deck deck3, Java_Deck deck4){
- if (deck1.t_hp > deck2.t_hp && deck1.t_hp > deck3.t_hp && deck1.t_hp >deck4.t_hp){
- deck1.player_name = player_namel;
- deck1.team = team_name;
- deck1.isHealth = true;
- }
- else if (deck2.t_hp > deck3.t_hp && deck2.t_hp > deck4.t_hp){
- deck2.player_name = player_namel;
- deck2.team = team_name;
- deck2.isHealth = true;
- }
- else if (deck3.t_hp > deck4.t_hp){
- deck3.player_name = player_namel;
- deck3.team = team_name;
- deck3.isHealth = true;
- }
- else{
- deck4.player_name = player_namel;
- deck4.team = team_name;
- deck4.isHealth = true;
- }
- }
- // Same as the method before, but this time for player Cuchii (what a weird name)
- void Cuchii_choice(String player_namel,String team_name, Java_Deck deck1, Java_Deck deck2, Java_Deck deck3, Java_Deck deck4){
- if (deck1.t_dam > deck2.t_dam && deck1.t_dam > deck3.t_dam && deck1.t_dam >deck4.t_dam){
- deck1.player_name = player_namel;
- deck1.team = team_name;
- deck1.isHealth = false;
- }
- else if (deck2.t_dam > deck3.t_dam && deck2.t_dam > deck4.t_dam){
- deck2.player_name = player_namel;
- deck2.team = team_name;
- deck2.isHealth = false;
- }
- else if (deck3.t_dam > deck4.t_dam){
- deck3.player_name = player_namel;
- deck3.team = team_name;
- deck3.isHealth = false;
- }
- else{
- deck4.player_name = player_namel;
- deck4.team = team_name;
- deck4.isHealth = false;
- }
- }
- //Method for changing the cards in the deck (or rather, subtracting)
- void changeCards(int oldhel, int olddmg, int oldhel2, int olddmg2)
- {
- t_hp -= oldhel;
- t_hp -= oldhel2;
- t_dam -= olddmg;
- t_dam -= olddmg2;
- }
- // toString method (PLEASE DO NOT TOUCH THIS UNLESS YOU ABSOLUTELY NEED TO)
- public String toString() {
- if (player_name != ""){
- if (isHealth == true){
- return "Player " + player_name + " in team " + team + " playing will choose in the CRL " + deck_name + " with a hit point average of " + (t_hp/card_count);
- }
- else{
- return "Player " + player_name + " in team " + team + " will choose in the CRL " + deck_name + " with a damage average of " + (t_dam/card_count);
- }
- }
- else{
- return deck_name + " with a hit point average of " + (t_hp/card_count) + " and a damage average of " + (t_dam/card_count) + " will not be played by any player in the CRL.";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement