Summer Vacation!!!
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Summer Vacation!!!
by zerker2000 » 19 Jun 2009, 03:42
Sorry immature teen outburst .
So anyways, now I have my finals done, and am free to do as I please for the next ~3 months =). I would like to spend some of that time helping with Forge programing, and am planning to dedicate this post to said topic(i.e. posting some "[code]" suggestions here instead of posting "make <card name> plz" in card requests).
Ok, so my initial question: what is the optimal way/ program in which to edit/test/debug forge on the fly? I am sure editing the java files in source.rar and recompiling every two lines is Not it .
So anyways, now I have my finals done, and am free to do as I please for the next ~3 months =). I would like to spend some of that time helping with Forge programing, and am planning to dedicate this post to said topic(i.e. posting some "[code]" suggestions here instead of posting "make <card name> plz" in card requests).
Ok, so my initial question: what is the optimal way/ program in which to edit/test/debug forge on the fly? I am sure editing the java files in source.rar and recompiling every two lines is Not it .
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
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: Summer Vacation!!!
by Rob Cashwalker » 19 Jun 2009, 04:16
eclipse
My suggestions for what to start with, is when looking through the source code, find some mechanic that shows up often in the code, and often in general. (with an eye towards spells, as we're lacking many of them) Then work up a keyword handler that makes that mechanic easily added for all the cards that the source code already handles plus all the others that you can find in gatherer.
Once you've gotten dirty with that, you should start with cards that are more unique, requiring explicit code, but not necessarily complex.
My suggestions for what to start with, is when looking through the source code, find some mechanic that shows up often in the code, and often in general. (with an eye towards spells, as we're lacking many of them) Then work up a keyword handler that makes that mechanic easily added for all the cards that the source code already handles plus all the others that you can find in gatherer.
Once you've gotten dirty with that, you should start with cards that are more unique, requiring explicit code, but not necessarily complex.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Summer Vacation!!!
by DennisBergkamp » 19 Jun 2009, 05:24
Yes, definitely Eclipse.
The way I started out is just checking out the code of various cards in CardFactory.java and trying to add some more cards.
The way I started out is just checking out the code of various cards in CardFactory.java and trying to add some more cards.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Summer Vacation!!!
by zerker2000 » 19 Jun 2009, 05:40
Ok, I downloaded Eclipse, but I couldn't figure out how to add the source into a project .
And by the way, I'm sorry in advance to the people who will have to walk me through(almost) everything, hopefully I'll learn the basics soon enough .
And by the way, I'm sorry in advance to the people who will have to walk me through(almost) everything, hopefully I'll learn the basics soon enough .
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
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: Summer Vacation!!!
by zerker2000 » 19 Jun 2009, 08:52
I'll try to get that working...Rob Cashwalker wrote:eclipse
Hmm...I think I found a problem: is it just me, or are +1/+1 and -1/-1 counters programmed not to cancel? I understand that constantly checking for that would be a problem, however now that wither is coded... anyways, is it intentional, or was that rule overlooked?My suggestions for what to start with, is when looking through the source code, find some mechanic that shows up often in the code, and often in general.
... actually, it doesn't seem like a fix that would require much work: all you need to do is put(something similar to)
- Code: Select all
public void cancelPMCounters()
{
if(counters.containsKey(Counter.P1P1)&&counters.containsKey(Counter.P1P1))
{
if (counters.get(Counter.P1P1)>=counters.get(Counter.M1M1)){
counters.put(Counter.P1P1,(counters.get(Counter.P1P1) -
counters.get(Counter.M1M1));
counters.put(Counter.M1M1,0);
}
else {
counters.put(Counter.M1M1,(counters.get(Counter.M1M1) -
counters.get(Counter.P1P1));
counters.put(Counter.P1P1,0);
}
}
this.updateObservers();
}
EDIT: or even better,
- Code: Select all
public void cancelPMCounters()
{
if(counters.containsKey(Counter.P1P1)&&counters.containsKey(Counter.P1P1))
{
int netc = getNetPTCounters();
counters.put(Counter.P1P1,(abs(netc) + netc)/2);
counters.put(Counter.M1M1,(abs(netc) - netc)/2);
}
this.updateObservers();
}
Last edited by zerker2000 on 19 Jun 2009, 21:19, edited 1 time in total.
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
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: Summer Vacation!!!
by Rob Cashwalker » 19 Jun 2009, 16:16
Eclpise is distributed as a zip archive. It's not installed, so you have to find the EXE and run it yourself and make your own shortcuts.
File -> New -> Java Project
A window pops up. Give the project a name. Select "Create project from existing source" and browse to the source code.
Click Next.
On the next page, click "Configure Output Folder Properties". Select "Specific output folder (path relative to 'project name'". Click Browse.
Another pop up comes up, select project name then click "Create New Folder".
Another pop up comes up. Click Advanced, then select "Link to folder in the file system". In the next window, browse to the source folder, then click "Make New Folder". It literally makes a "New Folder". Right-click it to rename. Then you have to browse off that folder and back onto it for the name to update in the Folder text box. Click OK. Click OK. Click OK. Then finally, click Finish.
Now your new project shows up in the project explorer on the left. Expand the "default project" item to see all the source files. Double-click to open in the editor on the right.
File -> New -> Java Project
A window pops up. Give the project a name. Select "Create project from existing source" and browse to the source code.
Click Next.
On the next page, click "Configure Output Folder Properties". Select "Specific output folder (path relative to 'project name'". Click Browse.
Another pop up comes up, select project name then click "Create New Folder".
Another pop up comes up. Click Advanced, then select "Link to folder in the file system". In the next window, browse to the source folder, then click "Make New Folder". It literally makes a "New Folder". Right-click it to rename. Then you have to browse off that folder and back onto it for the name to update in the Folder text box. Click OK. Click OK. Click OK. Then finally, click Finish.
Now your new project shows up in the project explorer on the left. Expand the "default project" item to see all the source files. Double-click to open in the editor on the right.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Summer Vacation!!!
by DennisBergkamp » 19 Jun 2009, 18:58
I was thinking about this. However, as it turns out, they don't really "cancel" each other out per se. For instance, I implemented Kinsbaile Borderguard, for which we have to keep track of how many +1/+1 and how many -1/-1 counters are on there (since they really do both count when it gets destroyed).Hmm...I think I found a problem: is it just me, or are +1/+1 and -1/-1 counters programmed not to cancel? I understand that constantly checking for that would be a problem, however now that wither is coded... anyways, is it intentional, or was that rule overlooked?
... actually, it doesn't seem like a fix that would require much work: all you need to do is put(something similar to)
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Summer Vacation!!!
by GandoTheBard » 19 Jun 2009, 19:13
Be that as it may it seems to me that MTGO cancels out +1/+1 counters with -1/-1 counters. The difference I think is whether a counter is named or not.
visit my personal homepage here: http://outofthebrokensky.com
Listen to my podcast with famed AJ_Impy "Freed from the Real" on http://puremtgo.com
Listen to my podcast with famed AJ_Impy "Freed from the Real" on http://puremtgo.com
-
GandoTheBard - Tester
- Posts: 1043
- Joined: 06 Sep 2008, 18:43
- Has thanked: 0 time
- Been thanked: 0 time
Re: Summer Vacation!!!
by zerker2000 » 19 Jun 2009, 21:03
Don't you guys read the Comprehensive Rules occasionally? I mean you are trying to write a program following them... Anyways,
Official sources wrote:420. State-Based Effects
...
420.3. Whenever a player would get priority ... the game checks for any of the listed conditions for state-based effects. All applicable effects resolve simultaneously as a single event, then the check is repeated. ...
...
420.5. The state-based effects are as follows:
...
420.5n If a permanent has both a +1/+1 counter and a -1/-1 counter on it, N +1/+1 and N -1/-1 counters are removed from it, where N is the smaller of the number of +1/+1 and -1/-1 counters on it.
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
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: Summer Vacation!!!
by zerker2000 » 19 Jun 2009, 21:54
Yes, I got that far by myself (though its not exactly an EXE: I'm on Fedora Core(5 I think)Rob Cashwalker wrote:Eclpise is distributed as a zip archive. It's not installed, so you have to find the EXE and run it yourself and make your own shortcuts.
Oh I clicked finish instead of nextFile -> New -> Java Project
A window pops up. Give the project a name. Select "Create project from existing source" and browse to the source code.
Click Next.
Where? EDIT: Ok, I have the project, how do I run forge from it?On the next page, click "Configure Output Folder Properties".
Last edited by zerker2000 on 19 Jun 2009, 22:49, edited 1 time in total.
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
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: Summer Vacation!!!
by MageKing17 » 19 Jun 2009, 22:20
Kinsbaile Borderguard only counts +1/+1 and -1/-1 counters because it dies before SBEs are checked and the counters can be "canceled out".DennisBergkamp wrote:I was thinking about this. However, as it turns out, they don't really "cancel" each other out per se. For instance, I implemented Kinsbaile Borderguard, for which we have to keep track of how many +1/+1 and how many -1/-1 counters are on there (since they really do both count when it gets destroyed).
-
MageKing17 - Programmer
- Posts: 473
- Joined: 12 Jun 2008, 20:40
- Has thanked: 5 times
- Been thanked: 9 times
Re: Summer Vacation!!!
by zerker2000 » 19 Jun 2009, 22:23
... so SBEs should still remove them right?MageKing17 wrote:Kinsbaile Borderguard only counts +1/+1 and -1/-1 counters because it dies before SBEs are checked and the counters can be "canceled out".
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
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: Summer Vacation!!!
by Incantus » 20 Jun 2009, 01:35
Yes. You do each SBE check in the order listed in the comp rules, and then the resulting actions are done at once.
Last edited by Incantus on 20 Jun 2009, 13:28, edited 1 time in total.
Re: Summer Vacation!!!
by Rob Cashwalker » 20 Jun 2009, 01:40
I don;t know if Eclipse is terribly the same in Linux.
You have to create a Run Configuration that points to Gui_NewGame.main. It will complain about some file error. You have to edit the properties of the Run Configuration to point to a working folder. The working folder should be the MTGForge folder where cards.txt and all the other data files are located. You could also try copying all the data files to the output folder created from creating the project.
Once you've created a Run Configuration, the Debug Configuration will work as well. In that mode, you can set breakpoints where execution will stop and allow you to inspect the contents of objects and variables.
You have to create a Run Configuration that points to Gui_NewGame.main. It will complain about some file error. You have to edit the properties of the Run Configuration to point to a working folder. The working folder should be the MTGForge folder where cards.txt and all the other data files are located. You could also try copying all the data files to the output folder created from creating the project.
Once you've created a Run Configuration, the Debug Configuration will work as well. In that mode, you can set breakpoints where execution will stop and allow you to inspect the contents of objects and variables.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Summer Vacation!!!
by zerker2000 » 21 Jun 2009, 06:26
Okay, here goes:
- Code: Select all
Blight Sickle
2
Artifact Equipment
Equipped creature gets +1/+0 and has Wither.
- Code: Select all
//*************** START *********** START **************************
if (cardName.equals("Blight Sickle"))
{
final Ability equip = new Ability(card, "2")
{
public void resolve()
{
if (AllZone.GameAction.isCardInPlay(getTargetCard()) && CardFactoryUtil.canTarget(card, getTargetCard()) )
{
if (card.isEquipping())
{
Card crd = card.getEquipping().get(0);
if (crd.equals(getTargetCard()) )
return;
card.unEquipCard(crd);
}
card.equipCard(getTargetCard());
}
}
public boolean canPlay()
{
return AllZone.getZone(card).is(Constant.Zone.Play) &&
AllZone.Phase.getActivePlayer().equals(card.getController()) &&
!AllZone.Phase.getPhase().equals("End of Turn") &&
!AllZone.Phase.getPhase().equals(Constant.Phase.Combat_Declare_Blockers_InstantAbility);
}
public boolean canPlayAI()
{
return getCreature().size() != 0 && !card.isEquipping();
}
public void chooseTargetAI()
{
Card target = CardFactoryUtil.AI_getBestCreature(getCreature());
setTargetCard(target);
}
CardList getCreature()
{
CardList list = new CardList(AllZone.Computer_Play.getCards());
list = list.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
return c.isCreature() && (!CardFactoryUtil.AI_doesCreatureAttack(c)) && CardFactoryUtil.canTarget(card, c) &&
(! c.getKeyword().contains("Defender"));
}
});
// list.remove(card); // if mana-only cost, allow self-target
return list;
}//getCreature()
};//equip ability
Command onEquip = new Command()
{
private static final long serialVersionUID = 8130682765214560887L;
public void execute()
{
if (card.isEquipping())
{
Card crd = card.getEquipping().get(0);
crd.addExtrinsicKeyword("Wither");
crd.addSemiPermanentAttackBoost(1);
}
}//execute()
};//Command
Command onUnEquip = new Command()
{
private static final long serialVersionUID = 5783423127748320501L;
public void execute()
{
if (card.isEquipping())
{
Card crd = card.getEquipping().get(0);
crd.removeExtrinsicKeyword("Wither");
crd.addSemiPermanentAttackBoost(-1);
}
}//execute()
};//Command
Input runtime = new Input()
{
private static final long serialVersionUID = -6785656229070523470L;
public void showMessage()
{
//get all creatures you control
CardList list = new CardList();
list.addAll(AllZone.Human_Play.getCards());
list = list.getType("Creature");
stopSetNext(CardFactoryUtil.input_targetSpecific(equip, list, "Select target creature to equip", true));
}
};//Input
equip.setBeforePayMana(runtime);
equip.setDescription("Equip: 2");
card.addSpellAbility(equip);
card.setEquip(onEquip);
card.setUnEquip(onUnEquip);
} //*************** END ************ END **************************
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
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
17 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 77 guests