Esempio n. 1
0
bool ActionSpellSetGuardian(Heroes & hero, const Spell & spell, u8 id)
{
    Maps::Tiles & tile = world.GetTiles(hero.GetIndex());

    if(MP2::OBJ_MINES != tile.GetObject(false))
    {
        Dialog::Message("", _("You must be standing on the entrance to a mine (sawmills and alchemists don't count) to cast this spell."), Font::BIG, Dialog::OK);
        return false;
    }

    const u16 count = hero.GetPower() * spell.ExtraValue();

    if(count)
    {
        Maps::TilesAddon* addon = tile.FindObject(MP2::OBJ_MINES);

        if(addon)
            addon->tmp = spell();

        if(spell == Spell::HAUNT)
        {
            world.CaptureObject(tile.GetIndex(), Color::UNUSED);
            tile.SetObject(MP2::OBJ_ABANDONEDMINE);
        }

        Army::Troop troop = world.GetCapturedObject(tile.GetIndex()).GetTroop();
        troop.Set(Monster(spell), count);
    }

    return false;
}
void Dialog::SpellInfo(const Spell & spell, bool ok_button)
{
    std::string msg = spell.GetDescription();
    u32 extra = spell.ExtraValue();

    switch(spell())
    {
	case Spell::HASTE:
	case Spell::MASSHASTE:
	    if(0 == extra) extra = 2;
	    break;

	default: break;
    }

    if(1 == extra)
        StringReplace(msg, "%{count}", _("one"));
    else
    if(2 == extra)
        StringReplace(msg, "%{count}", _("two"));
    else
	StringReplace(msg, "%{count}", extra);

    Dialog::SpellInfo(spell.GetName(), msg, spell, ok_button);
}