Commit Graph

975 Commits

Author SHA1 Message Date
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
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
2690a3f9a0 updated variable "type:" to act more like a targetchooser...
draw:type:creature|opponentbattlefield
will draw a card for each creature on the opponents battlefield

this defualts to "|mybattlefield" however any target zone can be used, hand, library ect....
this will add support to some cards which werent possible with previous version of it, without having to create new word variables to do the same exact thing as can now be done with this.
2011-02-12 16:21:54 +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
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
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
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
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
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
omegablast2002@yahoo.com
156fd4a601 fixed handsize issue in demo.
Issue: 587
2011-02-06 14:50:02 +00:00
Xawotihs
b7b584113b - Moved the card collection out of the GameApp class to clean up the dependencies
- Added method to build a card collection independently of the GUI to ease my unitary test application
- Added part of some network GUI I'm working on, it's #ifdef out, I'm only committing this part to ease later merges
- Added the beginning of a serialization code of the Player and related classes used for network support
- various other minor cleanup
2011-02-06 11:35:40 +00:00
techdragon.nguyen@gmail.com
91a2cb9c90 fixed deck renaming to make changes immediate. 2011-02-05 22:21:49 +00:00
wrenczes@gmail.com
d5777a6565 A simpler way to allow trim() to work with temporary strings. 2011-02-05 06:42:53 +00:00
wagic.the.homebrew@gmail.com
f6bef26243 Erwan
- added some cache for function getCardByName. On my machine, this divides the running time of the test suite by almost 2 (now runs in 12 minutes instead of 21)
2011-02-05 03:46:41 +00:00
techdragon.nguyen@gmail.com
767983631a * moved deck saving to end of match. It now only saves when you've actually completed a game.
* added additional meta data for decks when saving them back to file.
  - decks saved this way now are split into three regions: creatures, spells and lands.  It's more for a visual sorting if a
     player wanted to look at the deck outside of the game.  It does not impact the deck loading negatively at all.  It may
     increase performance in cases where the deck was previously defined using the canonical names of the cards as the numeric ids
     reduce the work done when looking up the cards by name.
* modified ManaCost toString method.
* added toString method for ManaCostHybrid ( possibly make ManaCostHybrid a subclass of ManaCost)
* added additional operator overloading for ManaCost for printing to cover ManaCost when it's a pointer as well as a copy
   ( TODO: might want to check if making usage of ManaCost as a copy as opposed to a ptr is really necessary in most cases. )
* added alternate version of "trim" to handle trimming temporary strings as returned by things like ostringstream.str().
 - This was necessary since the PSP compiler doesn't do the necessary adjustments for those types of calls.
2011-02-04 12:37:44 +00:00
omegablast2002@yahoo.com
6edef29d17 opps forget to wrap this. 2011-02-03 17:10:51 +00:00
omegablast2002@yahoo.com
75a9d7840d 3 things here, found my targets returns for @vampired we're screwy, which explained why doc didnt add 3 of the possible cards for it...corrected that but i need to rename the varibles which i will do at a later time, not in this patch..
2 fix for token creator livingweapons...this was actually a preexisting bug, but not noticed becuase these are the first equipments that use token gen...when equipping it would readd the oneshot tok gen as an activated ability with no cost...generally we dont want to pass oneshot token generation to another card by equipping...

and 3rd...
got rid of the disgusting vanishing workaround.
it was riddled with bugs, got exsample if the creatures would gain indestructible the -99/-99 they were reciving did nothing to rid the battlefield of the creature...

new vanishing is 
auto=vanishing:number
thats it, no crazy 2 trigger lines with lords ect...
2011-02-03 14:17:25 +00:00
omegablast2002@yahoo.com
37adf143c8 added abilities=split second 2011-02-03 00:04:11 +00:00
omegablast2002@yahoo.com
e47eb86304 added a return( effect ) to blink... 2011-02-02 21:22:10 +00:00
omegablast2002@yahoo.com
e7fc20bd4c added
this(damaged)
added
targetchooser [damaged] status
added
targetchooser [controllerdamager]
targetchooser [opponentdamager]

basically checks for whos doing damage to who in a match per turn.
2011-02-02 18:22:08 +00:00
wagic.jeck
8c18d155b8 Jeck - Fix for issue 580. StyleManager initialization was causing an infinite loop. Also started documentation for OptionItem. 2011-02-01 19:11:43 +00:00
omegablast2002@yahoo.com
ea285e673e 2 changes here, first AManaProducer abilities will no longer use the stack as per MTG rules, for the most part this worked fine however genericactivedability does not use the reactto click put in place in the mana producer...so an ability which contained a cost other then just {t} was actually useing the stack instead in the fireability function.
2nd change is a bug fix, i noticed that cards which were mana producers which contained a cost but did not contain a {t}: would still tap at first i thought this was graphical, however after further reveiw i noticed that the card was indeed truely tapping...this was happening becuase amaproducer had a defualt of 1 for doTap/tap...and since genericactived ability does not go through the motions of setting the true manaproducers "doTap" which can be witnessed by stepping through the processes...it was defualting to a tap, even tho the cost might have just be {1}:add{ ....
2011-02-01 14:24:41 +00:00
wrenczes@gmail.com
b6dcb0dcd3 Fixed some formatting issues that cause compile issues on bsd. 2011-02-01 11:54:38 +00:00
wrenczes@gmail.com
76cba56a1c Resuming on my threading support work with the card caching mechanism. This change unfortunately touches quite a few files, but I needed to get it out of the way before things got out of hand: one significant hurdle is the assumed lifetime of a JQuad pointer. In a single threaded model, the life time of the pointer is clear: you fetch it into the cache, the cache makes room, you use the pointer immediately. In a multithreaded context however, it's unsafe, as the drawing thread can request a few JQuads, and the cache operating on a separate thread can potentially bounce a JQuad out of the cache before the draw routine is done using it, which ends up in an access violation when you attempt to draw using an invalidated quad pointer. To prevent this, the bulk of this change swaps out the use of naked JQuad* pointers in the code with a JQuadPtr, which is basically a typedef to a boost shared_ptr<JQuad>.
This btw points out another circular dependancy between the texture and the JQuad - a texture owns a bunch of JQuads, yet the renderer uses JQuads and always assumes that the texture is valid.  We're going to need to add more defensiveness to JGE to protect against this.

Other changes in this check-in:  WResourceManager doesn't derive from JResourceManager anymore.  It actually didn't require anything from the base, so I killed the dependency.  Also cleaned up the notion of a WTrackedQuad in the WCachedResource - it didn't need a separate class, just a better container.

I've build this & tested against PSP, win, linux, QT (linux).  I haven't tried against iOS and QT Win, or Maemo.  If these other platforms are broken, I apologize in advance! - I'm hoping it should be fairly simple to put them back into play.
2011-02-01 10:37:21 +00:00
wrenczes@gmail.com
cfa7bc748a More logging calls to my threading header. 2011-02-01 05:58:19 +00:00
techdragon.nguyen@gmail.com
d9facfb73b * moved deck mana display code into separate method.
* since I rescaled the images down to 50%, I moved the display to the upper right
   info box on the last line to the right of the "# of games played" information.
   Things look like it will fit as long as the number of games is under 1000
2011-02-01 00:48:23 +00:00
wagic.jeck
c68a989915 Jeck - Begun documentation for the WGui classes. Also updated doxygen config to support STL. 2011-01-31 10:24:06 +00:00
techdragon.nguyen@gmail.com
8af5870d48 * Added new options parameter. "SaveDetailedDeckInfo". This will force the system to save all
deck files in long format.  This is not configurable from the game.  It must be set manually
     inside options.txt.
     ie.  saveDetailedDeckInfo=1

* added extra debug information (line number inside text file) when card parser fails to recognize a line.
    - modified return value from "processConfLine()" to return 0 only when a true error occurs and print out
         "MTGDeck: Bad Line:
         [<line no>]: <line with error>"
    - processConfLine will now return 1 for lines starting with "#".  Previously it returned 0 which is incorrect
         as comments should not be considered as errors.

* removed DeckMetaDataList class from code.  This was duplicating the DeckMetaData storage in DeckManager
* new feature for deck selection screens.
   - player decks will now have an indication of what mana color it consists of.
   - Ai decks will show symbols once the player has played against the AI deck at least once.
   -- This is made possible with a new meta data inside each deck file.
        MANA:<string representing color switches - 0/1 >
2011-01-31 10:04:18 +00:00
techdragon.nguyen@gmail.com
2973158a62 added new utility to check if a file exists on system. 2011-01-31 08:53:06 +00:00
techdragon.nguyen@gmail.com
6ddaf8b74b removed draw method from GameObserver as it is no longer used since the refactor of the
player mulligan code.
2011-01-31 08:38:14 +00:00
wrenczes@gmail.com
6675a7da31 Implemented a lazy load pattern for the deck stats - when the DeckMenu is displaying decks, it calls LoadStats() for only the ones visible in the list. This helps reduces the lag that occurs each time we attempt to load all the AI decks during match selection.
This still could be improved - DeckMetaData's constructor loads an MTGDeck object to parse out the name of a deck from its file.  This means that we crack open 106 files on the first attempt to show the list of opponent decks. I started optimizing this, but reverted, as the list itself is sorted alphabetically.  Currently, with these mods, it's still taking 4 1/2 seconds on my psp to load the opponent list on the first go around.

While at it, did some cleanup - removed the need for passing around a player pointer in some of the DeckStat functions, etc.
2011-01-30 13:06:21 +00:00
wagic.jeck
e0f7bf26d8 Jeck - First doxygen commit, basic information on WFilter classes. Also added filter price adjustment for some of the newer basic abilities (the CANTLOSE varieties now cost more to filter). 2011-01-30 11:14:36 +00:00
omegablast2002@yahoo.com
c4ffc214ab moved token creator under aequip so i can do the same fix to livingweapon as i did for new target...
also refactored it a bit to remove the livingweapon and battleready copy paste code.
2011-01-30 00:01:57 +00:00
omegablast2002@yahoo.com
853b8ea5c6 fixed gravetitan bug reported, added new keyword "retarget" as another support for newtarget...
reworked the handling of new target...auras and equipments can not be treated the same...doing so allowed the player to then use the equip function of the card and gain a double bonus. now i call directly on the equip function to do the equiping so that it works with its own function to add the effects. keeping a person from gaining double bonus.
2011-01-29 21:58:29 +00:00
omegablast2002@yahoo.com
7dfa655323 added support for cantbetargetof(something[optional])
for "this card cant be the target of green spells or abilities" style cards.

added poisoned status trigger for attacking, so far its the only place this is checked. we will see what the next set does with this keyword
2011-01-28 19:08:01 +00:00
Xawotihs
cba0a59023 Removed useless attribute 2011-01-28 17:34:49 +00:00
techdragon.nguyen@gmail.com
5e651f03b2 moved mulligan code out of GameStateDuel and into Player base class. Taking a mulligan seems better
encapsulated as a player function rather than loose code inside the state transitions of GameStateDuel

Note: Inside of the mulligan code I assigned game to currentPlayerZones for clarification rather than
something functionally required.  "game" seems ambiguous as "game" is also referenced throughout the code for the GameObserver
keeping this change localized to this method until more analysis can be done.  The pattern that was here before was
game->currentPlayer->game
where the first "game" represented the GameObserver and the second the collection of zones (MTPPlayerCards) to the current player.
I would suggest changing the Player instance of game to something that represents its data, the game zones associated to the current player.
"game" seems too generic, as it can be interpreted to encompass many things rather than just dealing with the different zones (library, exile, discard, etc )
2011-01-28 13:30:29 +00:00
wrenczes@gmail.com
f4f1fdcd3d Another LF property change. 2011-01-28 06:07:14 +00:00
wrenczes@gmail.com
32cabc15c2 Forcing LF as the line ending style through SVN properties. No actual code changes here. 2011-01-28 06:00:51 +00:00
techdragon.nguyen@gmail.com
8156619d49 added guard around TRACK_FILE_USAGE define to disable it on a PSP build. The related code does not compile for the PSP builds. 2011-01-27 16:15:12 +00:00
techdragon.nguyen@gmail.com
ce7745bfa6 First attempt to reduce load time of player deck selection screens.
This change makes use of caching the DeckStats and DeckStatsWrappers into singleton caches that
get flushed when you quit the game.  The initial load time will be significant as lazy loading has not
been coded yet for the ai decks.

TODO: lazy load the player and ai decks as they appear on the screen.  Currently, each screen loads
all decks.
2011-01-27 16:13:40 +00:00
omegablast2002@yahoo.com
beec00c254 2 changes, first fixed the bug where auras were causing the cards to slide to the right, auras always have targets, so i added a conditional to guiplay to ignore adding it to the horizontal shift as these auras should never be just laying in the battlefield with no target.
2nd, started laying some ground work for planeswalkers.
added the planeswalker rule, as per mtg rules, if you have a type=planeswalker subtype=jace already on the battlefield, both are sent to the graveyard. so you can not have a jace mind scuptor and a jace beleren out at the same time. i choose to use subtype= and type= rather then adding another variable to MTGCard...
also, added GuiPlay positioning for planeswalker,
i think theres been a HUGE misunderstanding about planeswalkers which has most going "battlefield is too crowded where would be put them...easy...slap them at the end of the lands ..done...theyre not creatures or artifacts/enchantments..so i moved them to the colum with the lands and have guiplay slap them at the end of that colum...btw this is in no means final...if someone can think of a better solution be my guest, but looking at the planeswalker (workaround) thread, its pretty obvious that no one will care where we slap the planeswalkers, as long as theyre supported. planeswalkers have alot more ground to cover...
2011-01-24 17:58:14 +00:00
omegablast2002@yahoo.com
46891d8de8 added a commit to "thatmuch" variable to explain what its for. 2011-01-23 18:23:44 +00:00
omegablast2002@yahoo.com
ee29fbc237 removed a unused variable and correct a bug with [share] spells tc's are deleted as they resolve so these effects couldnt take adventage of this type of targeting when the effect ability was a fizzle. 2011-01-23 17:29:26 +00:00