src/Card.c
[NalaBridge.git] / src / #GameCtr.c#
blob50f6ffc692d534946a3b9eb2cc6a85c775b39f34
1 /***************************************************************************
2  *   Copyright (C) 2008 by NalaGinrut   *
3  *   suimualatsuki@163.com   *
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  ***************************************************************************/
21 /*!
22 \file GameCtr.h
23 \brief ‘°ü‘º¬Game‘¿Ø‘ÖÆ‘µÄ‘Ëù‘ÓБº¯‘Êý
26 #include <stdio.h>
27 #include <assert.h>
29 #include "Game.h"
30 #include "COO.h"
31 #include "GameCtr.h"
32 #include "Player.h"
33 #include "my_types.h"
35 //‘¿Ø‘ÖÆ‘º¯‘Êý‘Ì呵đʵ‘ÏÖ
37 /**
38 \var GameData
39 \brief ‘È«‘¾Ö‘¿Ø‘ÖÆ‘±ä‘Á¿
40  */
41 extern global_data GameData;
43 /**
44  * \fn int GameStart()
45  * @return ERROR number
46  \brief ‘ÓΑϷ‘Æô‘¶¯
47 \n ‘Æô‘¶¯‘ÓΑϷ‘¹ý‘³Ì
48  */
49 int GameStart()
51   C_Class GameClass g=NewClass(GameClass,g);
52   C_Class PlayerClass west=NewClass(PlayerClass,west);
53   C_Class PlayerClass north=NewClass(PlayerClass,north);
54   C_Class PlayerClass east=NewClass(PlayerClass,east);
56   C_Class PlayerClass south=NewClass(PlayerClass,south);
58   /*
59   GameData.current=west;//FIXME:‘×¢‘Òâ‘¿¼‘ÂÇ‘È瑺Α½«‘¿Ø‘ÖƑȨ‘½»‘¸ø‘µ±‘Ç°‘Í摼ґ£¬‘ÊÇ‘±¾‘³Ì‘ÐòCOO‘ʵ‘ÏÖ‘µÄ‘¹Ø‘¼ü‘Ö®‘Ëù‘ÔÚ‘£»
60                         //FIXME:‘Ä¿‘Ç°‘»¹‘ÓБ´ý‘Íê‘ÉÆ‘£»*/
62   assert(g.run.bid!=NULL);
63   g.run.bid();
64   printf("g.run.noend()=%d\n",g.run.noend());
66   while (g.run.noend()==TRUE)
67     {
68       puts("ok here!\n");
70       GameData.end_vote++;//‘ʵ‘¼Ê‘ÉÏGameData‘ÔÚ‘±à‘³Ì‘ÖБ²»‘¿É‘¼û‘£¬‘Òª‘ͨ‘¹ý‘·½‘·¨‘À´‘Éè‘ÖÑËü‘£¬‘´Ë‘´¦‘Ö»‘ÊǑʾ‘Àý‘£»
71       g.run.play();
72       //FIXME:‘´Ë‘´¦‘Ó¦‘Õâ‘Ñù:
73       //g.run.refresh();
74     }
75   return OK;
79 /**
80  * \fn int GameRestart()
81  * @return ERROR number
82 \brief ‘ÖØ‘Æô‘ÓΑϷ
83 \n ‘ÓΑϷ‘ÖؑБÆô‘¶¯‘£¬‘Б¿ª‘Ò»‘¾Ö‘ÓΑϷ
84  */
85 int GameRestart()
88 /**
89  * \fn int GameEnd()
90  * @return ERROR number
91 \brief ‘ÓΑϷ‘½á‘Êø
92 \n ‘½á‘Êø‘ÓΑϷ‘£¬‘²¢‘ÍË‘³ö
93  */
94 int GameEnd()
97 /**
98  * \fn int GameScoreDisplay()
99  * @return ERROR number
100 \brief ‘Ïԑʾ‘ÓΑϷ‘·Ö‘Êý
101 \n ‘Ïԑʾ‘µ½‘Ä¿‘Ç°‘Ϊ‘Ö¹‘ÓΑϷ‘½ø‘¶È‘¸÷‘¸ö‘Í摼ґµÄ‘·Ö‘Êý
102  */
103 int GameScoreDisplay()
107  * \fn int NoQuit()
108  * @return ERROR number
109 \brief ‘ÅБ¶Ï‘Ò»‘¾Ö‘ÓΑϷ‘ÊÇ‘·ñ‘½á‘Êø
110 \n ‘ͨ‘¹ý‘ÅБ¶Ï‘Í摼ґµÄ ‘Íꑽá‘Ͷ‘Ʊ ‘À´‘¾ö‘¶¨‘ÊÇ‘·ñ‘½á‘Êø‘Ò»‘¾Ö‘ÓΑϷ
111 \n ‘ͨ‘³£‘È瑹û‘½á‘Êø‘µÄ‘»°‘Òâ‘ζ‘×Å‘£º(1)‘ÅÆ‘ÒÑ‘¾­‘³ö‘Íê‘¡¢(2)‘½Ð‘ÅÆ‘Íꑳɑ¡¢(3)‘Ëù‘ÓБÍ摼ґͨ‘¹ý‘ʤ‘Àû‘Ðû‘ÑÔ
112  */
113 int NoQuit()
115   return IsEqu(GameData.no_quit,NO);
119  * \fn int GameInit(game *g)
120  * @param g
121  * @return ERROR number
122 \brief ‘³õ‘ʼ‘»¯‘ÓΑϷ‘Êý‘¾Ý
123 \n ‘½«‘ÓΑϷ‘Àà‘¡¢‘Í摼ґÀà‘µÄ‘Êý‘¾Ý‘³õ‘ʼ‘»¯
124  */
125 int GameInit(game *g)
128   //SetData(*g,Init);
129   //*g={0};
130   SetData(g->trump ,South);
131   SetData(g->end_vote ,Begin);
132   //SetData(g->bid_order,Init);
133   //SetData(g->bid_list,Init);
134   //FIXME;
135   //‘´Ë‘´¦‘Ðè‘Òª‘¸Ä‘½ø‘£¬‘¹Ø‘ÓÚ‘Êý‘¾Ý‘Àà‘ÐÍ‘µÄ‘×Ô‘¶¯‘ʶ‘±ð‘¼°‘³õ‘ʼ‘»¯‘£»
137   SetData(g->play_order ,Init);
138   SetData(g->NS_score ,Init);
139   SetData(g->EW_score ,Init);
141   SetFunc(g->run.bid ,GameBid);
142   SetFunc(g->run.play ,GamePlay);
143   SetFunc(g->run.refresh ,GameRefresh);
144   SetFunc(g->run.noend ,NoEnd);
145   SetFunc(g->run.isfull ,GameIsFull);
146   SetFunc(g->run.join ,GameJoin);