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; }
/// 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; }
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; } }
/// 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; }
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); }
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); }
void SetFlag::Execute(GameWorldGame& gwg, GamePlayer& /*player*/, const unsigned char playerId) { gwg.SetFlag(pt_, playerId); }
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(); }
void UpgradeRoad::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.UpgradeRoad(x,y,start_dir); }
void AcceptPact::Execute(GameWorldGame& gwg, GamePlayer& player, const unsigned char playerId) { gwg.GetPlayer(fromPlayer).AcceptPact(id, pt, playerId); }
/// 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); }
void SetBuildingSite::Execute(GameWorldGame& gwg, GamePlayer& /*player*/, const unsigned char playerId) { gwg.SetBuildingSite(bt, pt_, playerId); }
void DestroyFlag::Execute(GameWorldGame& gwg, GamePlayer& /*player*/, const unsigned char /*playerId*/) { gwg.DestroyFlag(pt_); }
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(); }
void BuildRoad::Execute(GameWorldGame& gwg, GamePlayer& /*player*/, const unsigned char playerId) { gwg.BuildRoad(playerId, boat_road, pt_, route); }
void CallScout::Execute(GameWorldGame& gwg, GamePlayer& player, const unsigned char /*playerId*/) { if(gwg.GetNO(pt_)->GetGOT() == GOT_FLAG) player.CallFlagWorker(pt_, JOB_SCOUT); }
void DestroyBuilding::Execute(GameWorldGame& gwg, GamePlayer& /*player*/, const unsigned char playerId) { gwg.DestroyBuilding(pt_, playerId); }
void CheatArmageddon::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.Armageddon(); }
void DestroyFlag::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.DestroyFlag(x,y); }
void DestroyAll::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.Armageddon(playerid); }
void UpgradeRoad::Execute(GameWorldGame& gwg, GamePlayer& /*player*/, const unsigned char /*playerId*/) { gwg.UpgradeRoad(pt_, start_dir); }
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(); }
void SetBuildingSite::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.SetBuildingSite(bt,x,y,playerid); }
void SetFlag::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.SetFlag(x,y,playerid); }
void DestroyBuilding::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.DestroyBuilding(x,y,playerid); }
void BuildRoad::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.BuildRoad(playerid,boat_road,x,y,route); }
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); }
void SeaAttack::Execute(GameWorldGame& gwg, GameClientPlayer& player, const unsigned char playerid) { gwg.AttackViaSea(playerid,x,y,soldiers_count,strong_soldiers); }
void DestroyAll::Execute(GameWorldGame& gwg, GamePlayer& /*player*/, const unsigned char playerId) { gwg.Armageddon(playerId); }