It is currently 11 Sep 2025, 20:43
   
Text Size

please let me refactor references to static fields, etc.

Post MTG Forge Related Programming Questions Here

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

please let me refactor references to static fields, etc.

Postby Braids » 24 Jun 2011, 02:08

hi, i'd like to change the trunk (svn/src) (not my branch) in the following ways:

  • refactoring direct references to static fields in the following classes, making the fields private, with public, protected, or package level methods for getting, setting, or incrementing the values:
    • forge.AllZone (e.g., AllZone.getHumanPlayer() instead of AllZone.HumanPlayer)
    • forge.ComputerUtil_Block2
    • forge.Phase
    i won't move the fields, just filter access to them with methods. it's going to subtly change many lines of code, but the new references will have identical obviousness. this is going to make it much, much easier for me to keep the game state/AI code up to date with the latest fixes and features, since i've already performed a similar (and necessary) refactoring there.
  • removing SimultaneousEntry and SimultaneousEntryCounter fields from forge.PlayerZone_ComesIntoPlay. they just aren't being used (read).
  • seeing if i can change CardFactory to load cards on an as-needed basis, instead of all at once. this should improve startup time of the game and the unit tests i'm writing. i'll have to make sure it doesn't break the deck editor, however, which will still need to load all the cards. i think.
  • formally update the eclipse project file and build.xml to java 1.6. (i was encountering some compilation problems until i changed this setting.) the code is already 1.6 specific, as evidenced by our use of java.io.File.getFreeSpace and java.awt.Font.DIALOG.

what say all of ye?
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: please let me refactor references to static fields, etc.

Postby Chris H. » 24 Jun 2011, 10:03

I will release the next beta today and get that out of the way before the changes are made.

Over the last couple of years some people reported that a version of forge was not compatible with the java 5 on the computer they were using. Some people are able to play forge at work, school or the library and these computers could not be easily updated to java 6.

We also have a lot of people with Apple Macintosh computers using forge. Older models of Macs were built using the Power PC chip and these computers can not be updated to java 6 and are limited to java 5. Apple switched over to the Intel line of processors several years ago and the Intel based Macs can be updated to java 6.

We have tried supporting the computers that are limited to java 5 the last several years but I think that we will have to eventually require java 6.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: please let me refactor references to static fields, etc.

Postby Hellfish » 24 Jun 2011, 10:13

Sounds good to me, though I thought we were *trying* to keep compatibility with older java, what with some string shenanigans a while ago. (Actually, that was a long while ago... I don't mind either way.) (NOT-REALLY-EDIT: Yeah, what Chris said)

I'm gonna have to keep an eye on the svn updates so I don't keep going by the old ways :mrgreen:
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: please let me refactor references to static fields, etc.

Postby Chris H. » 24 Jun 2011, 10:32

Hehe, It is early morning where I live and I am working on my second cup of coffee.

:mrgreen:
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Java version

Postby alexAG76 » 24 Jun 2011, 11:29

If the code is using that DIALOG constant and File.getFreeSpace, it has already crossed into Java 6. I would suggest changing those references if you want to maintain compatibility with Java 5. Perhaps you could look at prior revisions using your revision control software?
User avatar
alexAG76
Programmer
 
Posts: 23
Joined: 02 Nov 2010, 00:07
Has thanked: 1 time
Been thanked: 0 time

Re: beta & java version

Postby Braids » 24 Jun 2011, 12:16

nevermind, i just saw the beta announcement from an hour ago. [strikethrough]chris - where do you announce the betas?[/strikethrough]

i'll see if there are other references to non java 5 api items. if they are few, maybe i should revert them to use java 5. i get to use svn blame! i mean, svn praise!
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: beta & java version

Postby Chris H. » 24 Jun 2011, 12:36

Braids wrote:nevermind, i just saw the beta announcement from an hour ago. [strikethrough]chris - where do you announce the betas?[/strikethrough]

i'll see if there are other references to non java 5 api items. if they are few, maybe i should revert them to use java 5. i get to use svn blame! i mean, svn praise!
`
The Beta announcements are made on the main CCGH Forum for Forge: Forge. Today's beta announcement can be found at Forge Beta: 06-24-2011 ver 1.0.14 SVN rev 10003.

For a number of months we have tried to release a new beta every 2 weeks. New betas tend to be released on either Friday or the following Monday.

You will notice that we devs at times mention holding off of a SVN merge until after the next beta is released. Some of the biggest changes that we make are merged into the SVN right after a beta is released. This will give us time to shake out a few bugs before the following beta release.

We all try work together with some co-ordination and so far it has worked out fairly well. If someone mentions that they have a big merge planned and that it may be disruptive of the SVN then I will respond by getting the beta out quickly. 8)
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: please let me refactor references to static fields, etc.

Postby Braids » 24 Jun 2011, 12:43

as they say, a version control system is no substitute for communication between developers.

maybe you can play this for its madness cost, but isn't it hard to debug a beta right after its codebase just got turned upside down?
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: getting the beta out quickly

Postby Braids » 24 Jun 2011, 12:44

oh, and if my ideas caused you to move with celerity, thank you.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: please let me refactor references to static fields, etc.

Postby friarsol » 24 Jun 2011, 14:34

Braids,
We don't exactly have a "New Developer starter guide" for pits and traps that they should watch out for before they start messing with our codebase. While we had been "trying" to keep things 1.5 Compatible, it appears things have switched over in the last few months. Since noone on the forums reported any issues with it, it will probably just be easier to add Java 1.6 as a Requirement.

As far as your suggested changes, I'll be the first (if I'm not sleeping) to approve removal of dead code. The accessors to the Global structures is reasonable.

I'm looking forward to the lazy load in CardFactory. I think speeding up the initial launch of Forge will be very useful, especially for people who want to get right in and play.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: please let me refactor references to static fields, etc.

Postby Rob Cashwalker » 24 Jun 2011, 16:09

Braids, welcome to the fray....

All those static references confuse me anyway... good riddance, I say. I had been doing some work in Constant.java, attempting to add dynamically loaded lists of card types. I jumped through quite a lot of hoops to get a static reference to an ArrayList which I could modify at runtime, but be accessible by all other modules.

We tend to simply comment out dead code and leave it there for a few releases, then if nothing serious breaks because of it, remove it entirely.

Sol, do you think you could rework the python scripts to deal with adding Oracle text so at the very least deck editors will operate without CardFactory?
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: please let me refactor references to static fields, etc.

Postby friarsol » 24 Jun 2011, 17:30

Rob Cashwalker wrote:Sol, do you think you could rework the python scripts to deal with adding Oracle text so at the very least deck editors will operate without CardFactory?
Sure I can take a look, I may even have a local file that had started this a while back. Will have to see if that's the case.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

lazy CardFactory is in r10095!

Postby Braids » 27 Jun 2011, 04:57

friarsol wrote:I'm looking forward to the lazy load in CardFactory. I think speeding up the initial launch of Forge will be very useful, especially for people who want to get right in and play.
the first draft is in r10095! i had to rewrite most of CardFactory and ReadCard, but i did it. it works fastest in constructed or constructed random. as soon as you try to generate a new random deck (instead of picking a random one from the list), edit a deck, or visit the store, forge delays while it loads all the cards. this is probably a bad thing for users, but the code is out there now for comments.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. ;)
User avatar
Braids
Programmer
 
Posts: 556
Joined: 22 Jun 2011, 00:39
Location: Unknown. Hobby: Driving myself and others to constructive madness.
Has thanked: 1 time
Been thanked: 1 time

Re: please let me refactor references to static fields, etc.

Postby Hellfish » 27 Jun 2011, 11:00

Hehe, found a somewhat amusing bug. The Mana Pool gets CardID 1 and overwrites whichever card in your deck *also* got CardID 1.If that card comes into play tapped you can actually succeed in tapping your manapool...Well, *I* thought it was amusing. :mrgreen:
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: please let me refactor references to static fields, etc.

Postby Sloth » 27 Jun 2011, 15:09

Hellfish wrote:Hehe, found a somewhat amusing bug. The Mana Pool gets CardID 1 and overwrites whichever card in your deck *also* got CardID 1.If that card comes into play tapped you can actually succeed in tapping your manapool...Well, *I* thought it was amusing. :mrgreen:
Maybe this is the dreaded unplayable card in your hand bug?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 49 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 49 users online :: 0 registered, 0 hidden and 49 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 49 guests

Login Form