Exemplo n.º 1
0
Spell Dialog::SelectSpell(u8 cur)
{
    Display & display = Display::Get();
    Cursor & cursor = Cursor::Get();
    LocalEvent & le = LocalEvent::Get();

    std::vector<int> spells(static_cast<int>(Spell::STONE - 1), Spell::NONE);

    cursor.Hide();
    cursor.SetThemes(cursor.POINTER);

    for(size_t ii = 0; ii < spells.size(); ++ii) spells[ii] = ii + 1;

    const u16 window_w = 340;
    const u16 window_h = 280;

    Dialog::FrameBorder frameborder;
    frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH,
			    (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h);
    frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0));

    const Rect & area = frameborder.GetArea();

    SelectEnumSpell listbox(area);

    listbox.SetListContent(spells);
    if(cur != Spell::NONE)
	listbox.SetCurrent(static_cast<int>(cur));
    listbox.Redraw();

    ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL);
    btnGroups.Draw();

    cursor.Show();
    display.Flip();

    u16 result = Dialog::ZERO;

    while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents())
    {
        result = btnGroups.QueueEventProcessing();
        listbox.QueueEventProcessing();

        if(!cursor.isVisible())
        {
            listbox.Redraw();
            cursor.Show();
            display.Flip();
        }
    }

    return result == Dialog::OK || listbox.ok ?
	Spell(listbox.GetCurrent()) : Spell(Spell::NONE);
}
Exemplo n.º 2
0
SpellCastResult PetAI::CanAutoCast(Unit* target, SpellEntry const* spellInfo)
{
    if (!spellInfo || !target)
        return SPELL_FAILED_DONT_REPORT;
    Spell spell = Spell(m_creature, spellInfo, false);
    return spell.CanAutoCast(target);
}
Exemplo n.º 3
0
bool PetAI::CanAutoCast(Unit* target, SpellEntry const* spellInfo)
{
    if (!spellInfo || !target)
        return false;

    Spell spell = Spell(m_creature, spellInfo, false);
    return spell.CanAutoCast(target);
}
Exemplo n.º 4
0
void SpellDatabase::loadSpells(char * filename)
{
  file<> xmlfile(filename);
  xml_document<> doc;
  doc.parse<0>(xmlfile.data());
  Spell spell;
  for (xml_node<> *node = doc.first_node();node;node=node->next_sibling())
  {
    spell = Spell();
    spell.xml_read(&doc,&*node);
    spells.push_back(spell);
  }
}
Exemplo n.º 5
0
Spell * ActionStack::addSpell(MTGCardInstance * _source, TargetChooser * tc, ManaCost * mana, int payResult,
                              int storm)
{
    DebugTrace("ACTIONSTACK Add spell");
    if (storm > 0)
    {
        mana = NULL;
    }
    Spell * spell = NEW Spell(observer, mObjects.size(), _source, tc, mana, payResult);
    addAction(spell);
    if (!observer->players[0]->isAI() && _source->controller() == observer->players[0] && 0 == options[Options::INTERRUPTMYSPELLS].number)
        interruptDecision[0] = DONT_INTERRUPT;
    return spell;
}
Exemplo n.º 6
0
std::string Artifact::GetDescription(void) const
{
    u32 count = ExtraValue();
    std::string str = GetPluralDescription(*this, count);

    StringReplace(str, "%{name}", GetName());

    if(id == Artifact::SPELL_SCROLL)
        StringReplace(str, "%{spell}", Spell(ext).GetName());
    else
        StringReplace(str, "%{count}", count);

    return str;
}
Exemplo n.º 7
0
Spell Magic::generateSpell(SpellField field)
{
    QList<Position> list;
    QList<ActiveEffect> effects;
    QList<ActiveEffect>::iterator iter;
    ActiveEffect* worker;

    //crating mask for field
    bool **mask = new bool*[field.size.x];
    for (int i = 0; i < field.size.x; ++i){
        mask[i] = new bool[field.size.y];
        for(int n = 0; n < field.size.y; ++n)
            if(field.map[i][n] != Runes::End)
                mask[i][n] = true;
            else
                mask[i][n] = false;
    }

    if(field.mainRune.x > -1 && field.mainRune.y > -1 && field.map[field.mainRune.x][field.mainRune.y] != Runes::End){
        Position current(field.mainRune.x,field.mainRune.y);

        ActiveEffect work;
        Effect effect;
        int cost = 0;

        Rune *mainRune = runes[field.map[current.x][current.y]];
        work.effect = mainRune->combinationEffect(field.map[current.x][current.y]);
        work.coefficient = 1;
        effects.append(work);
        cost += mainRune->getCost();
        mask[current.x][current.y] = false;

        //select next rune
        if(current.x > 0 && mask[current.x-1][current.y]){
            list.append(Position(current.x-1,current.y));
            mask[current.x-1][current.y] = false;
        }
        if(current.x < field.size.x-1 && mask[current.x+1][current.y]){
            list.append(Position(current.x+1,current.y));
            mask[current.x+1][current.y] = false;
        }
        if(current.y > 0 && mask[current.x][current.y-1]){
            list.append(Position(current.x,current.y-1));
            mask[current.x][current.y-1] = false;
        }
        if(current.y < field.size.y-1 && mask[current.x][current.y+1]){
            list.append(Position(current.x,current.y+1));
            mask[current.x][current.y+1] = false;
        }


        while(!list.isEmpty()){
            current = list.first();

            //qDebug() << current.x << " " << current.y;

            list.pop_front();
            effect = mainRune->combinationEffect(field.map[current.x][current.y]);
            bool flag = true;
            for(iter = effects.begin(); iter != effects.end(); iter++){
                if(iter->effect == effect)
                {
                    iter->coefficient++;
                    flag = false;
                    break;
                }
            }
            if(flag){
                work.effect = effect;
                effects.append(work);
            }
            cost += runes[field.map[current.x][current.y]]->getCost();

            //select next rune
            if(current.x > 0&& mask[current.x-1][current.y]){
                list.append(Position(current.x-1,current.y));
                mask[current.x-1][current.y] = false;
            }
            if(current.x < field.size.x-1 && mask[current.x+1][current.y]){
                list.append(Position(current.x+1,current.y));
                mask[current.x+1][current.y] = false;
            }
            if(current.y > 0 && mask[current.x][current.y-1]){
                list.append(Position(current.x,current.y-1));
                mask[current.x][current.y-1] = false;
            }
            if(current.y < field.size.y-1 && mask[current.x][current.y+1]){
                list.append(Position(current.x,current.y+1));
                mask[current.x][current.y+1] = false;
            }

        }
        int size;
        worker = new ActiveEffect[size = effects.size()];
        for(int i = 0; i < size; i++){
            worker[i] = effects.first();
            effects.pop_front();
        }
        return Spell("Success", cost, worker, size);
    }
    return Spell("Error", 1,worker, 0);
}
Exemplo n.º 8
0
void Rules::initGame(GameObserver *g)
{
    DebugTrace("RULES Init Game\n");

    //Set the current player/phase
    if (g->currentPlayer->playMode!= Player::MODE_TEST_SUITE &&  g->mRules->gamemode!= GAME_TYPE_STORY)
    {
        if(OptionWhosFirst::WHO_R == options[Options::FIRSTPLAYER].number)
            initState.player = g->getRandomGenerator()->random() % 2;
        if(OptionWhosFirst::WHO_O == options[Options::FIRSTPLAYER].number)
            initState.player = 1;
    }
    g->currentPlayer = g->players[initState.player];
    g->currentActionPlayer = g->currentPlayer;
    g->currentPlayerId = initState.player;
    g->phaseRing->goToPhase(0, g->currentPlayer, false);
    g->phaseRing->goToPhase(initState.phase, g->currentPlayer);
    g->currentGamePhase = initState.phase;

    for (int i = 0; i < 2; i++)
    {
        Player * p = g->players[i];
        p->life = initState.playerData[i].player->life;
        p->poisonCount = initState.playerData[i].player->poisonCount;
        p->damageCount = initState.playerData[i].player->damageCount;
        p->preventable = initState.playerData[i].player->preventable;
        if (initState.playerData[i].player->mAvatarName.size())
        {
            p->mAvatarName = initState.playerData[i].player->mAvatarName;
        }
        MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
        MTGGameZone * loadedPlayerZones[] = { initState.playerData[i].player->game->graveyard,
                                              initState.playerData[i].player->game->library,
                                              initState.playerData[i].player->game->hand,
                                              initState.playerData[i].player->game->inPlay };
        for (int j = 0; j < 4; j++)
        {
            MTGGameZone * zone = playerZones[j];
            for (size_t k = 0; k < loadedPlayerZones[j]->cards.size(); k++)
            {
                MTGCardInstance * card = getCardByMTGId(g, loadedPlayerZones[j]->cards[k]->getId());
                if (card && zone != p->game->library)
                {
                    if (zone == p->game->inPlay)
                    {
                        MTGCardInstance * copy = p->game->putInZone(card, p->game->library, p->game->stack);
                        Spell * spell = NEW Spell(g, copy);
                        spell->resolve();
                        delete spell;
                    }
                    else
                    {
                        if (!p->game->library->hasCard(card))
                        {
                            LOG ("RULES ERROR, CARD NOT FOUND IN LIBRARY\n");
                        }
                        p->game->putInZone(card, p->game->library, zone);
                    }
                }
                else
                {
                    if (!card)
                    {
                        LOG ("RULES ERROR, card is NULL\n");
                    }
                }
            }
        }
    }
    addExtraRules(g);

    postUpdateInitDone = false;
DebugTrace("RULES Init Game Done !\n");
}
// '#' 'version' NUMBER PROFILE?
void GLSLPreProcessor::ParseDirectiveVersion()
{
    /* Check if version was already defined */
    if (versionDefined_)
    {
        Error(R_GLSLVersionAlreadyDefined(versionNo_), true, false);
        IgnoreDirective();
        return;
    }

    versionDefined_ = true;

    /* Parse version number */
    IgnoreWhiteSpaces();

    auto versionTkn = Accept(Tokens::IntLiteral);
    versionNo_ = std::stoi(versionTkn->Spell());

    /* Parse profile */
    bool isESSL = false;
    bool isCompatibilityProfile = false;
    std::string profile;

    IgnoreWhiteSpaces();
    if (Is(Tokens::Ident))
    {
        profile = Accept(Tokens::Ident)->Spell();

        if (profile == "es")
        {
            /* Parse version for ESSL (OpenGL ES) */
            isESSL = true;
        }
        else
        {
            /* Parse version for GLSL (OpenGL or Vulkan) */
            if (profile == "compatibility")
                isCompatibilityProfile = true;
            else if (profile != "core")
                Error(R_InvalidGLSLVersionProfile(profile), true, false);
        }
    }

    if (isESSL)
    {
        /* Verify ESSL version number */
        static const int versionsESSL[] =
        {
            100, 300, 310, 320, 0
        };

        if (!VerifyVersionNo(versionsESSL))
            Error(R_UnknownESSLVersion(versionNo_), versionTkn.get(), false);
    }
    else
    {
        /* Verify GLSL version number */
        static const int versionsGLSL[] =
        {
            110, 120, 130, 140, 150, 330, 400, 410, 420, 430, 440, 450, 460, 0
        };

        if (!VerifyVersionNo(versionsGLSL))
            Error(R_UnknownGLSLVersion(versionNo_), versionTkn.get(), false);

        /* Only GLSL 150+ allows a profile */
        if (!profile.empty() && versionNo_ < 150)
            Error(R_NoProfileForGLSLVersionBefore150, true, false);
    }

    /* Write out version */
    Out() << "#version " << versionNo_;

    if (!profile.empty())
        Out() << ' ' << profile;

    /*
    Define standard macros: 'GL_core_profile', 'GL_es_profile', 'GL_compatibility_profile'
    see https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#Standard_macros
    */
    DefineStandardMacro("GL_core_profile");

    if (isESSL)
    {
        DefineStandardMacro("GL_es_profile");
        DefineStandardMacro("GL_ES");
    }
    else if (isCompatibilityProfile)
        DefineStandardMacro("GL_compatibility_profile");

    DefineStandardMacro("__VERSION__", versionNo_);
}
Exemplo n.º 10
0
bool GameEngine::moveAI(Actor* monster) {
	//Death Curse damage
	if (monster->getSpell().getSpellType() == 5) {
		monster->doDMG(3);
		if (monster->getHP() <= 0)
			killMonster(monster->getLoc());
	}

	Point heroLoc = hero->getLoc();
	Point loc = monster->getLoc();
	int xDist = heroLoc.x() - loc.x();
	int yDist = heroLoc.y() - loc.y();
	int which = 0;

	Point dir(0, 0);

	//Choose direction
	if (xDist == 0 && yDist == 0)
		dir = Point(0, 0);
	else if (xDist == 0 && yDist != 0)
		dir = Point(0, yDist / abs(yDist));
	else if (xDist != 0 && yDist == 0)
		dir = Point(xDist / abs(xDist), 0);
	else if (xDist != 0 && yDist != 0)
		dir = Point(xDist / abs(xDist), yDist / abs(yDist));


	//Move monster based on whether it's close enough to the hero or not
	if (abs(xDist) + abs(yDist) < 5) {
		loc = loc + pickAIPoint(monster, dir, false);
		monster->gettingTired();
	}
	else
		loc = loc + pickAIPoint(monster, dir, true);

	//Don't move the monster if it's next to the hero, make it attack
	if (Point(abs(xDist), abs(yDist)) == Point(0, 1) || Point(abs(xDist), abs(yDist)) == Point(1, 0))
		return true; //Is going to attack hero
	else {
		//Update loc in map grid
		try {
			if (loc > Point(0, 0) && loc < Point(63, 63)) {
				if (moveableCell(map[loc.x()][loc.y()].getLoc())) {
					if (!monster->isTired()) {
						if (map[monster->getLoc().x()][monster->getLoc().y()].getSpell().getSpellType() != 4) { //If monster is in ice block, don't move
							//Move the monster
							map[monster->getLoc().x()][monster->getLoc().y()].setActor(NULL);
							monster->setLoc(loc);
							map[loc.x()][loc.y()].setActor(monster);
						}

						if (map[loc.x()][loc.y()].getSpell().getSpellType() == 1) { //Field of fire, damage monster if they're in the spell
							monster->doDMG(2);
							if (monster->getHP() <= 0)
								killMonster(monster->getLoc());
						}
						else if (map[loc.x()][loc.y()].getSpell().getSpellType() == 6) {
							monster->doDMG(10);
							log.registerEvent(monster->getActorDef().getDESC() + " triggered Fist of Katar!");
							if (monster->getHP() <= 0)
								killMonster(monster->getLoc());
							map[loc.x()][loc.y()].setSpell(Spell());
						}
					}
				}
			}
		}
		catch (int e) {
			OutputDebugString(to_string(e).c_str());
		}
		return false;
	}
}
Exemplo n.º 11
0
void GameEngine::drawMap() {
	renderFogOfWar();

	Point world = screenOrientation - (lib.res() / 2);
	int yWorldOrig = world.y();

	for (int xScreen = 0; xScreen < lib.res().x(); xScreen++) {
		world.sety(yWorldOrig);
		for (int yScreen = 0; yScreen < lib.res().y(); yScreen++) {
			Point d(xScreen, yScreen);

			if (world.x() < 0 || world.y() < 0 || world.x() > worldSize - 1 || world.y() > worldSize - 1) {
				Cell t(d, 0, 0, 0);
				lib.rendertile(t.getTile(), d);
			}
			else {
				Cell t = map[world.x()][world.y()];

				//For of war stuff
				//Set stuff on screen back to not visible
				map[world.x()][world.y()].setVisibility(false);

				//Explore it if the bressenham lines
				if (t.isVisible() == false) {
					if (t.isExplored() && !t.isVisible())
						tl_color(0xFFFFFF70);
					else if (t.isExplored() && t.isVisible())
						tl_color(0xFFFFFFFF);
					else if (!t.isExplored() && !t.isVisible())
						tl_color(0xFFFFFF20);
				}

				if (t.getTile() != floorTile && t.getCellType() != 6)
					lib.rendertile(0, d);
				else if (t.getCellType() == 6)
					lib.rendertile(floorTile, d);

				lib.rendertile(t.getTile(), d);
				tl_color(0xFFFFFFFF);

				if (t.getPickup() != NULL && t.isVisible())
					lib.rendertile(t.getPickup()->getPickupDef().getTile(), d);

				//Set spell stuff
				if (t.getSpell().getSpellType() == 1) {
					if (turns > t.getSpell().getTurnActivated() + t.getSpell().getNumTurns())
						map[world.x()][world.y()].setSpell(Spell());
					else
						lib.rendertile(0x341, d);
				}
				if (t.getSpell().getSpellType() == 4) {
					if (turns > t.getSpell().getTurnActivated() + t.getSpell().getNumTurns()) {
						map[world.x()][world.y()].setSpell(Spell());
					}
					else
						lib.rendertile(0x377, d);
				}

				if (t.getActor() != NULL && t.isVisible()) {
					lib.rendertile(t.getActor()->getActorDef().getTile(), d);
					if (t.getActor()->getSpell().getSpellType() == 5) {
						if (turns > t.getActor()->getSpell().getTurnActivated() + t.getActor()->getSpell().getNumTurns()) {
							t.getActor()->setSpell(Spell());
						}
						else
							lib.rendertile(0x39D, d);
					}
				}

				if (t.getSpell().getSpellType() == 6)
					lib.rendertile(0x34A, d);
			}
			world = world + Point(0, 1);
		}
		world = world + Point(1, 0);
	}

	//Render MessageLog, InventoryLog, Shop
	log.renderMsgs();
	invLog.renderInventory();

	//Draw char
	if (!deadHero)
		lib.rendertile(hero->getActorDef().getTile(), lib.res() / 2);

	shop.renderShop();
}