| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2004-2007 Artur Wiebe * |
| 3 | * [email protected] * |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 2 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program; if not, write to the * |
| 17 | * Free Software Foundation, Inc., * |
| 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 19 | ***************************************************************************/ |
| 20 | #include <QDebug> |
| 21 | #include <QApplication> |
| 22 | #include <QEvent> |
| 23 | |
| 24 | #include "computerplayer.h"cxx . . $ `<file>/src/computerplayer.h`/ |
| 25 | #include "pdn.h"cxx . . $ `<file>/src/pdn.h`/ |
| 26 | #include "rcheckers.h"cxx . . $ `<file>/src/rcheckers.h`/ |
| 27 | #include "echeckers.h"cxx . . $ `<file>/src/echeckers.h`/ |
| 28 | #include "checkers.h"cxx . . $ `<file>/src/checkers.h`/ |
| 29 | |
| 30 | |
| 31 | myComputerPlayercxx . . $ myComputerPlayer#::myComputerPlayercxx . . $ myComputerPlayer#myComputerPlayer(f9776a75d1fc6294).(const QStringcxx . . $ QString#& name, bool white, int skill) |
| 32 | : myPlayercxx . . $ myPlayer#(name, white) |
| 33 | { |
| 34 | m_gamecxx . . $ myComputerPlayer#m_game. = 0; |
| 35 | m_threadcxx . . $ myComputerPlayer#m_thread. = 0; |
| 36 | m_skillcxx . . $ myComputerPlayer#m_skill. = skill; |
| 37 | } |
| 38 | |
| 39 | |
| 40 | myComputerPlayercxx . . $ myComputerPlayer#::~cxx . . $ myComputerPlayer#`~myComputerPlayer`(ced63f7c635d850d).myComputerPlayercxx . . $ myComputerPlayer#() |
| 41 | { |
| 42 | if(m_threadcxx . . $ myComputerPlayer#m_thread.) { |
| 43 | m_threadcxx . . $ myComputerPlayer#m_thread.->stopcxx . . $ myThread#stop(49f6e7a06ebc5aa8).(); |
| 44 | // delete m_thread |
| 45 | } |
| 46 | delete m_gamecxx . . $ myComputerPlayer#m_game.; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | void myComputerPlayercxx . . $ myComputerPlayer#::yourTurncxx . . $ myComputerPlayer#yourTurn(9164dfc221f1086f).(const Checkerscxx . . $ Checkers#* g) |
| 51 | { |
| 52 | if(m_threadcxx . . $ myComputerPlayer#m_thread.) { |
| 53 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("myComputerPlayer::yourTurn: a thread exists."); |
| 54 | } |
| 55 | |
| 56 | // first create it. |
| 57 | if(!m_gamecxx . . $ myComputerPlayer#m_game. || m_gamecxx . . $ myComputerPlayer#m_game.->typecxx . . $ Checkers#type(455f465bc33b4cdf).()!=g->typecxx . . $ Checkers#type(455f465bc33b4cdf).()) { |
| 58 | delete m_gamecxx . . $ myComputerPlayer#m_game.; |
| 59 | if(g->typecxx . . $ Checkers#type(455f465bc33b4cdf).()==RUSSIANcxx . . $ `src/pdn.h:35:9`!) { |
| 60 | m_gamecxx . . $ myComputerPlayer#m_game. = new RCheckerscxx . . $ RCheckers#(); |
| 61 | } else { |
| 62 | m_gamecxx . . $ myComputerPlayer#m_game. = new ECheckerscxx . . $ ECheckers#(); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | m_gamecxx . . $ myComputerPlayer#m_game.->setSkillcxx . . $ Checkers#setSkill(d4f767463ce0a6b3).(m_skillcxx . . $ myComputerPlayer#m_skill.); |
| 67 | m_gamecxx . . $ myComputerPlayer#m_game.->fromStringcxx . . $ Checkers#fromString(e1defb592416720d).(g->toStringcxx . . $ Checkers#toString(11ecdffe9192d1a2).(false)); |
| 68 | |
| 69 | m_threadcxx . . $ myComputerPlayer#m_thread. = new myThreadcxx . . $ myThread#myThread(bf0a7e61153f5cc1).(this, m_gamecxx . . $ myComputerPlayer#m_game.); |
| 70 | m_threadcxx . . $ myComputerPlayer#m_thread.->startcxx . . $ QThread#start(bd4fe741c868f69f).(); |
| 71 | } |
| 72 | |
| 73 | |
| 74 | void myComputerPlayercxx . . $ myComputerPlayer#::stopcxx . . $ myComputerPlayer#stop(49f6e7a06ebc5aa8).() |
| 75 | { |
| 76 | if(m_threadcxx . . $ myComputerPlayer#m_thread.) { |
| 77 | m_threadcxx . . $ myComputerPlayer#m_thread.->stopcxx . . $ myThread#stop(49f6e7a06ebc5aa8).(); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | |
| 82 | void myComputerPlayercxx . . $ myComputerPlayer#::customEventcxx . . $ myComputerPlayer#customEvent(c2473e2e70986fd7).(QEventcxx . . $ QEvent#* ev) |
| 83 | { |
| 84 | if(ev->typecxx . . $ QEvent#type(916a8de57f4d422b).() == QEventcxx . . $ QEvent#::MaxUsercxx . . $ QEvent#MaxUser.) { |
| 85 | m_threadcxx . . $ myComputerPlayer#m_thread.->waitcxx . . $ QThread#wait(534bc65d63671d2b).(); |
| 86 | |
| 87 | delete m_threadcxx . . $ myComputerPlayer#m_thread.; |
| 88 | m_threadcxx . . $ myComputerPlayer#m_thread. = 0; |
| 89 | |
| 90 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! moveDonecxx . . $ myPlayer#moveDone(3520e46b33348bf6).(m_gamecxx . . $ myComputerPlayer#m_game.->toStringcxx . . $ Checkers#toString(11ecdffe9192d1a2).(false)); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | |
| 95 | |
| 96 | /**************************************************************************** |
| 97 | * |
| 98 | * |
| 99 | ***************************************************************************/ |
| 100 | void myThreadcxx . . $ myThread#::runcxx . . $ myThread#run(49f6e7a06ebc5aa8).() |
| 101 | { |
| 102 | m_gamecxx . . $ myThread#m_game.->go2cxx . . $ Checkers#go2(49f6e7a06ebc5aa8).(); |
| 103 | if(!m_abortedcxx . . $ myThread#m_aborted.) { |
| 104 | QEventcxx . . $ QEvent#* ev = new QEventcxx . . $ QEvent#QEvent(ef9f6271f61bf4a0).(QEventcxx . . $ QEvent#::MaxUsercxx . . $ QEvent#MaxUser.); |
| 105 | QApplicationcxx . . $ QApplication#::postEventcxx . . $ QCoreApplication#postEvent(342146acb36c30fd).(m_playercxx . . $ myThread#m_player., ev); |
| 106 | } else { |
| 107 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("thread.aborted.done."); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | |
| 112 | void myThreadcxx . . $ myThread#::stopcxx . . $ myThread#stop(49f6e7a06ebc5aa8).() |
| 113 | { |
| 114 | m_abortedcxx . . $ myThread#m_aborted. = true; |
| 115 | m_gamecxx . . $ myThread#m_game.->setSkillcxx . . $ Checkers#setSkill(d4f767463ce0a6b3).(0); |
| 116 | } |
| 117 |