⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 suoha_main.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/********************************************************************************
 $History: Suoha_main.c
    Date .................. Modification ......................................
    08/14/2002    version 1.1.0 zhangzg 
    08/14/2002    version 1.1.1 zhangzg add a just about focus_opp<4
    08/14/2002    version 1.1.2 zhangzg 
    08/14/2002    version 1.1.3 zhangzg add \x80 before kaolv. To void random code
    08/14/2002    version 1.1.4 zhangzg 
    08/20/2002    version 1.2.0 zhangzg get rid of some bugs
    08/22/2002    version 1.2.4 zhangzg change stake putted
 $End

*******************************************************************************/

#define DEBUG

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "mfw_sys.h"
//#include "typedef.h"
//#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#include "p_sim.h"
#include "cus_aci.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_edt.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_sat.h"
#include "mfw_cnvt.h"
#include "dspl.h"
#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiSoftkeys.h"
#include "MmiIcons.h"
#include "MmiMenu.h"
#include "gdi.h"
#include "Audio.h"
#include "MmiSounds.h"
#include "MmiBookShared.h"
#include "mmi3dframe.h"


#include "suoha_dspl.h"
#include "suoha_algri.h"

#include "suoha_main.h"
#include "wstring.h"

/*****************************************************************************

*****************************************************************************/

//only for test!!
//be displayed in win of checking
const char duishoushengyu[] = "\x5b\xf9\x62\x4b\x52\x69\x4f\x59\x00" ;  ///对手剩余
const char wanjiashengyu[] = "\x73\xa9\x5b\xb6\x52\x69\x4f\x59\x00" ;   ///玩家剩余
const char zuoshangchouma[] = "\x68\x4c\x4e\x0a\x7b\x79\x78\x01\x00" ;  ///桌上筹码
const char duishounewzhu[] = "\x5b\xf9\x62\x4b\x67\x2c\x8f\x6e\x4e\x0b\x6c\xe8\x00";   ///对手本轮下注
//const char wanjia[] = "\0x80\x73\xa9\x5b\xb6\xff\x1a\x00";
const char wanjia[] = "\x73\xa9\x5b\xb6\xff\x1a\x00";

const char wanjiada[] = "\x73\xa9\x5b\xb6\x59\x27\x00";  ///玩家大
const char wanjiayinle[] = "\x73\xa9\x5b\xb6\x8d\x62\x4e\x86\x00" ;  ///玩家赢了
const char wanjiaqing[] = "\x8b\xf7\x73\xa9\x5b\xb6\x00" ;  ///请玩家
const char wanjiaxiazhu[] = "\x4e\x0b\x6c\xe8\xff\x01\x00" ;   ///下注!
const char wanjiamoney[] = "\x73\xa9\x5b\xb6\x4e\x0b\x6c\xe8\x00" ;  //4 玩家下注
const char wanjiagenle[] = "\x73\xa9\x5b\xb6\x8d\xdf\x4e\x86\x00" ;  ///玩家跟了
const char wanjiaquanbu[] = "\x73\xa9\x5b\xb6\x51\x68\x90\xe8\x00";  ///玩家全部
const char wanjiayashangle[] = "\x53\x8b\x4e\x0a\x4e\x86\xff\x01\x00";  ///压上了!
const char wanjiafangqi[] = "\x73\xa9\x5b\xb6\x65\x3e\x5f\x03\x00" ; ///玩家放弃

//const char duishou[] = "\0x80\x5b\xf9\x62\x4b\xff\x1a\x00";
const char duishou[] = "\x5b\xf9\x62\x4b\xff\x1a\x00";

const char duishouda[] = "\x5b\xf9\x62\x4b\x59\x27\x00" ;   ///对手大
const char duishouxiazhu[] = "\x5b\xf9\x62\x4b\x4e\x0b\x6c\xe8\x00" ;   ///对手下注
const char duishougenle[] = "\x5b\xf9\x62\x4b\x8d\xdf\x4e\x86\x00" ; ///对手跟了
const char duishouyinle[] = "\x5b\xf9\x62\x4b\x8d\x62\x4e\x86\x00" ; ///对手赢了
const char duishoufangqi[] = "\x5b\xf9\x62\x4b\x65\x3e\x5f\x03\x00" ;   ///对手放弃
const char duishoukaolv[] = "\x4e\xd4\x7e\xc6\x80\x03\x86\x51\x00" ; ///仔细考虑
const char kaolv[]="\x80\x80\x03\x86\x51\x00" ; ///考虑 //zhangzg 08/14/2002

const char dangqianju[] = "\x5f\x53\x52\x4d\x4e\x3a\x7b\x2c\x00" ;   ///当前为第
const char ju[] = "\x5c\x40\x00" ;///局

const char duibuqi[] = "\x5b\xf9\x4e\x0d\x8d\x77\x60\xa8\x00" ;   ///对不起您
const char buzhu[] = "\x76\x84\x4f\x59\x98\x9d\x4e\x0d\x8d\xb3\xff\x01\x00" ; ///的余额不足!

const char fanhui[] = "\x8f\xd4\x56\xde\x00" ;  ///返回
const char jixu[] = "\x7e\xe7\x7e\xed\x00" ; ///继续

const char tonghuasun[] = "\x54\x0c\x82\xb1\x98\x7a\x00" ;  ///同花顺
const char tiezi[] = "\x94\xc1\x65\x2f\x00" ;   ///铁支
const char hulu[] = "\x84\x6b\x82\xa6\x00" ; ///葫芦
const char tonghua[] = "\x54\x0c\x82\xb1\x00" ; ///同花
const char sunzi[] = "\x98\x7a\x5b\x50\x00" ;   ///顺子
const char shantiao[] = "\x4e\x09\x67\x61\x00" ;   ///三条
const char liangdui[] = "\x4e\x24\x5b\xf9\x00" ;   ///两对
const char duizi[] = "\x5b\xf9\x5b\x50\x00" ;   ///对子
const char shanpai[] = "\x65\x63\x72\x4c\x00" ; ///散牌

/***************************************************************************



****************************************************************************/
#define SUOHA_INIT  121  //initialization event
#define ANIMATION_TIME 200
#define WAIT_TIME 1500 //remaining time of start picture

/***************************************************************************


****************************************************************************/

typedef struct
{
   T_MMI_CONTROL   mmi_control;    // common control parameter
   T_MFW_HND win;
   T_MFW_HND kbd;
   T_MFW_HND tim;
   T_MFW_HND   parent_win; 
   INT8 timNeedStart;
}
T_Suoha;

T_Suoha* data = NULL;

EXTERN const unsigned char suoha_startpic1[], suoha_startpic2[], cardback[];
EXTERN unsigned short curr_CardTh, turnPlayerorComputer;
EXTERN unsigned short c_Cards[5], p_Cards[5];
EXTERN unsigned long  p_M, c_M, p_PreviousM, c_PreviousM,
p_CurrStake, c_CurrStake, desk_CurrStake;
unsigned long casenum=0; //the number of case
unsigned long oppmoney[3] = {CIM, CIM, CIM};
MONEY_SAVED p_c_money = {CIM, CIM, CIM, PIM};

BOOL isInteracting = 0 ; //if 1, computer is thinking, if 0, player can input
//BOOL isPreGame = 0;
BOOL isorsaved = 1;

T_SUOHA_WIN_STATES win_states; // states of whole game
ULONG mainwin_states, pre_mainwin_states;//states of main playing windows
ULONG time_state=0; //timer cb go to corresponding control according to this state
ULONG time_ani_state=0;
UBYTE animation_i=0, animation_j=0, animation_k=0;
UBYTE playermorestake=0;

/*three arrays contain all possible focuses!! It's very important!!*/
T_SUOHA_MAINWIN_FOCUSTHINGS 
playercards[5]
={{{LEFT_WIDTH_CARD,160-TOP_WIDTH_CARD-HEIGHT_CARD, WIDTH_CARD, HEIGHT_CARD}, PLAYER_CARD,0,0},
   {{LEFT_WIDTH_CARD+EXPOSED_WIDTH_CARD,160-TOP_WIDTH_CARD-HEIGHT_CARD, WIDTH_CARD, HEIGHT_CARD}, PLAYER_CARD,1,0},
   {{LEFT_WIDTH_CARD+2*EXPOSED_WIDTH_CARD,160-TOP_WIDTH_CARD-HEIGHT_CARD, WIDTH_CARD, HEIGHT_CARD}, PLAYER_CARD,2,0},
   {{LEFT_WIDTH_CARD+3*EXPOSED_WIDTH_CARD,160-TOP_WIDTH_CARD-HEIGHT_CARD, WIDTH_CARD, HEIGHT_CARD}, PLAYER_CARD,3,0},
   {{LEFT_WIDTH_CARD+4*EXPOSED_WIDTH_CARD,160-TOP_WIDTH_CARD-HEIGHT_CARD, WIDTH_CARD, HEIGHT_CARD}, PLAYER_CARD,4,0}
}, 
computercards[4]
={{{LEFT_WIDTH_CARD+EXPOSED_WIDTH_CARD,TOP_WIDTH_CARD,WIDTH_CARD, HEIGHT_CARD},COMPUTER_CARD, 0,0},
   {{LEFT_WIDTH_CARD+2*EXPOSED_WIDTH_CARD,TOP_WIDTH_CARD,WIDTH_CARD, HEIGHT_CARD},COMPUTER_CARD, 1,0},
   {{LEFT_WIDTH_CARD+3*EXPOSED_WIDTH_CARD,TOP_WIDTH_CARD,WIDTH_CARD, HEIGHT_CARD},COMPUTER_CARD, 2,0},
   {{LEFT_WIDTH_CARD+4*EXPOSED_WIDTH_CARD,TOP_WIDTH_CARD,WIDTH_CARD, HEIGHT_CARD},COMPUTER_CARD, 3,0}
} , 
playeractions[5]
={{{LEFT_ZONE3, TOP_ZONE3, 35, HEIGHT_ZONE},ACTIONS,0,0}, //4 查看
   {{LEFT_ZONE4, TOP_ZONE4, 34, HEIGHT_ZONE},ACTIONS,1,0}, //4 下注
   {{LEFT_ZONE5, TOP_ZONE5, 34, HEIGHT_ZONE}, ACTIONS,2,0}, //4 跟进
   {{LEFT_ZONE6, TOP_ZONE6, 34, HEIGHT_ZONE},ACTIONS,3,0},  //4放弃
   {{LEFT_ZONE7, TOP_ZONE7, 34, HEIGHT_ZONE}, ACTIONS, 4,0} //4 全梭
} ;
//must be initialized!!
T_SUOHA_MAINWIN_FOCUSTHINGS* mainwin_focus=(T_SUOHA_MAINWIN_FOCUSTHINGS*)&playeractions[1];

//
T_SUOHA_CURR_STR 
zone1_curr_str
={0, 1, 2},
zone2_curr_str
={0, 1, 0};

UBYTE focus_opp=1; //which opponent is selected currently

static USHORT unit_length = 500; //indicate the length of money every a pixel
//BOOL isEnd = FALSE; //end flag
unsigned char over_c=0, over_p=0; //true indicates the length of money is too long, otherwise false

char* arraycardtype[9] = 
{
   (char*)shanpai,
   (char*)duizi,
   (char*)liangdui,
   (char*)shantiao,
   (char*)sunzi,
   (char*)tonghua,
   (char*)hulu,
   (char*)tiezi,
   (char*)tonghuasun        
};

extern U8 winfocusout;
extern ffsgamedata ffs_gamedata;
/***************************************************************************



****************************************************************************/

int Suoha_Aktivate(MfwMnu* m, MfwMnuItem* i);
int Suoha_Pre(MfwMnu* m, MfwMnuItem* i);
T_MFW_HND Suoha_Start(T_MFW_HND win_parent,char *character);
T_MFW_HND Suoha_Create(T_MFW_HND parent_window);
static int Suoha_Win_Cb(MfwEvt e, MfwWin *w);
static int Suoha_Kbd_Cb(MfwEvt e, MfwKbd *k);
static int Suoha_Tim_Cb(MfwEvt e, MfwTim *t);
void Suoha_Destroy(T_MFW_HND own_window);
void Suoha(T_MFW_HND win, USHORT event, SHORT value, void * parameter);

//
//extern void Suoha_Display_Start_Picture();

BOOL Opponent_Select_init();
void Play_MainWin_data_Init();
void Play_Start();
void PreFocus();
void NextFocus();
SHORT ComputerAction(USHORT cardnum, UBYTE turnwho);
void Compare ();
USHORT FollorQuit();
void EndOne();
void PublishResults();
void Sleep(USHORT times);
void mfwSleep(U32 tvalue);
void SelectFocusItems();
void SelectAction(USHORT whichaction);
void SelectStake(USHORT whichstake);

void Display_Actions();
void Display_Focus();
void Display_Stakes(ULONG m1, ULONG m2, ULONG m3);
void Display_checkwin();
void Display_Left();
void Display_InteractiveStr(char* txt, char* txt2, ULONG m);
void HideInterArea();

void RedrawCards(USHORT who);
void RedrawMainWin();
void RedrawPreActionFocus(T_SUOHA_MAINWIN_FOCUSTHINGS *prefocus);
void RedrawPreCardFocus(T_SUOHA_MAINWIN_FOCUSTHINGS *prefocus);


void XiaZhu();
void GenJin();
void FangQi();
void QuanSuo();
void CheckCurr();

/*void Money1();
void Money2();
void Money3();
*/
void Money123(UBYTE num);

void Interactive();

void PlayerNoMoney(USHORT cardnum);
char* GetString(char* whochar, char* cardtype);
void GetCardType();
void DisplayCardType(CardType c_CardType, CardType p_CardType);

void SaveMoney();
void TakeMoney();

/****************************************************************************




*****************************************************************************/
int Suoha_Aktivate(MfwMnu* m, MfwMnuItem* i)
{
//	T_Suoha* data;
//	aut = s;
   T_MFW_HND parent = mfwParent( mfw_header());
   TRACE_EVENT("Suoha_Aktivate()");

//new game
//    isPreGame = 0;
   p_M = PIM;
   oppmoney[0] = CIM;
   oppmoney[1] = CIM;
   oppmoney[2] = CIM;

   p_c_money.opp1_money = oppmoney[0];
   p_c_money.opp2_money = oppmoney[1];
   p_c_money.opp3_money = oppmoney[2];
   p_c_money.player_money = p_M;

   Suoha_Start(parent,0);
   return MFW_EVENT_CONSUMED;

//char welcome[] = {0x6b,0x22,0x8f,0xce};
//dspl_ClearAll();
//dspl_TextOut(45, 70, 0, "welcome!");
}
int Suoha_Pre(MfwMnu* m, MfwMnuItem* i)
{
   T_MFW_HND parent; 
   TakeMoney();

   oppmoney[0] = p_c_money.opp1_money;
   oppmoney[1] = p_c_money.opp2_money;
   oppmoney[2] = p_c_money.opp3_money;
   p_M = p_c_money.player_money;       

//	isPreGame = 1;
   parent = mfwParent( mfw_header());
   Suoha_Start(parent,0);
   return MFW_EVENT_CONSUMED;

}

//MONEY_SAVED p_c_money = {20000,20000,20000,15000};

void TakeMoney()
{
   p_c_money=ffs_gamedata.p_c_ffsmoney;

}
void SaveMoney()
{
   p_c_money.opp1_money = oppmoney[0];
   p_c_money.opp2_money = oppmoney[1];
   p_c_money.opp3_money = oppmoney[2];
   p_c_money.player_money = p_M;
   ffs_gamedata.p_c_ffsmoney = p_c_money;
   p_c_money.opp1_money = 0;
   p_c_money.opp2_money = 0;
   p_c_money.opp3_money = 0;
   p_c_money.player_money = 0;  
}

T_MFW_HND Suoha_Start(T_MFW_HND win_parent,char *character)
{
   T_MFW_HND win = Suoha_Create (win_parent);

   TRACE_EVENT("Suoha_Start");

   if (win NEQ NULL)
   {
      SEND_EVENT(win,SUOHA_INIT,0,character);
   }
   return win;
}

T_MFW_HND Suoha_Create(T_MFW_HND parent_window)
{
   T_MFW_WIN* win;

   /*
    * This window is dynamic, for that reason the associated data are allocated in the mfw heap
    */
   data = (T_Suoha *)ALLOC_MEMORY (sizeof (T_Suoha));

//	T_Suoha* data = (T_Suoha *)ALLOC_MEMORY (sizeof (T_Suoha));

   TRACE_FUNCTION ("Suoha_Create()");

   /*
    * Create window handler
    */
   // mfwSetSignallingMethod(1);
   //winAutoFocus(0);

   data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)Suoha_Win_Cb);

   if (data->win EQ 0)
      return 0;

   /*
    * These assignments are necessary to attach the data to the window, 
    * and to handle the mmi event communication.
    */

   data->mmi_control.dialog    = (T_DIALOG_FUNC)Suoha;
   data->mmi_control.data      = data;
   win                         = ((T_MFW_HDR *)data->win)->data;
   win->user                   = (void *) data;
   data->parent_win    =  parent_window;
   data->timNeedStart=0;

   /*
   * Create any other handler
   */

   data->kbd      = kbd_create (data->win,KEY_ALL,(T_MFW_CB)Suoha_Kbd_Cb);
   data->tim      = timCreate(data->win, ANIMATION_TIME, (MfwCb)Suoha_Tim_Cb);

   win_states = SUOHA_START_ANI;
   winShow(data->win);

   return data->win;
}

void Suoha(T_MFW_HND win, USHORT event, SHORT value, void * parameter)
{
   T_MFW_WIN      * win_data = ((T_MFW_HDR *) win)->data;
   T_Suoha       * data = (T_Suoha *)win_data->user;

   TRACE_FUNCTION ("Suoha()");

   switch (event)
   {
   case SUOHA_INIT:
      //dspl_SetTxtTransparent(1);
      break;
   default :
      break;
   }
}

static int Suoha_Win_Cb(MfwEvt e, MfwWin *w)
{

   T_Suoha* data = (T_Suoha*)w->user;
   MfwRect rect = {0,0,120,160};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -