So I'm creating a card game and need some help with the best way to structure my classes. Let's use Hearthstone as an example though because lots of people are familiar with it. (No I'm not actually re-creating Hearthstone but many of the structural ideas are common among many card games)
Firstly, We have these
[Card] - has a name, cost, class, rarity, set, image, text, effects [Minion] - a type of card which also has Attack and Health [Spell] - a type of card [Weapon] - a type of card which also has Attack and Durability
Those attributes need to be accessed regularly (getAttack() etc) What's the best way to represent this hierarchy in Java classes? I've heard inheritance (Minion extends Card, Spell extends Card, Weapon extends Card) is generally frowned upon. But I also can't see the purpose in making Card an interface. Should I use one of these options anyway or is there a nicer alternative?
In a game of Hearthstone each player has a hand, deck, "graveyard", "board" (where minions are played), weapon slot and active Secrets. These are all arrays of Cards although "board" can only contain minions and the weapon slot can only contain a single weapon.
[Card in hand] - has a "base" Card and may have its attributes modified (cost, attack, health) by an effect [Minion on board] - has a "base" Minion, current Health, may be Divine Shielded/Stealthed, may have its attributes modified by effects [Weapon equipped] - has a "base" Weapon, current Durability, may have its attributes modified by effects [Active Secret] - has a "base" Spell and a trigger (something happening that causes it to activate)
Naturally cards can move around between these zones. My original idea is to have a separate class for each zone with an instance variable "Card basecard" and when a card moves from eg hand to board, remove the Card in Hand from the hand array and place a Minion on board in the board array. Again, is there a nicer alternative?
Cards have effects. There are different kinds of effects
[Battlecry, Deathrattle] - something happens when the minion is played or dies [Trigger] - something happens when a specific "trigger" affects the minion while it's on board (eg it takes damage like Acolyte of Pain) [Continuous] - the minion constantly affects the game in some way while it's on the board (eg buffs other minions like Dire Wolf Alpha) [Modifier] - the minion constantly modifies its own attributes in some way (eg lowers cost for each other card in hand like Mountain Giant)
Each Card has an array of Effects. But different effects require different methods; Trigger effects have a Trigger, Battlecries often have a "target" which may only include minions with certain attributes, continuous effects don't "do something" at a particular time they just need to be checked constantly by other objects etc
Is there a good way to represent THIS hierarchy? Again, my first thought is to just use inheritance but it gets messy. I know it seems like a big ask but is there a "nice" way to do something like this?
Create an HTML file AddCookies.html which contains four text boxes .When user enters the values in these text boxes and press the submit button, the values will be sent to AddCookies.java servlet and get saved in cookies.
Anyone Help me to explain how does this code works DataInputStream in= new DataInputStream(new FileInputStream(steg.getFile())); in.read(byteArray, 0, fileSize); in.close(); Cipher cipher= Cipher.getInstance("DES"); cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(password.substring(0, 8).getBytes(), "DES")); byteArray= cipher.doFinal(byteArray);
it's a forum another person had answered for this question. so if u know programming u can explain ,,,, how does this code process... it's Audio steganography using LSB technique by this u wouls have answered.