Click here to Skip to main content
15,885,182 members
Please Sign up or sign in to vote.
1.11/5 (3 votes)
See more:
Like the title say ^

I want to -reproduce- a game of cards. The name of the game is Hearthstone, because I like it. But I want to make it 'better' so I choose to give it a try. Please try to see it as me, as an exercise and nothing to do with commercial or anything else.

The main problem I have:
the structure ! How can you advise me about it's structure? The engine. The CORE as I say it. I think, the core is the graphic interface and everything orbits and links around it. The problem is how to make this Core? Now I have 2 problems - one of visibility as the code is arranged (in files,all together,in objects), and one of complexity as the details in code go. I wish I can make it on objects somehow... I partially did it (I made a Card object)- but that's it I could think of successfully . I was thinking of a Table object, but I eject it. The card object have 4 properties on itself, and is rapidly becoming very confusing. If I will have to add more properties to a card - custom stuff- it will become almost unreadable.
Any good ideas, are more than welcome.
Present an attack plan about how to proceed - from your experience is best.
In a way I imagine this is the most fragile part of the programming area and not many are willing to express their inner fight with this monster that is - the structure-.
Thank you and I hope to a nice discution !

What I have tried:

everything I tried - now I will listen.
Posted
Updated 7-Dec-16 22:16pm
Comments
Dave Kreskowiak 7-Dec-16 15:31pm    
No offense meant, but judging by the questions you've been asking, this project is far more difficult than you're ready to tackle.
_Q12_ 7-Dec-16 15:41pm    
I suppose it is more difficult than I can carry. It is a side project that I came to it from time to time. I am thinking for some time on it(1year or more). Now I want ideas, because I consumed all that I had. And the progress is terrible slow. Any ideas are very welcomed !
Dave Kreskowiak 7-Dec-16 16:27pm    
You're having the most difficult time understanding the basics of C#. What makes you think you're going to understand the advanced topics that are going to be required to build a project like this? Because those are the "ideas" that you're going to need.

This is something you're going to spend years working up to. You can't go from where you are now and just jump into complexity like this. You have to build up to it. You're trying to build a jet but right now, you're having problems just gluing two pieces of wood together. See what's going on yet?

As for ideas, you have to learn how to plan a piece of software, nevermind write a single line of code. For example, do you have your game rules completely fleshed out yet? If not, why are you even writing a class called "Card"?
_Q12_ 7-Dec-16 21:33pm    
I understand, thank you.
[no name] 7-Dec-16 20:13pm    
"How can you advise me about it's structure", we can't. We can't because you are attempting to get people to teach you programming one question at a time over the internet. It's not possible to teach you programming over the internet.

As this should be a solution i may try to hand you one but i need to say that your problem is quite huge, so a proper solution would be impossible to give.

First of all i admire your will to improve something that is this complex ( I know the Game myself) but as others already stated i have to say that this is a big effort and a big challenge since on that game multiple (if not even hundreds) of developers worked in their specific area.

For the Structural part i suggest you to read through "Design Patterns" and have a thought about what could a possible structure be, like you started off with the Cards Object. Mostly i suggest you to have separations like Objects (The Datahold actually) that are connected through Controlers (The Classes that do the work) to the UI which shall be more dumb than intelligent. This is known as MVC (if you don't know already). As a general structure, think of parts that are basics, like configuration and stuff, exception handling is another example. You may need an "Engine" that runs everything, being the startup and refreshing the UI, handling events. Meanwhile you also neeed the graphics which on ne side are objects but on the other side need a "Controler" or "Factory" how ever you may call it.

You may also need "Business" Classes, those are for any code that runs aside from refreshing UI, like calculating the values of cards or attacks or whatever.

It's huge and your architecture shall adapt to that, so you firstly need to identify what you need and how you can separate it. It makes alot sense to seperate as much as possible and to inherite wherever you may need it (Like Cards). You could have a basic Card that does have the overall needed specifics, then abbreviate from that to get Attack Cards (Mosters) and defense Cards (Traps or the like) (If you want it like that, so just an example).

I suggest you to start off with something small and as soon as you understood how to separate and construct the small you can scale bigger, maybe you are already able to use your stuff and just improve it to get to the next target. A well done Architecture can help develop bigger and bigger since the basics could be the same and you can reuse it for other projects. I for my self have, as an example, one basic Project that gets compiled to a .dll which contains Database access, configuration stuff, exception handling and the like.

I hope i could trigger your thoughts a bit and that it may help you. Anyway good like with your project :)
 
Share this answer
 
Comments
HobbyProggy 8-Dec-16 3:47am    
By the way, there is no "proper way" or "best thing" to tackle this. It is very specific and therefore you have to decide it everytime. A recipe like do it this way and you succed doesn't exist AFAIK.
_Q12_ 8-Dec-16 9:55am    
Yes, This is the conversation I was hoping for. Thank you for your good thoughts. So, after all, it is a huge problem not only for me, but for others too? I was thinking I am not good enough, heh. Ok.
-
I am very curious about your .dll and the "Business" Classes - can you exemplify them more for me? When you use it, in what situations, and where? If you have the pleasure, of course - think of this discussion as a good opportunity to brag a little bit with something that you have good. I think like you just said - I imagine it must be something basic, like a CORE, a very thin skeleton, that represents the idea for the entire game or the direction of it, and on top of this, dressed with a lot of objects from outside - even from files, from dll's, from different Classes ,same code, whatever.
-
Specifically, in this Card game project, all that I could think of and function properly, was the Card Object, and like you said, is the Base Object for any type of card that I will create from now on, with any number of powers on it. BUT (I use a Big BUT), this Card Object is a Object that is outside of the CORE. This Card will be attached to the CORE. The Core itself, I didnt figure it out yet, I will go backwards toward accomplishing it, from what I can observe - and by that, I mean, I will probably build the objects first, and all of them will (hopefully) give me clues about this CORE I am dreaming of. I am not sure if this CORE even exist!! maybe is in my imagination. That is the main reason that I came to ask you guys about it. So... any good suggestions to help me understand this thing (if it's a thing)?
-
The hardest thing that I can think of, is how to make this CORE, in such a way, that I can add any number of objects to it. And not only objects, but events too, or anything else. Whatever the necessities, this core is to be able to accept anything and in unlimited numbers and run it properly. Also, to be readable for the programmer, too. Like a tree. The trunk of the tree is very visible and easy to find, and the leaves are the objects attach to this tree trunk(or CORE).
-
Like I said, I am not a programmer, I am an artist. I hope you can give me your piece of mind, further.
_Q12_ 8-Dec-16 10:00am    
"Design Patterns" is a book? or is a chapter in c# language? I don't know about it very well.
I dont know about MVC.
But I like how you just exemplify: "the connectivity between a bunch of objects called Datahold, connected through Controlers (The Classes that do the work) to the UI which shall be more dumb."
-
It is very close to what I imagine myself, only that in practice, is waaaaaaaaay more complicated than it sounds. I suppose it is a matter of getting used to such a construction. Right?
-
My big problem is how to disseminate them - all the code (obj,events,clases,all) in one file? OR every one thing on it's separate file? like having 1000 files for the entire program. I try to visualize the structure here, that is why I ask how is best approach. Best, maybe is a big word, but how you guys are doing it from your practice, is all that I ask.
HobbyProggy 8-Dec-16 11:44am    
Glad you got a bit of what i wanted to point out, and yes it is a problem for most programmers, since this is the job of an architect. It is hard for everyone but with the experience and "design patterns" we get along with it cause we know how and have the "tools" for it. So you are probably good enough but lack the experience.
-
To design patterns, it ain't a book, it is a word for a set of designstructures you may use. So there are sevaral books and wikipedia articles about that stuff.
-
To .Dll's, i guess you know what they are for? If not then just programm a small software that has 2 project files, one is set to compile as dll and one is an executable. The executable project needs the dll project as reference and see how "magic" happens.
A ".dll Project" (if one can call it so) is just a project file consisting of classes, views, whatever that can be used by actual ".exe Projects". With this you create a modular system being able to modify one part without "needing" to touch the other part.
-
A business class for me is a class that does the business (funny right?), for example i have a UI that displays a set of data (think of an excel sheet). I click on show data -> the UI now calls it's controler and asks for data -> the controler asks it's business class to get the data he wants -> the business class now does the job and uses the Basic Module to get the requested objects. As soon as the business class has the objects it hands them to the controler -> the controler keeps them in his data hold and fills the UI with the data. Voila you see the data on screen. As this is just an example it might not fit 100% on your case but i hope you get the idea of it. And although this sounds complex it is worth it since you can change on every layer without needing (Sometimes you might need to change) to change stuff on the other parts.
To say it in one sentence, "A business class should be a class that is dedicated to exactly one job or subject and be holding the "production/business" code for this job or subject".
-
I can tell you this CORE you are talking about is existing, since every application needs a heart that keeps pumping. How the "CORE" will look like is something you gotta find out yourself. But you don't need to create the CORE and then switch to the other stuff. Do it the way you think you'll find the solution. Maybe start off with the objects and figure out how to punch them together. You have to find YOUR way of creating a system, nobody can teach you that, we just can give hints or perspectives how we would do it.
-
That is by far the hardest thing, but if you use your tools properly you can build a CORE and later separate it, extend it, separate it again and you'll finally have a CORE consisting of several classes working together and driving the machine to where you need it. You are an artist, think of a picture, you start at one point and fill it up, you separate the views on objects on that and specifiy it piece by piece to make a final whole painting right? It's just like that but more technical :)
-
MVC is one of the most used (i hope i am right :) ) Patterns though it gets pushed by MVVM which is another pattern i can't explain very well ^^.
The idea of MVC (Model-View-Controler) is to keep the UI as UI that is dumb and just presents data. The controler does the job on asking for data or shoving it into the UI. The Model is the actual data Object that is held by the controler. The idea is that if the UI requests a refresh the controler does it and if the Model got refreshed the Controler shovs it into the UI. You can modifiy the UI and let the controler be and vice versa, same goes for changes on the model, since everything is separated well and has it's dedicated job.
-
And yes it is a matter of getting into it, as soon as you have expierence you create your own patterns according to your previous steps and will easier take on such jobs.
-
Way 2, it sounds like a lot but you'll see it is less than a 1000 files
_Q12_ 9-Dec-16 2:13am    
I make a practical code after your explanation, better for me to understand what you are explaining. Only if you feel the need or the pleasure to correct it, please do. I tried to get as close as I can to what you said there. It is a bit mind bending for me. I definitely need practice with this stuff. You are helping fully right now!!
-
the entire code here:
-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

//here is the UI Requests:
private void button1_Click(object sender, EventArgs e)
{
Business b = new Business();
b.UI();
label1.Text = b.UI();
}
}


// this is usefull for the compartimentalization / layering - I see now.
// if I am not mistaken, this Class looks very close to my CORE thinghy. Right? Ocieni interesnaia :)
public class Business
{
public string UI()
{
if (Controller() != null) return Controller();
else return "Error: Controller empty";
//this else part is pointless - I have inside Controller another else that does the same thing !!!
}


public string Controller()
{
Business b = new Business();
Basic_Module bm = new Basic_Module();
// this is the only way I can interpret your statement: "the controler asks it's business class" +
//+ "the business class now does the job and uses the Basic Module to get the requested objects"
if (b.Contains(bm.Data01()))//if you see the same Data in both(here in Business and in Basic_Module) locations? thefak?
{
return Data01();
}
else
{
return "NO text Data";
}
}



public bool Contains(string data)
{
if (data != null) return true;
else return false;
}

public string Data01()
{
return "a lot of text data";
}
}


public class Basic_Module
{
public string Data01()
{
return "a lot of text data";
}
}
}
I gave you a suggestion yesterday at How to create void's array?[^] which would help you. But until you follow that and really get proficient at C'# you are not going to make any progress. Posting questions about programming when you still do not fully understand the language is just a waste of our time, and more importantly, a waste of yours.
 
Share this answer
 
Comments
_Q12_ 9-Dec-16 14:28pm    
Your suggestion was .NET Book Zero by Charles Petzold - I will read it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900