mill cards
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
mill cards
by Codeknight » 02 Jun 2009, 02:43
Hey guys, great programing. I'd like to help out and make a few cards but I'm just learning java so don't expect much .
Anyway I have a question regarding the programing of on of my favorite card effects: Milling.
I'm currently trying to make Ink Dissolver. I got it to ask if I want to use the ability but I'm not sure how to actually mill. By experimenting with code that is already in the program I have made Ink Dissolver do various other things but I'm not sure how to make him mill. Any suggestions?
Anyway I have a question regarding the programing of on of my favorite card effects: Milling.
I'm currently trying to make Ink Dissolver. I got it to ask if I want to use the ability but I'm not sure how to actually mill. By experimenting with code that is already in the program I have made Ink Dissolver do various other things but I'm not sure how to make him mill. Any suggestions?
- Codeknight
- Posts: 3
- Joined: 30 May 2009, 07:04
- Has thanked: 0 time
- Been thanked: 0 time
Re: mill cards
by DennisBergkamp » 02 Jun 2009, 03:56
Welcome! How about something like this:
- Code: Select all
...
String player = card.getController();
String opponent = AllZone.GameAction.getOpponent(player);
PlayerZone library = Allzone.getZone(Constant.Zone.Library, opponent);
PlayerZone grave = AllZone.getZone(Constant.Zone.Library, opponent);
CardList lib = new CardList(lib.getCards());
for (int i=0; i < 3; i++)
{
if (lib.size() == 0)
return;
Card c = lib.get(0);
lib.remove(c);
library.remove(c);
grave.add(c);
}
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: mill cards
by Rob Cashwalker » 02 Jun 2009, 11:25
PlayerZone grave = AllZone.getZone(Constant.Zone.Library, opponent);
won't work - just returns another copy of the library....
Constant.Zone.Graveyard
won't work - just returns another copy of the library....
Constant.Zone.Graveyard
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
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: mill cards
by Rob Cashwalker » 02 Jun 2009, 18:19
and also you probably want to avoid hard-coding the target being the opponent.... It would typically use the phrase "target player puts the top n cards into his or her graveyard". Some startegies involve self-milling to fill up the graveyard for threshold or returning cards from the graveyard to play, or soulshift.... Not that we have much of these spells yet.
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: mill cards
by DennisBergkamp » 02 Jun 2009, 18:40
Yes, but he was talking about Ink Dissolver, it has to target the opponent
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: mill cards
by Codeknight » 02 Jun 2009, 22:47
Thanks guys I'll try it out when I have access to my non-internet computer.
*EDIT*
Well I don't know what I did but know when I click "Play Game" nothing happens . I fiddled with some other pieces of the game but when I added the above suggested code I compiled the original source code, so the only thing different is "GameActionUtil.java". I would attach it but the site seems to not like text file attachments... should I put it in code tags? It'd be pretty long...
*EDIT*
I decided to post the parts I added but if you need to see the rest for what ever reason I could email or something.
*EDIT*
Well I don't know what I did but know when I click "Play Game" nothing happens . I fiddled with some other pieces of the game but when I added the above suggested code I compiled the original source code, so the only thing different is "GameActionUtil.java". I would attach it but the site seems to not like text file attachments... should I put it in code tags? It'd be pretty long...
*EDIT*
I decided to post the parts I added but if you need to see the rest for what ever reason I could email or something.
- Code: Select all
import java.util.*;
public class GameActionUtil
{
public static void executeUpkeepEffects()
{
upkeep_removeDealtCombatDamageToOppThisTurn();
//upkeep_Echo();
// upkeep_CheckEmptyDeck_Lose(); //still a little buggy
upkeep_Ink_Dissolver();
...
private static void upkeep_Ink_Dissolver()
{
final String player = AllZone.Phase.getActivePlayer();
PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player);
PlayerZone library = AllZone.getZone(Constant.Zone.Library, player);
CardList list = new CardList(playZone.getCards());
list = list.getName("Ink Dissolver");
Ability ability;
for (int i = 0; i < list.size(); i++)
{
if (library.size() <= 0)
{
return;
}
// System.out.println("top of deck: " + library.get(i).getName());
String creatureType = library.get(0).getType().toString();
String cardName = library.get(0).getName();
ability = new Ability(list.get(i), "0")
{
public void resolve()
{
PlayerZone play = AllZone.getZone(Constant.Zone.Play,
player);
PlayerZone library = AllZone.getZone(Constant.Zone.Library,
player);
String creatureType = library.get(0).getType().toString();
if (creatureType.contains("Merfolk")
|| creatureType.contains("Wizard") || library.get(0).getKeyword().contains("Changeling"))
{
String player = card.getController();
String opponent = AllZone.GameAction.getOpponent(player);
PlayerZone library = Allzone.getZone(Constant.Zone.Library, opponent);
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, opponent);
CardList lib = new CardList(lib.getCards());
for (int i=0; i < 3; i++)
{
if (lib.size() == 0)
return;
Card c = lib.get(0);
lib.remove(c);
library.remove(c);
grave.add(c);
}
}
}// resolve()
};// Ability
if (creatureType.contains("Merfolk")
|| creatureType.contains("Wizard"))
ability.setStackDescription("Ink Dissolver - " + player
+ "'s opponent discards the top 3 cards of his or her library.");
else
ability.setStackDescription("Ink Dissolver - " + player
+ " reveals top card: " + cardName + ".");
AllZone.Stack.add(ability);
}// for
}// upkeep_Ink_Dissolver()
- Codeknight
- Posts: 3
- Joined: 30 May 2009, 07:04
- Has thanked: 0 time
- Been thanked: 0 time
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 158 guests