It is currently 29 Apr 2024, 13:46
   
Text Size

Splitting GameActionUtil

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Splitting GameActionUtil

Postby DennisBergkamp » 10 Nov 2009, 18:19

Another big file is GameActionUtil (I've been adding some new cards and mechanics to this file, my local file is over 11,000 lines now).
Splitting this should be much easier than CardFactory. But how do you guys think it should be split up?

GameActionUtil currently consists of:
- Upkeep effects (lots of code)
- "Play card" effects (Standstill, Gilt-Leaf Archdruid, Sigil of the Empty Throne, etc.)
- "Draw Triggered" effects (currently only 3 cards: Niv-Mizzet, Hoofprints of the Stag and Lorescale Coatl - but this will most likely grow as well
- Some misc stuff: exalted, lifelink, a check to see if Rafiq of the Many is in play, "vampiric effects" (Sengir Vampire, ...), Guilty Conscience triggers, ... not even sure if these should be in this file.
- Ally effects
- Landfall effects
- "Destroy card" effects, this is what I've been playing around with, I've added cards like Fecundity, Dingus Egg, Dingus Staff, Goblin Sharpshooter and Dauthi Ghoul
- "Player combat damage" effects (Shadowmage Infiltrator, Hypnotic Specter, etc.)
- Last but not least, State Based Effects (Glorious Anthem, Goblin King, Nightmare, Engineered Plague, Fervor, etc.) which I think takes up most of the code.

What do you guys think? Should it be split up in 7 - 8 parts ? Or maybe for now just split the Upkeep, State Based Effects and the rest into three separate files?
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting GameActionUtil

Postby Marek14 » 10 Nov 2009, 21:38

DennisBergkamp wrote:Another big file is GameActionUtil (I've been adding some new cards and mechanics to this file, my local file is over 11,000 lines now).
Splitting this should be much easier than CardFactory. But how do you guys think it should be split up?

GameActionUtil currently consists of:
- Upkeep effects (lots of code)
- "Play card" effects (Standstill, Gilt-Leaf Archdruid, Sigil of the Empty Throne, etc.)
- "Draw Triggered" effects (currently only 3 cards: Niv-Mizzet, Hoofprints of the Stag and Lorescale Coatl - but this will most likely grow as well
- Some misc stuff: exalted, lifelink, a check to see if Rafiq of the Many is in play, "vampiric effects" (Sengir Vampire, ...), Guilty Conscience triggers, ... not even sure if these should be in this file.
- Ally effects
- Landfall effects
- "Destroy card" effects, this is what I've been playing around with, I've added cards like Fecundity, Dingus Egg, Dingus Staff, Goblin Sharpshooter and Dauthi Ghoul
- "Player combat damage" effects (Shadowmage Infiltrator, Hypnotic Specter, etc.)
- Last but not least, State Based Effects (Glorious Anthem, Goblin King, Nightmare, Engineered Plague, Fervor, etc.) which I think takes up most of the code.

What do you guys think? Should it be split up in 7 - 8 parts ? Or maybe for now just split the Upkeep, State Based Effects and the rest into three separate files?
Well, "State-Based Effects" is a bad name here (it means something different), better just call them "static effects". I think they should be definitely separate.

As for draw triggers, other possible cards for them are Diviner's Wand, Moonring Mirror, Kederekt Parasite, Mind's Eye, Phyrexian Tyranny, Psychic Possession, Spiteful Visions, Underworld Dreams
Marek14
Tester
 
Posts: 2762
Joined: 07 Jun 2008, 07:54
Has thanked: 0 time
Been thanked: 297 times

Re: Splitting GameActionUtil

Postby DennisBergkamp » 10 Nov 2009, 22:09

Ah, you're right! Wow, I even made a class called "StateBasedEffects.java" which keeps track of these "static effects". I guess I completely misnamed it :oops:
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting GameActionUtil

Postby zerker2000 » 11 Nov 2009, 02:47

Is it just me or should "some misc stuff" be moved to Combat?
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting GameActionUtil

Postby Rob Cashwalker » 11 Nov 2009, 16:11

I think it should be completely blown away.

Each individual card's code should be translated into an Execute method of a Command object, defined in CardFactory_{Type}. This Command is assigned to an array of Commands defined by the card. Whenever the state effects code would have executed the code it once contained it instead calls the execute method of the appropriate command for the card.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Splitting GameActionUtil

Postby DennisBergkamp » 11 Nov 2009, 18:40

Yes, this would be ideal. I will start messing around with this and move some of the code into Commands.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting GameActionUtil

Postby zerker2000 » 12 Nov 2009, 02:42

"Drat, foiled again!": I do remember thinking along the exact same lines, but ended up not posting for some reason :?.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting GameActionUtil

Postby Rob Cashwalker » 12 Nov 2009, 14:38

this approach would open up the ability to keyword static pumps and other standardized static effects.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 109 guests


Who is online

In total there are 109 users online :: 0 registered, 0 hidden and 109 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 109 guests

Login Form