Skip to content

Commit

Permalink
Refactor Video Game (#586)
Browse files Browse the repository at this point in the history
* Add VideoGameData draft

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add rest of data to VideoGame

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Fix helper usage for video game

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* avoid circular include

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* build missing videogame data

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Add namespace for videogame

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Use video game namespace for testing

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* fix genres conflict

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Use explicit namespace

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* use separated name for video game genres

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Revert "fix genres conflict"

This reverts commit bac4da6.

---------

Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed May 25, 2024
1 parent 3bb1d7a commit 7b92d63
Show file tree
Hide file tree
Showing 9 changed files with 3,000 additions and 3,000 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ set(FAKER_SOURCES
src/modules/system/System.cpp
src/modules/vehicle/Vehicle.cpp
src/modules/videoGame/VideoGame.cpp
src/modules/videoGame/VideoGameData.cpp
src/modules/weather/Weather.cpp
src/modules/word/Word.cpp
src/common/FormatHelper.cpp
Expand Down
10 changes: 5 additions & 5 deletions include/faker-cxx/VideoGame.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <string>
#include <string_view>

namespace faker
{
Expand All @@ -16,7 +16,7 @@ class VideoGame
* VideoGame::gameTitle() // "Rayman Arena"
* @endcode
*/
static std::string gameTitle();
static std::string_view gameTitle();

/**
* @brief Returns a random video game genre.
Expand All @@ -27,7 +27,7 @@ class VideoGame
* VideoGame::genre() // "Platformer"
* @endcode
*/
static std::string genre();
static std::string_view genre();

/**
* @brief Returns a random video game platform.
Expand All @@ -38,7 +38,7 @@ class VideoGame
* VideoGame::platform() // "Playstation 5"
* @endcode
*/
static std::string platform();
static std::string_view platform();

/**
* @brief Returns a random video game studio name.
Expand All @@ -49,6 +49,6 @@ class VideoGame
* VideoGame::studioName() // "Activision Blizzard"
* @endcode
*/
static std::string studioName();
static std::string_view studioName();
};
}
22 changes: 10 additions & 12 deletions src/modules/videoGame/VideoGame.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
#include "faker-cxx/VideoGame.h"

#include "data/GameTitles.h"
#include "data/Genres.h"
#include "data/Platforms.h"
#include "data/StudioNames.h"
#include "VideoGameData.h"
#include "faker-cxx/Helper.h"


namespace faker
{
std::string VideoGame::gameTitle()
std::string_view VideoGame::gameTitle()
{
return Helper::arrayElement<std::string>(videoGameNames);
return Helper::arrayElement(videoGame::videoGameNames);
}

std::string VideoGame::genre()
std::string_view VideoGame::genre()
{
return Helper::arrayElement<std::string>(videoGameGenres);
return Helper::arrayElement(videoGame::videoGameGenres);
}

std::string VideoGame::platform()
std::string_view VideoGame::platform()
{
return Helper::arrayElement<std::string>(platforms);
return Helper::arrayElement(videoGame::platforms);
}

std::string VideoGame::studioName()
std::string_view VideoGame::studioName()
{
return Helper::arrayElement<std::string>(studioNames);
return Helper::arrayElement(videoGame::studioNames);
}
}
Loading

0 comments on commit 7b92d63

Please sign in to comment.