Jimmy wrote:hi,
i have try your Code-Snip and have Problem with "missing" LIB ?
Error: Unresolved external '_HB_FUN_TCURSOR' referenced from C:\FWH\SAMPLES\2\FWPOKER.OBJ
Error: Unresolved external '_HB_FUN_SETRESOURCES' referenced from C:\FWH\SAMPLES\2\FWPOKER.OBJ
Error: Unresolved external '_HB_FUN_TDIALOG' referenced from C:\FWH\SAMPLES\2\FWPOKER.OBJ
Error: Unresolved external '_HB_FUN_TBITMAP' referenced from C:\FWH\SAMPLES\2\FWPOKER.OBJ
Error: Unresolved external '_HB_FUN_DURCHG1' referenced from C:\FWH\SAMPLES\2\FWPOKER.OBJ
Error: Unresolved external '_HB_FUN_DURCHG2' referenced from C:\FWH\SAMPLES\2\FWPOKER.OBJ
Error: Unresolved external '_HB_FUN_FREERESOURCES' referenced from C:\FWH\SAMPLES\2\FWPOKER.OBJ
Error: Unresolved external '_HB_FUN_FW_GT' referenced from C:\FWH\SAMPLES\2\FWPOKER.OBJ
i use
My code was
only a sample to see to you how you must make instead of use resources
For use resources
rem these lines on poker.prg ( to rem you must insert // before on each line
Code: Select all
set resources to "po.dll"
set 3dlook on
please create this file RC
Poker.rc
Code: Select all
Blatt DIALOG 18, 18, 327, 210
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "P O K E R"
FONT 10, "Arial"
{
CONTROL "", 121, "TBitmap", 0x50000000, 12, 64, 44, 58, 0x00000000
CONTROL "", 122, "TBitmap", 0x50000000, 75, 64, 44, 58, 0x00000000
CONTROL "", 123, "TBitmap", 0x50000000, 143, 64, 44, 58, 0x00000000
CONTROL "", 124, "TBitmap", 0x50000000, 209, 63, 44, 58, 0x00000000
CONTROL "", 125, "TBitmap", 0x50000000, 274, 63, 44, 58, 0x00000000
PUSHBUTTON "&Geben", 201, 25, 146, 60, 14, 0, WS_EX_LEFT
PUSHBUTTON "&Ziehen", 202, 106, 146, 60, 14, 0, WS_EX_LEFT
PUSHBUTTON "&Beenden", 203, 195, 146, 60, 14, 0, WS_EX_LEFT
EDITTEXT 301, 101, 175, 34, 12, 0, WS_EX_LEFT
LTEXT "Einsatz:", 65535, 66, 177, 34, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Text", 65535, 378, 4294967248, 16, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Buben-Paar oder besser", 65535, 10, 10, 82, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Zwei Paare", 65535, 10, 20, 82, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Drei Gleiche", 65535, 10, 30, 82, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Flash (Farbe)", 65535, 10, 40, 82, 8, SS_LEFT, WS_EX_LEFT
LTEXT " 2 zu 1", 65535, 95, 10, 32, 8, SS_LEFT, WS_EX_LEFT
LTEXT " 3 zu 1", 65535, 95, 20, 32, 8, SS_LEFT, WS_EX_LEFT
LTEXT " 5 zu 1", 65535, 95, 30, 32, 8, SS_LEFT, WS_EX_LEFT
LTEXT "20 zu 1", 65535, 95, 40, 32, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Full House", 65535, 196, 11, 82, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Vier Gleiche", 65535, 196, 21, 82, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Farbstraße", 65535, 196, 31, 82, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Royal Flash", 65535, 196, 41, 82, 8, SS_LEFT, WS_EX_LEFT
LTEXT " 50 zu 1", 65535, 281, 11, 32, 8, SS_LEFT, WS_EX_LEFT
LTEXT "100 zu 1", 65535, 281, 21, 32, 8, SS_LEFT, WS_EX_LEFT
LTEXT "200 zu 1", 65535, 281, 31, 32, 8, SS_LEFT, WS_EX_LEFT
LTEXT "500 zu 1", 65535, 281, 41, 32, 8, SS_LEFT, WS_EX_LEFT
}
and then recompile the poker.prg you found on samples/poker with the resource file poker.rc I send you on this topic
For not use resources
you must converte all to @x,y
1. please use this file I try to converte
Code: Select all
* POKER-SPIEL mit FIVEWIN+CLIPPER
*
*
* (c) 1995 Manfred Guettler , Ringweg 11 , D-29323 Wietze
* CIS - 100115,2725
* Tel.: 05149/4833
*
* Es sind sicherlich noch einige kleine Fehler vorhanden und
* es k”nnen noch einige Sachen ge„ndert werden, aber ...
* man kann spielen.
*
* A simple poker-play writen in Clipper with Fivewin
* if someone change or modify the code, please send
* me a copy. Thanks.
*
*
* POKER-SPIEL mit FIVEWIN+CLIPPER
*
*
* (c) 1995 Manfred Guettler , Ringweg 11 , D-29323 Wietze
* CIS - 100115,2725
* Tel.: 05149/4833
*
* Es sind sicherlich noch einige kleine Fehler vorhanden und
* es k”nnen noch einige Sachen ge„ndert werden, aber ...
* man kann spielen.
*
* A simple poker-play writen in Clipper with Fivewin
* if someone change or modify the code, please send
* me a copy. Thanks.
*
*
#include "fivewin.ch"
#include "constant.ch" //add by silvio
#DEFINE WINNING_AMT 100000
STATIC oDlg,oget,ob1,ob2,ob3,bi1,bi2,bi3,bi4,bi5
STATIC handstring,payoff,pdeck,flipped
STATIC pokermode,sbet,lasttitle
STATIC cardmap,cflag,score
STATIC cards,cardname
static cFolderBmp //add by silvio
FUNCTION poker()
LOCAL i
//set resources to "po.dll"
//set 3dlook on
Local nBottom := 30 //add by silvio
Local nRight := 85 //add by silvio
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 ) //add by silvio
Local nHeight := nBottom * DLG_CHARPIX_H //add by silvio
Local oCursor :=TCursor():New(,'HAND') //add by silvio
Local nRowCard:=64 //add by silvio
HandString := Array(10)
Payoff := Array(10)
PDeck := array(52)
flipped := {0,0,0,0,0}
HandString[1] = "Keine Wertung"
Payoff[1] = -1
HandString[2] = "Buben-Paar oder besser 2 zu 1"
Payoff[2] = 2
HandString[3] = "Zwei Paare 3 zu 1"
Payoff[3] = 3
HandString[4] = "Drei Gleiche 5 zu 1"
Payoff[4] = 5
HandString[5] = "Straße 10 zu 1"
Payoff[5] = 10
HandString[6] = "Flush (Farbe) 20 zu 1"
Payoff[6] = 20
HandString[7] = "Full House 50 zu 1"
Payoff[7] = 50
HandString[8] = "Vier Gleiche 100 zu 1"
Payoff[8] = 100
HandString[9] = "Farbstraße 200 zu 1"
Payoff[9] = 200
HandString[10] = "Royal Flush 500 zu 1"
Payoff[10] = 500
CFlag = 0
score = 1000
sBet = '10 '
lastTitle = 0
PokerMode = 1
cFolderBmp:= ".\bitmaps\" //add by silvio
cards := array(5)
cardname := array(52)
cardname[1]=cFolderBmp+"card1.bmp"
cardname[2]=cFolderBmp+"card2.bmp"
cardname[3]=cFolderBmp+"card3.bmp"
cardname[4]=cFolderBmp+"card4.bmp"
cardname[5]=cFolderBmp+"card5.bmp"
cardname[6]=cFolderBmp+"card6.bmp"
cardname[7]=cFolderBmp+"card7.bmp"
cardname[8]=cFolderBmp+"card8.bmp"
cardname[9]=cFolderBmp+"card9.bmp"
for i = 10 to 52
cardname[i] = cFolderBmp+"card" + alltrim(str(i),2,0) + ".bmp"
next
cardmap = "back.bmp"
/*
DEFINE DIALOG oDlg RESOURCE "Blatt"
REDEFINE Button id 203 OF oDlg action oDlg:end()
REDEFINE Button ob2 id 202 OF oDlg action ( IF(okbet(),DurchG2(1),) )
REDEFINE button ob1 id 201 OF oDlg action (IF(okbet(),playhand(),) )
REDEFINE get oget var sBet id 301 OF oDlg valid okbet()
REDEFINE bitmap bi1 file cardmap id 121 OF oDlg ;
on click (IF(pokermode=1,DurchG1(11),DurchG2(11)))
REDEFINE bitmap bi2 file cardmap id 122 OF oDlg ;
on click (IF(pokermode=1,DurchG1(12),DurchG2(12)))
REDEFINE bitmap bi3 file cardmap id 123 OF oDlg ;
on click (IF(pokermode=1,DurchG1(13),DurchG2(13)))
REDEFINE bitmap bi4 file cardmap id 124 OF oDlg ;
on click (IF(pokermode=1,DurchG1(14),DurchG2(14)))
REDEFINE bitmap bi5 file cardmap id 125 OF oDlg ;
on click (IF(pokermode=1,DurchG1(15),DurchG2(15)))
ACTIVATE DIALOG oDlg CENTERED
set resources to
RETURN nil
*/
//DIALOG SOURCE //add by silvio
DEFINE DIALOG oDlg ;
TITLE "Fivewin Poker" ;
SIZE nWidth, nHeight
@ nRowCard,12 bitmap bi1 file cardmap SIZE 40,50 PIXEL OF oDlg NOBORDER;
on click (IF(pokermode=1,DurchG1(11),DurchG2(11)))
@ nRowCard,75 bitmap bi1 file cardmap SIZE 40,50 PIXEL OF oDlg NOBORDER;
on click (IF(pokermode=1,DurchG1(12),DurchG2(12)))
@ nRowCard,143 bitmap bi1 file cardmap SIZE 40,50 PIXEL OF oDlg NOBORDER;
on click (IF(pokermode=1,DurchG1(13),DurchG2(13)))
@ nRowCard,209 bitmap bi1 file cardmap SIZE 40,50 PIXEL OF oDlg NOBORDER;
on click (IF(pokermode=1,DurchG1(14),DurchG2(14)))
@ nRowCard,274 bitmap bi1 file cardmap SIZE 40,50 PIXEL OF oDlg NOBORDER;
on click (IF(pokermode=1,DurchG1(15),DurchG2(15)))
@ 177,66 SAY "Einsatz:" size 40,10 PIXEL OF oDlg
//REDEFINE get oget var sBet id 301 OF oDlg valid okbet()
@ 177, 101 get oget var sBet Size 50,10 PIXEL OF oDlg valid okbet()
//REDEFINE Button id 203 OF oDlg action oDlg:end()
@ nRowCard+150,100 BUTTON "EXIT" size 40,10 PIXEL OF oDlg action oDlg:end()
//REDEFINE Button ob2 id 202 OF oDlg action ( IF(okbet(),DurchG2(1),) )
@ nRowCard+150,100 BUTTON ob2 PROMPT "DEAL" size 40,10 PIXEL OF oDlg action ( IF(okbet(),DurchG2(1),) )
//REDEFINE button ob1 id 201 OF oDlg action (IF(okbet(),playhand(),) )
@ nRowCard+150,200 BUTTON ob1 PROMPT "DRAW" size 40,10 PIXEL OF oDlg action (IF(okbet(),playhand(),) )
@ 10,10 SAY HandString[2] PROMPT "Buben-Paar oder besser" size 80,10 PIXEL OF oDlg
@ 10,95 SAY " 2 zu 1" size 80,10 PIXEL OF oDlg
ACTIVATE DIALOG oDlg CENTERED
return nil
FUNCTION playhand()
**********************************************
LOCAL i, sel, c, h
UpdateTitles(0)
FOR i = 1 to 5
DrawCardBack(i)
NEXT
ResetCards()
FOR i = 1 to 5
cards[i] = RandomCard()
DrawCard(i)
NEXT
h = HandCompute()
UpdateTitles( h )
ob1:disable()
ob2:enable()
pokerMode = 2
Return nil
FUNCTION ResetCards()
afill(@PDeck, 0)
flipped := {0,0,0,0,0}
IF CFlag = -1
PDeck[1] = 49
PDeck[2] = 52
PDeck[3] = 15
PDeck[4] = 33
PDeck[5] = 50
PDeck[6] = 40
PDeck[7] = 51
PDeck[8] = 19
PDeck[9] = 37
PDeck[10] = 8
CFlag = 1
ENDIF
Return nil
Function RandomCard
**********************************************
LOCAL i, stop
IF CFlag > 0
CFlag = CFlag + 1
RETURN PDeck[CFlag - 1]
ENDIF
stop = .t.
do while stop
i = nRandom( 53 ) // int(ft_rand1(53))
IF i=0
i:=1
ENDIF
IF i>52
i := 52
ENDIF
*sginfo(i)
IF PDeck[i] = 0
PDeck[i] = 1
stop = .f.
ENDIF
ENDDO
RETURN i
FUNCTION DrawCard(i)
**********************************************
cardmap = cardname[cards[i]]
IF i = 1
bi1:loadbmp(cardmap)
ENDIF
IF i = 2
bi2:loadbmp(cardmap)
ENDIF
IF i = 3
bi3:loadbmp(cardmap)
ENDIF
IF i = 4
bi4:loadbmp(cardmap)
ENDIF
IF i = 5
bi5:loadbmp(cardmap)
ENDIF
Return nil
FUNCTION UpdateTitles(n)
IF n = LastTitle
RETURN nil
ENDIF
Lasttitle = n
Return nil
Function HandCompute
**********************************************
LOCAL i, straight, flush, retv, ai,val,highpair,suit
LOCAL suits, counts, groups, high1, low1, high2, low2
counts := {0,0,0,0,0,0,0,0,0,0,0,0,0}
suits := {0,0,0,0}
groups := {0,0,0,0}
low1 = 15
high1 = 0
low2 = 15
high2 = 0
highpair = 0
straight = 0
ai = 0
i = 0
FOR i = 1 to 5
val = int(mod((cards[i] - 1), 13)) + 1
suit = int((cards[i] - 1)/13) + 1
counts[val] = counts[val] + 1
suits[suit] = suits[suit] + 1
low1 = Min(low1, val)
high1 = Max(high1, val)
IF val = 1
ai = 14
else
ai = val
endif
low2 = Min(low2, ai)
high2 = Max(high2, ai)
NEXT
ai = 0
FOR i = 1 to 13
val = counts[i]
IF val > 0
groups[val] = groups[val] + 1
IF val = 2
if i = 1
ai = 14
else
ai = i
endif
highpair = Max(highpair, ai)
ENDIF
endif
NEXT
if ((high1 - low1) = 4) .AND. (groups[1] = 5)
straight = 1
endif
if ((high2 - low2) = 4) .AND. (groups[1] = 5)
straight = 1
endif
flush = 0
retv = 1
FOR i = 1 to 4
IF suits[i] = 5
flush = 1
ENDIF
NEXT
IF straight = 1 .AND. flush = 1
IF low2 = 10
RETV = 10
ELSE
RETV = 9
ENDIF
ENDIF
IF groups[4] = 1
RETV = 8
ENDIF
IF groups[3] = 1
RETV = 4
ENDIF
IF groups[2] = 1 .AND. highpair > 10
RETV = 2
ENDIF
IF groups[3] = 1 .AND. groups[2] = 1
RETV = 7
ENDIF
IF flush = 1
RETV = 6
ENDIF
IF straight = 1
RETV = 5
ENDIF
IF groups[2] = 2
RETV = 3
ENDIF
RETURN RETV
FUNCTION DrawCardBack(i)
**********************************************
do case
case i=1
bi1:loadbmp("back.bmp")
case i=2
bi2:loadbmp("back.bmp")
case i=3
bi3:loadbmp("back.bmp")
case i=4
bi4:loadbmp("back.bmp")
case i=5
bi5:loadbmp("back.bmp")
endcase
Return NIL
FUNCTION DurchG2(sel)
**********************************************
LOCAL i, c, h
DO CASE
CASE sel = 1
FOR i = 1 to 5
IF flipped[i] = 1
cards[i] = RandomCard()
DrawCard(i)
ENDIF
NEXT i
h = HandCompute()
UpdateTitles(h)
afill(@PDeck, 0)
score = score + (Payoff[h] * val(sBet))
If Payoff[h]=-1
msgbeep()
msginfo("Sie haben verloren"+CRLF+handstring[lasttitle] )
else
msgbeep()
msginfo("Sie haben gewonnen"+CRLF+handstring[h] )
ENDIF
@ 21,20 say "Bank: DM " + str(score, 7, 0) OF oDlg
If WinOrLose()
oDlg:end()
ENDIF
ob2:disable()
ob1:enable()
IF CFlag > 1
CFlag = 0
ENDIF
PokerMode = 1
CASE sel > 10 .and. sel < 16
c = sel - 10
IF flipped[c] = 1
DrawCard(c)
flipped[c] = 0
ELSE
DrawCardBack(c)
flipped[c] = 1
ENDIF
ENDCASE
RETURN nil
**********************************************
FUNCTION DurchG1(sel)
**********************************************
IF sel = 1 &&eben
IF OKBet()
PlayHand()
PokerMode=2
ENDIF
ENDIF
RETURN nil
**************
Function OKBet
**************
IF val(sBet)>score
msginfo("Der Einsatz übersteigt Ihr Guthaben")
RETURN .f.
ELSEIF val(sBet)<1
msginfo("Mindesteinsatz: 1DM ")
RETURN .f.
ENDIF
RETURN .t.
******************
Function WinOrLose
******************
IF Score <=0
msginfo("Sie haben Ihr Guthaben verspielt. Mehr Glück beim naechsten Spiel.")
RETURN(.t.)
ELSEIF Score>=WINNING_AMT
msginfo("Gratulation! Sie haben die Bank gesprengt!")
RETURN(.t.)
ENDIF
RETURN .f.
I insert only some string HandString[2] you can continue to insert the others
you must use the folder bitmaps where you can insert all cards bitmaps ( also the back.bmp)
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC