r/programming • u/nickproud • Aug 14 '26
Coding Magic the Gathering in C# - PART ONE - Why Build A Card Game in WinForms
https://youtu.be/n7fhuIHD-gM
116
Upvotes
r/programming • u/nickproud • Aug 14 '26
279
u/xhable Aug 14 '26
The architecture looks pretty sound to me. My only warning would be that Magic starts off looking like a lovely OOP inheritance exercise, then spends 30 years inventing cards specifically to punish you for building a class hierarchy.
Creature : Cardfeels great right up until a land becomes a creature, an artifact is also a creature, and something removes all its types.I'd lean heavily towards composition. Magic is less a great example of OOP and more a great example of why OOP eventually invented composition.
32
u/jax024 Aug 14 '26
WinForms? Wew.
Let me know when your get to Blood Moon layering. With lands becoming creatures, losing subtypes, and all that chaos that even MTGO couldn’t get right lol.
14
u/king_Geedorah_ Aug 14 '26
Ive always wanted to something like this but with Haskell and Yugioh (the things im into lol).
Great vid!
35
u/EliSka93 Aug 14 '26
If we're using C# to its strengths, I'd build it as a library and then build a decoupled UI simply to display the game state.
From watching the video, I think you're separating your concerns properly, you're just doing it in a single project. That's fine, but if you ever plan to refactor the UI in a more modern framework (*cough* Blazor *cough*), you'll have to extract the code from the current project.
I think this is a good case as to why I'd be a bad content creator. The shortcuts you have to take to make the content approachable grind against my perfectionism in the worst way. It's not wrong to take those shortcuts - actually it's probably the right choice for content creation, I just can't help but want to go into an insane amount of unnecessary detail.
I'm currently writing a blog post about QR codes, and I had to create two supplementary blog posts about the binary system and barcodes because I felt like they were necessary building blocks for understanding the main topic...
10
u/slicerprime Aug 15 '26
Because you're off you meds?
1
u/rossisdead Aug 15 '26
I was not expecting the catchy earworm of an intro song lol
1
u/DarthPedro99 Aug 19 '26
This is a worthy undertaking in C# and WinForms. Having fun building something you love and getting better is worth it. Thanks for bringing us along with you.
0
u/_do_ob_ Aug 14 '26
Blazer is modern? I thought it was DOA.
It's perfectly fine to do it in winforms,has long like you said , visual is isolated from game mechanics
0
u/Hot-Software-9396 Aug 16 '26
I like your delivery and format. Subscribed!
-2
u/Slight-Bluebird-8921 Aug 15 '26
NO. NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
-1
u/languagehacker Aug 14 '26
I'm doing something similar with Clive Barker's Imajica CCG and Claude.
-1
u/bobdobbes Aug 15 '26
They only ever intended it to run on Windows