Beispiel #1
0
void AIStats::Render()
{
    GameObserver * g = player->getObserver();
    float x0 = 10;
    if (player == g->players[1])
        x0 = 280;
    JRenderer::GetInstance()->FillRoundRect(x0, 10, 200, 180, 5, ARGB(50,0,0,0));

    WFont * f = g->getResourceManager()->GetWFont(Fonts::MAIN_FONT);
    int i = 0;
    char buffer[512];
    list<AIStat *>::iterator it;
    for (it = stats.begin(); it != stats.end(); ++it)
    {
        if (i > 10)
            break;
        AIStat * stat = *it;
        if (stat->value > 0)
        {
            MTGCard * card = MTGCollection()->getCardById(stat->source);
            if (card)
            {
                sprintf(buffer, "%s %i", card->data->getName().c_str(), stat->value);
                f->DrawString(buffer, x0 + 5, 10 + 16 * (float) i);
                i++;
            }
        }
    }
}
Beispiel #2
0
// Moves a card from one zone to another
// If the card is not actually in the expected "from" zone, does nothing and returns null 
MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to,bool asCopy)
{
    MTGCardInstance * copy = NULL;
    GameObserver *g = owner->getObserver();
    if (!from || !to)
        return card; //Error check

    int doCopy = 1;
    bool shufflelibrary = card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH];
    bool inplaytoinplay = false;
    bool ripToken = false;
    if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace"))
        ripToken = true;
    //Madness or Put in Play...
    for(int i = 0; i < 2; ++i)
    {
        if (card->discarded && (to == g->players[i]->game->graveyard) && (from == g->players[i]->game->hand))
        {
            if(card->basicAbilities[(int)Constants::MADNESS])
                to = g->players[i]->game->exile;
        }
    }
    //Darksteel Colossus, Legacy Weapon ... top priority since we replace destination directly automatically...
    for(int i = 0; i < 2; ++i)
    {
        if ((to == g->players[i]->game->graveyard) && (
        card->basicAbilities[(int)Constants::LIBRARYDEATH]||
        card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH]))
        {
            to = g->players[i]->game->library;
        }
    }
    //Leyline of the Void, Yawgmoth's Agenda... effect...
    for(int i = 0; i < 2; ++i)
    {
        if ((to == g->players[i]->game->graveyard) && (
        (g->players[i]->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER) && card->isCreature()) ||
        (g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && card->isCreature())||
        g->players[i]->game->battlefield->hasAbility(Constants::MYGRAVEEXILER) ||
        g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER)))
        {
            if ((card->isToken && ripToken))
                to = g->players[i]->game->exile;
            if (!card->isToken)
                to = g->players[i]->game->exile;
        }
    }
    //When a card is moved from inPlay to inPlay (controller change, for example), it is still the same object
    if ((to == g->players[0]->game->inPlay || to == g->players[1]->game->inPlay) && (from == g->players[0]->game->inPlay || from
                    == g->players[1]->game->inPlay))
    {
        doCopy = 0;
        asCopy = true;//don't send zone change event so it will not destroy the GUI when multiple switching of control...
        inplaytoinplay = true;//try sending different event...
    }

    if (!(copy = from->removeCard(card, doCopy)))
        return NULL; //ERROR
    if (card->miracle)
    {
        copy->miracle = true;
    }
    if (card->discarded)
    {//set discarded for madness...
        if(from == g->players[0]->game->hand || from == g->players[1]->game->hand)
            copy->discarded = true;
        else//turn off discarded if its previous zone is not in hand...
            copy->discarded = false;
    }
    if (options[Options::SFXVOLUME].number > 0)
    {
        if (to == g->players[0]->game->graveyard || to == g->players[1]->game->graveyard)
        {
            if (card->isCreature() && g->getResourceManager())
            {
                g->getResourceManager()->PlaySample("graveyard.wav");
            }
        }
    }

    MTGCardInstance * ret = copy;
    for(int i = 0; i < 2; ++i)
    {
        if(to == g->players[i]->game->library && from == g->players[i]->game->library)//if its going to the library from the library we intend to put it on top.
        {
            g->players[i]->game->temp->addCard(copy);
            g->players[i]->game->library->placeOnTop.push_back(copy);
            return ret;//don't send event
        }
    }
    to->addCard(copy);
    //The "Temp" zone are purely for code purposes, and we don't want the abilities engine to
    //Trigger when cards move in this zone
    // Additionally, when they move "from" this zone,
    // we trick the engine into believing that they moved from the zone the card was previously in
    // See http://code.google.com/p/wagic/issues/detail?id=335
    {
        if (to == g->players[0]->game->temp || to == g->players[1]->game->temp)
        {
            //don't send event when moving to temp
            return ret;
        }

        if (from == g->players[0]->game->temp || from == g->players[1]->game->temp)
        {
            //remove temporary stuff
            MTGCardInstance * previous = copy->previous;
            MTGCardInstance * previous2 = previous->previous;
            from = previous->previousZone;
            copy->previous = previous2;
            if (previous2)
                previous2->next = copy;
            previous->previous = NULL;
            previous->next = NULL;
            SAFE_DELETE(previous);
        }
    }
    if(!asCopy)
    {
        if(shufflelibrary)
            copy->owner->game->library->shuffle();

    WEvent * e = NEW WEventZoneChange(copy, from, to);
    g->receiveEvent(e);
    }
    if(inplaytoinplay)
    {
    WEvent * ep = NEW WEventCardControllerChange(copy);
    g->receiveEvent(ep);
    }
    return ret;

}