theFarWilds.com http://thefarwilds.com/forum/ | |
Example: blocking a certain card http://thefarwilds.com/forum/viewtopic.php?f=14&t=1772 |
Page 1 of 1 |
Author: | jed [ Tue Mar 23, 2010 9:03 pm ] |
Post subject: | Example: blocking a certain card |
Take out all the Soul Plagues from a player's deck. Code: void beforeStart()
{ Player player=getHumanPlayer(0); ds=player.deckSize(); for(int n=0; n<ds; n++) { if( player.getDeckCard(n).getName()=="Soul Plague") { player.removeDeckCard(n); n--; } } } |
Author: | queeshai [ Tue Mar 23, 2010 10:52 pm ] |
Post subject: | Re: Example: blocking a certain card |
it is both exciting and terrifying that this is the API that has been exposed to players. anyway, if I am interpreting the code correctly, I think it will break (unless there is some embedded exception handling for accessing a card with an index greater than the deck size). in general, try to avoid changing the loop iterator (n, in this case) outside the loop definition. e.g., Code: void beforeStart()
{ Player p = getHumanPlayer(0); for ( int n = p.deckSize()-1; n >= 0; n-- ) { if ( p.getDeckCard(n).getName() == "Soul Plague" ) { p.removeDeckCard(n); } } } |
Author: | jed [ Wed Mar 24, 2010 2:10 am ] |
Post subject: | Re: Example: blocking a certain card |
Yeah it wont break. It will just return an invalid card at the end which will return "" on getName. But your version is probably cleaner. > it is both exciting and terrifying that this is the API that has been exposed to players. Yeah I wish I had done this a looooong time ago. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |