Ejemplo n.º 1
0
void CastleRedrawBuilding(const Castle & castle, const Point & dst_pt, u32 build, u32 frame, int alpha)
{
    const Rect max = CastleGetMaxArea(castle, dst_pt);

    // correct build
    switch(build)
    {
	case DWELLING_MONSTER2:
	case DWELLING_MONSTER3:
	case DWELLING_MONSTER4:
	case DWELLING_MONSTER5:
	case DWELLING_MONSTER6: build = castle.GetActualDwelling(build); break;

	default: break;
    }

    const int icn = Castle::GetICNBuilding(build, castle.GetRace());
    u32 index = 0;

    // correct index (mage guild)
    switch(build)
    {
        case BUILD_MAGEGUILD1: index = 0; break;
        case BUILD_MAGEGUILD2: index = Race::NECR == castle.GetRace() ? 6 : 1; break;
        case BUILD_MAGEGUILD3: index = Race::NECR == castle.GetRace() ? 12 : 2; break;
        case BUILD_MAGEGUILD4: index = Race::NECR == castle.GetRace() ? 18 : 3; break;
        case BUILD_MAGEGUILD5: index = Race::NECR == castle.GetRace() ? 24 : 4; break;
        default: break;
    }

    if(icn != ICN::UNKNOWN)
    {
	// simple first sprite
	Sprite sprite1 = AGG::GetICN(icn, index);

	if(alpha)
	{
	    sprite1.SetSurface(sprite1.GetSurface());
	    sprite1.SetAlphaMod(alpha);
	    sprite1.Blit(dst_pt.x + sprite1.x(), dst_pt.y + sprite1.y());
	}
	else
	    CastleDialog::RedrawBuildingSpriteToArea(sprite1, dst_pt.x + sprite1.x(), dst_pt.y + sprite1.y(), max);

	// second anime sprite
	if(const u32 index2 = ICN::AnimationFrame(icn, index, frame))
	{
	    Sprite sprite2 = AGG::GetICN(icn, index2);

	    if(alpha)
	    {
		sprite2.SetSurface(sprite2.GetSurface());
		sprite2.SetAlphaMod(alpha);
		sprite2.Blit(dst_pt.x + sprite2.x(), dst_pt.y + sprite2.y());
	    }
	    else
	        CastleDialog::RedrawBuildingSpriteToArea(sprite2, dst_pt.x + sprite2.x(), dst_pt.y + sprite2.y(), max);
	}
    }
}
Ejemplo n.º 2
0
void Kingdom::ApplyPlayWithStartingHero(void)
{
    if(isPlay() && castles.size())
    {
	// get first castle
	Castle* first = castles.GetFirstCastle();
	if(NULL == first) first = castles.front();

	// check manual set hero (castle position + point(0, 1))?
	const Point & cp = (first)->GetCenter();
	Heroes* hero = world.GetTiles(cp.x, cp.y + 1).GetHeroes();

    	// and move manual set hero to castle
	if(hero && hero->GetColor() == GetColor())
	{
		bool patrol = hero->Modes(Heroes::PATROL);
    		hero->SetFreeman(0);
    		hero->Recruit(*first);

		if(patrol)
		{
		    hero->SetModes(Heroes::PATROL);
		    hero->SetCenterPatrol(cp);
		}
	}
	else
	if(Settings::Get().GameStartWithHeroes())
	{
    	    Heroes* hero = world.GetFreemanHeroes(first->GetRace());
	    if(hero && AllowRecruitHero(false, 0)) hero->Recruit(*first);
	}
    }
}
Ejemplo n.º 3
0
void CastleRedrawBuildingExtended(const Castle & castle, const Point & dst_pt, u32 build, u32 frame)
{
    const Rect max = CastleGetMaxArea(castle, dst_pt);
    int icn = Castle::GetICNBuilding(build, castle.GetRace());

    // shipyard
    if(BUILD_SHIPYARD == build)
    {
	// boat
	if(castle.PresentBoat())
	{
	    const int icn2 = castle.GetICNBoat(castle.GetRace());

    	    const Sprite & sprite40 = AGG::GetICN(icn2, 0);
	    CastleDialog::RedrawBuildingSpriteToArea(sprite40, dst_pt.x + sprite40.x(), dst_pt.y + sprite40.y(), max);

    	    if(const u32 index2 = ICN::AnimationFrame(icn2, 0, frame))
	    {
		const Sprite & sprite41 = AGG::GetICN(icn2, index2);
		CastleDialog::RedrawBuildingSpriteToArea(sprite41, dst_pt.x + sprite41.x(), dst_pt.y + sprite41.y(), max);
	    }
	}
	else
	{
    	    if(const u32 index2 = ICN::AnimationFrame(icn, 0, frame))
	    {
		const Sprite & sprite3 = AGG::GetICN(icn, index2);
		CastleDialog::RedrawBuildingSpriteToArea(sprite3, dst_pt.x + sprite3.x(), dst_pt.y + sprite3.y(), max);
	    }
	}
    }
    else
    // sorc and anime wel2 or statue
    if(Race::SORC == castle.GetRace() && BUILD_WEL2 == build)
    {
	const int icn2 = castle.isBuild(BUILD_STATUE) ? ICN::TWNSEXT1 : icn;

    	const Sprite & sprite20 = AGG::GetICN(icn2, 0);
	CastleDialog::RedrawBuildingSpriteToArea(sprite20, dst_pt.x + sprite20.x(), dst_pt.y + sprite20.y(), max);

    	if(const u32 index2 = ICN::AnimationFrame(icn2, 0, frame))
	{
	    const Sprite & sprite21 = AGG::GetICN(icn2, index2);
	    CastleDialog::RedrawBuildingSpriteToArea(sprite21, dst_pt.x + sprite21.x(), dst_pt.y + sprite21.y(), max);
	}
    }
}
Ejemplo n.º 4
0
CastleDialog::CacheBuildings::CacheBuildings(const Castle & castle, const Point & top)
{
    std::vector<building_t> ordersBuildings;

    ordersBuildings.reserve(25);

    CastlePackOrdersBuildings(castle, ordersBuildings);

    for(std::vector<building_t>::const_iterator
        it = ordersBuildings.begin(); it != ordersBuildings.end(); ++it)
    {
        push_back(builds_t(*it, CastleGetCoordBuilding(castle.GetRace(), *it, top)));
    }
}
Ejemplo n.º 5
0
u16 HowManyRecruitMonster(const Castle & castle, u32 dw, const Funds & add, Funds & res)
{
    const Monster ms(castle.GetRace(), castle.GetActualDwelling(dw));
    const Kingdom & kingdom = world.GetKingdom(castle.GetColor());

    if(! castle.GetArmy().CanJoinTroop(ms)) return 0;
                                                                                                                         
    u16 count = castle.GetDwellingLivedCount(dw);
    payment_t payment;

    while(count)
    {
        payment = ms.GetCost() * count;
        res = payment;
        payment += add;
        if(kingdom.AllowPayment(payment)) break;
        --count;
    }

    return count;
}
Ejemplo n.º 6
0
Rect CastleGetMaxArea(const Castle & castle, const Point & top)
{
    Rect res(top, 0, 0);
    Sprite townbkg;

    switch(castle.GetRace())
    {
	case Race::KNGT: townbkg = AGG::GetICN(ICN::TOWNBKG0, 0); break;
	case Race::BARB: townbkg = AGG::GetICN(ICN::TOWNBKG1, 0); break;
	case Race::SORC: townbkg = AGG::GetICN(ICN::TOWNBKG2, 0); break;
	case Race::WRLK: townbkg = AGG::GetICN(ICN::TOWNBKG3, 0); break;
	case Race::WZRD: townbkg = AGG::GetICN(ICN::TOWNBKG4, 0); break;
	case Race::NECR: townbkg = AGG::GetICN(ICN::TOWNBKG5, 0); break;
	default: break;
    }

    if(townbkg.isValid())
    {
	res.w = townbkg.w();
	res.h = townbkg.h();
    }

    return res;
}
Ejemplo n.º 7
0
void AICastleDefense(Castle & c)
{
    if(c.isCastle())
    {
        if(!c.isBuild(BUILD_LEFTTURRET))
		c.BuyBuilding(BUILD_LEFTTURRET);

        if(!c.isBuild(BUILD_RIGHTTURRET))
		c.BuyBuilding(BUILD_RIGHTTURRET);

        if(!c.isBuild(BUILD_MOAT))
    		c.BuyBuilding(BUILD_MOAT);

        if(!c.isBuild(BUILD_CAPTAIN) && NULL == c.GetHeroes().Guest())
		c.BuyBuilding(BUILD_CAPTAIN);

        if(!c.isBuild(BUILD_TAVERN) && Race::KNGT == c.GetRace())
		c.BuyBuilding(BUILD_TAVERN);

        if(!c.isBuild(BUILD_SPEC))
		c.BuyBuilding(BUILD_SPEC);
    }
    c.RecruitAllMonster();
}
Ejemplo n.º 8
0
DwellingItem::DwellingItem(Castle & castle, u32 dw)
{
    type = castle.GetActualDwelling(dw);
    mons = Monster(castle.GetRace(), type);
}
Ejemplo n.º 9
0
void CastleRedrawCurrentBuilding(const Castle & castle, const Point & dst_pt,
				const CastleDialog::CacheBuildings & orders, u32 build, u32 flash)
{
    u32 & frame = Game::CastleAnimationFrame();

    Display & display = Display::Get();
    Cursor & cursor = Cursor::Get();

    Sprite townbkg;

    // before redraw
    switch(castle.GetRace())
    {
	case Race::KNGT: townbkg = AGG::GetICN(ICN::TOWNBKG0, 0); break;
	case Race::BARB: townbkg = AGG::GetICN(ICN::TOWNBKG1, 0); break;
	case Race::SORC: townbkg = AGG::GetICN(ICN::TOWNBKG2, 0); break;
	case Race::WRLK: townbkg = AGG::GetICN(ICN::TOWNBKG3, 0); break;
	case Race::WZRD: townbkg = AGG::GetICN(ICN::TOWNBKG4, 0); break;
	case Race::NECR: townbkg = AGG::GetICN(ICN::TOWNBKG5, 0); break;
	default: break;
    }

    const Rect max = CastleGetMaxArea(castle, dst_pt);

    if(townbkg.isValid())
	townbkg.Blit(dst_pt.x, dst_pt.y);

    if(Race::BARB == castle.GetRace())
    {
	const Sprite & sprite0 = AGG::GetICN(ICN::TWNBEXT1, 1 + frame % 5);
	sprite0.Blit(dst_pt.x + sprite0.x(), dst_pt.y + sprite0.y());
    }

    // sea anime
    if(Race::WZRD == castle.GetRace() || (!castle.isBuild(BUILD_SHIPYARD) && castle.HaveNearlySea()))
    {
    	Sprite sprite50, sprite51;

    	switch(castle.GetRace())
    	{
    	    case Race::KNGT:
    		sprite50 = AGG::GetICN(ICN::TWNKEXT0, 0);
    		sprite51 = AGG::GetICN(ICN::TWNKEXT0, 1 + frame % 5);
    		break;
    	    case Race::BARB:
    		sprite50 = AGG::GetICN(ICN::TWNBEXT0, 0);
    		sprite51 = AGG::GetICN(ICN::TWNBEXT0, 1 + frame % 5);
    		break;
    	    case Race::SORC:
    		sprite50 = AGG::GetICN(ICN::TWNSEXT0, 0);
    		sprite51 = AGG::GetICN(ICN::TWNSEXT0, 1 + frame % 5);
    		break;
    	    case Race::NECR:
    		sprite50 = AGG::GetICN(ICN::TWNNEXT0, 0);
    		sprite51 = AGG::GetICN(ICN::TWNNEXT0, 1 + frame % 5);
    		break;
    	    case Race::WRLK:
    		sprite50 = AGG::GetICN(ICN::TWNWEXT0, 0);
    		sprite51 = AGG::GetICN(ICN::TWNWEXT0, 1 + frame % 5);
    		break;
    	    case Race::WZRD:
    		sprite50 = AGG::GetICN(ICN::TWNZEXT0, 0);
    		sprite51 = AGG::GetICN(ICN::TWNZEXT0, 1 + frame % 5);
    		break;
    	    default:
    		break;
    	}

	if(sprite50.isValid())
	    CastleDialog::RedrawBuildingSpriteToArea(sprite50, dst_pt.x + sprite50.x(), dst_pt.y + sprite50.y(), max);

	if(sprite51.isValid())
	    CastleDialog::RedrawBuildingSpriteToArea(sprite51, dst_pt.x + sprite51.x(), dst_pt.y + sprite51.y(), max);
    }

    // redraw all builds
    if(BUILD_NOTHING == build)
    {
	for(CastleDialog::CacheBuildings::const_iterator
	    it = orders.begin(); it != orders.end(); ++it)
	{
	    if(castle.isBuild((*it).id))
	    {
		CastleRedrawBuilding(castle, dst_pt, (*it).id, frame, 0);

		if(flash == (*it).id)
		{
		    CastleDialog::RedrawBuildingSpriteToArea((*it).contour,
			dst_pt.x + (*it).contour.x(), dst_pt.y + (*it).contour.y(), max);
		}
		CastleRedrawBuildingExtended(castle, dst_pt, (*it).id, frame);
	    }
	}
    }
    // redraw build with alpha
    else
    if(orders.end() != std::find(orders.begin(), orders.end(), build))
    {
	LocalEvent & le = LocalEvent::Get();
	int alpha = 1;

	while(le.HandleEvents() && alpha < 250)
	{
    	    if(Game::AnimateInfrequentDelay(Game::CASTLE_BUILD_DELAY))
    	    {
    		cursor.Hide();

		for(CastleDialog::CacheBuildings::const_iterator
		    it = orders.begin(); it != orders.end(); ++it)
		{
		    const u32 & build2 = (*it).id;

		    if(castle.isBuild(build2))
		    {
			CastleRedrawBuilding(castle, dst_pt, build2, frame, 0);
			CastleRedrawBuildingExtended(castle, dst_pt, build2, frame);
		    }
		    else
		    if(build2 == build)
		    {
			CastleRedrawBuilding(castle, dst_pt, build2, frame, alpha);
			CastleRedrawTownName(castle, dst_pt);
			alpha += 10;
		    }
		}

		CastleRedrawTownName(castle, dst_pt);

		cursor.Show();
    		display.Flip();
	    }
	    ++frame;
	}

	cursor.Hide();
    }

    ++frame;
}
Ejemplo n.º 10
0
void CastlePackOrdersBuildings(const Castle & castle, std::vector<building_t> & ordersBuildings)
{
    ordersBuildings.reserve(30);

    switch(castle.GetRace())
    {
	case Race::KNGT:
	    ordersBuildings.push_back(BUILD_TENT);
	    ordersBuildings.push_back(BUILD_CASTLE);
	    ordersBuildings.push_back(BUILD_SPEC);
	    ordersBuildings.push_back(BUILD_WEL2);
	    ordersBuildings.push_back(BUILD_CAPTAIN);
	    ordersBuildings.push_back(BUILD_LEFTTURRET);
	    ordersBuildings.push_back(BUILD_RIGHTTURRET);
	    ordersBuildings.push_back(BUILD_MOAT);
	    ordersBuildings.push_back(BUILD_MARKETPLACE);
	    ordersBuildings.push_back(DWELLING_UPGRADE2);
	    ordersBuildings.push_back(DWELLING_MONSTER2);
	    ordersBuildings.push_back(BUILD_THIEVESGUILD);
	    ordersBuildings.push_back(BUILD_TAVERN);
	    ordersBuildings.push_back(BUILD_MAGEGUILD1);
	    ordersBuildings.push_back(BUILD_MAGEGUILD2);
	    ordersBuildings.push_back(BUILD_MAGEGUILD3);
	    ordersBuildings.push_back(BUILD_MAGEGUILD4);
	    ordersBuildings.push_back(BUILD_MAGEGUILD5);
	    ordersBuildings.push_back(DWELLING_UPGRADE5);
	    ordersBuildings.push_back(DWELLING_MONSTER5);
	    ordersBuildings.push_back(DWELLING_UPGRADE6);
	    ordersBuildings.push_back(DWELLING_MONSTER6);
	    ordersBuildings.push_back(DWELLING_MONSTER1);
	    ordersBuildings.push_back(DWELLING_UPGRADE3);
	    ordersBuildings.push_back(DWELLING_MONSTER3);
	    ordersBuildings.push_back(DWELLING_UPGRADE4);
	    ordersBuildings.push_back(DWELLING_MONSTER4);
	    ordersBuildings.push_back(BUILD_WELL);
	    ordersBuildings.push_back(BUILD_STATUE);
	    ordersBuildings.push_back(BUILD_SHIPYARD);
	    break;
	case Race::BARB:
	    ordersBuildings.push_back(BUILD_SPEC);
	    ordersBuildings.push_back(BUILD_WEL2);
	    ordersBuildings.push_back(DWELLING_MONSTER6);
	    ordersBuildings.push_back(BUILD_MAGEGUILD1);
	    ordersBuildings.push_back(BUILD_MAGEGUILD2);
	    ordersBuildings.push_back(BUILD_MAGEGUILD3);
	    ordersBuildings.push_back(BUILD_MAGEGUILD4);
	    ordersBuildings.push_back(BUILD_MAGEGUILD5);
	    ordersBuildings.push_back(BUILD_CAPTAIN);
	    ordersBuildings.push_back(BUILD_TENT);
	    ordersBuildings.push_back(BUILD_CASTLE);
	    ordersBuildings.push_back(BUILD_LEFTTURRET);
	    ordersBuildings.push_back(BUILD_RIGHTTURRET);
	    ordersBuildings.push_back(BUILD_MOAT);
	    ordersBuildings.push_back(DWELLING_MONSTER3);
	    ordersBuildings.push_back(BUILD_THIEVESGUILD);
	    ordersBuildings.push_back(BUILD_TAVERN);
	    ordersBuildings.push_back(DWELLING_MONSTER1);
	    ordersBuildings.push_back(BUILD_MARKETPLACE);
	    ordersBuildings.push_back(DWELLING_UPGRADE2);
	    ordersBuildings.push_back(DWELLING_MONSTER2);
	    ordersBuildings.push_back(DWELLING_UPGRADE4);
	    ordersBuildings.push_back(DWELLING_MONSTER4);
	    ordersBuildings.push_back(DWELLING_UPGRADE5);
	    ordersBuildings.push_back(DWELLING_MONSTER5);
	    ordersBuildings.push_back(BUILD_WELL);
	    ordersBuildings.push_back(BUILD_STATUE);
	    ordersBuildings.push_back(BUILD_SHIPYARD);
	    break;
	case Race::SORC:
	    ordersBuildings.push_back(BUILD_SPEC);
	    ordersBuildings.push_back(DWELLING_MONSTER6);
	    ordersBuildings.push_back(BUILD_MAGEGUILD1);
	    ordersBuildings.push_back(BUILD_MAGEGUILD2);
	    ordersBuildings.push_back(BUILD_MAGEGUILD3);
	    ordersBuildings.push_back(BUILD_MAGEGUILD4);
	    ordersBuildings.push_back(BUILD_MAGEGUILD5);
	    ordersBuildings.push_back(BUILD_CAPTAIN);
	    ordersBuildings.push_back(BUILD_TENT);
	    ordersBuildings.push_back(BUILD_CASTLE);
	    ordersBuildings.push_back(BUILD_LEFTTURRET);
	    ordersBuildings.push_back(BUILD_RIGHTTURRET);
	    ordersBuildings.push_back(BUILD_MOAT);
	    ordersBuildings.push_back(DWELLING_UPGRADE3);
	    ordersBuildings.push_back(DWELLING_MONSTER3);
	    ordersBuildings.push_back(BUILD_SHIPYARD);
	    ordersBuildings.push_back(BUILD_MARKETPLACE);
	    ordersBuildings.push_back(DWELLING_UPGRADE2);
	    ordersBuildings.push_back(DWELLING_MONSTER2);
	    ordersBuildings.push_back(BUILD_THIEVESGUILD);
	    ordersBuildings.push_back(DWELLING_MONSTER1);
	    ordersBuildings.push_back(BUILD_TAVERN);
	    ordersBuildings.push_back(BUILD_STATUE);
	    ordersBuildings.push_back(BUILD_WEL2);
	    ordersBuildings.push_back(DWELLING_UPGRADE4);
	    ordersBuildings.push_back(DWELLING_MONSTER4);
	    ordersBuildings.push_back(BUILD_WELL);
	    ordersBuildings.push_back(DWELLING_MONSTER5);
	    break;
	case Race::WRLK:
	    ordersBuildings.push_back(DWELLING_MONSTER5);
	    ordersBuildings.push_back(DWELLING_MONSTER3);
	    ordersBuildings.push_back(BUILD_TENT);
	    ordersBuildings.push_back(BUILD_CASTLE);
	    ordersBuildings.push_back(BUILD_LEFTTURRET);
	    ordersBuildings.push_back(BUILD_RIGHTTURRET);
	    ordersBuildings.push_back(BUILD_CAPTAIN);
	    ordersBuildings.push_back(BUILD_MOAT);
	    ordersBuildings.push_back(BUILD_SHIPYARD);
	    ordersBuildings.push_back(BUILD_MAGEGUILD1);
	    ordersBuildings.push_back(BUILD_MAGEGUILD2);
	    ordersBuildings.push_back(BUILD_MAGEGUILD3);
	    ordersBuildings.push_back(BUILD_MAGEGUILD4);
	    ordersBuildings.push_back(BUILD_MAGEGUILD5);
	    ordersBuildings.push_back(BUILD_TAVERN);
	    ordersBuildings.push_back(BUILD_THIEVESGUILD);
	    ordersBuildings.push_back(BUILD_MARKETPLACE);
	    ordersBuildings.push_back(BUILD_STATUE);
	    ordersBuildings.push_back(DWELLING_MONSTER1);
	    ordersBuildings.push_back(BUILD_WEL2);
	    ordersBuildings.push_back(BUILD_SPEC);
	    ordersBuildings.push_back(DWELLING_UPGRADE4);
	    ordersBuildings.push_back(DWELLING_MONSTER4);
	    ordersBuildings.push_back(DWELLING_MONSTER2);
	    ordersBuildings.push_back(DWELLING_UPGRADE7);
	    ordersBuildings.push_back(DWELLING_UPGRADE6);
	    ordersBuildings.push_back(DWELLING_MONSTER6);
	    ordersBuildings.push_back(BUILD_WELL);
	    break;
	case Race::WZRD:
	    ordersBuildings.push_back(DWELLING_UPGRADE6);
	    ordersBuildings.push_back(DWELLING_MONSTER6);
	    ordersBuildings.push_back(BUILD_TENT);
	    ordersBuildings.push_back(BUILD_CASTLE);
	    ordersBuildings.push_back(BUILD_LEFTTURRET);
	    ordersBuildings.push_back(BUILD_RIGHTTURRET);
	    ordersBuildings.push_back(BUILD_MOAT);
	    ordersBuildings.push_back(BUILD_CAPTAIN);
	    ordersBuildings.push_back(DWELLING_MONSTER2);
	    ordersBuildings.push_back(BUILD_THIEVESGUILD);
	    ordersBuildings.push_back(BUILD_TAVERN);
	    ordersBuildings.push_back(BUILD_SHIPYARD);
	    ordersBuildings.push_back(BUILD_WELL);
	    ordersBuildings.push_back(BUILD_SPEC);
	    ordersBuildings.push_back(DWELLING_UPGRADE3);
	    ordersBuildings.push_back(DWELLING_MONSTER3);
	    ordersBuildings.push_back(DWELLING_UPGRADE5);
	    ordersBuildings.push_back(DWELLING_MONSTER5);
	    ordersBuildings.push_back(BUILD_MAGEGUILD1);
	    ordersBuildings.push_back(BUILD_MAGEGUILD2);
	    ordersBuildings.push_back(BUILD_MAGEGUILD3);
	    ordersBuildings.push_back(BUILD_MAGEGUILD4);
	    ordersBuildings.push_back(BUILD_MAGEGUILD5);
	    ordersBuildings.push_back(BUILD_STATUE);
	    ordersBuildings.push_back(DWELLING_MONSTER1);
	    ordersBuildings.push_back(DWELLING_MONSTER4);
	    ordersBuildings.push_back(BUILD_MARKETPLACE);
	    ordersBuildings.push_back(BUILD_WEL2);
	    break;
	case Race::NECR:
	    ordersBuildings.push_back(BUILD_SPEC);
	    if(Settings::Get().PriceLoyaltyVersion())
		ordersBuildings.push_back(BUILD_SHRINE);
	    ordersBuildings.push_back(BUILD_TENT);
	    ordersBuildings.push_back(BUILD_CASTLE);
	    ordersBuildings.push_back(BUILD_CAPTAIN);
	    ordersBuildings.push_back(BUILD_LEFTTURRET);
	    ordersBuildings.push_back(BUILD_RIGHTTURRET);
	    ordersBuildings.push_back(DWELLING_MONSTER6);
	    ordersBuildings.push_back(BUILD_MOAT);
	    ordersBuildings.push_back(DWELLING_MONSTER1);
	    ordersBuildings.push_back(BUILD_THIEVESGUILD);
	    ordersBuildings.push_back(DWELLING_UPGRADE3);
	    ordersBuildings.push_back(DWELLING_MONSTER3);
	    ordersBuildings.push_back(DWELLING_UPGRADE5);
	    ordersBuildings.push_back(DWELLING_MONSTER5);
	    ordersBuildings.push_back(DWELLING_UPGRADE2);
	    ordersBuildings.push_back(DWELLING_MONSTER2);
	    ordersBuildings.push_back(DWELLING_UPGRADE4);
	    ordersBuildings.push_back(DWELLING_MONSTER4);
	    ordersBuildings.push_back(BUILD_MAGEGUILD1);
	    ordersBuildings.push_back(BUILD_MAGEGUILD2);
	    ordersBuildings.push_back(BUILD_MAGEGUILD3);
	    ordersBuildings.push_back(BUILD_MAGEGUILD4);
	    ordersBuildings.push_back(BUILD_MAGEGUILD5);
	    ordersBuildings.push_back(BUILD_SHIPYARD);
	    ordersBuildings.push_back(BUILD_WEL2);
	    ordersBuildings.push_back(BUILD_MARKETPLACE);
	    ordersBuildings.push_back(BUILD_STATUE);
	    ordersBuildings.push_back(BUILD_WELL);
	    break;
	default: break;
    }

    ordersBuildings.push_back(BUILD_NOTHING);
}
Ejemplo n.º 11
0
void AICastleDevelopment(Castle & c)
{
    const Kingdom & kingdom = c.GetKingdom();

    if(c.isCastle())
    {
	// build for capital or large golds
	if(c.isCapital() || kingdom.GetFunds().Get(Resource::GOLD) > 8000)
	{
	    if(!c.isBuild(BUILD_STATUE))
		c.BuyBuilding(BUILD_STATUE);

	    if(!c.isBuild(BUILD_SPEC) && Race::WRLK == c.GetRace())
		c.BuyBuilding(BUILD_SPEC);

	    if(!c.isBuild(BUILD_TAVERN) && Race::KNGT == c.GetRace())
		c.BuyBuilding(BUILD_TAVERN);

	    if(!c.isBuild(BUILD_MAGEGUILD1) && ((Race::SORC | Race::WZRD | Race::WRLK | Race::NECR) & c.GetRace()))
		c.BuyBuilding(BUILD_MAGEGUILD1);

	    if(!c.isBuild(BUILD_WELL))
		c.BuyBuilding(BUILD_WELL);


	    if(!c.isBuild(DWELLING_MONSTER1))
		c.BuyBuilding(DWELLING_MONSTER1);

	    if(!c.isBuild(DWELLING_MONSTER2))
		c.BuyBuilding(DWELLING_MONSTER2);

	    if(!c.isBuild(DWELLING_MONSTER3))
		c.BuyBuilding(DWELLING_MONSTER3);

	    if(!c.isBuild(DWELLING_MONSTER4))
		c.BuyBuilding(DWELLING_MONSTER4);


	    if(!c.isBuild(BUILD_THIEVESGUILD) && ((Race::NECR) & c.GetRace()))
		c.BuyBuilding(BUILD_THIEVESGUILD);

	    if(!c.isBuild(BUILD_MARKETPLACE))
		c.BuyBuilding(BUILD_MARKETPLACE);

	    if(!c.isBuild(BUILD_MAGEGUILD1))
		c.BuyBuilding(BUILD_MAGEGUILD1);

	    if(!c.isBuild(BUILD_MAGEGUILD2) && ((Race::SORC | Race::WZRD | Race::WRLK | Race::NECR) & c.GetRace()))
		c.BuyBuilding(BUILD_MAGEGUILD2);

	    if(!c.isBuild(DWELLING_UPGRADE2))
		c.BuyBuilding(DWELLING_UPGRADE2);

	    if(!c.isBuild(DWELLING_UPGRADE3))
		c.BuyBuilding(DWELLING_UPGRADE3);

	    if(!c.isBuild(DWELLING_UPGRADE4))
		c.BuyBuilding(DWELLING_UPGRADE4);

	    if(!c.isBuild(BUILD_LEFTTURRET))
		c.BuyBuilding(BUILD_LEFTTURRET);

	    if(!c.isBuild(BUILD_RIGHTTURRET))
		c.BuyBuilding(BUILD_RIGHTTURRET);

	    if(!c.isBuild(BUILD_MOAT))
		c.BuyBuilding(BUILD_MOAT);

	    if(!c.isBuild(BUILD_CAPTAIN))
		c.BuyBuilding(BUILD_CAPTAIN);


	    if(!c.isBuild(BUILD_MAGEGUILD2))
		c.BuyBuilding(BUILD_MAGEGUILD2);

	    if(!c.isBuild(DWELLING_MONSTER5))
		c.BuyBuilding(DWELLING_MONSTER5);

	    if(!c.isBuild(DWELLING_MONSTER6))
		c.BuyBuilding(DWELLING_MONSTER6);

	    if(!c.isBuild(BUILD_MAGEGUILD3))
		c.BuyBuilding(BUILD_MAGEGUILD3);

	    if(!c.isBuild(DWELLING_UPGRADE5))
		c.BuyBuilding(DWELLING_UPGRADE5);

	    if(!c.isBuild(DWELLING_UPGRADE6))
		c.BuyBuilding(DWELLING_UPGRADE6);
	}
    }
    else
    {
	// build castle only monday or tuesday or for capital
	if(c.isCapital() || 3 > world.GetDay()) c.BuyBuilding(BUILD_CASTLE);
    }

    // last day and buy monster
    if(world.LastDay()) c.RecruitAllMonster();
}
Ejemplo n.º 12
0
void Dialog::QuickInfo(const Castle & castle)
{
    Display & display = Display::Get();

    Cursor & cursor = Cursor::Get();
    cursor.Hide();

    const ICN::icn_t qwiktown = ICN::QWIKTOWN;
    AGG::PreloadObject(qwiktown);

    // image box
    const Sprite &box = AGG::GetICN(qwiktown, 0);
    const Interface::GameArea & gamearea = Interface::GameArea::Get();
    const Rect ar(BORDERWIDTH, BORDERWIDTH, gamearea.GetArea().w, gamearea.GetArea().h);

    LocalEvent & le = LocalEvent::Get();
    const Point & mp = le.GetMouseCursor();
    
    Rect cur_rt; 
    u16 mx = (mp.x - BORDERWIDTH) / TILEWIDTH;
    mx *= TILEWIDTH;
    u16 my = (mp.y - BORDERWIDTH) / TILEWIDTH;
    my *= TILEWIDTH;

    // top left
    if(mx <= ar.x + ar.w / 2 && my <= ar.y + ar.h / 2)
	cur_rt = Rect(mx + TILEWIDTH, my + TILEWIDTH, box.w(), box.h());
    else
    // top right
    if(mx > ar.x + ar.w / 2 && my <= ar.y + ar.h / 2)
	cur_rt = Rect(mx - box.w(), my + TILEWIDTH, box.w(), box.h());
    else
    // bottom left
    if(mx <= ar.x + ar.w / 2 && my > ar.y + ar.h / 2)
	cur_rt = Rect(mx + TILEWIDTH, my - box.h(), box.w(), box.h());
    else
    // bottom right
	cur_rt = Rect(mx - box.w(), my - box.h(), box.w(), box.h());

    if(Settings::Get().QVGA())
    {
	cur_rt = Rect((display.w() - box.w()) / 2, (display.h() - box.h()) / 2, box.w(), box.h());
    }

    Background back(cur_rt);
    back.Save();
    display.Blit(box, cur_rt.x, cur_rt.y);

    cur_rt = Rect(back.GetRect().x + 28 , back.GetRect().y + 12, 178, 140);
    Point dst_pt;
    Text text;

    // castle name
    text.Set(castle.GetName(), Font::SMALL);
    dst_pt.x = cur_rt.x + (cur_rt.w - text.w()) / 2;
    dst_pt.y = cur_rt.y + 5;
    text.Blit(dst_pt);

    u8 index = 0;

    switch(castle.GetRace())
    {
	case Race::KNGT: index = (castle.isCastle() ?  9 : 15); break;
	case Race::BARB: index = (castle.isCastle() ? 10 : 16); break;
	case Race::SORC: index = (castle.isCastle() ? 11 : 17); break;
	case Race::WRLK: index = (castle.isCastle() ? 12 : 18); break;
	case Race::WZRD: index = (castle.isCastle() ? 13 : 19); break;
	case Race::NECR: index = (castle.isCastle() ? 14 : 20); break;
	default: DEBUG(DBG_GAME , DBG_WARN, "Dialog::QuickInfo: unknown race."); return;
    }
    
    // castle icon
    const Sprite & sprite = AGG::GetICN(ICN::LOCATORS, index);

    dst_pt.x = cur_rt.x + (cur_rt.w - sprite.w()) / 2;
    dst_pt.y += 18;
    display.Blit(sprite, dst_pt);

    // color flags
    switch(castle.GetColor())
    {
	case Color::BLUE:	index = 0; break;
	case Color::GREEN:	index = 2; break;
	case Color::RED:	index = 4; break;
	case Color::YELLOW:	index = 6; break;
	case Color::ORANGE:	index = 8; break;
	case Color::PURPLE:	index = 10; break;
	case Color::GRAY:	index = 12; break;
    }

    const Sprite & l_flag = AGG::GetICN(ICN::FLAG32, index);
    dst_pt.x = cur_rt.x + (cur_rt.w - 60) / 2 - l_flag.w();
    display.Blit(l_flag, dst_pt);

    const Sprite & r_flag = AGG::GetICN(ICN::FLAG32, index + 1);
    dst_pt.x = cur_rt.x + (cur_rt.w + 60) / 2;
    display.Blit(r_flag, dst_pt);

    // info
    text.Set(_("Defenders:"));
    dst_pt.x = cur_rt.x + (cur_rt.w - text.w()) / 2;
    dst_pt.y += sprite.h() + 5;
    text.Blit(dst_pt);

    u8 count = castle.GetArmy().GetCount();

    if(! count)
    {
	text.Set(_("None"));
	dst_pt.x = cur_rt.x + (cur_rt.w - text.w()) / 2;
	dst_pt.y += 45;
	text.Blit(dst_pt);
    }
    else
	castle.GetArmy().DrawMons32Line(cur_rt.x - 5, cur_rt.y + 100, 192, 0, 0, (Settings::Get().MyColor() != castle.GetColor()));

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

    // quick info loop
    while(le.HandleEvents() && le.MousePressRight());

    // restore background
    cursor.Hide();
    back.Restore();
    cursor.Show();
    display.Flip();
}
Ejemplo n.º 13
0
Captain::Captain(Castle & cstl) : HeroBase(Skill::Primary::CAPTAIN, cstl.GetRace()), home(cstl)
{
    SetCenter(home.GetCenter());
}