summaryrefslogtreecommitdiff
path: root/quacker/macondo.cpp
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-08-12 13:26:06 -0400
committerpommicket <pommicket@gmail.com>2025-08-12 13:26:06 -0400
commita1a21037c465a1a01b2ca13b70f89becfc93546e (patch)
tree2ab98ea347e8e6095a109b1dfe43670e39ea7bba /quacker/macondo.cpp
parentc197d84de85d4bc1f6ab9f9d3defebdd86820748 (diff)
add move box
Diffstat (limited to 'quacker/macondo.cpp')
-rw-r--r--quacker/macondo.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/quacker/macondo.cpp b/quacker/macondo.cpp
index 8c53beb..c089b42 100644
--- a/quacker/macondo.cpp
+++ b/quacker/macondo.cpp
@@ -1,33 +1,49 @@
#include "macondo.h"
#include "macondobackend.h"
+#include "movebox.h"
#include "quacker.h"
#include <QGridLayout>
#include <QPushButton>
Macondo::Macondo(Quackle::Game *game) : QWidget() {
+ m_game = game;
QGridLayout *layout = new QGridLayout(this);
+ m_moveBox = new MoveBox;
m_simulateButton = new QPushButton(tr("Simulate"));
- layout->addWidget(m_simulateButton, 0, 0);
layout->setAlignment(Qt::AlignTop);
+ layout->addWidget(m_simulateButton, 0, 0);
+ layout->addWidget(m_moveBox, 1, 0);
const char *home = getenv("HOME");
// TODO: configurable path
std::string execPath = home ? home : "/";
execPath += "/apps/macondo/macondo";
- MacondoBackend::InitOptions initOptions(execPath);
- m_backend = new MacondoBackend(game, initOptions);
+ initOptions = std::make_unique<MacondoInitOptions>(execPath);
+ m_backend = new MacondoBackend(game, *initOptions);
connect(m_simulateButton, SIGNAL(clicked()), this, SLOT(simulate()));
- connect(m_backend, SIGNAL(gotSimMoves(const std::vector<Quackle::Move> &)), this, SLOT(gotSimMoves(const std::vector<Quackle::Move> &)));
+ connect(m_backend, SIGNAL(gotSimMoves(const Quackle::MoveList &)), this, SLOT(gotSimMoves(const Quackle::MoveList &)));
}
+Macondo::~Macondo() {}
+
void Macondo::simulate() {
- MacondoBackend::SimulateOptions options;
+ MacondoSimulateOptions options;
m_backend->simulate(options);
+ m_moveBox->positionChanged(&m_game->currentPosition());
+}
+
+
+void Macondo::setGame(Quackle::Game *game) {
+ delete m_backend;
+ m_backend = new MacondoBackend(game, *initOptions);
+ m_game = game;
}
-void Macondo::gotSimMoves(const std::vector<Quackle::Move> &moves) {
- printf("got %zu moves\n",moves.size());
+void Macondo::gotSimMoves(const Quackle::MoveList &moves) {
+ m_moveBox->movesChanged(&moves);
+ /*printf("got %zu moves\n",moves.size());
for (const Quackle::Move &move: moves) {
std::cout << move << std::endl;
}
+ */
}