src/Card.c
[NalaBridge.git] / src / GameCtr.c~
blob2efc41f40d50769be45d08d71b8c44d91f16ba49
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);
55   C_Class PlayerClass south=NewClass(PlayerClass,south);
57   /*
58   GameData.current=west;//FIXME:×¢Ò⿼ÂÇÈçºÎ½«¿ØÖÆȨ½»¸øµ±Ç°Íæ¼Ò£¬ÊDZ¾³ÌÐòCOOʵÏֵĹؼüÖ®ËùÔÚ£»
59                         //FIXME:Ä¿Ç°»¹ÓдýÍêÉÆ£»*/
61   assert(g.run.bid!=NULL);
62   g.run.bid();
63   printf("g.run.noend()=%d\n",g.run.noend());
65   while (g.run.noend()==TRUE)
66     {
67       puts("ok here!\n");
69       GameData.end_vote++;//ʵ¼ÊÉÏGameDataÔÚ±à³ÌÖв»¿É¼û£¬ÒªÍ¨¹ý·½·¨À´ÉèÖÃËü£¬´Ë´¦Ö»ÊÇʾÀý£»
70       g.run.play();
71       //FIXME:´Ë´¦Ó¦ÕâÑù:
72       //g.run.refresh();
73     }
74   return OK;
78 /**
79  * \fn int GameRestart()
80  * @return ERROR number
81 \brief ÖØÆôÓÎÏ·
82 \n ÓÎÏ·ÖØÐÂÆô¶¯£¬Ð¿ªÒ»¾ÖÓÎÏ·
83  */
84 int GameRestart()
87 /**
88  * \fn int GameEnd()
89  * @return ERROR number
90 \brief ÓÎÏ·½áÊø
91 \n ½áÊøÓÎÏ·£¬²¢Í˳ö
92  */
93 int GameEnd()
96 /**
97  * \fn int GameScoreDisplay()
98  * @return ERROR number
99 \brief ÏÔʾÓÎÏ··ÖÊý
100 \n ÏÔʾµ½Ä¿Ç°ÎªÖ¹ÓÎÏ·½ø¶È¸÷¸öÍæ¼ÒµÄ·ÖÊý
101  */
102 int GameScoreDisplay()
106  * \fn int NoQuit()
107  * @return ERROR number
108 \brief ÅжÏÒ»¾ÖÓÎÏ·ÊÇ·ñ½áÊø
109 \n Í¨¹ýÅжÏÍæ¼ÒµÄ Íê½áͶƱ À´¾ö¶¨ÊÇ·ñ½áÊøÒ»¾ÖÓÎÏ·
110 \n Í¨³£Èç¹û½áÊøµÄ»°Òâζ×Å£º(1)ÅÆÒѾ­³öÍê¡¢(2)½ÐÅÆÍê³É¡¢(3)ËùÓÐÍæ¼Òͨ¹ýʤÀûÐûÑÔ
111  */
112 int NoQuit()
114   return IsEqu(GameData.no_quit,NO);
118  * \fn int GameInit(game *g)
119  * @param g 
120  * @return ERROR number
121 \brief ³õʼ»¯ÓÎÏ·Êý¾Ý
122 \n ½«ÓÎÏ·Àà¡¢Íæ¼ÒÀàµÄÊý¾Ý³õʼ»¯
123  */
124 int GameInit(game *g)
127   //SetData(*g,Init);
128   //*g={0};
129   SetData(g->trump ,South);
130   SetData(g->end_vote ,Begin);
131   //SetData(g->bid_order,Init);
132   //SetData(g->bid_list,Init);
133   //FIXME;
134   //´Ë´¦ÐèÒª¸Ä½ø£¬¹ØÓÚÊý¾ÝÀàÐ͵Ä×Ô¶¯Ê¶±ð¼°³õʼ»¯£»
136   SetData(g->play_order ,Init);
137   SetData(g->NS_score ,Init);
138   SetData(g->EW_score ,Init);
140   SetFunc(g->run.bid ,GameBid);
141   SetFunc(g->run.play ,GamePlay);
142   SetFunc(g->run.refresh ,GameRefresh);
143   SetFunc(g->run.noend ,NoEnd);
144   SetFunc(g->run.isfull ,GameIsFull);
145   SetFunc(g->run.join ,GameJoin);