Debian Codegraph @

src/humanplayer.cc

raw symbols SCIP
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
21 #include <QDebug>
22
23 #include "humanplayer.h"cxx . . $ `<file>/src/humanplayer.h`/
24 #include "rcheckers.h"cxx . . $ `<file>/src/rcheckers.h`/
25 #include "echeckers.h"cxx . . $ `<file>/src/echeckers.h`/
26 #include "pdn.h"cxx . . $ `<file>/src/pdn.h`/
27
28
29 myHumanPlayercxx . . $ myHumanPlayer#::myHumanPlayercxx . . $ myHumanPlayer#myHumanPlayer(5f6801bd00533ebd).(const QStringcxx . . $ QString#& name, bool white,
30 bool second_player)
31 : myPlayercxx . . $ myPlayer#(name, white)
32 {
33 selectedcxx . . $ myHumanPlayer#selected. = false;
34
35 m_secondcxx . . $ myHumanPlayer#m_second. = second_player;
36 m_gamecxx . . $ myHumanPlayer#m_game. = 0;
37 }
38
39
40 myHumanPlayercxx . . $ myHumanPlayer#::~cxx . . $ myHumanPlayer#`~myHumanPlayer`(ced63f7c635d850d).myHumanPlayercxx . . $ myHumanPlayer#()
41 {
42 }
43
44
45 void myHumanPlayercxx . . $ myHumanPlayer#::yourTurncxx . . $ myHumanPlayer#yourTurn(9164dfc221f1086f).(const Checkerscxx . . $ Checkers#* g)
46 {
47 if(!m_gamecxx . . $ myHumanPlayer#m_game. || m_gamecxx . . $ myHumanPlayer#m_game.->typecxx . . $ Checkers#type(455f465bc33b4cdf).()!=g->typecxx . . $ Checkers#type(455f465bc33b4cdf).()) {
48 delete m_gamecxx . . $ myHumanPlayer#m_game.;
49 if(g->typecxx . . $ Checkers#type(455f465bc33b4cdf).()==RUSSIANcxx . . $ `src/pdn.h:35:9`!) {
50 m_gamecxx . . $ myHumanPlayer#m_game. = new RCheckerscxx . . $ RCheckers#();
51 } else {
52 m_gamecxx . . $ myHumanPlayer#m_game. = new ECheckerscxx . . $ ECheckers#();
53 }
54 }
55
56 // synchronize
57 m_gamecxx . . $ myHumanPlayer#m_game.->fromStringcxx . . $ Checkers#fromString(e1defb592416720d).(g->toStringcxx . . $ Checkers#toString(11ecdffe9192d1a2).(m_secondcxx . . $ myHumanPlayer#m_second.));
58 }
59
60 bool myHumanPlayercxx . . $ myHumanPlayer#::fieldClickedcxx . . $ myHumanPlayer#fieldClicked(3ac92b0331bc49b4).(int field_num, bool* select, bool bottom_is_white, QStringcxx . . $ QString#& errmsg)
61 {
62 if(m_secondcxx . . $ myHumanPlayer#m_second.) {
63 field_num = 31 - field_num;
64 }
65
66 switch(m_gamecxx . . $ myHumanPlayer#m_game.->itemcxx . . $ Checkers#item(7ccb52b1bfe01045).(field_num)) {
67 case MAN1cxx . . $ `src/checkers.h:33:9`!:
68 case KING1cxx . . $ `src/checkers.h:34:9`!: {
69 Capturescxx . . $ Captures#* capture = m_gamecxx . . $ myHumanPlayer#m_game.->getPossibleCapturecxx . . $ Checkers#getPossibleCapture(c7fafa7f4063b43f).();
70 bool must_capture = !capture->isEmptycxx . . $ Captures#isEmpty(50ce9a9e25b4a850).() && !m_gamecxx . . $ myHumanPlayer#m_game.->canCapture1cxx . . $ Checkers#canCapture1(83c267b20bac841a).(field_num);
71 QStringcxx . . $ QString# captureStr = m_gamecxx . . $ myHumanPlayer#m_game.->describeCapturecxx . . $ Checkers#describeCapture(6184de0e49b7442e).(bottom_is_white, capture);
72 delete capture;
73 if (must_capture) {
74 errmsg =cxx . . $ QString#`operator=`(4f35bf974e7f8568). trcxx . . $ myHumanPlayer#tr(75d9f1c324b4579d).("You must capture. Available moves are: %1").argcxx . . $ QString#arg(bc823072288cbbb5).(captureStr);
75 return false;
76 }
77 if(!m_gamecxx . . $ myHumanPlayer#m_game.->canCapture1cxx . . $ Checkers#canCapture1(83c267b20bac841a).(field_num)
78 && !m_gamecxx . . $ myHumanPlayer#m_game.->canMove1cxx . . $ Checkers#canMove1(83c267b20bac841a).(field_num)) {
79 errmsg =cxx . . $ QString#`operator=`(4f35bf974e7f8568). trcxx . . $ myHumanPlayer#tr(75d9f1c324b4579d).("This unit does not have valid moves.");//TODO better text.
80 return false;
81 }
82
83 // Player (re)selects
84 fromcxx . . $ myHumanPlayer#from. = field_num;
85 fromFieldcxx . . $ myHumanPlayer#fromField. = field_num;
86 selectedcxx . . $ myHumanPlayer#selected. = true;
87 *select = true;
88 return true;
89 break;
90 }
91
92 case FREEcxx . . $ `src/checkers.h:35:9`!:
93 if(!selectedcxx . . $ myHumanPlayer#selected.) {
94 return true;
95 }
96
97 if (!gocxx . . $ myHumanPlayer#go(83c267b20bac841a).(field_num)) {
98 errmsg =cxx . . $ QString#`operator=`(4f35bf974e7f8568). trcxx . . $ myHumanPlayer#tr(75d9f1c324b4579d).("This unit cannot be moved to field you pointed.");
99 return false; // incorrect course
100 }
101
102 // move done - unselect
103 if(selectedcxx . . $ myHumanPlayer#selected.) {
104 *select = false;
105 }
106 selectedcxx . . $ myHumanPlayer#selected. = false;
107
108 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! moveDonecxx . . $ myPlayer#moveDone(3520e46b33348bf6).(m_gamecxx . . $ myHumanPlayer#m_game.->toStringcxx . . $ Checkers#toString(11ecdffe9192d1a2).(m_secondcxx . . $ myHumanPlayer#m_second.));
109 break;
110
111 default:
112 break;
113 }
114
115 return true;
116 }
117
118
119 bool myHumanPlayercxx . . $ myHumanPlayer#::gocxx . . $ myHumanPlayer#go(83c267b20bac841a).(int to)
120 {
121 return m_gamecxx . . $ myHumanPlayer#m_game.->go1cxx . . $ Checkers#go1(cf9ef193275fa6d8).(fromcxx . . $ myHumanPlayer#from., to);
122 }
123