📄 suoha_main.c
字号:
uMode = dspl_Enable(0);
if (who==PLAYER) //
{
for (i=0;i<=curr_CardTh-1;i++)
{
DisplayOneCard(PLAYER, i+1, p_Cards[i]);
}
} else //redraw the cards of computer
{
DisplayOneCard(COMPUTER, BACKCARD, c_Cards[0]);
for (i=1;i<=curr_CardTh-1;i++)
{
DisplayOneCard(COMPUTER, i+1, c_Cards[i]);
}
}
dspl_Enable(uMode);
}
//4 如果上一次是聚焦在按钮上,那么需要重新画按钮,对于注和动作是有区别的
void RedrawPreActionFocus(T_SUOHA_MAINWIN_FOCUSTHINGS *prefocus)
{
USHORT i;
switch (prefocus->thingtype)
{
case STAKES:
Display_Actions();
XiaZhu();
break;
case ACTIONS:
//4 画一下需要画的按钮,因为顺序是从1开始并且前面2个是文本所以加3
i = prefocus->codenum; //codenum = 0~4
DisplayZone(i+3, 0, DSPL_TXTATTR_UNICODE); //i = 3~7
break;
default:
DisplayZone(3, 0, DSPL_TXTATTR_UNICODE); //i = 3~7
break;
}
}
//4因为如果小手是聚焦在扑克牌上那么移开的时候只需要刷新小手所在的位置,
//4而手在的位置是空白,所以设成白色即可
void RedrawPreCardFocus(T_SUOHA_MAINWIN_FOCUSTHINGS *prefocus)
{
USHORT i;
MfwRect rect;
i = prefocus->codenum;
if (prefocus->thingtype==COMPUTER_CARD) //4如果是聚焦在电脑的牌上
{
rect.px = LEFT_WIDTH_CARD+(i+1)*EXPOSED_WIDTH_CARD+LEFT_HAND-2;
rect.py = TOP_WIDTH_CARD+TOP_HAND-2;
rect.sx = 11;
rect.sy = 14;
PaintBackground(rect, 0xffffff); //fill with white color
} else
{//4如果是聚焦在玩家的牌上
rect.px = LEFT_WIDTH_CARD+i*EXPOSED_WIDTH_CARD+LEFT_HAND-2;
rect.py = 160-HEIGHT_CARD+TOP_HAND-2;
rect.sx = 11;
rect.sy = 14;
PaintBackground(rect, 0xffffff); //fill with white color
}
}
/********************************************************************
when entering the action of "chakan", the checking window appears. In this window, many items are published
*********************************************************************/
void Display_checkwin()
{
char m[20];
MfwRect rect = {0,0,120,160};
PaintBackground(rect, 0x80ffff); //浅蓝色
Display_Left();
//display the newest stake 对手 is chipping in
//4 显示对手下注的情况,和桌面上还剩多少钱
sprintf(m, "$%d", c_CurrStake);
dspl_TextOut(5, 72+over_c*17+over_p*17, DSPL_TXTATTR_UNICODE | DSPL_TXTATTR_TRANSPARENT, (char *)duishounewzhu);
dspl_TextOut(20, 89+over_c*17+over_p*17, DSPL_TXTATTR_NORMAL| DSPL_TXTATTR_TRANSPARENT, (char *) m);
sprintf(m, "$%d", desk_CurrStake);
dspl_TextOut(1, 107+over_c*17+over_p*17, DSPL_TXTATTR_UNICODE | DSPL_TXTATTR_TRANSPARENT, (char *) zuoshangchouma);
dspl_TextOut(68, 107+over_c*17+over_p*17, DSPL_TXTATTR_NORMAL| DSPL_TXTATTR_TRANSPARENT, (char *) m);
}
//display the left money of both computer and player
//4 显示对手和玩家所拥有的注的情况
void Display_Left()
{
char m[20];
USHORT length_player, length_computer;
U32 oldcolor;
length_player = p_M/unit_length;
if ((p_M-length_player*unit_length)>unit_length/2)
length_player++;
if (length_player>116)
over_p=1;
else
over_p=0;
length_computer = c_M/unit_length;
if ((c_M-length_computer*unit_length)>unit_length/2)
length_computer++;
if (length_computer>116)
over_c=1;
else
over_c=0;
sprintf(m, "$%d", c_M);
dspl_TextOut(1, 2, DSPL_TXTATTR_UNICODE | DSPL_TXTATTR_TRANSPARENT, (char *)duishoushengyu);
dspl_TextOut(65, 2, DSPL_TXTATTR_NORMAL |DSPL_TXTATTR_TRANSPARENT , (char *)m);
//display column of money of computer
oldcolor = dspl_SetFrgColor(0x000000);
//zhangzg 08/20/2002
if (over_c)
{
dspl_DrawRect(1, 19, 1+116, 34);
dspl_DrawRect(1, 35, 1+length_computer-116, 50);
} else
dspl_DrawRect(1, 19, 1+length_computer, 34);
dspl_SetFrgColor(oldcolor);
oldcolor = dspl_SetBkgColor(0xff0000); //set red
if (over_c)
{
dspl_fill_rectangle(2, 20, 116, 33);
dspl_fill_rectangle(2, 36, length_computer-116, 49);
} else
dspl_fill_rectangle(2, 20, length_computer, 33);
dspl_SetBkgColor(oldcolor);
sprintf(m, "$%d", p_M);
//zhangzg 08/20/2002
dspl_TextOut(1, 37+17*over_c, DSPL_TXTATTR_UNICODE | DSPL_TXTATTR_TRANSPARENT, (char *)wanjiashengyu);
dspl_TextOut(65, 37+17*over_c, DSPL_TXTATTR_NORMAL | DSPL_TXTATTR_TRANSPARENT, (char *)m);
//display column of money of player
oldcolor = dspl_SetFrgColor(0x000000);
//zhangzg 08/20/2002
if (over_p)
{
dspl_DrawRect(1, 54+over_c*17, 1+116, 69+over_c*17);
dspl_DrawRect(1, 69+over_c*17+1, 1+length_player-116, 69+over_c*17+16);
} else
dspl_DrawRect(1, 54+over_c*17, 1+length_player, 69+over_c*17);
dspl_SetFrgColor(oldcolor);
oldcolor = dspl_SetBkgColor(0xff0000); //set red
if (over_p)
{
dspl_fill_rectangle(2, 55+over_c*17, 116, 68+over_c*17);
dspl_fill_rectangle(2, 69+over_c*17+2, length_player-116, 69+over_c*17+15);
} else
dspl_fill_rectangle(2, 55+over_c*17, length_player, 68+over_c*17);
dspl_SetBkgColor(oldcolor);
}
//4 显示交互的内容的信息,常被调用
void Display_InteractiveStr(char* txt, char* txt2, ULONG m)
{
char mstr[10];U8 uMode;
uMode = dspl_Enable(0);
DisplayMainWinTxtZone();
memcpy(zone1_curr_str.curr_str,txt,30);
//zone1_curr_str.curr_str = (char*)txt;
zone1_curr_str.isEmpty = 0;
zone1_curr_str.attr = DSPL_TXTATTR_UNICODE | DSPL_TXTATTR_TRANSPARENT;
DisplayZone(1, (char *)txt, zone1_curr_str.attr);
if (txt2!=0 && m==0) //txt2 is a chinese text
{
memcpy(zone2_curr_str.curr_str,txt2,30);
//zone2_curr_str.curr_str = (char*)txt2;
zone2_curr_str.isEmpty = 0;
zone2_curr_str.attr = DSPL_TXTATTR_UNICODE | DSPL_TXTATTR_TRANSPARENT;
DisplayZone(2, (char *) txt2, zone2_curr_str.attr);
} else if (m!=0) //txt2 are words or numbers
{
sprintf(mstr, "$%d", m);
memcpy(zone2_curr_str.curr_str,mstr,10);
//zone2_curr_str.curr_str = (char*)mstr;
zone2_curr_str.isEmpty = 0;
zone2_curr_str.attr = DSPL_TXTATTR_NORMAL | DSPL_TXTATTR_TRANSPARENT;
DisplayZone(2, (char *)mstr, zone2_curr_str.attr);
} else
{
}
dspl_Enable(uMode);
}
/********************************************************************************
**********************************************************************/
void HideInterArea()
{
MfwRect rect = {0, 59, 120, 42};
PaintBackground(rect, BKCOLOR);
}
/********************************************************************
display the actions player executes in the zone3, zone4, zone5, zone6, zone7
the pupose is only for general convenience, because you may display every zone respectively
*********************************************************************/
//4 刷新五个按钮(mainwin_states的初始状态)
void Display_Actions()
{
UBYTE uMode;
TRACE_FUNCTION("Display_Actions()");
uMode = dspl_Enable(0);
DisplayZone(3, 0, DSPL_TXTATTR_UNICODE); //only display one bmp or text on the buttons. when the attr is set
DisplayZone(4, 0, DSPL_TXTATTR_UNICODE); //DSPL_TXTATTR_UNICODE, one bmp is displayed!! otherwise number text is displayed
DisplayZone(5, 0, DSPL_TXTATTR_UNICODE);
DisplayZone(6, 0, DSPL_TXTATTR_UNICODE);
DisplayZone(7, 0, DSPL_TXTATTR_UNICODE);
// mfwSleep(0);
dspl_Enable(uMode);
}
//4 显示全部的注
void Display_Stakes(ULONG m1, ULONG m2, ULONG m3)
{
UBYTE uMode;
char sm[10];
uMode = dspl_Enable(0);
sprintf(sm, "%d", m1);
DisplayZone(4, (char *) sm, DSPL_TXTATTR_NORMAL | DSPL_TXTATTR_TRANSPARENT);
sprintf(sm, "%d", m2);
DisplayZone(5, (char *) sm, DSPL_TXTATTR_NORMAL | DSPL_TXTATTR_TRANSPARENT);
sprintf(sm, "%d", m3);
DisplayZone(6, (char *) sm, DSPL_TXTATTR_NORMAL | DSPL_TXTATTR_TRANSPARENT);
dspl_Enable(uMode);
}
void Display_Focus()
{
USHORT x, y, i;
i = mainwin_focus->codenum;
switch (mainwin_focus->thingtype)
{
case COMPUTER_CARD: //4如果是聚焦在电脑的牌上
x = LEFT_WIDTH_CARD+(i+1)*EXPOSED_WIDTH_CARD+LEFT_HAND;
y = TOP_WIDTH_CARD+TOP_HAND;
break;
case PLAYER_CARD: //4如果是聚焦在玩家的牌上
x = LEFT_WIDTH_CARD+i*EXPOSED_WIDTH_CARD+LEFT_HAND;
y = 160 - HEIGHT_CARD + TOP_HAND;
break;
case ACTIONS: //actions is equal with stakes
case STAKES: //4计算如果是聚焦在按钮或者是注上
switch (i)
{
case 0:
x = LEFT_ZONE3+15;
y = TOP_ZONE3+2;
break;
case 1:
x = LEFT_ZONE4+15;
y = TOP_ZONE4+2;
break;
case 2:
x = LEFT_ZONE5+15;
y = TOP_ZONE5+2;
break;
case 3:
x = LEFT_ZONE6+15;
y = TOP_ZONE6+2;
break;
case 4: //4全索的按钮上
x = LEFT_ZONE7+15;
y = TOP_ZONE7+2;
break;
default: //4 到这里就出错了
x = 0;
y = 0;
break;
}
default:
break;
}
DrawHand(x, y);
}
/*************************************************************************
**************************************************************************/
SHORT ComputerAction(USHORT cardnum, UBYTE turnwho)
{
CardType p_CardType, c_CardType, temp_CardType;
ULONG c_Money;
USHORT p_TempCards[5] = {0,0,0,0,0};
USHORT i;
ULONG c_tempstake;
switch (cardnum)
{
case 2:
c_CardType = Status_Two(c_Cards); //get card type of the first two cards of computer
c_Money = Two_Greater(c_CardType, turnPlayerorComputer); //get the stake computer is chipping in
goto label;
case 3:
c_CardType = Status_Two(c_Cards);
c_CardType = Status_Three(c_CardType, c_Cards);
p_TempCards[0] = p_Cards[1];
p_TempCards[1] = p_Cards[2];
p_CardType = Status_Two(p_TempCards); //get the card type of two cards of player, which is known
//zhangzg 08/23/2002
if (focus_opp==1 && playermorestake==0)
c_Money = Three_Greater_Opp1(c_CardType, p_CardType, turnwho, p_CurrStake);
else
c_Money = Three_Greater(c_CardType,p_CardType,turnPlayerorComputer);
goto label;
case 4:
c_CardType = Status_Two(c_Cards);
c_CardType = Status_Three(c_CardType, c_Cards);
c_CardType = Status_Four(c_CardType, c_Cards);
p_TempCards[0] = p_Cards[1];
p_TempCards[1] = p_Cards[2];
p_TempCards[2] = p_Cards[3];
p_CardType = Status_Two(p_TempCards); //get the card type of two cards of player, which is known
p_CardType = Status_Three(p_CardType, p_TempCards); //get the card type of two cards of player, which is known
//zhangzg 08/23/2002
if (focus_opp==1 && playermorestake==0)
c_Money = Four_Greater_Opp1(c_CardType, p_CardType, turnwho, p_CurrStake);
else
c_Money = Four_Greater(c_CardType,p_CardType,turnPlayerorComputer);
goto label;
label: if (c_Money==0)
return;
if (c_M>=10)
{
if (c_Money<FOURCARDSFOLL)
{
if (c_M>c_Money)
{
if (p_M<c_Money)
c_CurrStake = p_M;
else
c_CurrStake = c_Money;
} else
c_CurrStake = c_M;
c_M = c_M-c_CurrStake;
desk_CurrStake +=c_CurrStake;
Display_InteractiveStr((char *)duishouxiazhu, 0, c_CurrStake);
time_state = TIMER_TPLAYER;
if (data)
{
isInteracting = 1; //cannot respond to player's input
timStart(data->tim);
}
//zhangzg 08/23/2002
//4 如果电脑要下更多的注设置跟进为可执行,下注不可执行
if (turnwho==PLAYER && c_Money>p_CurrStake && playermorestake==0)
{
playeractions[1].isenabled = 0;
playeractions[2].isenabled = 1;
//4如果原来小手focus在下注按钮上那么就需要重新刷新下注按钮
if (mainwin_focus->thingtype==ACTIONS && mainwin_focus->codenum==1)
{
NextFocus();
}
}
return 1;
} else
//4 如果玩家跟进并且下更多的注,那么电脑肯定跟进然后发牌
if (c_Money==TWOCARDSFOLL || c_Money==THREECARDSFOLL || c_Money==FOURCARDSFOLL) //FOLLOW
{
if (c_M>(p_CurrStake-playermorestake*c_CurrStake)) //zhangzg 08/22/2002
{
c_tempstake = p_CurrStake-playermorestake*c_CurrStake; //zhangzg 08/22/2002
} else
c_tempstake = c_M;
c_M = c_M-c_tempstake;
desk_CurrStake += c_tempstake;
c_CurrStake = c_tempstake+playermorestake*c_CurrStake;
Display_InteractiveStr((char *)duishougenle, 0, 0);
time_state = TIMER_INTERACTIVE;
if (data)
{
isInteracting = 1; //cannot respond to player's input
timStart(data->tim);
}
return 2;
} else //QUIT
{
p_M +=desk_CurrStake;
desk_CurrStake = 0;
Display_InteractiveStr((char *)duishoufangqi, 0, 0);
time_state = TIMER_FANGQI;
if (data)
{
isInteracting = 1; //cannot respond to player's input
timStart(data->tim);
}
return 0;
}
} else //对手没有mon
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -