Skip to content

Commit

Permalink
dededebug
Browse files Browse the repository at this point in the history
  • Loading branch information
ce-amtic committed Jun 6, 2023
1 parent a9d79e5 commit ba41472
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Object/bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void Bot::run()
curPlayer = 0;
judge->PlaceAPiece(finalx, finaly);
if(judge->runMode == 2 || judge->runMode == 3) // 发送 MOVE_OP 以及处理 recData
judge->send(NetworkData(OPCODE::MOVE_OP, QString(QChar('A'+finalx))+QString(QChar('1'+finaly)), ""));
judge->send(NetworkData(OPCODE::MOVE_OP, QString(QChar('A'+finalx))+QString(QChar('1'+finaly)), QString::number(QDateTime::currentMSecsSinceEpoch())));
double curRatio = judgeBoard();
if(curRatio < 0.5)
{
Expand Down
3 changes: 2 additions & 1 deletion Object/judge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ void Judge::connect()
}
else
{
send(NetworkData(OPCODE::CHAT_OP, "", ""));
// server cannot initiate new game
// send(NetworkData(OPCODE::CHAT_OP, "", ""));
socketConnected = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Widget/gamewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void GameWidget::mousePressEvent(QMouseEvent *event)

if(!judge->runMode) emit turnForBot();
if(judge->runMode == 2 || judge->runMode == 3) // 发送 MOVE_OP 以及处理 recData
judge->send(NetworkData(OPCODE::MOVE_OP, QString(QChar('A'+row-1))+QString(QChar('1'+column-1)), ""));
judge->send(NetworkData(OPCODE::MOVE_OP, QString(QChar('A'+row-1))+QString(QChar('1'+column-1)), QString::number(QDateTime::currentMSecsSinceEpoch())));
startTimer();
}
else sendMessage(2);
Expand Down
14 changes: 6 additions & 8 deletions Widget/startwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ StartWidget::StartWidget(Judge *j, QWidget *parent) :
connect(ui->startAsBlack, &QPushButton::clicked, this, &StartWidget::on_startAsBlack_clicked_OFFL);
connect(ui->startAsWhite, &QPushButton::clicked, this, &StartWidget::on_startAsWhite_clicked_OFFL);
connect(confirmD, &OptionDialog::OK, this, [&](){
if(oppoRole == 1) {sendStartAsWhite(); on_startAsWhite_clicked_OFFL();}
else {sendStartAsBlack(); on_startAsBlack_clicked_OFFL();}
if(oppoRole == 1) {sendStartAsWhite(true); on_startAsWhite_clicked_OFFL();}
else {sendStartAsBlack(true); on_startAsBlack_clicked_OFFL();}
confirmD->close();
});
connect(confirmD, &OptionDialog::NO, this, [&](){
Expand Down Expand Up @@ -121,15 +121,13 @@ void StartWidget::goOFFL()
connect(ui->startAsBlack, &QPushButton::clicked, this, &StartWidget::on_startAsBlack_clicked_OFFL);
connect(ui->startAsWhite, &QPushButton::clicked, this, &StartWidget::on_startAsWhite_clicked_OFFL);
}
void StartWidget::sendStartAsBlack()
void StartWidget::sendStartAsBlack(bool isReply)
{
NetworkData d = NetworkData(OPCODE::READY_OP, judge->usrnameOL, "b");
judge->send(d);
judge->send(NetworkData(OPCODE::READY_OP, judge->usrnameOL, isReply?"":"b"));
}
void StartWidget::sendStartAsWhite()
void StartWidget::sendStartAsWhite(bool isReply)
{
NetworkData d = NetworkData(OPCODE::READY_OP, judge->usrnameOL, "w");
judge->send(d);
judge->send(NetworkData(OPCODE::READY_OP, judge->usrnameOL, isReply?"":"w"));
}
void StartWidget::sendReject() {judge->send(NetworkData(OPCODE::REJECT_OP, judge->usrnameOL, ""));}

Expand Down
4 changes: 2 additions & 2 deletions Widget/startwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ private slots:

private:
void paintEvent(QPaintEvent *event) override;
void sendStartAsBlack(); // 联机
void sendStartAsWhite(); // 联机
void sendStartAsBlack(bool isReply = false); // 联机
void sendStartAsWhite(bool isReply = false); // 联机
void sendReject(); // 联机被拒

Judge* judge;
Expand Down

0 comments on commit ba41472

Please sign in to comment.