[WIP] Split Cards Support
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: [WIP] Split Cards Support
by Max mtg » 05 Mar 2013, 18:50
Since that branch is not going to be developed further, I am pretty sure it's safe to integrate just the new code.
Yet, I am not an expert in propper use of SVN, so your option might be the most correct one despite of its taking so much time.
Yet, I am not an expert in propper use of SVN, so your option might be the most correct one despite of its taking so much time.
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: [WIP] Split Cards Support
by Agetian » 06 Mar 2013, 04:33
Thanks a lot for the assistance, myk!
So, as of r20117, the initial effort to add support for split cards may be considered complete and the relevant branch has reen reintegrated to trunk. Expect some rough edges and incompatibilities along the way. The current situation as of the time of merge is as follows:
DONE:
- Support for loading, displaying, and playing split cards with script format similar to transformable cards (check out the included two scripts for examples).
- Split cards are correctly identified by the combination of their features (CMC, color) when not on stack.
- Split cards correctly go on stack as only one (chosen) half.
- Split cards correctly change zones after being resolved on stack (e.g. when they go to graveyard, are exiled, or are returned to hand when payment or targeting is canceled), thus returning to their original full form.
- Split cards correctly interact with other cards in some important test cases (e.g. Dark Confidant uses the combined CMC of both sides, while Isochron Scepter uses the "two answers" rule to check whether the CMC of the card is less than or equal to 2, checking both sides invidivudally).
- Added a good number of split cards to the game (thanks a lot, swordshine!).
- Split cards show their mana costs properly (for each half side by side) both in the game and in the deck editor (thanks a lot, Max Mtg!)
POTENTIAL IMPROVEMENTS:
- Might be worth it to rig the display of mana cost in the game (and possibly in the deck editor) to show two mana costs separated by a "/" instead of the combined mana cost (e.g. 1R/1U for Fire // Ice instead of 2RU).
KNOWN ISSUES:
- The keyword CARDNAME in spell description does not correctly change into the names of individual sides of the card (tried to fix by rigging the relevant replaceAll calls in the Card class, but failed so far).
Big thanks to everyone who helped out with this project and who continue to help out - Max Mtg, Sloth, friarsol, myk, swordshine, and everybody else whom I might have missed!
- Agetian
So, as of r20117, the initial effort to add support for split cards may be considered complete and the relevant branch has reen reintegrated to trunk. Expect some rough edges and incompatibilities along the way. The current situation as of the time of merge is as follows:
DONE:
- Support for loading, displaying, and playing split cards with script format similar to transformable cards (check out the included two scripts for examples).
- Split cards are correctly identified by the combination of their features (CMC, color) when not on stack.
- Split cards correctly go on stack as only one (chosen) half.
- Split cards correctly change zones after being resolved on stack (e.g. when they go to graveyard, are exiled, or are returned to hand when payment or targeting is canceled), thus returning to their original full form.
- Split cards correctly interact with other cards in some important test cases (e.g. Dark Confidant uses the combined CMC of both sides, while Isochron Scepter uses the "two answers" rule to check whether the CMC of the card is less than or equal to 2, checking both sides invidivudally).
- Added a good number of split cards to the game (thanks a lot, swordshine!).
- Split cards show their mana costs properly (for each half side by side) both in the game and in the deck editor (thanks a lot, Max Mtg!)
POTENTIAL IMPROVEMENTS:
- Might be worth it to rig the display of mana cost in the game (and possibly in the deck editor) to show two mana costs separated by a "/" instead of the combined mana cost (e.g. 1R/1U for Fire // Ice instead of 2RU).
KNOWN ISSUES:
- The keyword CARDNAME in spell description does not correctly change into the names of individual sides of the card (tried to fix by rigging the relevant replaceAll calls in the Card class, but failed so far).
Big thanks to everyone who helped out with this project and who continue to help out - Max Mtg, Sloth, friarsol, myk, swordshine, and everybody else whom I might have missed!
- Agetian
Last edited by Agetian on 07 Mar 2013, 04:03, edited 6 times in total.
- Agetian
- Programmer
- Posts: 3489
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: [WIP] Split Cards Support
by friarsol » 06 Mar 2013, 05:01
Alright, this is updated for Card Detail Panel. Hopefully someone can hook the same function up for the Deck Editor and the Overlay.Agetian wrote:POTENTIAL IMPROVEMENTS:
- Might be worth it to rig the display of mana cost in the game (and possibly in the deck editor) to show two mana costs separated by a "/" instead of the combined mana cost (e.g. 1R/1U for Fire // Ice instead of 2RU)
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: [WIP] Split Cards Support
by Agetian » 06 Mar 2013, 05:15
I'm on it.friarsol wrote:Alright, this is updated for Card Detail Panel. Hopefully someone can hook the same function up for the Deck Editor and the Overlay.Agetian wrote:POTENTIAL IMPROVEMENTS:
- Might be worth it to rig the display of mana cost in the game (and possibly in the deck editor) to show two mana costs separated by a "/" instead of the combined mana cost (e.g. 1R/1U for Fire // Ice instead of 2RU)

- Agetian
- Agetian
- Programmer
- Posts: 3489
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: [WIP] Split Cards Support
by Agetian » 06 Mar 2013, 05:41
Sadly, it seems like it won't be possible to simply hook up GetManaDisplay because both the Deck Editor and the Overlay process the mana cost differently, and both depend on being able to calculate the width of the final mana cost representation with symbols (which depends on how the ManaCost class operates). I'm not particularly good at modifying that part of code, to be honest, since it seems like changing it too drastically may have unpredictable results elsewhere - if anyone is in the know how exactly it operates and what is safe enough to do in order to modify the functionality, I've found the relevant spots in code which need to be modified to add support for split mana costs to both Overlay and Deck Editor:
Deck Editor - forge.gui.deckeditor.tables.ManaCostRenderer.paint()
Match Overlay - forge.view.arcane.CardPanel.paintChildren(final Graphics g)
- Agetian
Deck Editor - forge.gui.deckeditor.tables.ManaCostRenderer.paint()
Match Overlay - forge.view.arcane.CardPanel.paintChildren(final Graphics g)
- Agetian
Last edited by Agetian on 06 Mar 2013, 05:56, edited 1 time in total.
- Agetian
- Programmer
- Posts: 3489
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: [WIP] Split Cards Support
by swordshine » 06 Mar 2013, 05:50
An issue about card picture urls. I tried to add these urls to Assault//Battery in the assaut part. Forge downloaded the picture and renamed "assault.jpg", but it cannot be recognized in deck editor.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: [WIP] Split Cards Support
by Agetian » 06 Mar 2013, 06:12
@ swordshine: I committed an experimental fix for the issue you mentioned, sadly I can't test it because the LQ picture downloader crashes for me for some reason (even without any changes at all). Basically, it should now rename the picture file name to assaultbattery.jpg and that should be visible from the deck editor (hopefully). Please let me know how it goes.
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3489
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: [WIP] Split Cards Support
by Max mtg » 06 Mar 2013, 06:50
do never write such code:
- Code: Select all
* Display for the field <code>manaCost</code>.
* </p>
*
* @return a {@link java.lang.String} object.
*/
public final String getManaDisplay() {
// If this is a split card, display mana as X / Y. Otherwise, Display it as normal
if (this.getRules() != null && this.getRules().getSplitType() == CardSplitType.Split) {
return String.format("%s / %s", this.getState(CardCharacteristicName.LeftSplit).getManaCost(),
this.getState(CardCharacteristicName.RightSplit).getManaCost());
}
return this.getCharacteristics().getManaCost().toString();
}
/**
* <p>
Single class for single responsibility.
- Max mtg
- Programmer
- Posts: 1997
- Joined: 02 Jul 2011, 14:26
- Has thanked: 173 times
- Been thanked: 334 times
Re: [WIP] Split Cards Support
by swordshine » 06 Mar 2013, 06:56
Got an NPE when downloading the Lq pics after updated to r20125Agetian wrote:@ swordshine: I committed an experimental fix for the issue you mentioned, sadly I can't test it because the LQ picture downloader crashes for me for some reason (even without any changes at all). Basically, it should now rename the picture file name to assaultbattery.jpg and that should be visible from the deck editor (hopefully). Please let me know how it goes.
- Agetian
- NullPointerException | Open
- Code: Select all
java.lang.NullPointerException
at forge.gui.download.GuiDownloader.readyToStart(GuiDownloader.java:177)
at forge.gui.download.GuiDownloader.access$6(GuiDownloader.java:176)
at forge.gui.download.GuiDownloader$4.done(GuiDownloader.java:169)
at javax.swing.SwingWorker$5.run(SwingWorker.java:717)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:814)
at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:95)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:824)
at javax.swing.Timer.fireActionPerformed(Timer.java:291)
at javax.swing.Timer$DoPostEvent.run(Timer.java:221)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:666)
at java.awt.EventQueue.access$400(EventQueue.java:81)
at java.awt.EventQueue$2.run(EventQueue.java:627)
at java.awt.EventQueue$2.run(EventQueue.java:625)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:636)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Re: [WIP] Split Cards Support
by Agetian » 06 Mar 2013, 06:58
- Agetian
- Agetian
- Programmer
- Posts: 3489
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: [WIP] Split Cards Support
by Agetian » 06 Mar 2013, 07:18
@ swordshine: OK, please try again, r20127 doesn't crash for me and downloads/processes the card picture properly.
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3489
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: [WIP] Split Cards Support
by Agetian » 06 Mar 2013, 07:35
By the way, I noticed one more issue with this implementation... it always shows the full mana cost of the card even when it goes on stack as only one side.Max mtg wrote:do never write such code:It's the component's responsibility to display such odd cards like split ones. The Card MUST NOT take card of everyone who could use it
- Code: Select all
* Display for the field <code>manaCost</code>.
* </p>
*
* @return a {@link java.lang.String} object.
*/
public final String getManaDisplay() {
// If this is a split card, display mana as X / Y. Otherwise, Display it as normal
if (this.getRules() != null && this.getRules().getSplitType() == CardSplitType.Split) {
return String.format("%s / %s", this.getState(CardCharacteristicName.LeftSplit).getManaCost(),
this.getState(CardCharacteristicName.RightSplit).getManaCost());
}
return this.getCharacteristics().getManaCost().toString();
}
/**
* <p>
- Agetian
- Agetian
- Programmer
- Posts: 3489
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: [WIP] Split Cards Support
by Agetian » 06 Mar 2013, 08:04
New known issue: SetInfoScript, OracleScript, and PerSetTracking may not yet work properly with split cards correctly (SetInfoScript and OracleScript did not detect Night // Day I added properly for some reason, while PerSetTracking appears to only account for one side of the split card but not the other).
- Agetian
- Agetian
- Agetian
- Programmer
- Posts: 3489
- Joined: 14 Mar 2011, 05:58
- Has thanked: 684 times
- Been thanked: 572 times
Re: [WIP] Split Cards Support
by swordshine » 06 Mar 2013, 11:37
It seems split cards in the stack show a golden color, not the correct color the side should be.
- swordshine
- Posts: 682
- Joined: 11 Jul 2010, 02:37
- Has thanked: 116 times
- Been thanked: 87 times
Who is online
Users browsing this forum: No registered users and 40 guests