tag:blogger.com,1999:blog-889604442512373664.post5668415602633710628..comments2023-10-31T08:28:52.391-07:00Comments on Computer Programming and Magic: The Gathering: MTG Forge ArchitectureForgehttp://www.blogger.com/profile/15838286606081721333noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-889604442512373664.post-45129532843786680792009-01-10T16:05:00.000-08:002009-01-10T16:05:00.000-08:00sounds like a flaw in your initial design. you sho...sounds like a flaw in your initial design. you should only cache the global variables in local methods, but not in attributes. if you have to, for example in the gui, you could use some kind of observation.Silly Freakhttps://www.blogger.com/profile/09963238585847993157noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-74029905827516665652009-01-09T11:28:00.000-08:002009-01-09T11:28:00.000-08:00When a new game starts I could create new global v...When a new game starts I could create new global variables, the problem is that the rest of the program doesn't reinitialize itself. The rest of the program doesn't assume that the global variables will ever change.Forgehttps://www.blogger.com/profile/15838286606081721333noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-36149950783133436062009-01-07T23:00:00.000-08:002009-01-07T23:00:00.000-08:00the best would be to keep all these "static classe...the best would be to keep all these "static classes" tracked by a songle object, something like:<BR/>Game.getInstance().getAllZone();<BR/>so, all these singleton objects can be dropped with a single Game.drop();<BR/><BR/>if it's not clear, it would somethin like this:<BR/><BR/>public class Game {<BR/> <B>private static Game instance;</B><BR/><BR/> private AllZone allZone;<BR/><BR/> <B>private</B> Game() {<BR/> allZone = new AllZone();<BR/> }<BR/><BR/> <B>public static void drop() {<BR/> instance = null;<BR/> }<BR/><BR/> public static Game getInstance() {<BR/> if(instance == null) instance = new Game();<BR/> return instance;<BR/> }</B><BR/><BR/> public AllZone getAllZone() {<BR/> return allZone;<BR/> }<BR/>}Silly Freakhttps://www.blogger.com/profile/09963238585847993157noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-24914043176843910192009-01-07T12:47:00.000-08:002009-01-07T12:47:00.000-08:00Wow, such a thing might actually work in MTG Forge...Wow, such a thing might actually work in MTG Forge?<BR/><BR/>In Incantus, we still don't have "new game" capabilities (that is, playing a new game after you've already played one [i]without[/i] forcing you to quit and restart) because the sheer number of things to keep track of is just too much. Even if we were to destroy ever card object and zone object and even player object and replace them all with fresh, new versions, we would still might have some continuous effect code running.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-61893845077287161402009-01-06T08:03:00.000-08:002009-01-06T08:03:00.000-08:00the most important reason to use singleton objects...the most important reason to use singleton objects is that you can clear the state after a game. I remember some bugs that triggered abilities triggered also in the next game. if you do something like AllZone.drop() to create a new AllZone object you can be sure that every modification on the game is goneSilly Freakhttps://www.blogger.com/profile/09963238585847993157noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-87248404902954470872009-01-06T07:09:00.000-08:002009-01-06T07:09:00.000-08:00Yeah global variables tend to be bad and hard to d...Yeah global variables tend to be bad and hard to debug (which they are). In version 2, I use the singleton pattern which is similar to a global variable but it doesn't have any nasty side effects.Forgehttps://www.blogger.com/profile/15838286606081721333noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-12512365053390575132009-01-05T23:45:00.000-08:002009-01-05T23:45:00.000-08:00yes, Anonymous is right: just look at faerie rogue...yes, Anonymous is right: just look at faerie rogue token - it has the same name "Faerie Rogue" at the top:<BR/>http://www.magicmadhouse.co.uk/catalog/images/faerie_rogue.jpg<BR/><BR/>about static variables: as far as I know it is not so good to use classes with members that are all static (like AllZone), it's better to use singleton pattern instead: smth like<BR/>AllZone.getInstance().getGraveyard()nantuko84https://www.blogger.com/profile/15891352523600843744noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-12733868313324007542009-01-05T12:28:00.000-08:002009-01-05T12:28:00.000-08:00Actually, if the token doesn't have a name, then i...Actually, if the token doesn't have a name, then it's name is the same as the creature type line (so for ex. "Elf Warrior")Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-69489831402631688412009-01-05T12:13:00.000-08:002009-01-05T12:13:00.000-08:00Most tokens don't have a name, so MTG Forge doesn'...Most tokens don't have a name, so MTG Forge doesn't show anything. Tokens made by Kiki-Jiki and Llanowar Mentor create tokens that DO have a name.Forgehttps://www.blogger.com/profile/15838286606081721333noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-11386292330265763892009-01-05T12:12:00.000-08:002009-01-05T12:12:00.000-08:00Currently MTG Forge loads the card picture based o...Currently MTG Forge loads the card picture based on the card name, it probably should load the picture based on the whole card (is the card a token, etc...)Forgehttps://www.blogger.com/profile/15838286606081721333noreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-86091360252902167792009-01-05T11:49:00.000-08:002009-01-05T11:49:00.000-08:00This reminds me, it would be cool to add the token...This reminds me, it would be cool to add the token pictures into MTGForge, since I think we have quite a few tokens right now (Voja, Soldiers, Pegasuses (Pegasi?), Goblins, Giant Warriors, etc.)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-889604442512373664.post-77635182109571106092009-01-05T10:45:00.000-08:002009-01-05T10:45:00.000-08:00Architecture tends to be a little bit dry (uninter...Architecture tends to be a little bit dry (uninteresting). I've been using token pictures because Magic has a ton of tokens that I haven't seen.Forgehttps://www.blogger.com/profile/15838286606081721333noreply@blogger.com