Commit Graph

946 Commits

Author SHA1 Message Date
wagic.the.homebrew
b26bfb09bd Fix Build error on psp 2011-05-06 13:46:20 +00:00
wagic.the.homebrew
7beb958067 Adding a way to mark decks as "locked" based on options requirements (option on or off). Can be used for example to lock a deck until a specific set is not unlocked. Works for both player decks (could be used for premade?) and AI decks. 2011-05-06 06:40:00 +00:00
wagic.the.homebrew
efad3f652f Minor refactor of menu text for "move" abilities. Zeth, Dr.Solomat, please let me know if something goes wrong. 2011-05-06 04:43:27 +00:00
wagic.the.homebrew
12228b51a0 - Minor refactor of "transforms" ability
- Updated changeling and transforms to only get creature types (as initially intended by the code), removed hardcoded list of "types to avoid"

The test suite passes
2011-05-06 03:52:35 +00:00
wagic.the.homebrew
1e2ed785eb Fix for issue 646 (Tidal Warrior) 2011-05-06 02:27:49 +00:00
wagic.the.homebrew
691a1e1b91 - Fixed a Bug where AI would not block any attacker in Demo mode (bug introduced in r2759)
- Fixed a Bug where AI would not correctly assign blockers if the first attacker is super strong.
- Added a hack to prevent AI from an infinite loop while choosing a target. There are edge cases where the AI gets to choose the targets for a TargetChooser that doesn't belong to it. I couldn't dig too long for the root cause, so I added a "return 0" when the case happens. Should probably open a ticket
- Added a "Hint" System in AI decks, to help the AI with its strategy. This is not really usable yet, it only works with abilities (not cards to play), and I only added some basic code for counters and tokens. This can probably be extended, but let's wait until we see it working on that other game I'm working on, before rushing into adding hints to all AI decks...
- minor cleanup of AI Code
2011-05-05 14:27:46 +00:00
wagic.the.homebrew
748af5b461 - Adding a generic "ueot" effect. This will be initially confusing, but the ultimate goal is to get rid of all the particular cases we handled with "until end of turn" effects. this "ueot " works like "may " and "choice ", it has to be at the very beginning of the ability(ies) it targets. The reason is to avoid conflicts with the existing "ueot" we have all over the place. I have only tested it with transforms and loseabilities for now (see "ovinize") but hopefully this will become the new norm. This should also reduce the code inside the parser, long term.
- Adding "Ovinize" as an example of this new keyword.
- moved "parseBetween" in utils as I am using it in other files for wome work in Progress.
2011-05-05 06:18:50 +00:00
wrenczes
5041916fdd Fixed the psp build breakage in r3595. Erwan, pls review - I think that the subtypesToType map probably should be unsigned ints instead of signed, but I wasn't about to sweep through the file right now. 2011-05-04 10:27:18 +00:00
wrenczes
0cb8c50b39 Replaced ManaCost's int array with int8_t. Shrinks ManaCost by another 24 bytes, which in turn lowers CardPrimitive's footprint by the same amount. 2011-05-04 10:02:47 +00:00
wagic.the.homebrew
d922d4fe06 - Added "loseSubtypesOf(type)" ability. For example, loseSubtypesOf(land) means "target loses all its land subtypes"
- Added Evil Presence, as an example of the new keywords loseabilities and losesubtypes. It's quite experimental but I added 3 tests that cover the basics. Please report if you find bugs.
- moved the "lands produce mana" rules outside of the primitives, and into the external rules. This was a necessary step to create cards such as Evil Presence. 
- real support for subtypes. Needs some more testing, but there are now functions in Subtypes.cpp to know if a given subtype is a creature subtype, or a land subtype, etc...
- minor refactor of MTGDeck.cpp

Notes:
- I checked that the AI can still use lands
- This change has a bad impact on primitives loading performance (thanks Wil for the loading time output). This is probably due to suboptimal algorithms and data structures for subtypes. If the impact is strong on lowend devices, I can probably optimize a bit (the map subtypesOf could be changed into a vector with some work)
- The test suite passes, added 3 tests for evil presence.
2011-05-04 04:04:03 +00:00
wagic.the.homebrew
494bcf3315 Adding a "loseAbilities" keyword per Dr.Solomat's request. The Goal was to code Evil Presence, but I think there is still some work to do to achieve this. The main concern is that (according to the Miki), neither transforms(( nor "becomes(" allow to lose some subtypes. A land enchanted with Evil Presence is supposed to lose its land subtypes. Since we don't support subtypes that good, I don't think this is possible. Additionally, Evil PResence would require to move "{T}:Add{X}" from the basic lands primitives into the rules (which sounds quite easy to do). I've nevertheless tested this on Gaea's Cradle, and it works. (Gaea's Cradle loses its abilities) 2011-05-04 01:33:34 +00:00
wagic.the.homebrew
0b9ff076e6 Please update your rules folder
- "Manapool empties at the end of each step" becomes an ability, and was moved into the external rules file. "removemana(*) to remove all, removemana(*{G}) to remove all green, removemana(*{G}{B}{R}) to remove all green black red, removemana({G}{G}{B}{U}) (no "*") to remove a specific value.
- Added a possibility to make abilities non interruptible. With little work, this could be added to the parser if needed. Please use with care, let's discuss what is an acceptable usage of this now functionality, if needed.
2011-05-03 11:59:27 +00:00
wagic.the.homebrew
b7cc42ed67 Moved "reset damage on creatures at cleanup phase" outside of the engine and made it an ability. This is mostly because I need this for the mod I'm working on, but I hope it can be used by others 2011-05-02 14:02:12 +00:00
wagic.the.homebrew
53f45a8b8e cleanup: Remove "computeXX" functions and XX variables, these were always returning X/2 in all cases.
Test suite passes
2011-05-02 11:28:04 +00:00
wagic.the.homebrew
13dd07973e Removing "oldSchoolDeathtouch", as it seems Cockatrice and Thicket Basislisk are now softcoded. Zeth, Dr.Solomat, please review :) 2011-05-02 08:44:02 +00:00
wagic.the.homebrew
e100bd826c Refactor of the parser. The goal is to reduce maintenance cost, by refactoring some of the most frequent "copy/paste" we have in there. This removes roughly 500 lines, going from 4850 to 4350 lines. I'm getting closer to my goal of getting this file back to 4000 lines :)
Crossing fingers I didn't break anything major. The test suite passes, though I expect some edge case bugs to appear. Apologies in advance, I think this change is worth it.
2011-05-01 15:53:13 +00:00
wagic.the.homebrew
8b6400e12d Cleanup of some trigger parsing 2011-04-30 15:52:48 +00:00
wagic.the.homebrew
cd07248df5 UPDATE YOUR rules FOLDER!!!
- This is some Work in progress to make Wagic less "game" dependent.
This change especially is an attempt at moving away from some dangerous patents owned by some company.
It introduces "modrules.xml", a global configuration file describing dynamic settings for any given Wagic mod. It is very basic for now, but allows to customize a bit. In particular, it allows to remove the concept of shop and deck editor from the game, dynamically generate the main menu, and represent card activation with a mask rather than a rotation.
I have a sample in progress which I hope to submit in the days to come, a proof of concept (nothing fancy yet) for another type of game using these ideas, as well as a few other things I introduced recently.
In the future, I am hoping to extend modrules.xml so that it entirely describes the rules of a given card game. the other files in rules.txt will describe "extensions" to the core rules, just like they do right now, so this new file does not make them obsolete.


- Also fixed minor bugs I stumbled upon while developing
2011-04-29 17:30:57 +00:00
omegablast2002@yahoo.com
0fba6994a6 fixed a reported bug with @vampired, it was tricky, but ultimately i had to move the building of vampevent outside of TRVampired...the reason being that all instances of TRVamp were able to send and react to other instances of it sending out "vampevents", so move it into rules so only one object handles that, also changed the method it was handled, it now maps the cards with a 2nd vector of the vampires...basically "this card was dealt damage by X, Y, Z this turn"...
let me know if i missed some strange edge case somewhere. as far as i tested, it seems to work just fine.
2011-04-29 13:24:02 +00:00
omegablast2002@yahoo.com
669f8744b6 changed a previous fix a bit, also, altho this is not the "layers system" and we don't really support it, i thought i could atleast support the reapply of p/t bonuses from counters for atransformer...
and while messing around i found out that i forgot an important check in the new kicker with menu, to check if the card was still in the hand :P
2011-04-28 15:17:49 +00:00
omegablast2002@yahoo.com
7840e3cde8 fixed a issue where token workaround revealed that 2 "may" abilities back to back screws up "isInterrupting" player variable..this was only when the may ability contained manaproducers, which truely no longer use the stack in any format. 2011-04-28 10:20:42 +00:00
wrenczes@gmail.com
ba0f5c4191 Reduced ManaCostHybrid's internals to uint8_t instead of ints. Removed the hardsized array of ManaCostHybrid pointers, and replaced it with a vector of objects, got rid of all the unnecessary new/delete code everywhere.
Also deleted "extraCostsIsCopy" from ManaCost - unused variable.

Overall, drops ManaCost from 148 bytes to 120 (which in turn reduces CardPrimitive's memory footprint by the same amount, since it encapsulates a ManaCost).
2011-04-28 07:49:51 +00:00
wrenczes
8610531bf3 Fixes for exclusion/inclusion combinations of colors or abilities. 2011-04-28 05:01:06 +00:00
omegablast2002@yahoo.com
6e6ccddbde fixed a crash witnessed when ai was trying to get the efficiency return of aamover the ai had a target, but the ability did not have a target, when "destinationZone()" was run, the game would crash due to a null pointer.
increase the "random" chance to use unknown, the old method almost always returned 0.
2011-04-26 14:49:15 +00:00
wrenczes@gmail.com
a73fd4e99f Converted CardPrimitive's basicAbilities from a map<int, int> to a bitset. With 92 abilities, that means our base container for abilities is now 16 bytes in size (down from 28), and is a fixed size, whereas the map would grow by 8 bytes per added ability. 2011-04-26 09:35:38 +00:00
wrenczes@gmail.com
f5bd6b2794 Removed ABasicAbilityModifierUntilEOT. Zeth, please review - I started to try to fix the array notation of this class, but then realized that the compiler was optimizing out this class entirely out of the binary - it's not currently used at all. Is this deprecated, and just got left behind..?
(If you do have a reason to put it back, let's find a more compact way to write this.)
2011-04-26 06:15:58 +00:00
wrenczes@gmail.com
46168bfb6d Fixed tab alignment. No code changes. 2011-04-26 06:08:53 +00:00
omegablast2002@yahoo.com
9de076db75 added",once" tag for phaseaction, to denote that the effect is only to happen once before forcedestroy is declared.
auto=@movedTo(graveyard) from(this|battlefield):phaseaction[endofturn,once] token(Bird,Creature Bird,4/4,red,flying)
2011-04-25 14:48:03 +00:00
wrenczes@gmail.com
1cbf3db582 Reducing the memory footprint: reworked the concept of 'colors' in CardPrimitives. What used to be an array of ints (ie 28 bytes) is now contained in a single byte, we use bit masking to support setting multiple colors on this variable. This also eliminates a lot of silly loops for setting colors in the code - now it's a straight byte copy.
Also thrown in are a couple of string to const string& conversions.
2011-04-25 11:20:07 +00:00
wrenczes@gmail.com
3ea5e54d95 Tweaks to allow the file usage statistics utils to run on psp. 2011-04-25 06:26:19 +00:00
wrenczes@gmail.com
6fbc019ecc Added object analytics around ExtraCost & ManaCost; some formatting style cleanup. 2011-04-24 10:33:38 +00:00
wagic.the.homebrew
e1e52f910d - removed unused variables in Menu. These where used for the old moving "W" which is probably not coming back any time soon... 2011-04-23 13:52:46 +00:00
wagic.the.homebrew
66ad0f4694 - Files in Res/rules are now loaded dynamically. This allows people to add their own mods fairly easily
- also has a basic support for unlocks (does not yet allow people to create their own unlock rules, though...)
- Some things are still hardcoded and should progressively move to these rules files (such as Game Type, how random decks are created, etc...)
- Test suite doesn't foolishly ask you to choose a game mode (momir, etc...) anymore
- UPDATE YOUR Res/rules/ folder !!!
2011-04-23 13:24:19 +00:00
wrenczes@gmail.com
ba07ca2334 Improvement on my last change for reducing the formatted text caching: chopped it out altogether. I ran some profiling to see how much time on the psp it took to process the formatting on the description text (ie word wrapping it into several lines to fit on a card), and it ends up taking an average of 0.14 ms per card. For context, 60 fps is 16 ms. So clearly the formatting time is not the bottleneck here, and we gain no real performance caching the text, but lose memory due to pooling. So I cut it out entirely of the base class and we format on the fly during renders.
I also profiled this after the fact, as we have an open bug on poor drawing performance on psp when in text mode - it turns out that in the AlternateRender() function, my numbers look like this: 10.2 seconds were spent in JBLFont::DrawString(); 0.5 seconds were spent in my new helper FormatText() call, so we know where the perf hit is now.

I compared before & after on the psp with this mod, and the difference really isn't perceptible.  (It's still juddery, but no worse than before.)  I'll look at the DrawString() call next to see if we can make it any faster, although at first glance it looks like a pain.
2011-04-23 09:54:19 +00:00
wrenczes@gmail.com
fc67e1515a Added some calls for tracking dynamic allocations to the InstanceCounter. 2011-04-23 08:43:34 +00:00
wrenczes@gmail.com
bd56723bc0 Checkpoint on a utility helper class. Basically, if you have a class that you want to count the numbers of instances, you do this:
class Foo
#ifdef TRACK_OBJECT_USAGE
      : public InstanceCounter<Foo>
#endif

Then, use this macro somewhere in the class body:
SUPPORT_OBJECT_ANALYTICS(Foo)

Lastly, add whatever information you want to trace out to the function ObjectAnalytics::DumpStatistics().

Here's a sample of the output of what I've instrumented so far:

-----------------------------------------------------------
Object Usage Stats

CardPrimitive current count: 7899
CardPrimitive current byte usage: 2053740
CardPrimitive max count: 7908
CardPrimitive max byte usage: 2056080

MTGCard current count: 13973
MTGCard current byte usage: 670704
MTGCard max count: 13982
MTGCard max byte usage: 671136

MTGCardInstance current count: 180
MTGCardInstance current byte usage: 172080
MTGCardInstance max count: 189
MTGCardInstance max byte usage: 180684

-----------------------------------------------------------
2011-04-23 05:16:53 +00:00
wrenczes@gmail.com
224b140f9f First pass at reducing the overall memory footprint: moved GetFormattedText() out of CardPrimitives and into MTGCard. The idea being, only keep the formatted text around for cards that are actually in use.
Also fixed a subtle memory pooling issue in the RenderCountersBig() routine:  if you're in regular card display mode, the idea is that formatted text is only fetched if you flip into alternate render mode.  However, in this function, if counters are being drawn, it would fetch the formatted text in order to determine where to draw the counters, EVEN IF the counters count was zero.  So it had nothing to draw, but it meanwhile pooled the formatted strings into memory anyway.
2011-04-22 16:04:41 +00:00
wrenczes@gmail.com
ae227a7cb8 Minor project cleanup:
- Consolidated duplicate PSP / PSPENV defines;
- removed some ancillary file crap from the 2010 projects;
- pulled 1xx references from the makefiles;
- consolidated multiple #defines for OutputDebugString into one header (previously was split between config.h & DebugRoutines.h).
2011-04-22 13:12:36 +00:00
omegablast2002@yahoo.com
ad56dfa8d0 3 things here
first as requested, kicker will now act like the other cost, offering a menu choice, heres the catch tho, 
it was also thought up that we should maintain the "pay automatically" method of it as it feels more natural to some(even tho as per MTG rules its supposed to be a choice).
so here is what i did that i hope satisfies everyone, i added a new menu option under advanced tab..."kicker payment" with 2 setting, by defualt "always pay" but also an option to "always offer choice"...

2nd, minor tweaks to player avatar, every tme i saw it i was like "i need to do something about that", the avatar getting completely sucked into the corner just looked bad imo, so i about doubled the "inactive" size, so it looks a little more uniform with the opponents avatar. also move the library and grave icons just a thin hair to the left so they don't grossly overlap the players avatar as much when active, and increased the dark box theyre contained in my just a few pixels.

3rd, something else thats really bothered me to no end was that the title text of simple menus which display the cards name which owns the box was using small face font, which on pc was *barely* ok...but on psp(smaller devices) looks like white smears and dots. i changed it to share the font and size used inside the menubox itself, the end result is a lot nicer look...and alot easier to read on psp. now if only we can convince wololo that "spades" is alot like a lava lamp, cool at first, but *extremely* dated. the menu box should have a much slicker look, maybe rounded corners instead and lose the street light poles?

minor fix for phaseaction, becuase of the nature of this ability finding a happy safe medium without losing function is tough. hopefully this corrects it for good.

dropped cast methods menutext returns to lower case, for uniformity.
2011-04-22 11:17:20 +00:00
wrenczes@gmail.com
7203ce9436 Style formatting - no code changes here. 2011-04-22 04:31:55 +00:00
wrenczes@gmail.com
aaa169f86c Consolidated some loose strings into constant declarations in order to reduce allocation thrashing on temporary string constructs. I'm sure there are more, but "back_thumb", "back", and "backdrop.jpg" were the ones that showed up most in memory profiling. 2011-04-21 22:48:22 +00:00
wagic.the.homebrew
6f5919ed06 Reverting r3496 to fix failing tests 2011-04-21 15:16:22 +00:00
wagic.the.homebrew
8ff6839c8d Some preparation work for new platform support.
- Added a "PSP" compile-time define to clean up some compile time checks (replaced !WIN32 && !LINUX && !IOS with PSP) 
-- Wil, I am aware that this is redundant with the PSPENV variable you introduced recently, I think we can clean that up easily
-- This looks like lots of changes, but most of the time I just moved some blocks here and there
-- tested on VC 2010, PSP, and a bit of NDK
-- I might have broken maemo, iOS, or Linux compilation, can you guys check?
- Fixed some warnings reported by NDK
- NDK still does not compile because recent boost additions (mutex, etc...) are apparently not supported
2011-04-21 13:16:11 +00:00
techdragon.nguyen@gmail.com
8bf983e2e5 Flagged numerous peices of code that have local variables that are masking either member variables or variables scoped outside the current scope.
I've marked all the ones I found with the following TODO comment:

TODO: C6246: <blah blah>

a few in particular are the ones related to "oneShot" and "_target".  These are local variables that are declared that
mask either a method parameter or a member variable.
2011-04-21 10:04:32 +00:00
wrenczes@gmail.com
cc55042477 Formatting cleanup. No code changes here. 2011-04-21 06:14:54 +00:00
wrenczes@gmail.com
d212f08618 Added a missing forward class declaration to fix the psp build. I'm surprised that VS2010 didn't complain... 2011-04-21 05:51:21 +00:00
wrenczes@gmail.com
7bf6374fc7 Another minor change to eliminate an unneeded #include. 2011-04-21 03:21:15 +00:00
wrenczes@gmail.com
39870c91f6 Removed GameApp.h from GameOptions.h - this should help prevent the precompiled header from rebuilding constantly when any header is touched, as GameApp.h ends up pulling virtually every other header by some level of indirection. We really need though to sit down at some point & refactor the inclusion tree. It's a big yarn ball at the moment. 2011-04-21 02:35:51 +00:00
wrenczes@gmail.com
babda2bc0f Some minor tweaks to make the image prefetching feel less flickery : when a card goes from a player's library into their hand, trigger a prefetch of the image. Also do the same thing when the AI decides on what card to play and creates an action. The idea being, new cards in play will probably want to be viewed by the player (and in the case of the AI playing a spell, we automatically show the image during the interrupt window before it comes into play). This makes for a much smoother gameplay - we have to get the image at some point anyway, and by doing it before we get to the render call, we no longer have the back card image pop up briefly. 2011-04-20 21:07:24 +00:00
Xawotihs
78e34386ee Android cross-compiling fixes regarding constants 2011-04-20 20:14:25 +00:00