mirror of
https://github.com/jorenchik/testing-spring-2024.git
synced 2025-10-21 20:10:36 +00:00
refactor(room): move room to separate file
This commit is contained in:
parent
b4b01c4a11
commit
cad8e6d032
@ -5,24 +5,6 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
Room::Room(
|
|
||||||
uint32_t id, std::string title, uint32_t utcTimestampCreatedAt, RoomStatus status, std::vector<Player> players):
|
|
||||||
id(id),
|
|
||||||
title(title),
|
|
||||||
status(status),
|
|
||||||
players(players) {
|
|
||||||
this->utcTimestampCreatedAt = createUTCTimestamp(utcTimestampCreatedAt);
|
|
||||||
}
|
|
||||||
|
|
||||||
Room::Room(uint32_t id,
|
|
||||||
std::string title,
|
|
||||||
uint32_t utcTimestampCreatedAt,
|
|
||||||
RoomStatus status,
|
|
||||||
std::initializer_list<Player> players):
|
|
||||||
Room(id, title, utcTimestampCreatedAt, status, std::vector<Player>(players)) {
|
|
||||||
this->utcTimestampCreatedAt = createUTCTimestamp(utcTimestampCreatedAt);
|
|
||||||
}
|
|
||||||
|
|
||||||
Event::Event(std::string title,
|
Event::Event(std::string title,
|
||||||
uint32_t utcTimestampCreatedAt,
|
uint32_t utcTimestampCreatedAt,
|
||||||
uint32_t numberNight,
|
uint32_t numberNight,
|
||||||
|
|||||||
@ -14,32 +14,8 @@ enum EventType {
|
|||||||
PLAYER_STATE_CHANGE,
|
PLAYER_STATE_CHANGE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RoomStatus {
|
|
||||||
AWAITING_START,
|
|
||||||
IN_PROGRESS,
|
|
||||||
STOPPED,
|
|
||||||
ENDED,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Room;
|
|
||||||
struct Event;
|
struct Event;
|
||||||
|
|
||||||
struct Room {
|
|
||||||
uint32_t id;
|
|
||||||
std::string title;
|
|
||||||
std::tm *utcTimestampCreatedAt;
|
|
||||||
RoomStatus status;
|
|
||||||
std::vector<Player> players;
|
|
||||||
|
|
||||||
Room(
|
|
||||||
uint32_t id, std::string title, uint32_t utcTimestampCreatedAt, RoomStatus status, std::vector<Player> players);
|
|
||||||
Room(uint32_t id,
|
|
||||||
std::string title,
|
|
||||||
uint32_t utcTimestampCreatedAt,
|
|
||||||
RoomStatus status,
|
|
||||||
std::initializer_list<Player> players);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Event {
|
struct Event {
|
||||||
std::string title;
|
std::string title;
|
||||||
std::tm *utcTimestampCreatedAt;
|
std::tm *utcTimestampCreatedAt;
|
||||||
|
|||||||
23
src/room.cc
Normal file
23
src/room.cc
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include "room.hh"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
Room::Room(uint32_t id, std::string title, uint32_t created_at, RoomStatus status, std::vector<Player> players):
|
||||||
|
id(id),
|
||||||
|
title(title),
|
||||||
|
created_at(createUTCTimestamp(created_at)),
|
||||||
|
status(status),
|
||||||
|
players(players) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Room::Room(
|
||||||
|
uint32_t id, std::string title, uint32_t created_at, RoomStatus status, std::initializer_list<Player> players):
|
||||||
|
id(id),
|
||||||
|
title(title),
|
||||||
|
created_at(createUTCTimestamp(created_at)),
|
||||||
|
status(status),
|
||||||
|
players(players) {
|
||||||
|
}
|
||||||
30
src/room.hh
Normal file
30
src/room.hh
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef ROOM_HH
|
||||||
|
#define ROOM_HH
|
||||||
|
|
||||||
|
#include "player.hh"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <ctime>
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
enum RoomStatus {
|
||||||
|
AwaitingStart,
|
||||||
|
InProgress,
|
||||||
|
Stopped,
|
||||||
|
Ended,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Room {
|
||||||
|
uint32_t id;
|
||||||
|
std::string title;
|
||||||
|
std::tm *created_at;
|
||||||
|
RoomStatus status;
|
||||||
|
std::vector<Player> players;
|
||||||
|
|
||||||
|
Room(uint32_t id, std::string title, uint32_t created_at, RoomStatus status, std::vector<Player> players);
|
||||||
|
Room(uint32_t id, std::string title, uint32_t created_at, RoomStatus status, std::initializer_list<Player> players);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !ROOM_HH
|
||||||
Loading…
Reference in New Issue
Block a user