Skip to content

Commit

Permalink
check all pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
irrld committed Oct 13, 2023
1 parent a918d48 commit 8df306c
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 97 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/build-windows.yml

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/build-windows.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Build Windows

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# https://github.com/GlistEngine/glistzbin-win64/releases/download/v.2.0.2/glistzbin-win64-2.0.2.zip
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-2022

steps:
- uses: actions/checkout@v3

- name: checkout submodule
run: |
git submodule update --init --recursive

#working-directory: ${{github.workspace}}/glist/myglistapps/${{github.repository}}
- name: Set path
run: |
Add-Content $env:GITHUB_PATH "D:/a/chesstacos/chesstacos/zbin/glistzbin-win64/clang64/bin"
Add-Content $env:GITHUB_PATH "D:/a/chesstacos/chesstacos/zbin/glistzbin-win64/CMake/bin"

- name: Clone GlistEngine
uses: GuillaumeFalourd/[email protected]
with:
depth: 1
branch: 'main'
owner: 'GlistEngine'
repository: 'GlistEngine'

- name: cd zbin
run: |
mkdir ${{github.workspace}}/zbin
cd ${{github.workspace}}/zbin

- name: Download zbin
uses: suisei-cn/actions-download-file@v1
id: glistzbin-win64 # Remember to give an ID if you need the output
with:
url: 'https://github.com/GlistEngine/glistzbin-win64/releases/download/v.2.0.2/glistzbin-win64-2.0.2.zip'
target: ${{github.workspace}}/zbin

- name: Extract zip
run: |
7z l "D:/a/chesstacos/chesstacos/zbin/glistzbin-win64-2.0.2.zip"
7z x "D:/a/chesstacos/chesstacos/zbin/glistzbin-win64-2.0.2.zip" -o"D:/a/chesstacos/chesstacos/zbin"

- name: List
run: |
cd ${{github.workspace}}
tree /f

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B '${{github.workspace}}/build' -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DTOP_DIR='D:/a/chesstacos/chesstacos' -S .

- name: Build
# Build your program with the given configuration
run: cmake --build '${{github.workspace}}/build' --config ${{env.BUILD_TYPE}}


12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ endif()
# Clang compiler definition for Windows. Do not change this value for other OS.
# For UNIX like systems, configure the compiler via OS commands.
if(WIN32)
set(CMAKE_C_COMPILER "${CMAKE_SOURCE_DIR}/../../zbin/glistzbin-win64/clang64/bin/clang.exe")
set(CMAKE_CXX_COMPILER "${CMAKE_SOURCE_DIR}/../../zbin/glistzbin-win64/clang64/bin/clang++.exe")
if(NOT DEFINED CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER "${CMAKE_SOURCE_DIR}/../../zbin/glistzbin-win64/clang64/bin/clang.exe")
endif()
if(NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER "${CMAKE_SOURCE_DIR}/../../zbin/glistzbin-win64/clang64/bin/clang++.exe")
endif()
endif(WIN32)


Expand Down Expand Up @@ -65,7 +69,9 @@ set(APP_DIR ${CMAKE_SOURCE_DIR})
project (${APP_NAME})
set(CMAKE_BUILD_TYPE Debug)

set(TOP_DIR ${APP_DIR}/../..)
if(NOT DEFINED TOP_DIR)
set(TOP_DIR ${APP_DIR}/../..)
endif()
set(MAIN_DIR ${TOP_DIR}/GlistEngine)
set(ENGINE_DIR ${MAIN_DIR}/engine)

Expand Down
2 changes: 0 additions & 2 deletions src/canvas/game_canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ bool GameCanvas::Move(int x, int y, int to_x, int to_y) {
if (piece->GetType() == kPieceTypePawn) {
if (to_y == 0 && piece->GetColor() == kPieceColorBlack) {
// black promote
// promote after switch
if (player_color_ == kPieceColorBlack) {
SetInfoText("Promote your pawn!");
promoting_ = true;
Expand All @@ -172,7 +171,6 @@ bool GameCanvas::Move(int x, int y, int to_x, int to_y) {
}
} else if (to_y == 7 && piece->GetColor() == kPieceColorWhite) {
// white promote
// promote after switch
if (player_color_ == kPieceColorWhite) {
SetInfoText("Promote your pawn!");
promoting_ = true;
Expand Down
4 changes: 2 additions & 2 deletions src/canvas/loading_canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "menu_canvas.h"

LoadingCanvas::LoadingCanvas(gApp* root) : gBaseCanvas(root) {
this->root = root;
this->root_ = root;
}

LoadingCanvas::~LoadingCanvas() {
Expand Down Expand Up @@ -45,7 +45,7 @@ void LoadingCanvas::draw() {
renderer->setColor(255, 255, 255, std::min(opacity, 255));
glist_logo_.draw(glist_x_, glist_y_, glist_width_, glist_height_);
} else {
root->setCurrentCanvas(new MenuCanvas(root));
root_->setCurrentCanvas(new MenuCanvas(root_));
}
renderer->setColor(old_color);
}
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/loading_canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LoadingCanvas : public gBaseCanvas {
void hideNotify() {}

private:
gApp* root;
gApp* root_;
gImage brand_logo_;
int brand_width_, brand_height_, brand_x_, brand_y_;
gImage glist_logo_;
Expand Down
70 changes: 35 additions & 35 deletions src/canvas/menu_canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "task_canvas.h"

MenuCanvas::MenuCanvas(gApp* root) : gBaseCanvas(root) {
this->root = root;
this->root_ = root;
}

MenuCanvas::~MenuCanvas() {
Expand All @@ -14,12 +14,12 @@ MenuCanvas::~MenuCanvas() {
void MenuCanvas::setup() {
int buttons_x = getWidth() / 2;
int buttons_y = getHeight() / 2 + 100;
join_button = new Button("JOIN", buttons_x, buttons_y, 180, 60);
host_button = new Button("HOST", buttons_x, buttons_y + 70, 180, 60);
quit_button = new Button("QUIT", buttons_x, buttons_y + 140, 180, 60);
logo_font.loadFont("PixeloidSansBold.ttf", 64, false, 80);
fade_in_ = !root->loaded_;
root->loaded_ = true;
join_button_ = new Button("JOIN", buttons_x, buttons_y, 180, 60);
host_button_ = new Button("HOST", buttons_x, buttons_y + 70, 180, 60);
quit_button_ = new Button("QUIT", buttons_x, buttons_y + 140, 180, 60);
logo_font_.loadFont("PixeloidSansBold.ttf", 64, false, 80);
fade_in_ = !root_->loaded_;
root_->loaded_ = true;
fade_in_timer_ = 0.0f;
fade_color_ = CreateRGB(0x1c1e25);
back_color_ = CreateRGB(0x4c5465);
Expand All @@ -37,17 +37,17 @@ void MenuCanvas::update() {
return;
}

join_button->Update();
host_button->Update();
quit_button->Update();
if (host_button->GetState() == ButtonState::Pressed) {
host_button->Lock();
root->setCurrentCanvas(new TaskCanvas(root, CreateRef<HostTask>(root)));
} else if (join_button->GetState() == ButtonState::Pressed) {
join_button->Lock();
root->setCurrentCanvas(new JoinCanvas(root));
} else if (quit_button->GetState() == ButtonState::Pressed) {
quit_button->Lock();
join_button_->Update();
host_button_->Update();
quit_button_->Update();
if (host_button_->GetState() == ButtonState::Pressed) {
host_button_->Lock();
root_->setCurrentCanvas(new TaskCanvas(root_, CreateRef<HostTask>(root_)));
} else if (join_button_->GetState() == ButtonState::Pressed) {
join_button_->Lock();
root_->setCurrentCanvas(new JoinCanvas(root_));
} else if (quit_button_->GetState() == ButtonState::Pressed) {
quit_button_->Lock();
appmanager->stop();
}
}
Expand All @@ -62,43 +62,43 @@ void MenuCanvas::draw() {
setColor(255, 255, 255, std::min((int) ((fade_in_timer_ - 0.5f) * 255.0f), 255));
}
// buttons
join_button->Draw();
host_button->Draw();
quit_button->Draw();
join_button_->Draw();
host_button_->Draw();
quit_button_->Draw();
// logo
RenderUtil::DrawFont(&logo_font, "Chess Tacos", getWidth() / 2 - logo_font.getStringWidth("Chess Tacos") / 2, 150, 8);
RenderUtil::DrawFont(&logo_font_, "Chess Tacos", getWidth() / 2 - logo_font_.getStringWidth("Chess Tacos") / 2, 150, 8);
setColor(og_color);
RenderUtil::DrawFont(kVersion, 0, getHeight() - 33, {100, 100, 100}, false, true);
root->DrawCursor();
root_->DrawCursor();
}

void MenuCanvas::mouseMoved(int x, int y) {
root->SetCursorPos(x, y);
root_->SetCursorPos(x, y);
if (fade_in_) {
return;
}
join_button->OnMouseMoved(x, y);
host_button->OnMouseMoved(x, y);
quit_button->OnMouseMoved(x, y);
join_button_->OnMouseMoved(x, y);
host_button_->OnMouseMoved(x, y);
quit_button_->OnMouseMoved(x, y);
}

void MenuCanvas::mousePressed(int x, int y, int button) {
root->SetCursorType(CursorType::kHandClosed);
root_->SetCursorType(CursorType::kHandClosed);
if (fade_in_) {
return;
}
join_button->OnMousePressed(x, y);
host_button->OnMousePressed(x, y);
quit_button->OnMousePressed(x, y);
join_button_->OnMousePressed(x, y);
host_button_->OnMousePressed(x, y);
quit_button_->OnMousePressed(x, y);
}

void MenuCanvas::mouseReleased(int x, int y, int button) {
root->SetCursorType(CursorType::kArrow);
root_->SetCursorType(CursorType::kArrow);
if (fade_in_) {
return;
}
join_button->OnMouseReleased(x, y);
host_button->OnMouseReleased(x, y);
quit_button->OnMouseReleased(x, y);
join_button_->OnMouseReleased(x, y);
host_button_->OnMouseReleased(x, y);
quit_button_->OnMouseReleased(x, y);
}

10 changes: 5 additions & 5 deletions src/canvas/menu_canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class MenuCanvas : public gBaseCanvas {
void hideNotify() {}

private:
gApp* root;
Button* join_button;
Button* host_button;
Button* quit_button;
gFont logo_font;
gApp* root_;
Button* join_button_;
Button* host_button_;
Button* quit_button_;
gFont logo_font_;
bool fade_in_;
RGB fade_color_;
RGB back_color_;
Expand Down
15 changes: 6 additions & 9 deletions src/chess/chess_board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,12 @@ bool ChessBoard::IsValidMove(int x, int y, int to_x, int to_y) {
return false;
}
if (piece->IsValidMove(x, y, to_x, to_y)) {
if (piece->GetType() == kPieceTypeKing) {
SetPiece(to_x, to_y, piece);
SetPiece(x, y, nullptr);
auto state = CheckState(GetOppositeColor(piece->GetColor()));
SetPiece(x, y, piece);
SetPiece(to_x, to_y, to_piece);
return state == ChessState::Playing;
}
return true;
SetPiece(to_x, to_y, piece);
SetPiece(x, y, nullptr);
auto state = CheckState(GetOppositeColor(piece->GetColor()));
SetPiece(x, y, piece);
SetPiece(to_x, to_y, to_piece);
return state == ChessState::Playing;
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion znet

0 comments on commit 8df306c

Please sign in to comment.