File indexing completed on 2022-09-27 13:16:04

0001 /*
0002     SPDX-FileCopyrightText: 2013 Denis Kuplyakov <dener.kup@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "kreversihumanplayer.h"
0008 
0009 KReversiHumanPlayer::KReversiHumanPlayer(ChipColor color, const QString &name):
0010     KReversiPlayer(color, name, true, true)
0011 {
0012 }
0013 
0014 void KReversiHumanPlayer::prepare(KReversiGame* game)
0015 {
0016     // ready to start
0017     m_game = game;
0018     m_state = WAITING;
0019 
0020     Q_EMIT ready();
0021 }
0022 
0023 void KReversiHumanPlayer::takeTurn()
0024 {
0025     m_state = THINKING;
0026 }
0027 
0028 void KReversiHumanPlayer::skipTurn()
0029 {
0030     m_state = WAITING; // waiting for opponent move
0031 }
0032 
0033 void KReversiHumanPlayer::gameOver()
0034 {
0035     m_state = UNKNOWN; // game ended
0036 }
0037 
0038 void KReversiHumanPlayer::onUICellClick(KReversiPos pos)
0039 {
0040     if (m_state != THINKING) {
0041         // it is not our turn ignore it
0042         return;
0043     }
0044 
0045     m_state = WAITING;
0046     Q_EMIT makeMove(KReversiMove(m_color, pos));
0047 }