Commit Graph

1378 Commits

Author SHA1 Message Date
omegablast2002@yahoo.com 6f792e5546 2011-02-22 14:38:07 +00:00
wagic.the.homebrew@gmail.com dc48b5472b Erwan
- fixing incorrect case for include of PlayRestrictions.h
2011-02-19 16:52:37 +00:00
techdragon.nguyen@gmail.com 788ae5e629 fixed a division by zero error when AI has equipment on field but no creatures to equip them to.
fixed formatting of getEfficiency code block
2011-02-19 15:39:48 +00:00
wagic.the.homebrew@gmail.com db0c55b4dd Erwan
- Fixed an issue with maxCast targeting opponent
2011-02-16 14:35:49 +00:00
wagic.the.homebrew@gmail.com 8dd6856453 Erwan
- fixed issue 595 (MaxCast not working). Root cause was the stupidest typo ever in the code (maxCost instead of maxCast...)
- fixed an issue with Storm mentioned by zethfox (was counting only spells played by current player)
- Moved "max lands per turn" rule outside of the code (yay!) Please be sure to update your Rules folder!
2011-02-15 14:17:34 +00:00
techdragon.nguyen@gmail.com 2cd72cc4ca we should access the data required within a given context. Using DeckStats in this way works
but only by chance that the previous step set the current deck file.  Used victory percentage
from the MetaData object rather than forcing what has already been computed.

TODO:  getVictoryPercentage() needs to represent Overall VictoryPercentage for all decks, not just
player decks.  AI Decks use getVictoryPercentage() to represent the VictoryPercentage against a
specific deck.  There should be an additional method that says getVictoryPercentageVsDeck( deckObject )
2011-02-14 17:44:35 +00:00
techdragon.nguyen@gmail.com 16f7d2d675 added conditional to avoid having to ping the stats map all the time. The data
is already cached, but there's no need to spend a function call to check the hashmap
if we have a bool for that reason.
2011-02-14 17:38:57 +00:00
techdragon.nguyen@gmail.com 73b2d5ded8 removed redundant code for card loading. getCardByName already loads by Id and caches the result
duplicating that code in MTGDeck is redundant.
2011-02-14 17:36:19 +00:00
wagic.the.homebrew@gmail.com 5b365e53f0 Erwan
- submit a fix for TestSuiteAI, I don't understand why it wasn't submitted with my other changes yesterday. This fixes a bug in the test suite (One storm test would fail without this)
- minor refactor to AI code
2011-02-14 13:29:27 +00:00
techdragon.nguyen@gmail.com f4d1154cd6 reverted latest change 2011-02-14 09:35:43 +00:00
techdragon.nguyen@gmail.com d9efb408e5 * optimized card loading. There was some redundant code that wasn't necessary.
* getCardByName seemed to have a initialization error if you tried to use it before the entire game loaded.  The cache would
throw an exception if you tried to use find and it was empty.  I put a guard around it to avoid this issue.

* refactored Zeth's "toggledifficuly" feature to be stored in meta data.  http://code.google.com/p/wagic/source/detail?r=3106
 -- This is slightly modified as it forces a 1 for 1 swap of cards that are specified.
    from the example given this is how it seemed to be used anyways.
 -- since all the information is stored in the meta data, there's no need to alter the deck's
    definition.
2011-02-14 08:14:35 +00:00
techdragon.nguyen@gmail.com 1b5002726c altered condition to srcLenth -1 and not "srcLength - 2" 2011-02-14 06:54:28 +00:00
techdragon.nguyen@gmail.com 7047b1ccfc fixed typo 2011-02-14 06:52:11 +00:00
techdragon.nguyen@gmail.com ee71b6bf0e Added a guard to ensure array access is within bounds of filter.
For some reason, the VS2008 compiler allows this illegal access and VS2010 does not.  In all actuality it should never be permitted.

Please review the thread posted on the SVN thread for details as to why this needs a fix.
http://code.google.com/p/wagic/issues/detail?id=593&sort=-id


Issue: 593
2011-02-14 06:07:04 +00:00
omegablast2002@yahoo.com 072a250dc0 reverted it completely now in hopes that this is whats stalling ai...for some strange reason im noticing that ai is tapping an extra mana every time it tries to play something...
exsample it wants to play a {2}{b}{b} ...so it taps 5 mana instead of the 4 it would have tapped before....
2011-02-14 01:45:14 +00:00
omegablast2002@yahoo.com 3826355b6b reverting a peice of a change i did a couple days ago...
the way getPotentialMana and the payment of cost needs a SERIOUS revamp, i would almost say that these function only work because of bugs.....
2011-02-14 00:28:44 +00:00
techdragon.nguyen@gmail.com 67026849a6 sealed possible memory leak when WCFilterGROUP is created. 2011-02-13 13:28:25 +00:00
techdragon.nguyen@gmail.com 5be429c48f combined nbzone increment and zone assignment into one statement. 2011-02-13 13:25:41 +00:00
wagic.the.homebrew@gmail.com 6b89899d1b Erwan
- deprecated the following keywords (see list below for new usage)
-- cantcreaturecast => auto=maxCast(creature)0
-- cantspellcast => auto=maxCast(*)0
-- onlyonecast => auto=maxCast(*)1 
-- bothcantcast => auto=maxCast(*)0 auto=maxCast(*)0 opponent
-- bothnocreature => auto=maxCast(creature)0 auto=maxCast(creature)0 opponent
-- oneboth => auto=maxCast(*)1 auto=maxCast(*)1 opponent

Strangely enough, I couldn't find most of these keywords in mtg.txt?

I also removed variables such as "spellCastedThisTurn" and stuff like that... now if you want to know how many spells were cast in one turn by a given player, use player->game->stack->seenThisTurn("*").
seenThisTurn can take a string representing a TargetChooser, or better, a TargetChooser.

I can't guarantee I didn't break anything, but the test suite passes and the AI seems to run ok
2011-02-13 11:23:51 +00:00
wagic.the.homebrew@gmail.com 8eac9c587e Erwan
- added maxCast and maxPlay abilities, this deprecates the following abilities: nospells,nocreatures,onlyonespell,land
I usually don't like to deprecate abilities, but the existing ones, despite having easy to remember names, were really not flexible enough.

If you want to use these old keywords, instead use:
-- nospells  =>  maxCast(*)0
-- onlyOneSpell => maxCast(*)1
--nocreatures => maxCast(creature)0
--land:1 => maxplay(land)+1

note maxPlay and maxCast. They follow similar rules, but maxPlay monitors the number of cards that are going on the Battlefield, while maxCast monitors the stack. In most cases, maxCast should be the one to use, but lands are a special case because they go directly to play.

I unfortunately cannot guarantee I didn't break anything, especially in the AI, but the test suite passes ,and I added a few additional tests yesterday and today, to feel more confident about the change.

next step is removing the creatures keywords that do the same kind of thing (cantcast, etc...) and replace them with maxCast
2011-02-13 08:01:13 +00:00
omegablast2002@yahoo.com b21ca5d91c had to change it, psp compile didnt like it. source->XX 2011-02-13 04:46:57 +00:00
omegablast2002@yahoo.com e36cf18d26 added support for {x}{x}: word variable returns for activated target abilities...sometimes im not told when things break or dont work completely, and i find out later myself. :) 2011-02-12 20:29:42 +00:00
wagic.the.homebrew@gmail.com 60017a6652 Erwan
- replaced variables canPutLandsIntoPlay and landsPlayerCanStillPlay with a PlayRestrictions class.
- Added  seenThisTurn(TargetChooser * tc) in MTGGameZones, which allows to count how many cards matching a targetChooser have been in a given zone in the current turn. With minor work, this can probably be reused by the ability parser for some cards that need to count how many **** where played or put on the stack during a turn.
-- for example player->game->stack->seenThisTurn([put a TypeTargetChooser("creature") here]) would give you the number of creature spells cast by the player this turn.
- This is the first step of a refactor that aims at removing all the adhoc variables for "cant cast". I plan to get rid of the following variables in Player.h (and the associated code, which hopefully will become smaller):  
    int castedspellsthisturn;
    bool onlyonecast;
    int castcount;
    bool nocreatureinstant;
    bool nospellinstant;
    bool onlyoneinstant;
    bool castrestrictedcreature;
    bool castrestrictedspell;
    bool onlyoneboth;
    bool bothrestrictedspell;
    bool bothrestrictedcreature;

They will be replaced by the PlayRestrictions system, and hopefully I'll have time to update the parser to make this more generic as well.
My initial goal with this change was to move the limit of 1 land per turn outside of the code, and make it an external rule in Rules/mtg.txt. I have yet to do it.
2011-02-12 16:31:07 +00:00
omegablast2002@yahoo.com 0a60979554 fix and completely reworked affinity AGAIN.
moved it out of rules, it was FAR to error prone and after fixing bugs on this ability about 12 times, im done with it.

noticed yesterday that it was removing the completely wrong amounts, and not maintaining its cost AT ALL. so i got sick of adjusting it as a rule, its now a statebased effect, called through gamestatebasedeffect as a side function.

the new affinity is less then 100 lines of code, down from 300. to acomplish the effect with FAR less effort. it is also FAR easier to maintain in the future if i die or leave the scene or whatever.

added a new count tool for MTGGameZones canByCanTarget...which allows for returns of amounts based on if it can be targetted by a tc. much like how listmaintainer does it. affinitygreencreature will not be the only ability to use this function, just a heads up. its just the first to do so.

hopefully this much more accurate affinity will be the last version...considering adding the other types which old affinity couldnt handle :D
2011-02-12 15:06:28 +00:00
omegablast2002@yahoo.com 53477bfae2 opps if you were at exactly 65% then none of the 2 appeared XD ..this should correct that 2011-02-12 03:23:36 +00:00
omegablast2002@yahoo.com 19c3e903bc just cleaning, removed a double check i added ages ago that isnt really needed anymore, ai handles fine now without having to double check if it can cast after it already did so. 2011-02-12 03:00:45 +00:00
omegablast2002@yahoo.com e3ecc612d0 removed a part that wasnt actually supposed to be in the change...my bad. 2011-02-12 02:42:26 +00:00
omegablast2002@yahoo.com e9b47944e3 reverted a 2nd atempted fix at the infinate loop with ai using inkmoth nexus...
it was making ai tap itself out.

i think im about 99% sure i know where the issue is now, hopefully.
2011-02-12 02:27:30 +00:00
omegablast2002@yahoo.com 76653b6f54 going to go ahead and commit this now as updating the ai decks to use this tool is going to be a huge task...i originally wanted to commit this when i had a substantial amount of ai decks using it, to show case how it makes a huge difference.
it is a feature that is for ai deck building
what it will do is as follows

#NAME:sample deck
#DESC:The forces of fire and nature unite. 
#DESC: 
#DESC:Can you withstand 
#DESC:their combined fervor? 

toggledifficulty:lotus petal|black lotus (*) * 4
grizzly bear (*) * 4
someCard (8) *4

notice the toggle dificulty?
syntax is ....toggledifficulty:easy card name or number|hard card (optional set if both belong to same set otheriwse use * ) *howmany

toggledifficulty:frying pan|machine gun
toggledifficulty:tomatoe|pumpkin (MBS) * 3
toggledifficulty:tomatoe|squash
grizzly bear (*) * 4

the above exsample as easy will have a deck with:
frying pan
4X tomatoe
4X grizzly bear

and on hard it will have:
machine gun
3x pumpkin
squash
4X grizzly bears

the entire deck can be built with toggledifficulty cards....its not limited to just a single use.
you can also mix it up, some can be toggledifficulty some can be just like normal, you are not limited to having to have a complete deck of toggled cards...

if your currently selected deck has an over all win ratio of 65% or higher...this deck will have 4 black lotuses in it...if youre overall win with the current deck you are playing is below 65% then those 4 black lotuses are replaced by 4 lotus petals instead...effectively making it an easier ai deck...

note, the 2 cards used are exsamples...its a great way to show you the potential this change can have...an ai deck with 4 black lotuses will do WAY better then the same deck with 4 lotus petal...if you catch my drift...
2011-02-11 18:01:50 +00:00
omegablast2002@yahoo.com 25fe86ad89 added "turnlimited" restriction for blocked, blocking, combatdamaged, and damaged triggers. 2011-02-10 19:50:09 +00:00
techdragon.nguyen@gmail.com 93c63cef3d reimplemented mana color display for deck selection. This is now totally controlled by
stats generation.  No data needs to be written to the deck master files themselves.
Now the mana colors will only show if you have battled with a particular deck at least once.
This is not retroactive, so you will need to battle the ai again.  This can not be edited manually
either to prevent tampering with the statistical data.  Player deck mana color display is also
covered this way.

Decks will still be saved in the new layout if a disk write is necessary.  So any changes via
the deck editor will result in a deck file rewrite is was always the case.:)
2011-02-10 17:19:11 +00:00
techdragon.nguyen@gmail.com bfd8cf8527 fixed a mem leak I introduced in last update 2011-02-10 00:18:52 +00:00
techdragon.nguyen@gmail.com 9c8ff0e27a updated ManaCost copy constructor to do a true deep copy.
added copy constructors to ManaCostHybrid.
2011-02-09 20:42:19 +00:00
wagic.the.homebrew@gmail.com 7f4c001a1d Erwan
- minor cleanup of MTGRules.cpp based on my comments in r3084. I visually verified that I didn't break the fix in r3084. Also ran the test suite.
-- in case somebody wonders about some of the tests I deleted, most of these tests are useless because all callers make sure alternateCost is not null (in isReactingToClick) and that the manapool can afford the cost, before doing the call to reacttoclick. Proving it by adding an assert, and also making the function protected, to be sure it is only called by the authorized children.
2011-02-09 14:33:09 +00:00
techdragon.nguyen@gmail.com 4cbf3ddeb5 removed extraneous function. Not meant for last check in 2011-02-09 13:21:26 +00:00
techdragon.nguyen@gmail.com 2c0da5e7e6 added copy constructor with operator=
updated constructor for ManaCost*

TODO:  May have to look at ManaPool in case that needs updates as well.
2011-02-09 12:03:15 +00:00
omegablast2002@yahoo.com d8da946f5d forgot a "break;" here on this restriction 2011-02-08 23:09:20 +00:00
omegablast2002@yahoo.com 44fe3cffec fixed a crash that was happening when ai would try to play a card like wurmcalling. 2011-02-08 20:25:41 +00:00
omegablast2002@yahoo.com 4d28bdd925 fixed a bug where mana icons were not being removed from mana pool when using extracost types...this happened during the refactor..the mana was changed from engaging the players mana pool which sends those events, into a sort of "bypass everything and just subtract the mana from the pool" you actually WANT to engage the players mana pool, as its directly tied to the events which remove those mana from the pool. 2011-02-08 19:20:04 +00:00
omegablast2002@yahoo.com 80b35e8071 fix for black sun zeneth...we were checking the wrong thing for a refreshed number...i had it checking the target instead of the source of that ability. 2011-02-08 15:50:57 +00:00
omegablast2002@yahoo.com f7b34295fb added a way to set the max amount a counter ability can give you...aka the clockworks effect...as per mtg rules, you are still allowed to activate the effect but if it would put the target counters higher then the max allowed by that ability, then it will do nothing.
it strings exactly like normal counters did, except now after the name you can add yet another "," and a number or word varible...if you will not have a name it is still required that you add the extra comma, as it is a seperator for the parser. so clock works swarm would be counter(1/0,1,,4)...no matter what, this ability will do nothing if the amount of the target counter is already higher then the max allowed, in this case 4...other effects can give the creature more counters...however..this ability will resolve to nothing if youve exceeded the limit. until you are under the amount again.
2011-02-08 15:12:14 +00:00
techdragon.nguyen@gmail.com 1b5a379387 added empty string check when save and quiting from the deck editor.
Issue: 3052
2011-02-08 06:30:18 +00:00
omegablast2002@yahoo.com 104a626b3b excluding these types from allsubtype transforms subability. 2011-02-07 17:12:12 +00:00
omegablast2002@yahoo.com cba1849ef6 i subjected poor changelings to planeswalker legend rule lol. 2011-02-07 15:37:21 +00:00
omegablast2002@yahoo.com 79d4312660 it was reported to me that blinking a token can potentially crash the game on the "return" my fault..forgot that once tokens go to exile, we're done with them for good. 2011-02-07 14:00:42 +00:00
omegablast2002@yahoo.com 18c70ec187 found the cause of the loop in inkmoth, it has to do with the way manaproducers set thier "needsTapping" depending on the way the ability is called, it can set it 3 ways, {t}<--sets only the manaproducers "tap" and completely ignores the "doTap" which is the way actiavted mana producers call it. 2011-02-07 13:48:27 +00:00
omegablast2002@yahoo.com 9b076d6791 removed a fix to an infinate loop bug with Ai using cards such as inkmoth nexus...
as it removed ais ability to momir...protip in MTG youre not allowed to interrupt your own abilities...the way momir is working now, it select an action that doesnt pass priority instead it instantly searchs for a momir ability...which is wrong...
2011-02-07 13:29:27 +00:00
techdragon.nguyen@gmail.com 6ccc859ca0 The issue is the controller for the menu fails badly when the triangle button is pressed. That particular menu uses the menu item id to index into an array somewhere. Since the triangle key is valued at -200, this causes a negative index into an array.
I've added a guard to ignore the triangle key for now.  If there is a more elegant solution we can find later than great.
Issue: 577
2011-02-07 06:55:04 +00:00
omegablast2002@yahoo.com bf427b6402 i actually misinterperated the fading rule...
the difference between vainshing and fading is...
fading sac triggers the NEXT time you try to remove a fade counter but cant, vanishing sac triggers WHEN you remove the last counter.
2011-02-06 18:48:08 +00:00
omegablast2002@yahoo.com de6e5ed7eb extended "vanishing" to support "fading" these 2 abilities are the same with the exception of the name of the counter the creature receive. 2011-02-06 18:20:59 +00:00