im forced to do this commit in whole instead of parts as originally planned, and before my beta test period of the changes is complete BECAUSE there are people doing "clean up" and the MASSIVE amount of conflicts i have to resolve from it is WAY too much for me to take on after nearly 200 hours of coding this patch. i cant seem to get enough respect to have people hold off on "clean up" so this brings me to being forced to do a full commit before playtest period is done, so they can go ahead with there *super important* clean up.
ok i WAS going to write a full change log with code exsamples ect, but since im rushed you will get the short version of this log.
first bug fixes, and there were many,
indestructible creature bug fixed
halimar execavator *embearessing youtube video" bug is fixed
token text now displays source name and tokens abilities
fixed a card view null pointer in an iterator when code used combinations of foreach and aslongas with CD.
epic struggle bug fixed, aslongas was only parsing one space to the right of the operator.
extra cost containing targetting fixed, cards can now have multiple extra cost in all mana...this includes giving a card 2 targeted sacrifices as its main cost.
angelic chorus bug fixed, the card will be soft coded now.
and many other minor bugs fixed, hard to remember all which were fixed.
now, new abilities = words
"legendarylandwalk",
"desertlandwalk",
"snowforestlandwalk",
"snowplainslandwalk",
"snowmountainlandwalk",
"snowislandlandwalk",
"snowswamplandwalk",
"snowlandwalk",
"nonbasiclandwalk",
"strong",//cant be blocked by creature with less power
"weak",//cant block creatures with more power
"phasing",
all true landwalks will now be supported.
new cost types:
morph which is coded as follows
[card]
name=Bloodstoke Howler
facedown={3}
autofacedown={6}{R}:morph
autofaceup=3/0 all(beast|mybattlefield))
text=Morph {6}{R} (You may cast this face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost.) -- When Bloodstoke Howler is turned
face up, Beast creatures you control get +3/+0 until end of turn.
mana={5}{R}
type=Creature
subtype=Beast
power=3
toughness=4
[/card]
you will notice new auto lines autofaceup and autofacedown
these are abilities the cards will have when theyre in that state.
the cost is coded as
facedown={cost}
when a card is faced up it gains auto= lines also.
tho is played normally it will NOT gain autofaceup=lines
card restrictions:
cards can now have restrictions placed on them the restrictions are.
all previous restrictions usable in activated abilities
with the follow additions
control two or more vampires
control less creatures
control snow land
casted a spell
one of a kind
fourth turn
before battle damage
after battle
during battle
[card]
name=Blood Frenzy
target=creature[attacking;blocking]
restriction=before battle damage
auto=4/0
auto=treason
text=Cast Blood Frenzy only before the combat damage step. -- Target attacking or blocking creature gets +4/+0 until end of turn. Destroy that creature
at the beginning of the next end step.
mana={1}{R}
type=Instant
[/card]
other cost now can have specail restrictions also:
otherrestriction=mytypemin:1 type(swamp),opponenttypemin:1 opponenttype(plains)
these are minimums required inplay of a type
it can be just you, or you and opponent or just opponent
you can also use the words "more" and "less" and * to compare the 2 players fields.
[card]
name=Cho-Arrim Legate
abilities=protection from black
other={0}
otherrestriction=mytypemin:1 type(swamp) , opponenttypemin:1 opponenttype(plains)
text=Protection from black -- If an opponent controls a Swamp and you control a Plains, you may cast Cho-Arrim Legate without paying its mana cost.
mana={2}{W}
type=Creature
subtype=Human Soldier
power=1
toughness=2
[/card]
activated ability gained a new restriction "opponentturnonly"
variables will now be recalculated during the resolve of the major abilities to produce the most current number.
{x}:draw:x <----
new number variables words:
using draw as an exsample
draw:auras <--auras on a creature
draw:type:ally <---counts the allys in your field. self explanitory
draw:thatmuch <--mostly a triggered effects number.
when you take damage draw that much
draw:lifelost
draw:oplifelost
these return the value of the life lost that turn.
new TRIGGER restricitions
sourcenottap
sourceTap
foelostthree<--card cycle uses opponent lost life
foelosttwo<--same as above
once<--this trigger will only ever trigger one time and never again.
new card discriptor words
[multicolor]
[leveler]
[enchanted]
[blackandgreen]
[blackandwhite]
[redandblue]
[blueandgreen]
[redandwhite]
CD will now recalculate the number again on resolve
meaning {x}:target(CreatureTargetChooser[manacost <=x]) will work, with an added bonus {x}:target(CreatureTargetChooser[manacost <=any word variable])
new this(:
this(tapped)<--for strange case cards.
this(untapped)
this(auras)
new MTGAbility keywords
(blink)
(blink)forsrc <--stay blinked while source inplay
hand(blink <---adding hand to the front makes it target hand.
livingweapon
this is an extension of token, simple attach the words "livingweapon" to the front of token( and it will autoamtically token that and attach the card to it.
token( gained:
"targetcontroller" targetting.
"battleready" if put in the tokens abilities it will be a attacker and tapped as it is entering play.
phaseout <--self explanitory
spiritlink <--stacking lifelink style effect that benifits the OWNER of the card.
combatspiritlink same as above.
stacking flanking, requires 2 abilities unfortunately
[card]
name=Agility
target=creature
auto=teach(creature) flanker
auto=teach(creature) flanking
text=Enchant creature -- Enchanted creature gets +1/+1 and has flanking. (Whenever a creature without flanking blocks this creature, the blocking
creature gets -1/-1 until end of turn.)
mana={1}{R}
type=Enchantment
subtype=Aura
[/card]
removeallcounters(number/number,name)
removes all counters of the type from a card, can all be
"all"
vampire hexmage effect.
added new tools for transforms
,setpower=number
,settoughness=number
removetypes
morph
autofacedown={0}:morph
eradicate <---same as the card name.
cumulativeupcost[ <--self explanitory
upcostmulti[ <--an upcost that will resolve with a && ability
phaseaction[ phase name ] ability
an ability that will trigger on the stated phase name.
also support for phaseactionmulti[
new triggers added:
@vampired( <--sengir vampire effect
@targeted(
@lifeloss(
@lifed(
add a special ability builder called dynamicability
it acts alot like a choose your own adventure book
dynamicability<! variable 1, variable 2, variable 3,variable 4!> optional ability targetting the original target.
variable list 1:
this is the primary amount source
source
mytgt
myself
myfoe
variable list 2:
this is the variable we're after, or the amount
power
toughness
manacost
colors
age
charge
oneonecounters
thatmuch
variable list 3:
this is the main effect
strike
draw
lifeloss
lifegain
pumppow
pumptough
pumpboth
deplete
countersoneone
variable list 4:
how it will do this effect to.
itself
eachother
targetcontroller
targetopponent
tosrc
srccontroller
srcopponent
the best way to explain its usage is to look at cards coded with this ability. or experiment with combinations.
new gameoption
First turn player:player, opponent, random
who takes the first turn
added poisoned status, tho not complete since MBS hasnt spoiled enough cards to see where this variable will be used.
taught ai how to counter spell
improved ai, it will now cast instants during interupts and during your turn.
previously ai treated instant cards the same as it treated sorceries, which was not fair to the ai.
im sure there is some messed items, but the rev directly before this one had formatting in the code that created hundreds of conflicts with this one, so i had to dig this info out of red and green sections.
cards and test are coming soon, i ask PLEASE do not alter these new additions until the test are commited.
im commiting without the test because instead of allowing me to proceed with my beta test period, there are some that wish to rush me into a commit. if you do not like this commit revert it, i absolutely on no grounds give permission to recommit afterwards. and i will not recommit if a revert is called.
This commit is contained in:
@@ -150,7 +150,7 @@ ManaCost * AIPlayer::getPotentialMana(MTGCardInstance * target)
|
||||
MTGCardInstance * card = amp->source;
|
||||
if (card == target)
|
||||
used[card] = true; //http://code.google.com/p/wagic/issues/detail?id=76
|
||||
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() == 1)
|
||||
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
||||
{
|
||||
result->add(amp->output);
|
||||
used[card] = true;
|
||||
@@ -771,7 +771,7 @@ int AIPlayer::effectBadOrGood(MTGCardInstance * card, int mode, TargetChooser *
|
||||
return BAKA_EFFECT_DONTKNOW;
|
||||
}
|
||||
|
||||
int AIPlayer::chooseTarget(TargetChooser * _tc, Player * forceTarget)
|
||||
int AIPlayer::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCardInstance * Choosencard)
|
||||
{
|
||||
vector<Targetable *> potentialTargets;
|
||||
TargetChooser * tc = _tc;
|
||||
@@ -780,11 +780,13 @@ int AIPlayer::chooseTarget(TargetChooser * _tc, Player * forceTarget)
|
||||
int checkOnly = 0;
|
||||
if (tc)
|
||||
{
|
||||
if(!Choosencard)
|
||||
checkOnly = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tc = gameObs->getCurrentTargetChooser();
|
||||
tc = gameObs->getCurrentTargetChooser();
|
||||
|
||||
}
|
||||
if (!tc)
|
||||
return 0;
|
||||
@@ -845,6 +847,35 @@ int AIPlayer::chooseTarget(TargetChooser * _tc, Player * forceTarget)
|
||||
}
|
||||
}
|
||||
}
|
||||
//targetting the stack
|
||||
zone = playerZones->stack;
|
||||
for (int k = 0; k < zone->nb_cards; k++)
|
||||
{
|
||||
MTGCardInstance* card = zone->cards[k];
|
||||
if (!tc->alreadyHasTarget(card) && tc->canTarget(card) && nbtargets < 50)
|
||||
{
|
||||
if (checkOnly)
|
||||
return 1;
|
||||
int multiplier = 1;
|
||||
if (getStats() && getStats()->isInTop(card, 10))
|
||||
{
|
||||
multiplier++;
|
||||
if (getStats()->isInTop(card, 5))
|
||||
{
|
||||
multiplier++;
|
||||
if (getStats()->isInTop(card, 3))
|
||||
{
|
||||
multiplier++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int l = 0; l < multiplier; l++)
|
||||
{
|
||||
potentialTargets.push_back(card);
|
||||
nbtargets++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nbtargets)
|
||||
{
|
||||
@@ -853,26 +884,28 @@ int AIPlayer::chooseTarget(TargetChooser * _tc, Player * forceTarget)
|
||||
switch (type)
|
||||
{
|
||||
case TARGET_CARD:
|
||||
{
|
||||
MTGCardInstance * card = ((MTGCardInstance *) potentialTargets[i]);
|
||||
clickstream.push(NEW AIAction(card));
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
MTGCardInstance * card = ((MTGCardInstance *) potentialTargets[i]);
|
||||
clickstream.push(NEW AIAction(card));
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case TARGET_PLAYER:
|
||||
{
|
||||
Player * player = ((Player *) potentialTargets[i]);
|
||||
clickstream.push(NEW AIAction(player));
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
Player * player = ((Player *) potentialTargets[i]);
|
||||
clickstream.push(NEW AIAction(player));
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Couldn't find any valid target,
|
||||
//usually that's because we played a card that has bad side effects (ex: when X comes into play, return target land you own to your hand)
|
||||
//so we try again to choose a target in the other player's field...
|
||||
if (checkOnly)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int cancel = gameObs->cancelCurrentAction();
|
||||
if (!cancel && !forceTarget)
|
||||
return chooseTarget(_tc, target->opponent());
|
||||
@@ -1180,6 +1213,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
if (tc)
|
||||
{
|
||||
int hasTarget = (chooseTarget(tc));
|
||||
if(tc)
|
||||
delete tc;
|
||||
if (!hasTarget)
|
||||
continue;
|
||||
@@ -1241,7 +1275,6 @@ void AIPlayerBaka::initTimer()
|
||||
{
|
||||
timer = 0.1f;
|
||||
}
|
||||
|
||||
int AIPlayerBaka::computeActions()
|
||||
{
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
@@ -1256,121 +1289,160 @@ int AIPlayerBaka::computeActions()
|
||||
if (chooseTarget())
|
||||
return 1;
|
||||
int currentGamePhase = g->getCurrentGamePhase();
|
||||
if (g->isInterrupting == this)
|
||||
{ // interrupting
|
||||
selectAbility();
|
||||
return 1;
|
||||
static bool findingCard = false;
|
||||
//this guard is put in place to prevent Ai from
|
||||
//ever running computeActions() function WHILE its already doing so.
|
||||
// Break if this happens in debug mode. If this happens, it's actually a bug
|
||||
assert(!findingCard);
|
||||
if (findingCard)
|
||||
{//is already looking kick me out of this function!
|
||||
return 0;
|
||||
}
|
||||
if (p != this && (Player*)g->isInterrupting == this && g->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 1)
|
||||
{
|
||||
findingCard = true;
|
||||
CardDescriptor cd;
|
||||
ManaCost * currentMana = getPotentialMana();
|
||||
bool potential = false;
|
||||
if (currentMana->getConvertedCost())
|
||||
{
|
||||
//if theres mana i can use there then potential is true.
|
||||
potential = true;
|
||||
}
|
||||
//look for an instant of ability to interupt with
|
||||
if((castrestrictedspell == false && nospellinstant == false)&&
|
||||
(onlyonecast == false || castcount < 2) && (onlyoneinstant == false || castcount < 2))
|
||||
{
|
||||
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
selectAbility();
|
||||
}
|
||||
}
|
||||
if (currentMana != NULL)
|
||||
delete (currentMana);
|
||||
if (nextCardToPlay)
|
||||
{
|
||||
if (potential)
|
||||
{
|
||||
tapLandsForMana(nextCardToPlay->getManaCost());
|
||||
}
|
||||
AIAction * a = NEW AIAction(nextCardToPlay);
|
||||
clickstream.push(a);
|
||||
findingCard = false;
|
||||
nextCardToPlay = NULL;
|
||||
return 1;
|
||||
}
|
||||
nextCardToPlay = NULL;
|
||||
findingCard = false;
|
||||
return 0;
|
||||
}
|
||||
else if (p == this && g->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
|
||||
else if(p == this && g->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
|
||||
{ //standard actions
|
||||
CardDescriptor cd;
|
||||
|
||||
switch (currentGamePhase)
|
||||
{
|
||||
case Constants::MTG_PHASE_FIRSTMAIN:
|
||||
case Constants::MTG_PHASE_SECONDMAIN:
|
||||
{
|
||||
|
||||
bool potential = false;
|
||||
ManaCost * currentMana = getPotentialMana();
|
||||
if (currentMana->getConvertedCost())
|
||||
{
|
||||
//if theres mana i can use there then potential is true.
|
||||
potential = true;
|
||||
}
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "land");
|
||||
selectAbility();
|
||||
//look for the most expensive creature we can afford
|
||||
if (castrestrictedspell == false && nospellinstant == false)
|
||||
{
|
||||
if (onlyonecast == false || castcount < 2)
|
||||
ManaCost * currentMana = getPotentialMana();
|
||||
bool potential = false;
|
||||
if (currentMana->getConvertedCost())
|
||||
{
|
||||
if (onlyoneinstant == false || castcount < 2)
|
||||
//if theres mana i can use there then potential is true.
|
||||
potential = true;
|
||||
}
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "land");
|
||||
selectAbility();
|
||||
//look for the most expensive creature we can afford
|
||||
if((castrestrictedspell == false && nospellinstant == false)&&
|
||||
(onlyonecast == false || castcount < 2)&&(onlyoneinstant == false || castcount < 2))
|
||||
{
|
||||
if (castrestrictedcreature == false && nocreatureinstant == false)
|
||||
{
|
||||
if (castrestrictedcreature == false && nocreatureinstant == false)
|
||||
{
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "creature");
|
||||
}
|
||||
}
|
||||
//Let's Try an enchantment maybe ?
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "enchantment");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "artifact");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "sorcery");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
selectAbility();
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "creature");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (currentMana != NULL)
|
||||
delete (currentMana);
|
||||
if (nextCardToPlay)
|
||||
{
|
||||
if (potential)
|
||||
{
|
||||
/////////////////////////
|
||||
//had to force this on Ai other wise it would pay nothing but 1 color for a sunburst card.
|
||||
//this does not teach it to use manaproducer more effectively, it simply allow it to use the manaproducers it does understand better on sunburst by force.
|
||||
if (nextCardToPlay->has(Constants::SUNBURST))
|
||||
//Let's Try an enchantment maybe ?
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
ManaCost * SunCheck = manaPool;
|
||||
SunCheck = getPotentialMana();
|
||||
for (int i = Constants::MTG_NB_COLORS - 1; i > 0; i--)
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "enchantment");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "artifact");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "sorcery");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
nextCardToPlay = FindCardToPlay(currentMana, "instant");
|
||||
}
|
||||
if (!nextCardToPlay)
|
||||
{
|
||||
selectAbility();
|
||||
}
|
||||
}
|
||||
if (currentMana != NULL)
|
||||
delete (currentMana);
|
||||
if (nextCardToPlay)
|
||||
{
|
||||
if (potential)
|
||||
{
|
||||
/////////////////////////
|
||||
//had to force this on Ai other wise it would pay nothing but 1 color for a sunburst card.
|
||||
//this does not teach it to use manaproducer more effectively, it simply allow it to use the manaproducers it does understand better on sunburst by force.
|
||||
if (nextCardToPlay->has(Constants::SUNBURST))
|
||||
{
|
||||
//sunburst for Ai
|
||||
if (SunCheck->hasColor(i))
|
||||
ManaCost * SunCheck = manaPool;
|
||||
SunCheck = getPotentialMana();
|
||||
for (int i = Constants::MTG_NB_COLORS - 1; i > 0; i--)
|
||||
{
|
||||
if (nextCardToPlay->getManaCost()->hasColor(i) > 0)
|
||||
{//do nothing if the card already has this color.
|
||||
}
|
||||
else
|
||||
//sunburst for Ai
|
||||
if (SunCheck->hasColor(i))
|
||||
{
|
||||
if (nextCardToPlay->sunburst < nextCardToPlay->getManaCost()->getConvertedCost())
|
||||
if (nextCardToPlay->getManaCost()->hasColor(i) > 0)
|
||||
{//do nothing if the card already has this color.
|
||||
}
|
||||
else
|
||||
{
|
||||
nextCardToPlay->getManaCost()->add(i, 1);
|
||||
nextCardToPlay->getManaCost()->remove(0, 1);
|
||||
nextCardToPlay->sunburst += 1;
|
||||
if (nextCardToPlay->sunburst < nextCardToPlay->getManaCost()->getConvertedCost())
|
||||
{
|
||||
nextCardToPlay->getManaCost()->add(i, 1);
|
||||
nextCardToPlay->getManaCost()->remove(0, 1);
|
||||
nextCardToPlay->sunburst += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete (SunCheck);
|
||||
}
|
||||
delete (SunCheck);
|
||||
/////////////////////////
|
||||
tapLandsForMana(nextCardToPlay->getManaCost());
|
||||
}
|
||||
/////////////////////////
|
||||
tapLandsForMana(nextCardToPlay->getManaCost());
|
||||
AIAction * a = NEW AIAction(nextCardToPlay);
|
||||
clickstream.push(a);
|
||||
return 1;
|
||||
}
|
||||
AIAction * a = NEW AIAction(nextCardToPlay);
|
||||
clickstream.push(a);
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
selectAbility();
|
||||
}
|
||||
if (p->getManaPool()->getConvertedCost() > 0 && Checked == false)//not the best thing ever, but allows the Ai a chance to double check if its mana pool has something before moving on, atleast one time.
|
||||
{
|
||||
Checked = true;
|
||||
computeActions();
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectAbility();
|
||||
}
|
||||
if (p->getManaPool()->getConvertedCost() > 0 && Checked == false)//not the best thing ever, but allows the Ai a chance to double check if its mana pool has something before moving on, atleast one time.
|
||||
{
|
||||
Checked = true;
|
||||
computeActions();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Constants::MTG_PHASE_COMBATATTACKERS:
|
||||
chooseAttackers();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user