qmlfrontend/hwengine.h
author Wuzzy <Wuzzy2@mail.ru>
Mon, 08 Jul 2019 21:44:26 +0200
changeset 15220 ceb289e8a582
parent 14372 b6824a53d4b1
child 15891 d52f5d8e75e6
permissions -rw-r--r--
King Mode: Fix king placement phase not working correctly with multiple teams in a clan New king placement phase rules: * Before the game begins, each team can walk with their king and teleport for free, everything else is disabled * This special round does not count towards the round counter, like in gfPlaceHog * TotalRounds is set to -1 during this round, like in gfPlaceHog Under the old rules, this was much more hacky. The delay of all delay-less weapons was just set to 1 The problem with the old rules was that if any clan had more than 1 team, eventually the weapon delay will time out before all kings have been placed.

#ifndef HWENGINE_H
#define HWENGINE_H

#include <QList>
#include <QObject>

#include "engine_interface.h"
#include "game_config.h"

class QQmlEngine;
class EngineInstance;
class PreviewAcceptor;

class HWEngine : public QObject {
  Q_OBJECT

  Q_PROPERTY(int previewHedgehogsCount READ previewHedgehogsCount NOTIFY
                 previewHedgehogsCountChanged)
  Q_PROPERTY(PreviewAcceptor* previewAcceptor READ previewAcceptor WRITE
                 setPreviewAcceptor NOTIFY previewAcceptorChanged)
  Q_PROPERTY(QString engineLibrary READ engineLibrary WRITE setEngineLibrary
                 NOTIFY engineLibraryChanged)

 public:
  explicit HWEngine(QObject* parent = nullptr);
  ~HWEngine();

  Q_INVOKABLE void getPreview();
  Q_INVOKABLE EngineInstance* runQuickGame();

  int previewHedgehogsCount() const;
  PreviewAcceptor* previewAcceptor() const;
  QString engineLibrary() const;

 public slots:
  void setPreviewAcceptor(PreviewAcceptor* previewAcceptor);
  void setEngineLibrary(const QString& engineLibrary);

 signals:
  void previewIsRendering();
  void previewImageChanged();
  void previewHogCountChanged(int count);
  void gameFinished();
  void previewHedgehogsCountChanged(int previewHedgehogsCount);
  void previewAcceptorChanged(PreviewAcceptor* previewAcceptor);
  void engineLibraryChanged(const QString& engineLibrary);

 private:
  QQmlEngine* m_engine;
  GameConfig m_gameConfig;
  int m_previewHedgehogsCount;
  PreviewAcceptor* m_previewAcceptor;
  QString m_engineLibrary;
};

#endif  // HWENGINE_H