Skip to content

Commit 1496155

Browse files
committed
Use Point and Vector string conversion operators in MapViewState
1 parent 2b3a19b commit 1496155

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

appOPHD/States/MapViewState.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,19 @@ namespace
130130

131131
void pushAgingRobotMessage(const Robot* robot, const MapCoordinate& position, NotificationArea& notificationArea)
132132
{
133-
const auto robotLocationText = "(" + std::to_string(position.xy.x) + ", " + std::to_string(position.xy.y) + ")";
134-
135133
if (robot->fuelCellAge() == 190) // FIXME: magic number
136134
{
137135
notificationArea.push({
138136
"Aging Robot",
139-
"Robot '" + robot->name() + "' at location " + robotLocationText + " is approaching its maximum age.",
137+
"Robot '" + robot->name() + "' at location " + std::string{position.xy} + " is approaching its maximum age.",
140138
position,
141139
NotificationArea::NotificationType::Warning});
142140
}
143141
else if (robot->fuelCellAge() == 195) // FIXME: magic number
144142
{
145143
notificationArea.push({
146144
"Aging Robot",
147-
"Robot '" + robot->name() + "' at location " + robotLocationText + " will fail in a few turns. Replace immediately.",
145+
"Robot '" + robot->name() + "' at location " + std::string{position.xy} + " will fail in a few turns. Replace immediately.",
148146
position,
149147
NotificationArea::NotificationType::Critical});
150148
}
@@ -1115,7 +1113,7 @@ void MapViewState::placeRobodigger(Tile& tile)
11151113
const auto position = tile.xy();
11161114
mNotificationArea.push({
11171115
"Mine destroyed",
1118-
"Digger destroyed a Mine at (" + std::to_string(position.x) + ", " + std::to_string(position.y) + ").",
1116+
"Digger destroyed a Mine at " + std::string{position} + ".",
11191117
tile.xyz(),
11201118
NotificationArea::NotificationType::Information});
11211119
mTileMap->removeMineLocation(position);
@@ -1293,20 +1291,18 @@ void MapViewState::updateRobots()
12931291

12941292
if (robot->isDead())
12951293
{
1296-
const auto robotLocationText = "(" + std::to_string(position.xy.x) + ", " + std::to_string(position.xy.y) + ")";
1297-
12981294
if (robot->selfDestruct())
12991295
{
13001296
mNotificationArea.push({
13011297
"Robot Self-Destructed",
1302-
robot->name() + " at location " + robotLocationText + " self destructed.",
1298+
robot->name() + " at location " + std::string{position.xy} + " self destructed.",
13031299
position,
13041300
NotificationArea::NotificationType::Critical
13051301
});
13061302
}
13071303
else if (robot->type() != Robot::Type::Miner)
13081304
{
1309-
const auto text = "Your " + robot->name() + " at location " + robotLocationText + " has broken down. It will not be able to complete its task and will be removed from your inventory.";
1305+
const auto text = "Your " + robot->name() + " at location " + std::string{position.xy} + " has broken down. It will not be able to complete its task and will be removed from your inventory.";
13101306
mNotificationArea.push({"Robot Broke Down", text, position, NotificationArea::NotificationType::Critical});
13111307
robot->abortTask(*tile);
13121308
}
@@ -1329,7 +1325,7 @@ void MapViewState::updateRobots()
13291325

13301326
mNotificationArea.push({
13311327
"Robot Task Completed",
1332-
robot->name() + " completed its task at (" + std::to_string(tile->xy().x) + ", " + std::to_string(tile->xy().y) + ").",
1328+
robot->name() + " completed its task at " + std::string{tile->xy()} + ".",
13331329
tile->xyz(),
13341330
NotificationArea::NotificationType::Success
13351331
});
@@ -1344,7 +1340,7 @@ void MapViewState::updateRobots()
13441340

13451341
mNotificationArea.push({
13461342
"Robot Task Canceled",
1347-
robot->name() + " canceled its task at (" + std::to_string(tile->xy().x) + ", " + std::to_string(tile->xy().y) + ").",
1343+
robot->name() + " canceled its task at " + std::string{tile->xy()} + ".",
13481344
tile->xyz(),
13491345
NotificationArea::NotificationType::Information
13501346
});

0 commit comments

Comments
 (0)