Click here to Skip to main content
15,885,141 members
Home / Discussions / Java
   

Java

 
AnswerRe: pc sharing Pin
Richard MacCutchan19-Mar-17 22:57
mveRichard MacCutchan19-Mar-17 22:57 
Questiongui components for multipart email Pin
ashoknailwal18-Mar-17 9:03
ashoknailwal18-Mar-17 9:03 
AnswerRe: gui components for multipart email Pin
Richard MacCutchan18-Mar-17 22:02
mveRichard MacCutchan18-Mar-17 22:02 
GeneralRe: gui components for multipart email Pin
ashoknailwal18-Mar-17 23:32
ashoknailwal18-Mar-17 23:32 
GeneralRe: gui components for multipart email Pin
Richard MacCutchan19-Mar-17 2:42
mveRichard MacCutchan19-Mar-17 2:42 
Questiongetting error RuntimeException: instantiationException: Pin
Member 1305920814-Mar-17 12:08
Member 1305920814-Mar-17 12:08 
AnswerRe: getting error RuntimeException: instantiationException: Pin
Richard MacCutchan14-Mar-17 21:51
mveRichard MacCutchan14-Mar-17 21:51 
QuestionClass Structure (3 questions) Pin
ShikadiMaster13-Mar-17 23:09
ShikadiMaster13-Mar-17 23:09 
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)

Question 1

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?

Question 2

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?

Question 3

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?
SuggestionRe: Class Structure (3 questions) Pin
CHill6013-Mar-17 23:15
mveCHill6013-Mar-17 23:15 
Questionto print the occurence of the unique words in a string using java-->why my counter is not working Pin
LOKENDRA YADAV12-Mar-17 0:58
LOKENDRA YADAV12-Mar-17 0:58 
AnswerRe: to print the occurence of the unique words in a string using java-->why my counter is not working Pin
Richard MacCutchan12-Mar-17 21:50
mveRichard MacCutchan12-Mar-17 21:50 
QuestionCreate an HTML file AddCookies.html which contains four text boxes . Pin
Member 1270377511-Mar-17 16:51
Member 1270377511-Mar-17 16:51 
AnswerRe: Create an HTML file AddCookies.html which contains four text boxes . Pin
Richard MacCutchan11-Mar-17 22:06
mveRichard MacCutchan11-Mar-17 22:06 
Questionprogram to find the last occurence of a character in a string without using built in function Pin
LOKENDRA YADAV8-Mar-17 22:15
LOKENDRA YADAV8-Mar-17 22:15 
AnswerRe: program to find the last occurence of a character in a string without using built in function Pin
Jochen Arndt8-Mar-17 22:36
professionalJochen Arndt8-Mar-17 22:36 
AnswerRe: program to find the last occurence of a character in a string without using built in function Pin
Patrice T9-Mar-17 15:34
mvePatrice T9-Mar-17 15:34 
AnswerRe: program to find the last occurence of a character in a string without using built in function Pin
Member 1209512219-Mar-17 22:37
Member 1209512219-Mar-17 22:37 
QuestionGetting javax.xml.ws.soap.SOAPFaultException: Error in deserializing body of request message for operation xxxx. Pin
Member 130427416-Mar-17 19:53
Member 130427416-Mar-17 19:53 
QuestionRe: Getting javax.xml.ws.soap.SOAPFaultException: Error in deserializing body of request message for operation xxxx. Pin
Richard MacCutchan6-Mar-17 22:25
mveRichard MacCutchan6-Mar-17 22:25 
QuestionAudio Steganography Pin
Member 129105895-Mar-17 21:27
Member 129105895-Mar-17 21:27 
AnswerRe: Audio Steganography Pin
Richard MacCutchan5-Mar-17 22:27
mveRichard MacCutchan5-Mar-17 22:27 
GeneralRe: Audio Steganography Pin
Member 129105895-Mar-17 22:33
Member 129105895-Mar-17 22:33 
GeneralRe: Audio Steganography Pin
Richard MacCutchan5-Mar-17 22:40
mveRichard MacCutchan5-Mar-17 22:40 
GeneralRe: Audio Steganography Pin
Member 129105895-Mar-17 22:49
Member 129105895-Mar-17 22:49 
GeneralRe: Audio Steganography Pin
Richard MacCutchan5-Mar-17 22:54
mveRichard MacCutchan5-Mar-17 22:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.