Skip to content

Commit

Permalink
增加了make board filled again按钮,限制了login的账户名长度
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouzhouyou committed Jun 12, 2019
1 parent b10938a commit 07f2781
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 12 deletions.
5 changes: 5 additions & 0 deletions testWidget/GameBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ void GameBoard::restart()
ui.enemy->initialStatus();
}

void GameBoard::makeBoardFilledAgain()
{
ui.gameCore->makeBoardFilledAgain();
}

GameBoard::~GameBoard()
{
qDebug();
Expand Down
3 changes: 3 additions & 0 deletions testWidget/GameBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public slots:
void gameStart(QString enemy, QString enemyCharacter);
void playerDead(QString playerAccount);
void restart();

private slots:
void makeBoardFilledAgain();
signals:
void sendPlayerDead(QString playerAccount);

Expand Down
51 changes: 50 additions & 1 deletion testWidget/GameBoard.ui
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,35 @@
<bool>true</bool>
</property>
</widget>
<widget class="MainSceneButton" name="pushButton">
<property name="geometry">
<rect>
<x>992</x>
<y>560</y>
<width>100</width>
<height>70</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="testWidget.qrc">
<normaloff>:/button/Resources/button/Refresh_button.png</normaloff>:/button/Resources/button/Refresh_button.png</iconset>
</property>
<property name="iconSize">
<size>
<width>100</width>
<height>70</height>
</size>
</property>
</widget>
<zorder>backPic</zorder>
<zorder>player</zorder>
<zorder>enemy</zorder>
<zorder>label</zorder>
<zorder>gameCore</zorder>
<zorder>pushButton</zorder>
</widget>
<customwidgets>
<customwidget>
Expand All @@ -106,9 +130,34 @@
<header location="global">gamelogic.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MainSceneButton</class>
<extends>QPushButton</extends>
<header location="global">mainscenebutton.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="testWidget.qrc"/>
</resources>
<connections/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>GameBoard</receiver>
<slot>makeBoardFilledAgain()</slot>
<hints>
<hint type="sourcelabel">
<x>1038</x>
<y>603</y>
</hint>
<hint type="destinationlabel">
<x>1036</x>
<y>667</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>makeBoardFilledAgain()</slot>
</slots>
</ui>
24 changes: 18 additions & 6 deletions testWidget/GameLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ void GameLogic::fillBoard()
first = second = nullptr;
}

void GameLogic::makeBoardFilledAgain()
{
waitForStopAnimation();
countEffect = false;
for (auto col = 0; col < boardSize; col++)
for (auto row = 0; row < boardSize; row++)
stoneToCrush.append({ col, row });
gravity();
waitForStopAnimation();
countEffect = true;
}

void GameLogic::setMoveData(const int fx, const int fy, const int sx, const int sy)
{
md = MoveData(fx, fy, sx, sy);
Expand Down Expand Up @@ -506,13 +518,13 @@ void GameLogic::sinisterStrike(const QString& account)

void GameLogic::forceOfNature(const QString& account)
{
const auto col = qrand() % (boardSize - 1);
const auto row = qrand() % (boardSize - 1);
const auto type = NORMAL_STONE;
changeStone(col, row, type);
changeStone(col + 1, row, type);
changeStone(col, row + 1, type);
changeStone(col + 1, row + 1, type);
for (auto i = 0; i < 4; i++)
{
const auto col = qrand() % (boardSize - 1);
const auto row = qrand() % (boardSize - 1);
changeStone(col, row, type);
}
}

void GameLogic::gravity()
Expand Down
10 changes: 6 additions & 4 deletions testWidget/GameLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Q_OBJECT
~GameLogic();
void waitForStopAnimation() const;
void setMoveData(int fx, int fy, int sx, int sy);
void fillBoard();
void makeBoardFilledAgain();
private:
QPoint getPosition(const Stone* stone) const;
bool willDrop(QPoint location) const;
Expand Down Expand Up @@ -66,13 +68,13 @@ Q_OBJECT

public slots:
void useSkill(const QString& skill, const QString& account);
void fillBoard();
void clickedStone(Stone* stone); //invoke by Stone::clicked()

protected slots:

private slots:
void endMove();
void gravity();
void gravityFinished();

void clickedStone(Stone* stone); //invoke by Stone::clicked()
/*members*/
public:
const int boardSize = 8;
Expand Down
3 changes: 3 additions & 0 deletions testWidget/Login.ui
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ border-bottom:1px solid #717207;
<pointsize>10</pointsize>
</font>
</property>
<property name="maxLength">
<number>20</number>
</property>
<property name="placeholderText">
<string>User Name</string>
</property>
Expand Down
2 changes: 1 addition & 1 deletion testWidget/skill/forceOfNature.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ForceOfNature
summon 2x2 basic stones in random location.
summon 4 basic stones in random location.
125

0 comments on commit 07f2781

Please sign in to comment.