Implementing a basic ability...

If you have a question about the git repository and the code, or if you have code to propose then please post in this forum.
Do not post request here.
Locked
GammaPaladin
Posts: 4
Joined: Tue Jan 15, 2013 12:25 pm

Implementing a basic ability...

Post by GammaPaladin »

So... There's a few cards I love that I've been hoping to see implemented for ages (As in years, literally), but it hasn't happened. Sooo... Since I'd already downloaded the latest master from github to compile anyway... I started hacking through the code to try and see if I could figure out how things work.

I think I've figured parts of it out, but I've clearly missed something, because I attempted to test with something simple (Which probably isn't), getting the Rhox Faithmender working.

So, in AllAbilities.h I added the following:

Code: Select all

class ALifeMultiply: public TriggeredAbility
{
	ALifeMultiply(GameObserver* observer, int _id, MTGCardInstance * _source, int _power = 1, int _toughness = 1) :
		TriggeredAbility(observer, _id, _source)
	{
	}
		
	int triggerOnEvent(WEvent * event)
	{
		if(WEventLife* le = dynamic_cast<WEventLife*>(event))
		{
			if (le->player == source->controller())
			{
				if (source->has(Constants::LIFEMULTIPLY))
				{
					return 0;
				}
				else
				{
					source->controller()->gainLife(le->amount);
					le->amount = le->amount * 2;
					return 1;
				}
			}
		}
		else
		{
			return 0;
		}
	}
};
And I changed the enum in MTGDefinitions.h to add my ability to the basic abilities, and incremented NB_BASIC_ABILITIES. Then in MTGDefinitions.cpp I added "lifemultiply" to Constants:MTGBasicAbilities.

And then obviously I added Rhox Faithmender to mtg.txt and removed it from unsupported.txt...

Code: Select all

[card]
name=Rhox Faithmender
abilities=lifelink,lifemultiply
text=Lifelink (Damage dealt by this creature also causes you to gain that much life.) -- If you would gain life, you gain twice that much life instead.
mana={3}{W}
type=Creature
subtype=Rhino Monk
power=1
toughness=5
[/card]
It all compiled and it runs without crashing, the card is available, and can be played, and works fine as just a simple 1/5 lifelink creature, but the ability I tried to add doesn't work... When I gain life, it isn't increased any. So, what (Probably incredibly obvious) thing have I missed?

I should note that I'm totally guessing at most of this, based on a couple hours of looking through the code.
hzxcasndd
Posts: 1
Joined: Tue Jun 14, 2022 3:52 pm

Re: Implementing a basic ability...

Post by hzxcasndd »

تُعد زجاجات الرذاذ من الأدوات البسيطة والمُهمة وغير المُكلفة في المنزل، فهي مثالية لصنع خلطات للمُساعدة في عملية التنظيف، وكذلك يُمكن استخدامها لرشّ المُعطرات والمُنظفات على الملابس قبل الكيّ.
تُساعد قِطع القُماش في التخلص من طبقات الأتربة والغبار المُتراكم على الأثاث سواءً أكان مصنوعاً من الخشب أو الرخام او الزُجاج، مِثل الطاوِلات والكراسي والثُريات والخَزائن، وأيضاً هي مُهمة لتنظيف الأرضيات والأجهزة الكهربائية.

شركة تعقيم منازل
يعتمد مبدأ عمل معظم المكيفات على غاز التبريد الموجود بداخلها ألا وهو الفريون، وفي البداية يقوم الضاغط الموجود بداخل المكيف بضغط غاز الفريون البارد، وعادةً ما يتم خلط كمية صغيرة من النفط مع الفريون لتليين الضاغط، وعندما يتم ضغط الفريون فإن ضغطه يرتفع مما يؤدي إلى تسخينه، وينتقل هذا الغاز الساخن ضمن سلسلة من الأنابيب الموجودة داخل المكيف، وتمتلك هذه الأنابيب القدرة على تبريد غاز الفريون وتحويله إلى الحالة السائلة،

تنظيف مكيفات
Locked