Skip to content

Commit

Permalink
backend files added to main prj
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahdijamebozorg committed Aug 25, 2021
1 parent 6f87319 commit fc80a74
Show file tree
Hide file tree
Showing 44 changed files with 402,667 additions and 1,227 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
src/*
Header/*
include/*
*.o
Binary file modified Advanced_Chess
Binary file not shown.
8 changes: 4 additions & 4 deletions Advanced_Chess.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.0, 2021-08-15T15:25:48. -->
<!-- Written by QtCreator 4.10.0, 2021-08-25T03:41:28. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -66,7 +66,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/mahdi/programming/CPP/Final_project/build-Advanced_Chess-Desktop_Qt_5_13_1_GCC_64bit_qt_qt5-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/mahdi/programming/CPP/Projects/Chess/Advanced_Chess</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
Expand Down Expand Up @@ -302,7 +302,7 @@
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Advanced_Chess</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/mahdi/programming/CPP/Final_project/Advanced_Chess/Advanced_Chess.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/mahdi/programming/CPP/Projects/Chess/temp/Advanced_Chess/Advanced_Chess.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
Expand All @@ -312,7 +312,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/mahdi/programming/CPP/Final_project/build-Advanced_Chess-Desktop_Qt_5_13_1_GCC_64bit_qt_qt5-Debug</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/mahdi/programming/CPP/Projects/Chess/Advanced_Chess</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
Expand Down
Binary file added Assets/Sound_Effects/move.mp3
Binary file not shown.
107 changes: 87 additions & 20 deletions Board.qml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ Item {
width: src.width / 8
height: src.height / 8
border.width: bknd.isMoved(index) ? 3.4 : 0.5

border.color: bknd.isMoved(index) ? "#42e7ac" : "black"
color: "#00000000"

Expand Down Expand Up @@ -156,14 +155,79 @@ Item {

//Chessmen icons
Image {

id: chessmanIcon
source: bknd.getIcon(index)
anchors.centerIn: parent
width: parent.width * 0.95
height: parent.height * 0.95
}
}
}

//_____________________moving animations
OpacityAnimator {
id: destOpasity
target: chessmanIcon
duration: 400
from: 1
to: 0
}
ParallelAnimation {
id: anim
animations: [
NumberAnimation {
id: pieceXAnim
target: chessmanIcon
property: "x"
from: chessmanIcon.x
duration: 400
},
NumberAnimation {
id: pieceYAnim
target: chessmanIcon
property: "y"
from: chessmanIcon.y
duration: 400
}
]

onStopped: {
moveSound.play()
mystack.replace("GamePage.qml")
}
}
Connections {
target: bknd
onMoved: {

//____________________________________________________ unchoose
srcCell.visible = true
dest.visible = false
cellRec.color = "#00000000"

//Heighlight passed cells
cellRec.border.color = bknd.isMoved(
index) ? "#42e7ac" : "balck"

cellRec.border.width = bknd.isMoved(
index) ? 3.4 : 0.5

//___________________________________________________ animations
if (bknd.getDestIndex() === index)
destOpasity.start()

//did not word
// if (chessmanIcon.source === bknd.getHitPiece())
// mystack.pop()
if (bknd.getSrcIndex() === index) {
pieceXAnim.to = (bknd.getDestJ() - bknd.getSrcJ(
)) * cellRec.width
pieceYAnim.to = (bknd.getDestI() - bknd.getSrcI(
)) * cellRec.height
anim.start()
}
}
}
} //Image End
} //CellRec End
} //GridView End

//New grid buttons for move destination
GridView {
Expand All @@ -181,37 +245,42 @@ Item {
model: 64

//Content
delegate: Button {
id: destCell
delegate: Rectangle {
color: "#00000000"
width: dest.width / 8
height: dest.height / 8
flat: true
onClicked: {
//If piece can go there
if (bknd.move(index))
mystack.replace("GamePage.qml")
//If piece can't go to dest and dest is not its current cell
else if (!bknd.unchoosePiece(index)) {
errText.text
= persian.checked ? "نمیتوان به آنجا رفت!" : "Can't move there!"
wrongChoose.open()
Button {
id: destCell
anchors.fill: parent
flat: true
onClicked: {
//If piece can go there
if (bknd.move(index)) {

} //If piece can't go to dest and dest is not its current cell
else if (!bknd.unchoosePiece(index)) {
errText.text
= persian.checked ? "نمیتوان به آنجا رفت!" : "Can't move there!"
wrongChoose.open()
}
}
}
}
}
}
Component.onCompleted: {

switch (bknd.gameStatus()) {
////NORMAL
case 0:
bknd.checkRandomMove()
break

//CHECKED
case 1:
errText.text = persian.checked ? "شما کیش شدید!" : "You're checked!"
wrongChoose.title = persian.checked ? "کیش" : "Checked"
wrongChoose.open()
bknd.checkRandomMove()
break

//STALEMATE
Expand All @@ -222,7 +291,5 @@ Item {
endOfGame.open()
break
}
if (bknd.checkRandomMove())
mystack.replace("GamePage.qml")
}
}
5 changes: 5 additions & 0 deletions BoardBottomSide.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Item {
source: bknd.getP1OutsIcon(index)
width: bottomCell.width * 0.8
height: bottomCell.height * 0.8
NumberAnimation on opacity {
duration: 600
from: 0
to: 1
}
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions BoardLeftSide.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import QtQuick.Window 2.3
Item {
id: left

EndOfGameDialog {
id: endOfGame
}

Dialog {
id: cancelAlert
title: persian.checked ? "آیا مطمعنید؟" : "Are you sure?"
Expand All @@ -15,13 +19,10 @@ Item {
}
standardButtons: Dialog.Ok | Dialog.Cancel
onAccepted: {
bknd.endGame()
mystack.pop()
window.width = Screen.width * 0.5
window.height = Screen.height * 0.75
fullScreen.checked = false
bknd.setCanceler()
endOfGame.open()
}
onRejected: cancelalert.close()
onRejected: cancelAlert.close()
}
Dialog {
id: restartAlert
Expand Down Expand Up @@ -129,7 +130,7 @@ Item {
flat: true
onClicked: {
bknd.undo()
mystack.replace("GamePage.qml")
// mystack.replace("GamePage.qml")
}
Text {
text: persian.checked ? "بازگشت" : "Undo"
Expand Down
5 changes: 2 additions & 3 deletions BoardRightSide.qml
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ Item {
}
Text {
id: p2NegativeScore
text: bknd.getP2_NScore()
horizontalAlignment: Text.AlignHCenter
height: scores2Rec.height * 0.18
width: scores2Rec.width * 0.6
textFormat: Text.StyledText
fontSizeMode: Text.Fit
minimumPixelSize: 2
font.pixelSize: 15
text: bknd.getP2_NScore()
color: "#e2d29d"
anchors.horizontalCenter: score2Col.horizontalCenter
}
Expand Down Expand Up @@ -309,8 +309,7 @@ Item {
anchors.fill: parent
flat: true
onClicked: {
if (bknd.randomMove())
mystack.replace("GamePage.qml")
bknd.randomMove()
}
Text {
text: persian.checked ? "حرکت تصادفی" : "Random Move"
Expand Down
6 changes: 6 additions & 0 deletions BoardTopSide.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ Item {

//outs icons
Image {
id: image
anchors.centerIn: parent
source: bknd.getP2OutsIcon(index)
width: topCell.width * 0.78
height: topCell.height * 0.8
NumberAnimation on opacity {
duration: 600
from: 0
to: 1
}
}
}
}
Expand Down
54 changes: 38 additions & 16 deletions EndOfGameDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import QtQuick.Dialogs 1.2

Dialog {
id: endOfGame
title: persian.checked ? "پایان بازی" : "End of Game"
height: parent.height * 0.17
title: persina.checked ? "پایان بازی" : "End of Game"
width: parent.width * 0.3

contentItem: Rectangle {
Expand Down Expand Up @@ -41,24 +41,47 @@ Dialog {
width: parent.width - 2
font.pixelSize: this.width * 0.1
Component.onCompleted: {
switch (bknd.winner()) {
//user 1
case 0:

bknd.cellState(0)
//------------------------------------------------------------------ title
switch (bknd.gameStatus()) {
case 2:
endOfGame.title = persian.checked ? "پات" : "Stalemate"
break
case 3:
endOfGame.title = persian.checked ? "کیش و مات" : "Checkmate"
break
}

//------------------------------------------------------------------ text
// winner : user 1
if (bknd.winner() === 0)
this.text = persian.checked ? "برنده: " + bknd.getP1Name(
) : "Winner: " + bknd.getP1Name()
break
//user 2
case 1:
endOfGame.title = persian.checked ? "کیش و مات" : "Checkmate"

// winner : user 2
else if (bknd.winner() === 1)
this.text = persian.checked ? "برنده: " + bknd.getP2Name(
) : "Winner: " + bknd.getP2Name()
break
//draw
case 2:
endOfGame.title = persian.checked ? "پات" : "Stalemate"
// draw
else if (bknd.getCanceler() === 2 && bknd.winner() === 2)
this.text = persian.checked ? "مساوی" : "Draw"
break
}
Connections {
target: bknd
onCancel: {
endOfGame.title = persian.checked ? "تسلیم" : "Surrend"
// winner : user 1
if (bknd.getCanceler() === 1)
endGameText.text
= persian.checked ? "برنده: " + bknd.getP1Name(
) : "Winner: " + bknd.getP1Name()

// winner : user 2
else if (bknd.getCanceler() === 0)
endGameText.text
= persian.checked ? "برنده: " + bknd.getP2Name(
) : "Winner: " + bknd.getP2Name()
}
}
}
Expand Down Expand Up @@ -91,12 +114,11 @@ Dialog {
height: parent.height
font.pixelSize: this.width * 0.1
onClicked: {
endOfGame.close()
bknd.endGame()
mystack.pop()
bknd.endGame()
endOfGame.close()
window.width = Screen.width * 0.5
window.height = Screen.height * 0.75
fullScreen.checked = false
}
}
Button {
Expand Down
1 change: 0 additions & 1 deletion LoginPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Page {
}

children: [

//P1 Name
TextField {
id: player1
Expand Down
Loading

0 comments on commit fc80a74

Please sign in to comment.