Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KReversi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Games
KReversi
Commits
a0243986
Commit
a0243986
authored
May 26, 2020
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix clazy warning
parent
d52bf802
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
19 deletions
+15
-19
commondefs.cpp
commondefs.cpp
+2
-2
commondefs.h
commondefs.h
+3
-3
kreversigame.cpp
kreversigame.cpp
+5
-5
kreversigame.h
kreversigame.h
+5
-5
mainwindow.cpp
mainwindow.cpp
+0
-4
No files found.
commondefs.cpp
View file @
a0243986
...
...
@@ -41,14 +41,14 @@ ChipColor Utils::opponentColorFor(ChipColor color)
}
QString
Utils
::
colorToString
(
const
ChipColor
&
color
)
QString
Utils
::
colorToString
(
ChipColor
color
)
{
if
(
Preferences
::
useColoredChips
())
return
(
color
==
Black
?
i18n
(
"Blue"
)
:
i18n
(
"Red"
));
return
(
color
==
Black
?
i18n
(
"Black"
)
:
i18n
(
"White"
));
}
QString
Utils
::
moveToString
(
const
KReversiMove
&
move
)
QString
Utils
::
moveToString
(
KReversiMove
move
)
{
QString
moveString
=
colorToString
(
move
.
color
);
...
...
commondefs.h
View file @
a0243986
...
...
@@ -67,7 +67,7 @@ struct KReversiMove: public KReversiPos {
KReversiMove
(
ChipColor
col
=
NoColor
,
int
r
=
-
1
,
int
c
=
-
1
)
:
KReversiPos
(
r
,
c
),
color
(
col
)
{
}
KReversiMove
(
ChipColor
col
,
const
KReversiPos
&
pos
)
KReversiMove
(
ChipColor
col
,
KReversiPos
pos
)
:
KReversiPos
(
pos
),
color
(
col
)
{
}
ChipColor
color
;
...
...
@@ -109,11 +109,11 @@ ChipColor opponentColorFor(ChipColor color);
/**
* @return Human-readable string representing @p color
*/
QString
colorToString
(
const
ChipColor
&
color
);
QString
colorToString
(
ChipColor
color
);
/**
* @return Human-readable string representing @p move
*/
QString
moveToString
(
const
KReversiMove
&
move
);
QString
moveToString
(
KReversiMove
move
);
/**
* @return Index of current difficulty level in increasing order
*/
...
...
kreversigame.cpp
View file @
a0243986
...
...
@@ -75,7 +75,7 @@ bool KReversiGame::canUndo() const
return
(
m_player
[
m_curPlayer
]
->
isUndoAllowed
()
&&
!
m_undoStack
.
isEmpty
());
}
void
KReversiGame
::
makeMove
(
const
KReversiMove
&
move
)
void
KReversiGame
::
makeMove
(
KReversiMove
move
)
{
if
(
!
move
.
isValid
())
{
kickCurrentPlayer
();
...
...
@@ -174,7 +174,7 @@ int KReversiGame::undo()
return
movesUndone
;
}
void
KReversiGame
::
turnChips
(
const
KReversiMove
&
move
)
void
KReversiGame
::
turnChips
(
KReversiMove
move
)
{
m_changedChips
.
clear
();
...
...
@@ -198,7 +198,7 @@ void KReversiGame::turnChips(const KReversiMove &move)
m_undoStack
.
push
(
m_changedChips
);
}
bool
KReversiGame
::
isMovePossible
(
const
KReversiMove
&
move
)
const
bool
KReversiGame
::
isMovePossible
(
KReversiMove
move
)
const
{
// first - the trivial case:
if
(
m_cells
[
move
.
row
][
move
.
col
]
!=
NoColor
||
move
.
color
==
NoColor
)
...
...
@@ -211,7 +211,7 @@ bool KReversiGame::isMovePossible(const KReversiMove& move) const
return
false
;
}
bool
KReversiGame
::
hasChunk
(
int
dirNum
,
const
KReversiMove
&
move
)
const
bool
KReversiGame
::
hasChunk
(
int
dirNum
,
KReversiMove
move
)
const
{
// On each step (as we proceed) we must ensure that current chip is of the
// opponent color.
...
...
@@ -367,7 +367,7 @@ int KReversiGame::playerScore(ChipColor player) const
return
m_score
[
player
];
}
void
KReversiGame
::
setChipColor
(
const
KReversiMove
&
move
)
void
KReversiGame
::
setChipColor
(
KReversiMove
move
)
{
// first: if the current cell already contains a chip we remove it
if
(
m_cells
[
move
.
row
][
move
.
col
]
!=
NoColor
)
...
...
kreversigame.h
View file @
a0243986
...
...
@@ -177,11 +177,11 @@ private:
* This will make the player @p move
* If that is possible, of course
*/
void
makeMove
(
const
KReversiMove
&
move
);
void
makeMove
(
KReversiMove
move
);
/**
* This function will tell you if the move is possible.
*/
bool
isMovePossible
(
const
KReversiMove
&
move
)
const
;
bool
isMovePossible
(
KReversiMove
move
)
const
;
/**
* Searches for "chunk" in direction @p dirNum for @p move.
* As my English-skills are somewhat limited, let me introduce
...
...
@@ -191,16 +191,16 @@ private:
* CO[O]C <-- this is a chunk
* where [O] is one or more opponent's pieces
*/
bool
hasChunk
(
int
dirNum
,
const
KReversiMove
&
move
)
const
;
bool
hasChunk
(
int
dirNum
,
KReversiMove
move
)
const
;
/**
* Performs @p move, i.e. marks all the chips that player wins with
* this move with current player color
*/
void
turnChips
(
const
KReversiMove
&
move
);
void
turnChips
(
KReversiMove
move
);
/**
* Sets the type of chip according to @p move
*/
void
setChipColor
(
const
KReversiMove
&
move
);
void
setChipColor
(
KReversiMove
move
);
/**
* Delay time
*/
...
...
mainwindow.cpp
View file @
a0243986
...
...
@@ -41,10 +41,6 @@
#include "kreversicomputerplayer.h"
#include "kexthighscore.h"
static
const
int
BLACK_STATUSBAR_ID
=
1
;
static
const
int
WHITE_STATUSBAR_ID
=
2
;
static
const
int
COMMON_STATUSBAR_ID
=
0
;
KReversiMainWindow
::
KReversiMainWindow
(
QWidget
*
parent
,
bool
startDemo
)
:
KXmlGuiWindow
(
parent
),
m_startDialog
(
nullptr
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment