Skip to content

Commit

Permalink
recover
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthOuterTowner committed Dec 25, 2024
1 parent 22d39bb commit cb162f2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
5 changes: 5 additions & 0 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ void Game::mousePressEvent(QMouseEvent *event) {
clickDistrict[3]++;
}
}
if(isHammerMode){
useHammer(row, col);
return;

}
StoneLabel* curLabel = stones[row][col];
if (curLabel->isFrozen) { // 如果当前点击的棋子处于冰冻状态,直接返回,不做任何操作
return;
Expand Down
6 changes: 6 additions & 0 deletions game.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class Game : public QWidget
// 获取当前竖向消除道具数量
int getVerticalCount() const;
void setVerticalCount(int count);
int gethammerCount() const;
void sethammerCount(int count);
void updateItemCountLabels(); // 更新道具数量标签的函数

Ui::Game *ui;
Expand Down Expand Up @@ -137,6 +139,8 @@ private slots:

void on_Shop_clicked();

void on_hammer_clicked();

private:
explicit Game(QWidget *parent = nullptr,Game::GameMode mode = Game::GameMode::CLASSIC_MODE,Client* client=nullptr);//经典模式构造器
explicit Game(QWidget *parent = nullptr,int LevelNum = -1,Game::GameMode mode = Game::GameMode::ADVENTURE_MODE,Client* client=nullptr);//冒险模式构造器
Expand Down Expand Up @@ -181,6 +185,8 @@ private slots:
bool vertical=false;//是否竖向消除
void triggerBomb(int row, int col);
bool isBombMode = false; // 标记是否处于炸弹模式
bool isHammerMode = false; // 标记是否处于锤子模式
void useHammer(int row, int col);
QSoundEffect* sound; // 背景音乐
int hintCount = 5;//提示的初始次数
Client* client;
Expand Down
29 changes: 26 additions & 3 deletions shopwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
int ShopWidget::bombCount = 1; // 炸弹数量
int ShopWidget::horizonCount = 1; // 横向消除道具数量
int ShopWidget::verticalCount = 1; // 竖向消除道具数量
int ShopWidget::hammerCount = 1; //锤子道具数量




Expand Down Expand Up @@ -59,8 +61,9 @@ ShopWidget::ShopWidget(QWidget *parent) :
ui->horizonLabel->setText(QString("横向: %1").arg(horizonCount));
// 更新显示当前积分


ui->verticalLabel->setText(QString("竖向: %1").arg(verticalCount));
ui->hammerLabel->setText(QString("竖向: %1").arg(hammerCount));




Expand Down Expand Up @@ -115,6 +118,7 @@ void ShopWidget::on_Buy_clicked()
break;
case ItemType::HORIZON:
case ItemType::VERTICAL:
case ItemType::HAMMER:
itemPrice = 30; // 横向和竖向消除的价格
break;
}
Expand All @@ -132,17 +136,22 @@ void ShopWidget::on_Buy_clicked()
bombCount++;
// 更新 Game 中的炸弹数量
ui->bombLabel->setText(QString("炸弹: %1").arg(bombCount));
break;
break;
case ItemType::HORIZON:
horizonCount++;
// 更新 Game 中的横向消除数量
ui->horizonLabel->setText(QString("横向消除: %1").arg(horizonCount));
break;
case ItemType::VERTICAL:
verticalCount++;
// 更新 Game 中的竖向消除数量
// 更新 Game 中的竖向消除数量
ui->verticalLabel->setText(QString("竖向消除: %1").arg(verticalCount));
break;
case ItemType::HAMMER:
hammerCount++;
// 更新 Game 中的锤子数量
ui->hammerLabel->setText(QString("竖向消除: %1").arg(hammerCount));
break;
}

// 更新游戏界面中的道具数量标签
Expand Down Expand Up @@ -200,9 +209,23 @@ void ShopWidget::resetItemCounts() {
bombCount = 1; // 重置炸弹数量
horizonCount = 1; // 重置横向消除道具数量
verticalCount = 1; // 重置竖向消除道具数量
hammerCount = 1;

// 更新 UI 显示
ui->bombLabel->setText(QString("炸弹: %1").arg(bombCount));
ui->horizonLabel->setText(QString("横向: %1").arg(horizonCount));
ui->verticalLabel->setText(QString("竖向: %1").arg(verticalCount));
ui->hammerLabel->setText(QString("小锤子: %1").arg(hammerCount));

}

void ShopWidget::on_hammer_clicked()
{
currentItemType = ItemType::HAMMER; // 设置为竖向消除道具

// 显示竖向消除的图片和描述
ui->picture->setPixmap(QPixmap(":/button/HAMMER.png"));
ui->introduction->setText("小锤子吹冰块bang!\n价格:30积分");
ui->picture->show();
ui->introduction->show();
}
8 changes: 6 additions & 2 deletions shopwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ShopWidget : public QWidget
static int bombCount; // 炸弹数量
static int horizonCount; // 横向消除道具数量
static int verticalCount; // 竖向消除道具数量
static int hammerCount;//锤子道具
// 重置道具数量
void resetItemCounts();

Expand All @@ -40,6 +41,8 @@ private slots:
void on_vertical_clicked();


void on_hammer_clicked();

private:
Ui::ShopWidget *ui; // UI 控件的指针
Game* game; // 游戏对象指针,用于访问分数
Expand All @@ -48,10 +51,11 @@ private slots:
NONE, // 没有选择道具
BOMB, // 炸弹
HORIZON, // 横向消除
VERTICAL // 竖向消除
VERTICAL, // 竖向消除
HAMMER //锤子道具
};

ItemType currentItemType; // 当前选中的道具类型
ItemType currentItemType; // 当前选中的道具类型

};

Expand Down

0 comments on commit cb162f2

Please sign in to comment.