예제 #1
0
void StopGold::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	if(gwg.GetNO(x,y)->GetGOT() == GOT_NOB_MILITARY)
	{
		if(gwg.GetSpecObj<nobMilitary>(x,y)->GetPlayer() == playerid)
			gwg.GetSpecObj<nobMilitary>(x,y)->StopGold();
	}
}
bool CreateSeaWorld::operator()(GameWorldGame& world) const
{
    // For consistent results
    initGameRNG(0);

    loadGameData(world.GetDescriptionWriteable());
    world.Init(size_);
    // Set everything to water
    DescIdx<TerrainDesc> t(0);
    const WorldDescription& desc = world.GetDescription();
    for(; t.value < desc.terrain.size(); t.value++)
    {
        if(desc.get(t).Is(ETerrain::Shippable) && desc.get(t).kind == TerrainKind::WATER) //-V807
            break;
    }
    RTTR_FOREACH_PT(MapPoint, size_)
    {
        MapNode& node = world.GetNodeWriteable(pt);
        node.t1 = node.t2 = t;
    }
예제 #3
0
/// Check if we can walk on the point if it is completely covered in terrain
boost::test_tools::predicate_result checkWalkOnPoint(GameWorldGame& world, const MapPoint& startPt, const MapPoint& targetPt,
    Direction dir, TerrainType t)
{
    // Block whole point
    const MapPoint nextPt = world.GetNeighbour(startPt, dir);
    for(unsigned i=0; i<6; i++)
        SetRightTerrain(world, nextPt, Direction::fromInt(i), t);
    if(world.FindHumanPath(startPt, targetPt) != INVALID_DIR)
    {
        boost::test_tools::predicate_result result(false);
        result.message() << "Failed for fwd direction";
        return result;
    }
    if(world.FindHumanPath(targetPt, startPt) != INVALID_DIR)
    {
        boost::test_tools::predicate_result result(false);
        result.message() << "Failed for bwd direction";
        return result;
    }
    for(unsigned i = 0; i < 6; i++)
        SetRightTerrain(world, nextPt, Direction::fromInt(i), TT_STEPPE);
    return true;
}
예제 #4
0
void SetRightTerrain(GameWorldGame& world, const MapPoint& pt, Direction dir, TerrainType t)
{
    switch(Direction::Type(dir))
    {
    case Direction::WEST:
        world.GetNodeWriteable(world.GetNeighbour(pt, Direction::NORTHWEST)).t1 = t;
        break;
    case Direction::NORTHWEST:
        world.GetNodeWriteable(world.GetNeighbour(pt, Direction::NORTHWEST)).t2 = t;
        break;
    case Direction::NORTHEAST:
        world.GetNodeWriteable(world.GetNeighbour(pt, Direction::NORTHEAST)).t1 = t;
        break;
    case Direction::EAST:
        world.GetNodeWriteable(pt).t2 = t;
        break;
    case Direction::SOUTHEAST:
        world.GetNodeWriteable(pt).t1 = t;
        break;
    case Direction::SOUTHWEST:
        world.GetNodeWriteable(world.GetNeighbour(pt, Direction::WEST)).t2 = t;
        break;
    }
}
예제 #5
0
/// Check if we can walk if on of the 2 or both surrounding terrains is changed
boost::test_tools::predicate_result checkWalkOnTerrain(GameWorldGame& world, const MapPoint& startPt, const MapPoint& targetPt,
    Direction dir, TerrainType t, bool isWalkable)
{
    // Block either side
    SetRightTerrain(world, startPt, dir, t);
    if((world.FindHumanPath(startPt, targetPt) != INVALID_DIR) != isWalkable)
    {
        boost::test_tools::predicate_result result(false);
        result.message() << "Failed for right terrain";
        return result;
    }
    if((world.FindHumanPath(targetPt, startPt) != INVALID_DIR) != isWalkable)
    {
        boost::test_tools::predicate_result result(false);
        result.message() << "Failed for right terrain2";
        return result;
    }
    SetRightTerrain(world, startPt, dir, TT_STEPPE);
    SetLeftTerrain(world, startPt, dir, t);
    if((world.FindHumanPath(startPt, targetPt) != INVALID_DIR) != isWalkable)
    {
        boost::test_tools::predicate_result result(false);
        result.message() << "Failed for left terrain";
        return result;
    }
    if((world.FindHumanPath(targetPt, startPt) != INVALID_DIR) != isWalkable)
    {
        boost::test_tools::predicate_result result(false);
        result.message() << "Failed for left terrain2";
        return result;
    }
    SetRightTerrain(world, startPt, dir, t);
    if((world.FindHumanPath(startPt, targetPt) != INVALID_DIR) != isWalkable)
    {
        boost::test_tools::predicate_result result(false);
        result.message() << "Failed for both terrain";
        return result;
    }
    if((world.FindHumanPath(targetPt, startPt) != INVALID_DIR) != isWalkable)
    {
        boost::test_tools::predicate_result result(false);
        result.message() << "Failed for both terrain2";
        return result;
    }
    SetRightTerrain(world, startPt, dir, TT_STEPPE);
    SetLeftTerrain(world, startPt, dir, TT_STEPPE);
    return true;
}
예제 #6
0
void ChangeAllInventorySettings::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	if(gwg.GetNO(x,y)->GetType() == NOP_BUILDING)
		gwg.GetSpecObj<nobBaseWarehouse>(x,y)
		->ChangeAllRealInventorySettings(category,state);
}
예제 #7
0
void ChangeReserve::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	if(gwg.GetNO(x,y)->GetType() == NOP_BUILDING)
		gwg.GetSpecObj<nobBaseWarehouse>(x,y)->SetRealReserve(rank,count);
	
}
예제 #8
0
 void SetFlag::Execute(GameWorldGame& gwg, GamePlayer&  /*player*/, const unsigned char playerId)
 {
     gwg.SetFlag(pt_, playerId);
 }
예제 #9
0
void StopProduction::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	if(gwg.GetNO(x,y)->GetGOT() == GOT_NOB_USUAL || gwg.GetNO(x,y)->GetGOT() == GOT_NOB_SHIPYARD)
		gwg.GetSpecObj<nobUsual>(x,y)->StopProduction();
}
예제 #10
0
void UpgradeRoad::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	gwg.UpgradeRoad(x,y,start_dir);
}
예제 #11
0
 void AcceptPact::Execute(GameWorldGame& gwg, GamePlayer&  player, const unsigned char playerId)
 {
     gwg.GetPlayer(fromPlayer).AcceptPact(id, pt, playerId);
 }
예제 #12
0
/// Fuehrt das GameCommand aus
void TradeOverLand::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	noBase * nob = gwg.GetNO(x,y);
	if(nob->GetGOT() == GOT_NOB_HARBORBUILDING || nob->GetGOT() == GOT_NOB_HQ || nob->GetGOT() == GOT_NOB_STOREHOUSE)
		player.Trade(static_cast<nobBaseWarehouse*>(nob),gt,job,count);
}
예제 #13
0
 void SetBuildingSite::Execute(GameWorldGame& gwg, GamePlayer&  /*player*/, const unsigned char playerId)
 {
     gwg.SetBuildingSite(bt, pt_, playerId);
 }
예제 #14
0
 void DestroyFlag::Execute(GameWorldGame& gwg, GamePlayer&  /*player*/, const unsigned char  /*playerId*/)
 {
     gwg.DestroyFlag(pt_);
 }
예제 #15
0
void ChangeShipYardMode::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	if(gwg.GetNO(x,y)->GetGOT() == GOT_NOB_SHIPYARD)
		gwg.GetSpecObj<nobShipYard>(x,y)->ToggleMode();
}
예제 #16
0
 void BuildRoad::Execute(GameWorldGame& gwg, GamePlayer&  /*player*/, const unsigned char playerId)
 {
     gwg.BuildRoad(playerId, boat_road, pt_, route);
 }
예제 #17
0
 void CallScout::Execute(GameWorldGame& gwg, GamePlayer& player, const unsigned char  /*playerId*/)
 {
     if(gwg.GetNO(pt_)->GetGOT() == GOT_FLAG)
         player.CallFlagWorker(pt_, JOB_SCOUT);
 }
예제 #18
0
 void DestroyBuilding::Execute(GameWorldGame& gwg, GamePlayer&  /*player*/, const unsigned char playerId)
 {
     gwg.DestroyBuilding(pt_, playerId);
 }
예제 #19
0
void CheatArmageddon::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	gwg.Armageddon();
}
예제 #20
0
void DestroyFlag::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	gwg.DestroyFlag(x,y);
}
예제 #21
0
void DestroyAll::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	 gwg.Armageddon(playerid);
}
예제 #22
0
 void UpgradeRoad::Execute(GameWorldGame& gwg, GamePlayer&  /*player*/, const unsigned char  /*playerId*/)
 {
     gwg.UpgradeRoad(pt_, start_dir);
 }
예제 #23
0
void StartExplorationExpedition::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	if(gwg.GetNO(x,y)->GetGOT() == GOT_NOB_HARBORBUILDING)
		gwg.GetSpecObj<nobHarborBuilding>(x,y)->StartExplorationExpedition();
}
예제 #24
0
void SetBuildingSite::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	gwg.SetBuildingSite(bt,x,y,playerid);
}
예제 #25
0
void SetFlag::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	gwg.SetFlag(x,y,playerid);
}
예제 #26
0
void DestroyBuilding::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	gwg.DestroyBuilding(x,y,playerid);
}
예제 #27
0
void BuildRoad::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	gwg.BuildRoad(playerid,boat_road,x,y,route);
}
예제 #28
0
void CallScout::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	if(gwg.GetNO(x,y)->GetGOT() == GOT_FLAG)
		player.CallFlagWorker(x,y,JOB_SCOUT);
}
예제 #29
0
void SeaAttack::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid)
{
	gwg.AttackViaSea(playerid,x,y,soldiers_count,strong_soldiers);
}
예제 #30
0
 void DestroyAll::Execute(GameWorldGame& gwg, GamePlayer&  /*player*/, const unsigned char playerId)
 {
     gwg.Armageddon(playerId);
 }