Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- run: |
sudo apt update
sudo apt install gcc-12 g++-12

- name: Install dependences
run: sudo apt-get remove libunwind-14 -y; sudo apt-get install -y libgoogle-glog-dev libgflags-dev libgtest-dev libsqlite3-dev libqt5webkit5-dev python3-pybind11

Expand All @@ -27,7 +27,9 @@ jobs:
submodules: recursive

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWITH_GCOV=OFF -DWITH_ASAN=OFF -DWITH_GLOG=OFF -DWITH_SQLITE=ON -DWITH_TEST=ON -DWITH_SIMULATOR=ON -DWITH_GAMES=ON
run: |
cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DWITH_GCOV=OFF -DWITH_ASAN=OFF -DWITH_GLOG=OFF -DWITH_SQLITE=ON -DWITH_TEST=ON -DWITH_TOOLS=ON -DWITH_GAMES=ON
shell: bash
env:
CC: gcc-12
Expand Down Expand Up @@ -71,7 +73,14 @@ jobs:
submodules: recursive

- name: Configure CMake
run: cmake -G "MinGW Makefiles" -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWITH_GCOV=OFF -DWITH_ASAN=OFF -DWITH_GLOG=OFF -DWITH_SQLITE=ON -DWITH_TEST=ON -DWITH_SIMULATOR=ON -DWITH_GAMES=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5
# Temporary: fix gflags compile error
# define GFLAGS_IS_A_DLL=0 to avoid "operator '&&' has no left operand" in gflags.h
# -Dgoogle=gflags resolves undefined 'google::RegisterFlagValidator' symbol
run: |
cmake -G "MinGW Makefiles" -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DWITH_GCOV=OFF -DWITH_ASAN=OFF -DWITH_GLOG=OFF -DWITH_SQLITE=ON -DWITH_TEST=ON -DWITH_TOOLS=ON -DWITH_GAMES=ON \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_CXX_FLAGS="-DGFLAGS_IS_A_DLL=0 -Dgoogle=gflags"

- name: Build
working-directory: build
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsigned-char -g")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/json/include)

if (WITH_IMAGE)
find_package(gflags REQUIRED)
add_subdirectory(third_party/markdown2image)
endif()

Expand Down
4 changes: 2 additions & 2 deletions bot_core/bot_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ static ErrCode HandleRequest(BotCtx& bot, const std::optional<GroupID> gid, cons
return EC_MATCH_USER_NOT_IN_MATCH;
}
if (match->gid() != gid && gid.has_value()) {
reply() << "[错误] 您未在本群参与游戏\n";
"若您想执行元指令,请尝试在请求前加\"" META_COMMAND_SIGN "\",或通过\"" META_COMMAND_SIGN "帮助\"查看所有支持的元指令";
reply() << "[错误] 您未在本群参与游戏\n"
"若您想执行元指令,请尝试在请求前加\"" META_COMMAND_SIGN "\",或通过\"" META_COMMAND_SIGN "帮助\"查看所有支持的元指令";
return EC_MATCH_NOT_THIS_GROUP;
}
return match->Request(uid, gid, msg, reply);
Expand Down
3 changes: 3 additions & 0 deletions game_util/othello.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class Board

bool Place(const Coor& coor, const ChessType type)
{
if (coor.row_ < 0 || coor.row_ >= k_size_ || coor.col_ < 0 || coor.col_ >= k_size_) {
return false;
}
auto& box = Get_(coor);
if (box.cur_type_ != ChessType::NONE) {
return false; // there is already a chess
Expand Down
6 changes: 3 additions & 3 deletions game_util/quixo.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ class Board
if (src_type != Type::_ && src_type != type) {
return ErrCode::INVALID_SRC;
}
if (!TryPush_<true>(src_coor, dst_coor, type) && !TryPush_<false>(src_coor, dst_coor, type)) {
return ErrCode::INVALID_DST;
}
if (src_type == Type::_) {
if (type == Type::X1 || type == Type::X2) {
++chess_counts_[static_cast<uint32_t>(Symbol::X)];
} else if (type == Type::O1 || type == Type::O2) {
++chess_counts_[static_cast<uint32_t>(Symbol::O)];
}
}
if (!TryPush_<true>(src_coor, dst_coor, type) && !TryPush_<false>(src_coor, dst_coor, type)) {
return ErrCode::INVALID_DST;
}
areas_[dst_coor.x_][dst_coor.y_] = type;
last_move_coor_.emplace(dst_coor);
return ErrCode::OK;
Expand Down
24 changes: 18 additions & 6 deletions games/blocked_road/mygame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ bool AdaptOptions(MsgSenderBase& reply, CustomOptions& game_options, const Gener
}

const std::vector<InitOptionsCommand> k_init_options_commands = {
InitOptionsCommand("设置棋子数和边长",
[] (CustomOptions& game_options, MutableGenericOptions& generic_options, const uint32_t& num, const uint32_t& size)
{
GET_OPTION_VALUE(game_options, 棋子) = num;
GET_OPTION_VALUE(game_options, 边长) = size;
return NewGameMode::MULTIPLE_USERS;
},
ArithChecker<uint32_t>(3, 6, "棋子"), OptionalDefaultChecker<ArithChecker<uint32_t>>(4, 4, 6, "边长")),
InitOptionsCommand("独自一人开始游戏",
[] (CustomOptions& game_options, MutableGenericOptions& generic_options)
{
Expand Down Expand Up @@ -337,15 +345,19 @@ class RoundStage : public SubGameStage<>
if (pid == Main().currentPlayer) {
int X, Y, addx, addy;
string result;
while (result != "OK") {
int c = rand() % GAME_OPTION(棋子) + 1;
for (int i = 1; i <= Main().board.size; i++) {
for (int j = 1; j <= Main().board.size; j++) {
if (Main().board.chess[i][j] == pid + 1 && c >= 0) {
c--; X = i; Y = j;
int try_count = 0;
while (result != "OK" && try_count++ < 1000) {
std::vector<pair<int, int>> pieces;
for (int i = 1; i <= Main().board.size; ++i) {
for (int j = 1; j <= Main().board.size; ++j) {
if (Main().board.chess[i][j] == pid + 1) {
pieces.push_back({i, j});
}
}
}
int c = rand() % GAME_OPTION(棋子);
X = pieces[c].first;
Y = pieces[c].second;
addx = addy = 0;
if (rand() % 2) {
addx = rand() % 2 == 1 ? 1 : -1;
Expand Down
15 changes: 7 additions & 8 deletions games/dvalue_tender/mygame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,22 +365,21 @@ void MainStage::FirstStageFsm(SubStageFsmSetter setter)

void MainStage::NextStageFsm(RoundStage& sub_stage, const CheckoutReason reason, SubStageFsmSetter setter)
{
round_++;

// Global().Boardcast()<<std::to_string(round_)<<std::to_string(player_wins_[0])<<std::to_string(player_wins_[1]);

if (round_ != 10 && round_ != 13) {
int win_need = GAME_OPTION(回合数) / 2 + 1;
if (round_ != GAME_OPTION(回合数) && round_ != GAME_OPTION(回合数) + 3) {
if(
(round_ < 10 && (player_wins_[0] < 5 && player_wins_[1] < 5) )
||(round_ > 10 && (player_wins_[0] < 6 && player_wins_[1] < 6) )
(round_ < GAME_OPTION(回合数) && (player_wins_[0] < win_need && player_wins_[1] < win_need) )
||(round_ > GAME_OPTION(回合数) && (player_wins_[0] < win_need + 1 && player_wins_[1] < win_need + 1) )
) {
setter.Emplace<RoundStage>(*this, round_);
setter.Emplace<RoundStage>(*this, ++round_);
return;
}
}
else if(round_ == 10){
else if(round_ == GAME_OPTION(回合数)){
if(player_wins_[0] == player_wins_[1]){
setter.Emplace<RoundStage>(*this, round_);
setter.Emplace<RoundStage>(*this, ++round_);
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion games/dvalue_tender/options.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
EXTEND_OPTION("回合数", 回合数, (ArithChecker<uint32_t>(1, 20, "回合数")), 15)
EXTEND_OPTION("回合数", 回合数, (ArithChecker<uint32_t>(3, 20, "回合数")), 9)
EXTEND_OPTION("金币", 金币, (ArithChecker<uint32_t>(10, 1000000, "金币")), 30)
EXTEND_OPTION("每回合时间限制", 时限, (ArithChecker<uint32_t>(10, 3600, "超时时间(秒)")), 90)
Empty file.
Binary file added games/garnet_thief/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading