first somehow accidentally line 3616 mtgability.cpp removefromgame was adding an observer instead of removing it, this explains "abilities sometimes acting strangely or not being removed"...I'm surprised it didn't create memleaks or extremely visible side-effects...
2nd fixed a bug where triggered abilities would share a menu with activated abilities of a card when ever you had enough mana floating to pay an activated ability before the trigger resolved.
adjust the way ai calculates if it should use cards like wrath of god, though it is still open to using it at a random chance, i noticed that the method we use might not be the best.
an ability with an eff of 1 for example actually has a 10% chance of being choosen....
lets say rng rolls 3402
when you % this it simply takes the 2 last numbers making this roll 2...meaning that unless we assign no "random chance to do blah" the actual chance of ai using a stupid ability is 10%...I'm leaving that logic how it is tho I "unfactored"(?) it to make it easier to track the numbers, also added a debug trace to help see how often we hit "lottery chance" ...
fixed a minor crash from multiability trying to fetch menutext when no abilities existed in the vector anymore.
this patch introduces a new subkeyword for "may " which is syntax pay(manacost)
auto=may pay({w}) untap
this is to allow the card group that was coded using the activated ability loophole i described at the start. it works the same way as it did with the loophole only it is actually something we want to happen instead of a flaw in the engine...you float the mana same as before and when the may line is triggered it will check if payment can be made with exist mana if so then it displays the menutext for the ability, if that ability is choosen it then charges you the mana directly before activation.
this patch also include flip( ability, tho not intended originally for this version, I had previously had it finished and was polishing it right before I noticed the bugs above. since this keyword is not intended to add cards for this version, I wont go into massive details about it at this time.
126 lines
3.2 KiB
C++
126 lines
3.2 KiB
C++
/* CardPrimitive objects represent the cards database.
|
|
* For MTG we have thousands of those, that stay constantly in Ram
|
|
* on low-end devices such as the PSP, adding stuff to this class can have a very high cost
|
|
* As an example, with 16'000 card primitives (the rough number of cards in MTG), adding a simple 16 bytes attribute costs 250kB (2% of the total available ram on the PSP)
|
|
*/
|
|
#ifndef _CARDPRIMITIVE_H_
|
|
#define _CARDPRIMITIVE_H_
|
|
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <bitset>
|
|
#include "config.h"
|
|
#include "ManaCost.h"
|
|
#include "ObjectAnalytics.h"
|
|
|
|
using namespace std;
|
|
|
|
const uint8_t kColorBitMask_Artifact = 0x01;
|
|
const uint8_t kColorBitMask_Green = 0x02;
|
|
const uint8_t kColorBitMask_Blue = 0x04;
|
|
const uint8_t kColorBitMask_Red = 0x08;
|
|
const uint8_t kColorBitMask_Black = 0x10;
|
|
const uint8_t kColorBitMask_White = 0x20;
|
|
const uint8_t kColorBitMask_Land = 0x40;
|
|
|
|
|
|
class CastRestrictions {
|
|
public:
|
|
string restriction;
|
|
string otherrestriction;
|
|
|
|
CastRestrictions * clone() const
|
|
{
|
|
return NEW CastRestrictions(*this);
|
|
};
|
|
};
|
|
|
|
class CardPrimitive
|
|
#ifdef TRACK_OBJECT_USAGE
|
|
: public InstanceCounter<CardPrimitive>
|
|
#endif
|
|
{
|
|
private:
|
|
CastRestrictions * restrictions;
|
|
|
|
protected:
|
|
string lcname;
|
|
ManaCost manaCost;
|
|
|
|
public:
|
|
vector<string> formattedText;
|
|
string text;
|
|
string name;
|
|
int init();
|
|
|
|
uint8_t colors;
|
|
typedef std::bitset<Constants::NB_BASIC_ABILITIES> BasicAbilitiesSet;
|
|
BasicAbilitiesSet basicAbilities;
|
|
|
|
map<string,string> magicTexts;
|
|
string magicText;
|
|
int alias;
|
|
string spellTargetType;
|
|
int power;
|
|
int toughness;
|
|
int suspendedTime;
|
|
|
|
vector<int>types;
|
|
CardPrimitive();
|
|
CardPrimitive(CardPrimitive * source);
|
|
virtual ~CardPrimitive();
|
|
|
|
void setColor(int _color, int removeAllOthers = 0);
|
|
void setColor(const string& _color, int removeAllOthers = 0);
|
|
void removeColor(int color);
|
|
int getColor();
|
|
bool hasColor(int inColor);
|
|
int countColors();
|
|
|
|
static uint8_t ConvertColorToBitMask(int inColor);
|
|
|
|
int has(int ability);
|
|
|
|
void setText(const string& value);
|
|
const vector<string>& getFormattedText();
|
|
|
|
void addMagicText(string value);
|
|
void addMagicText(string value, string zone);
|
|
|
|
void setName(const string& value);
|
|
const string& getName() const;
|
|
const string& getLCName() const;
|
|
|
|
void addType(char * type_text);
|
|
void addType(int id);
|
|
void setType(const string& type_text);
|
|
void setSubtype(const string& value);
|
|
int removeType(string value, int removeAll = 0);
|
|
int removeType(int value, int removeAll = 0);
|
|
bool hasSubtype(int _subtype);
|
|
bool hasSubtype(const char * _subtype);
|
|
bool hasSubtype(const string& _subtype);
|
|
bool hasType(int _type);
|
|
bool hasType(const char * type);
|
|
|
|
void setManaCost(const string& value);
|
|
ManaCost * getManaCost();
|
|
bool isCreature();
|
|
bool isLand();
|
|
bool isSpell();
|
|
|
|
void setPower(int _power);
|
|
int getPower();
|
|
void setToughness(int _toughness);
|
|
int getToughness();
|
|
void setRestrictions(string _restriction);
|
|
const string getRestrictions();
|
|
void setOtherRestrictions(string _restriction);
|
|
const string getOtherRestrictions();
|
|
};
|
|
|
|
|
|
#endif
|