mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-16 20:17:45 -07:00
PB: everything compiles except for deck storage
This commit is contained in:
parent
695fde7541
commit
d5c628966f
51 changed files with 659 additions and 628 deletions
|
|
@ -1,3 +1,6 @@
|
|||
[Dolphin]
|
||||
Timestamp=2009,10,26,13,45,44
|
||||
ViewMode=1
|
||||
Timestamp=2011,12,31,17,13,2
|
||||
Version=2
|
||||
|
||||
[Settings]
|
||||
ShowDotFiles=true
|
||||
|
|
|
|||
|
|
@ -7,32 +7,29 @@
|
|||
|
||||
#include "pb/color.pb.h"
|
||||
|
||||
class Color {
|
||||
private:
|
||||
int value;
|
||||
public:
|
||||
Color(const color &other) : value(other.r() * 65536 + other.g() * 256 + other.b()) { } // TEMPORARY HACK
|
||||
Color(int _value = 0) : value(_value) { }
|
||||
Color(int r, int g, int b) : value(r * 65536 + g * 256 + b) { }
|
||||
int getValue() const { return value; }
|
||||
#ifdef QT_GUI_LIB
|
||||
Color(const QColor &_color)
|
||||
{
|
||||
value = _color.red() * 65536 + _color.green() * 256 + _color.blue();
|
||||
}
|
||||
QColor getQColor() const
|
||||
{
|
||||
return QColor(value / 65536, (value % 65536) / 256, value % 256);
|
||||
}
|
||||
inline QColor convertColorToQColor(const color &c)
|
||||
{
|
||||
return QColor(c.r(), c.g(), c.b());
|
||||
}
|
||||
|
||||
inline color convertQColorToColor(const QColor &c)
|
||||
{
|
||||
color result;
|
||||
result.set_r(c.red());
|
||||
result.set_g(c.green());
|
||||
result.set_b(c.blue());
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
color get_color() const // HACK
|
||||
{
|
||||
color c;
|
||||
c.set_r(value / 65536);
|
||||
c.set_g((value % 65536) / 256);
|
||||
c.set_b(value % 256);
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
inline color makeColor(int r, int g, int b)
|
||||
{
|
||||
color result;
|
||||
result.set_r(r);
|
||||
result.set_g(g);
|
||||
result.set_b(b);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -4,14 +4,14 @@ message Event_MoveCard {
|
|||
extend GameEvent {
|
||||
optional Event_MoveCard ext = 2009;
|
||||
}
|
||||
optional sint32 card_id = 1;
|
||||
optional sint32 card_id = 1 [default = -1];
|
||||
optional string card_name = 2;
|
||||
optional string start_zone = 3;
|
||||
optional sint32 position = 4;
|
||||
optional sint32 target_player_id = 5;
|
||||
optional sint32 position = 4 [default = -1];
|
||||
optional sint32 target_player_id = 5 [default = -1];
|
||||
optional string target_zone = 6;
|
||||
optional sint32 x = 7;
|
||||
optional sint32 y = 8;
|
||||
optional sint32 new_card_id = 9;
|
||||
optional sint32 x = 7 [default = -1];
|
||||
optional sint32 y = 8 [default = -1];
|
||||
optional sint32 new_card_id = 9 [default = -1];
|
||||
optional bool face_down = 10;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,6 @@ message GameEvent {
|
|||
DUMP_ZONE = 2018;
|
||||
STOP_DUMP_ZONE = 2019;
|
||||
}
|
||||
optional sint32 player_id = 1;
|
||||
optional sint32 player_id = 1 [default = -1];
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,21 +163,6 @@ void SerializableItem_Bool::writeElement(QXmlStreamWriter *xml)
|
|||
xml->writeCharacters(data ? "1" : "0");
|
||||
}
|
||||
|
||||
bool SerializableItem_Color::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isCharacters() && !xml->isWhitespace()) {
|
||||
bool ok;
|
||||
int colorValue = xml->text().toString().toInt(&ok);
|
||||
data = ok ? Color(colorValue) : Color();
|
||||
}
|
||||
return SerializableItem::readElement(xml);
|
||||
}
|
||||
|
||||
void SerializableItem_Color::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeCharacters(QString::number(data.getValue()));
|
||||
}
|
||||
|
||||
bool SerializableItem_DateTime::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isCharacters() && !xml->isWhitespace()) {
|
||||
|
|
|
|||
|
|
@ -122,20 +122,6 @@ public:
|
|||
bool isEmpty() const { return data == false; }
|
||||
};
|
||||
|
||||
class SerializableItem_Color : public SerializableItem {
|
||||
private:
|
||||
Color data;
|
||||
protected:
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
public:
|
||||
SerializableItem_Color(const QString &_itemType, const Color &_data = Color())
|
||||
: SerializableItem(_itemType), data(_data) { }
|
||||
const Color &getData() { return data; }
|
||||
void setData(const Color &_data) { data = _data; }
|
||||
bool isEmpty() const { return data.getValue() == 0; }
|
||||
};
|
||||
|
||||
class SerializableItem_DateTime : public SerializableItem {
|
||||
private:
|
||||
QDateTime data;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef SERVER_ARROW_H
|
||||
#define SERVER_ARROW_H
|
||||
|
||||
#include "color.h"
|
||||
#include "pb/color.pb.h"
|
||||
|
||||
class Server_Card;
|
||||
class Server_ArrowTarget;
|
||||
|
|
@ -11,14 +11,14 @@ private:
|
|||
int id;
|
||||
Server_Card *startCard;
|
||||
Server_ArrowTarget *targetItem;
|
||||
Color color;
|
||||
color arrowColor;
|
||||
public:
|
||||
Server_Arrow(int _id, Server_Card *_startCard, Server_ArrowTarget *_targetItem, const Color &_color)
|
||||
: id(_id), startCard(_startCard), targetItem(_targetItem), color(_color) { }
|
||||
Server_Arrow(int _id, Server_Card *_startCard, Server_ArrowTarget *_targetItem, const color &_arrowColor)
|
||||
: id(_id), startCard(_startCard), targetItem(_targetItem), arrowColor(_arrowColor) { }
|
||||
int getId() const { return id; }
|
||||
Server_Card *getStartCard() const { return startCard; }
|
||||
Server_ArrowTarget *getTargetItem() const { return targetItem; }
|
||||
const Color &getColor() const { return color; }
|
||||
const color &getColor() const { return arrowColor; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,21 +21,21 @@
|
|||
#define SERVER_COUNTER_H
|
||||
|
||||
#include <QString>
|
||||
#include "color.h"
|
||||
#include "pb/color.pb.h"
|
||||
|
||||
class Server_Counter {
|
||||
protected:
|
||||
int id;
|
||||
QString name;
|
||||
Color color;
|
||||
color counterColor;
|
||||
int radius;
|
||||
int count;
|
||||
public:
|
||||
Server_Counter(int _id, const QString &_name, const Color &_color, int _radius, int _count = 0) : id(_id), name(_name), color(_color), radius(_radius), count(_count) { }
|
||||
Server_Counter(int _id, const QString &_name, const color &_counterColor, int _radius, int _count = 0) : id(_id), name(_name), counterColor(_counterColor), radius(_radius), count(_count) { }
|
||||
~Server_Counter() { }
|
||||
int getId() const { return id; }
|
||||
QString getName() const { return name; }
|
||||
Color getColor() const { return color; }
|
||||
const color &getColor() const { return counterColor; }
|
||||
int getRadius() const { return radius; }
|
||||
int getCount() const { return count; }
|
||||
void setCount(int _count) { count = _count; }
|
||||
|
|
|
|||
|
|
@ -460,7 +460,8 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
|
|||
ServerInfo_Player playerInfo;
|
||||
playerInfo.mutable_properties()->CopyFrom(player->getProperties());
|
||||
if (player == playerWhosAsking)
|
||||
playerInfo.set_deck_list(player->getDeck()->writeToString_Native().toStdString());
|
||||
if (player->getDeck())
|
||||
playerInfo.set_deck_list(player->getDeck()->writeToString_Native().toStdString());
|
||||
|
||||
QList<ServerInfo_Arrow *> arrowList;
|
||||
QMapIterator<int, Server_Arrow *> arrowIterator(player->getArrows());
|
||||
|
|
@ -472,7 +473,7 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
|
|||
arrowInfo->set_start_player_id(arrow->getStartCard()->getZone()->getPlayer()->getPlayerId());
|
||||
arrowInfo->set_start_zone(arrow->getStartCard()->getZone()->getName().toStdString());
|
||||
arrowInfo->set_start_card_id(arrow->getStartCard()->getId());
|
||||
arrowInfo->mutable_arrow_color()->CopyFrom(arrow->getColor().get_color());
|
||||
arrowInfo->mutable_arrow_color()->CopyFrom(arrow->getColor());
|
||||
if (targetCard) {
|
||||
arrowInfo->set_target_player_id(targetCard->getZone()->getPlayer()->getPlayerId());
|
||||
arrowInfo->set_target_zone(targetCard->getZone()->getName().toStdString());
|
||||
|
|
@ -487,7 +488,7 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
|
|||
ServerInfo_Counter *counterInfo = playerInfo.add_counter_list();
|
||||
counterInfo->set_id(counter->getId());
|
||||
counterInfo->set_name(counter->getName().toStdString());
|
||||
counterInfo->mutable_counter_color()->CopyFrom(counter->getColor().get_color());
|
||||
counterInfo->mutable_counter_color()->CopyFrom(counter->getColor());
|
||||
counterInfo->set_radius(counter->getRadius());
|
||||
counterInfo->set_count(counter->getCount());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,14 +99,14 @@ void Server_Player::setupZones()
|
|||
addZone(new Server_CardZone(this, "grave", false, ServerInfo_Zone::PublicZone));
|
||||
addZone(new Server_CardZone(this, "rfg", false, ServerInfo_Zone::PublicZone));
|
||||
|
||||
addCounter(new Server_Counter(0, "life", Color(255, 255, 255), 25, 20));
|
||||
addCounter(new Server_Counter(1, "w", Color(255, 255, 150), 20, 0));
|
||||
addCounter(new Server_Counter(2, "u", Color(150, 150, 255), 20, 0));
|
||||
addCounter(new Server_Counter(3, "b", Color(150, 150, 150), 20, 0));
|
||||
addCounter(new Server_Counter(4, "r", Color(250, 150, 150), 20, 0));
|
||||
addCounter(new Server_Counter(5, "g", Color(150, 255, 150), 20, 0));
|
||||
addCounter(new Server_Counter(6, "x", Color(255, 255, 255), 20, 0));
|
||||
addCounter(new Server_Counter(7, "storm", Color(255, 255, 255), 20, 0));
|
||||
addCounter(new Server_Counter(0, "life", makeColor(255, 255, 255), 25, 20));
|
||||
addCounter(new Server_Counter(1, "w", makeColor(255, 255, 150), 20, 0));
|
||||
addCounter(new Server_Counter(2, "u", makeColor(150, 150, 255), 20, 0));
|
||||
addCounter(new Server_Counter(3, "b", makeColor(150, 150, 150), 20, 0));
|
||||
addCounter(new Server_Counter(4, "r", makeColor(250, 150, 150), 20, 0));
|
||||
addCounter(new Server_Counter(5, "g", makeColor(150, 255, 150), 20, 0));
|
||||
addCounter(new Server_Counter(6, "x", makeColor(255, 255, 255), 20, 0));
|
||||
addCounter(new Server_Counter(7, "storm", makeColor(255, 255, 255), 20, 0));
|
||||
|
||||
initialCards = 7;
|
||||
|
||||
|
|
@ -467,7 +467,8 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
|||
Event_MoveCard eventOthers;
|
||||
eventOthers.set_start_zone(startzone->getName().toStdString());
|
||||
eventOthers.set_target_player_id(targetzone->getPlayer()->getPlayerId());
|
||||
eventOthers.set_target_zone(targetzone->getName().toStdString());
|
||||
if (startzone != targetzone)
|
||||
eventOthers.set_target_zone(targetzone->getName().toStdString());
|
||||
eventOthers.set_x(newX);
|
||||
eventOthers.set_y(y);
|
||||
eventOthers.set_face_down(thisCardProperties->face_down());
|
||||
|
|
|
|||
|
|
@ -532,7 +532,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
|||
|
||||
server->serverMutex.lock();
|
||||
|
||||
QList<ServerInfo_Game *> gameList;
|
||||
QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
|
||||
QMutexLocker gameListLocker(&gameListMutex);
|
||||
while (roomIterator.hasNext()) {
|
||||
|
|
@ -613,8 +612,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetGamesOfUser(const Command_G
|
|||
return Response::RespNameNotFound;
|
||||
|
||||
Response_GetGamesOfUser *re = new Response_GetGamesOfUser;
|
||||
QList<ServerInfo_Room *> roomList;
|
||||
QList<ServerInfo_Game *> gameList;
|
||||
QMapIterator<int, Server_Room *> roomIterator(server->getRooms());
|
||||
while (roomIterator.hasNext()) {
|
||||
Server_Room *room = roomIterator.next().value();
|
||||
|
|
@ -1574,7 +1571,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdDumpZone(const Command_DumpZon
|
|||
zoneInfo->set_with_coords(zone->hasCoords());
|
||||
zoneInfo->set_card_count(numberCards < zone->cards.size() ? zone->cards.size() : numberCards);
|
||||
|
||||
QList<ServerInfo_Card *> respCardList;
|
||||
for (int i = 0; (i < zone->cards.size()) && (i < numberCards || numberCards == -1); ++i) {
|
||||
Server_Card *card = zone->cards[i];
|
||||
QString displayedName = card->getFaceDown() ? QString() : card->getName();
|
||||
|
|
@ -1595,7 +1591,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdDumpZone(const Command_DumpZon
|
|||
cardInfo->set_destroy_on_zone_change(card->getDestroyOnZoneChange());
|
||||
cardInfo->set_doesnt_untap(card->getDoesntUntap());
|
||||
|
||||
QList<ServerInfo_CardCounter *> cardCounterList;
|
||||
QMapIterator<int, int> cardCounterIterator(card->getCounters());
|
||||
while (cardCounterIterator.hasNext()) {
|
||||
cardCounterIterator.next();
|
||||
|
|
@ -1692,7 +1687,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_Reve
|
|||
|
||||
Event_RevealCards eventPrivate(eventOthers);
|
||||
|
||||
QList<ServerInfo_Card *> respCardListPrivate, respCardListOmniscient;
|
||||
for (int i = 0; i < cardsToReveal.size(); ++i) {
|
||||
Server_Card *card = cardsToReveal[i];
|
||||
ServerInfo_Card *cardInfo = eventPrivate.add_cards();
|
||||
|
|
@ -1710,7 +1704,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_Reve
|
|||
cardInfo->set_destroy_on_zone_change(card->getDestroyOnZoneChange());
|
||||
cardInfo->set_doesnt_untap(card->getDoesntUntap());
|
||||
|
||||
QList<ServerInfo_CardCounter *> cardCounterList;
|
||||
QMapIterator<int, int> cardCounterIterator(card->getCounters());
|
||||
while (cardCounterIterator.hasNext()) {
|
||||
cardCounterIterator.next();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue