mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 03:28:49 -07:00
* Player refactor. Took 1 hour 43 minutes Took 1 minute Took 23 seconds * Tiny lint. Took 3 minutes * Hook up tap logic again. Took 13 minutes * Fix an include. Took 3 minutes * Stuff. Took 6 minutes * Fix typo. Took 7 minutes * Include. Took 1 minute * Reorganize method/variable definitions, remove unused ones. Took 1 hour 8 minutes Took 24 seconds * Clean up some unused imports. Took 6 minutes * Player holds the deck, emits deckChanged(), other elements player->getDeck() to respond to changes. Took 37 minutes * Connect player->openDeckEditor signal directly in the player constructor Took 6 minutes * Emit openDeckEditor signal in player_actions again. Took 3 minutes * Do to-do's Took 3 hours 32 minutes * Lint. Took 3 minutes * Lint again. Took 2 minutes * Fix include. Took 32 minutes * The stack should ensure card visibility. Took 21 minutes * Fine, the game can remember the tab. Took 10 minutes Took 21 seconds Took 9 seconds * zoneId is a dynamic gameplay property and thus belongs in player.cpp Took 11 minutes Took 19 seconds * Signal view removal, addition. Took 5 minutes * Ensure all players are considered local in local game. Took 10 minutes * ENSURE they are. Took 8 minutes * Bounds check data sent by QAction() Took 54 minutes * Move comment. Took 20 seconds * Reimplement logging category for game_event_handler.cpp, remove linebreaks. Took 36 seconds * PlayerGraphicsItem is responsible for retranslateUi, not Player. Took 14 seconds * Set menu for sideboard again, translate some menu titles, reimplement actIncPT action Took 54 seconds * Comment spacing. Took 43 seconds * Change message_log_widget.cpp slots to take CardZoneLogic parameters as emitted by PlayerEventHandler. Took 7 minutes Took 14 seconds * Remove unused player_logger.cpp Took 2 minutes * Query local game state correctly from tab_supervisor again Took 3 minutes * Revert Deck legality checker. Took 3 minutes * Instantiate menu before graphics item. Took 1 hour 5 minutes Took 55 minutes * Differentiate games and replays. Took 9 seconds * Lint. Took 10 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
112 lines
2.5 KiB
C++
112 lines
2.5 KiB
C++
#ifndef GAME_META_INFO_H
|
|
#define GAME_META_INFO_H
|
|
|
|
#include "pb/serverinfo_game.pb.h"
|
|
|
|
#include <QMap>
|
|
#include <QObject>
|
|
|
|
// Translation layer class to expose protobuf safely and hook it up to Qt Signals.
|
|
// This class de-couples the domain object (i.e. the GameMetaInfo) from the network object.
|
|
// If the network object changes, only this class needs to be adjusted.
|
|
|
|
class AbstractGame;
|
|
class GameMetaInfo : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit GameMetaInfo(AbstractGame *_game);
|
|
|
|
QMap<int, QString> roomGameTypes;
|
|
|
|
// Populate from protobuf (e.g., after network message)
|
|
void setFromProto(const ServerInfo_Game &gi)
|
|
{
|
|
gameInfo_.CopyFrom(gi);
|
|
}
|
|
|
|
const ServerInfo_Game &proto() const
|
|
{
|
|
return gameInfo_;
|
|
}
|
|
|
|
// High-level getters that avoid exposing protobuf directly
|
|
int gameId() const
|
|
{
|
|
return gameInfo_.game_id();
|
|
}
|
|
int maxPlayers() const
|
|
{
|
|
return gameInfo_.max_players();
|
|
}
|
|
QString description() const
|
|
{
|
|
return QString::fromStdString(gameInfo_.description());
|
|
}
|
|
bool started() const
|
|
{
|
|
return gameInfo_.started();
|
|
}
|
|
bool spectatorsOmniscient() const
|
|
{
|
|
return gameInfo_.spectators_omniscient();
|
|
}
|
|
bool spectatorsCanChat() const
|
|
{
|
|
return gameInfo_.spectators_can_chat();
|
|
}
|
|
int gameTypesSize() const
|
|
{
|
|
return gameInfo_.game_types_size();
|
|
}
|
|
int gameTypeIdAt(int index) const
|
|
{
|
|
return gameInfo_.game_types(index);
|
|
}
|
|
|
|
QMap<int, QString> getRoomGameTypes() const
|
|
{
|
|
return roomGameTypes;
|
|
}
|
|
|
|
void setRoomGameTypes(QMap<int, QString> _roomGameTypes)
|
|
{
|
|
roomGameTypes = _roomGameTypes;
|
|
}
|
|
|
|
QString findRoomGameType(int index)
|
|
{
|
|
return roomGameTypes.find(gameInfo_.game_types(index)).value();
|
|
}
|
|
|
|
AbstractGame *getGame() const
|
|
{
|
|
return game;
|
|
}
|
|
|
|
public slots:
|
|
void setStarted(bool s)
|
|
{
|
|
if (gameInfo_.started() == s)
|
|
return;
|
|
gameInfo_.set_started(s);
|
|
emit startedChanged(s);
|
|
}
|
|
void setSpectatorsOmniscient(bool v)
|
|
{
|
|
if (gameInfo_.spectators_omniscient() == v)
|
|
return;
|
|
gameInfo_.set_spectators_omniscient(v);
|
|
emit spectatorsOmniscienceChanged(v);
|
|
}
|
|
|
|
signals:
|
|
void startedChanged(bool started);
|
|
void spectatorsOmniscienceChanged(bool omniscient);
|
|
|
|
private:
|
|
AbstractGame *game;
|
|
ServerInfo_Game gameInfo_;
|
|
};
|
|
|
|
#endif // GAME_META_INFO_H
|