Erwan
- add Mercadian Masques, Mirrodin, Odyssey -> let's do some cleanup! - Attempt at solving a bug with AI+psychic venom (manaburn), not tested - Added Abrasax's monocolor AI decks - Momir better randomizer - Removed 64 Abilities limitation, I hope...
This commit is contained in:
@@ -253,7 +253,8 @@ int AIPlayer::interruptIfICan(){
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
|
||||
if (g->mLayers->stackLayer()->askIfWishesToInterrupt == this){
|
||||
g->mLayers->stackLayer()->setIsInterrupting(this);
|
||||
if (!clickstream.empty()) g->mLayers->stackLayer()->cancelInterruptOffer();
|
||||
else g->mLayers->stackLayer()->setIsInterrupting(this);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -445,6 +445,33 @@ void ActionStack::unpackDamageStacks(){
|
||||
}
|
||||
|
||||
void ActionStack::repackDamageStacks(){
|
||||
std::vector<JGuiObject *>::iterator iter = mObjects.begin() ;
|
||||
|
||||
while( iter != mObjects.end() ){
|
||||
Interruptible * action = ((Interruptible *) *iter);
|
||||
int found = 0;
|
||||
if (action->type == ACTION_DAMAGE){
|
||||
Damage * damage = (Damage *) action;
|
||||
for (int j = 0; j < mCount; j++){
|
||||
Interruptible * action2 = ((Interruptible *)mObjects[j]);
|
||||
if (action2->type == ACTION_DAMAGES){
|
||||
DamageStack * ds = (DamageStack *) action2;
|
||||
for (int k = 0; k< ds->mCount; k++){
|
||||
Damage * dsdamage = ((Damage *)ds->mObjects[k]);
|
||||
if (dsdamage==damage){
|
||||
//Remove(damage);
|
||||
iter = mObjects.erase( iter ) ;
|
||||
found = 1;
|
||||
mCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) ++iter;
|
||||
}
|
||||
|
||||
/*
|
||||
for (int i = mCount-1; i >=0; i--){
|
||||
Interruptible * action = ((Interruptible *)mObjects[i]);
|
||||
if (action->type == ACTION_DAMAGE){
|
||||
@@ -465,6 +492,7 @@ void ActionStack::repackDamageStacks(){
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void ActionStack::Update(float dt){
|
||||
@@ -657,14 +685,18 @@ int ActionStack::CombatDamages(int strike){
|
||||
|
||||
//Cleans history of last turn
|
||||
int ActionStack::garbageCollect(){
|
||||
for (int i=mCount-1;i>=0; i--){
|
||||
Interruptible * current = ((Interruptible *)mObjects[i]);
|
||||
if (current->state != NOT_RESOLVED){
|
||||
mObjects[i] = mObjects[mCount-1];
|
||||
mCount--;
|
||||
SAFE_DELETE(current);
|
||||
}
|
||||
}
|
||||
std::vector<JGuiObject *>::iterator iter = mObjects.begin() ;
|
||||
|
||||
while( iter != mObjects.end() ){
|
||||
Interruptible * current = ((Interruptible *) *iter);
|
||||
if (current->state != NOT_RESOLVED){
|
||||
iter = mObjects.erase( iter ) ;
|
||||
mCount--;
|
||||
SAFE_DELETE(current);
|
||||
}else {
|
||||
++iter ;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,20 +2,48 @@
|
||||
#include "../include/GuiLayers.h"
|
||||
#include "../include/Player.h"
|
||||
|
||||
GuiLayer::GuiLayer(int id, GameObserver* _game):JGuiController(id, NULL){
|
||||
GuiLayer::GuiLayer(int id, GameObserver* _game){
|
||||
mId = id;
|
||||
game = _game;
|
||||
modal = 0;
|
||||
hasFocus = false;
|
||||
mCount = 0;
|
||||
mCurr = 0;
|
||||
mActionButton = PSP_CTRL_CIRCLE;
|
||||
}
|
||||
|
||||
GuiLayer::~GuiLayer(){
|
||||
//TODO
|
||||
resetObjects();
|
||||
}
|
||||
|
||||
void GuiLayer::Add(JGuiObject *object){
|
||||
mObjects.push_back(object);
|
||||
mCount++;
|
||||
}
|
||||
|
||||
void GuiLayer::Remove(JGuiObject *object){
|
||||
for (int i=0;i<mCount;i++){
|
||||
if (mObjects[i]==object){
|
||||
delete mObjects[i];
|
||||
mObjects.erase(mObjects.begin()+i);
|
||||
mCount--;
|
||||
if (mCurr == mCount)
|
||||
mCurr = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int GuiLayer::getMaxId(){
|
||||
return mCount;
|
||||
}
|
||||
|
||||
void GuiLayer::Render(){
|
||||
for (int i=0;i<mCount;i++)
|
||||
if (mObjects[i]!=NULL)
|
||||
mObjects[i]->Render();
|
||||
}
|
||||
|
||||
void GuiLayer::Update(float dt){
|
||||
for (int i=0;i<mCount;i++)
|
||||
if (mObjects[i]!=NULL)
|
||||
@@ -27,7 +55,7 @@ void GuiLayer::resetObjects(){
|
||||
for (int i=0;i<mCount;i++)
|
||||
if (mObjects[i])
|
||||
delete mObjects[i];
|
||||
|
||||
mObjects.clear();
|
||||
mCount = 0;
|
||||
mCurr = 0;
|
||||
}
|
||||
|
||||
@@ -154,8 +154,23 @@ int MTGBlockRule::testDestroy(){
|
||||
// * Momir
|
||||
//
|
||||
|
||||
int MTGMomirRule::initialized = 0;
|
||||
vector<int> MTGMomirRule::pool[20];
|
||||
|
||||
MTGMomirRule::MTGMomirRule(int _id, MTGAllCards * _collection):MTGAbility(_id, NULL){
|
||||
collection = _collection;
|
||||
if (!initialized){
|
||||
int total_cards = collection->totalCards();
|
||||
for (int i = 0; i < total_cards; i++){
|
||||
MTGCard * card = collection->collection[i];
|
||||
if (card->isACreature()){
|
||||
int convertedCost = card->getManaCost()->getConvertedCost();
|
||||
if (convertedCost>20) continue;
|
||||
pool[convertedCost].push_back(card->getMTGId());
|
||||
}
|
||||
}
|
||||
initialized =1;
|
||||
}
|
||||
alreadyplayed = 0;
|
||||
aType=MTGAbility::MOMIR;
|
||||
}
|
||||
@@ -207,20 +222,11 @@ MTGCardInstance * MTGMomirRule::genCreature( int id){
|
||||
}
|
||||
|
||||
int MTGMomirRule::genRandomCreatureId(int convertedCost){
|
||||
Player * p = game->currentlyActing();
|
||||
int total_cards = collection->totalCards();
|
||||
if (convertedCost > 20) return 0;
|
||||
int total_cards = pool[convertedCost].size();
|
||||
if (!total_cards) return 0;
|
||||
int start = (rand() % total_cards);
|
||||
int id2 = start;
|
||||
while (id2 < total_cards){
|
||||
MTGCard * card = collection->collection[id2];
|
||||
if (card->isACreature() && card->getManaCost()->getConvertedCost() == convertedCost){
|
||||
return card->getMTGId();
|
||||
}
|
||||
id2++;
|
||||
if (id2 == start) return 0;
|
||||
if (id2 == total_cards) id2 = 0;
|
||||
}
|
||||
return 0;
|
||||
return pool[convertedCost][start];
|
||||
}
|
||||
|
||||
//The Momir rule is never destroyed
|
||||
|
||||
Reference in New Issue
Block a user