|
Resource translation is big business - I doubt you'll find a robust mechanical solution. That being said, check out the translator example in this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
the question is about a poker game.....i need to finish the check function to check whether it won or not!!!! the question is ....have to draw 5 cards and check win or not!... need help
Winning Conditions
// To be implemented in check_winnings
Combination Winnings Winning Status
Nothing 0 0
3 of a kind Bet * 5 100
4 of a kind Bet * 10 200
BONUS : Each 2 of a kind Bet * 8 300
BONUS : Straight Bet * 50 400
BONUS : Flush Bet * 100 500
BONUS : Royal Straight Flush Bet * 500 600
|
|
|
|
|
koalacui wrote:
i need to finish the check function...
Which implies that you have started it but have run into a snag. What exactly is troubling you? The more specific you are, the more help you'll potentially receive.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
more details:
/* Sample Output 1////////////////////////////////////////////////
========================================
Your current balance is $100 dollars.
========================================
Please enter the amount to bid: 150
ALERT! You do not have enough to bet $150.
Please enter the amount to bid: 90
========================================
Your current balance is $10 dollars.
========================================
Please [ENTER] to draw your first card …
-- Your Cards on hand ------------------
- A of Spades
----------------------------------------
Please [ENTER] to draw your second card …
-- Your Cards on hand ------------------
- A of Spades (61)
- 10 of Spades (70)
----------------------------------------
Please [ENTER] to draw your third card …
-- Your Cards on hand ------------------
- A of Spades (61)
- 10 of Spades (70)
- K of Spades (73)
----------------------------------------
Please [ENTER] to draw your forth card …
-- Your Cards on hand ------------------
- A of Spades (61)
- 10 of Spades (70)
- K of Spades (73)
- J of Spades (71)
----------------------------------------
Please [ENTER] to draw your last card …
-- Your Cards on hand ------------------
- A of Spades (61)
- 10 of Spades (70)
- K of Spades (73)
- J of Spades (71)
- Q of Spades (72)
----------------------------------------
== Winning Result ======================
Congratulation, you have a Royal Flush!!
You have won $2000 dollars.
========================================
|
|
|
|
|
#include <iostream>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <conio.h>
using namespace std;
void print_balance( int ) ;
void print_result( int ) ;
void Print_Cards_At_Hand ( void ) ;
void Check_Winning ( void ) ;
int draw_Card( void ) ;
int deck[52] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73 } ;
void main( void )
{
srand (time (0));
int balance = 100 ;
int bet = 0 ;
while( balance > 0 )
{
balance = balance - bet;
print_balance( balance ) ;
cout << endl ;
if (balance != 0)
{
do
{
cout << "Please enter the amount to bid: $" ;
cin >> bet ;
if( bet > balance )
{
cout << "ALERT! You do not have enough " << "to bet $" << bet << endl ;
}
cout << endl ;
}while( bet > balance || bet == 0) ;
Print_Cards_At_Hand();
cout << endl ;
}
}
} // main()
void print_balance( int balance )
{
cout << "========================================" << endl;
cout << "Your current balance is $" << balance << " dollars" ;
cout << endl ;
if( balance <= 0 )
{
cout << "You are bankrupted" ;
cout << endl;
}
cout << "========================================" << endl;
}
void print_result( int winning_amt )
{
cout << "== Winning Result ======================" << endl;
if( winning_amt > 0 )
{
cout << "You have won " << winning_amt << "dollars."
<< endl ;
}
else
{
cout << "Sorry, you have not won anything." << endl ;
cout << "You have lost $" << winning_amt << " dollars." ;
}
cout << "========================================" << endl;
}
int draw_Card( void )
{
int c = (rand() % 52) ;
return c;
}
void Print_Cards_At_Hand ( void )
{
int i;
int x;
int y;
int number[6];
int identity[6];
int value[6];
string type;
for (i=1;i<6;i++)
{
cout << "Press [ENTER] to draw your " << i << " card ... " << endl;
while (_getch() !=13)
{}
cout << "-- Your Cards on hand ------------------" << endl;
int card_index = draw_Card();
y = deck[card_index]/20;
if( y == 0 )
{
identity[i] = 1;
value[i] = deck[card_index];
number[i] = deck[card_index];
}
else if( y == 1 )
{
identity[i] = 2;
value[i] = deck[card_index];
number[i] = deck[card_index] - 20;
}
else if( y == 2 )
{
identity[i] = 3;
value[i] = deck[card_index];
number[i] = deck[card_index] - 40;
}
else
{
identity[i] = 4;
value[i] = deck[card_index];
number[i] = deck[card_index] - 60;
}
for (x=1;x<=i;x++)
{
if ( identity[x] == 1 )
{
cout << "- " << number[x] << " of Diamonds" << " ("<< value[x] << ")"<< endl;
}
else if ( identity[x] == 2 )
{
cout << "- " << number[x] << " of Clubs" << " ("<< value[x] << ")"<< endl;
}
else if ( identity[x] == 3 )
{
cout << "- " << number[x] << " of Hearts" << " ("<< value[x] << ")"<< endl;
}
else
{
cout << "- " << number[x] << " of Spades" << " ("<< value[x] << ")"<< endl;
}
}
}
}
void Check_Winning ( void )
{
}
|
|
|
|
|
How to get last access time of some directory?
On files, I use GetFileTime() function and it is
working property, but on folder, it returns null.
Thanks in advanvce.
|
|
|
|
|
MirkoMax wrote:
...but on folder, it returns null.
And what does GetLastError() return?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I am a beginner in the windows programming world, and am having a bit of trouble figuring out how to determine the state of my checkbox when it's ownerdraw.
If I use BM_GETCHECK it always returns 0, even if I send BM_SETCHECK a line above passing BST_CHECKED. I also tried ORing BS_CHECKBOX and/or BS_AUTOCHECKBOX with BS_OWNERDRAW but BM_GETCHECK still returned 0.
I then attempted to use BM_SETIMAGE as general storage (a pointer) but BM_GETIMAGE always returns 0 as well.
Is it due to the fact my checkboxes are ownerdraw, or is there some other problem I'm unaware of?
thanks
|
|
|
|
|
May we see a code snippet?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hTempWnd = CreateWindowEx (
0,
"Button",
"Compression",
WS_VISIBLE | WS_CHILD | BS_OWNERDRAW,
clientRect.right - MM_DBUTTON_WIDTH - MMPADDING_RIGHT,
clientRect.top + MMPADDING_TOP + MM_GROUPPADDING_BOTTOM,
MM_DBUTTON_WIDTH, MM_DBUTTON_HEIGHT,
hWnd,
(HMENU) MMENU_BUTTON_COMPRESSION,
GetModuleHandle ( NULL ),
NULL
) ;
LPDRAWITEMSTRUCT lpdis from lParam in WM_DRAWITEM
long lResult = 0;
lResult = SendMessage ( lpdis->hwndItem, BM_GETCHECK, (WPARAM) 0, (LPARAM) 0 ) ;
if ( lResult == BST_CHECKED ) ...
When I was trying BM_GETIMAGE I used the same procedure as the second code snippet
edit: It seems that BM_GETCHECK and BM_SETCHECK just don't work with ownerdraw, so that solves that issue, but I'm still unsure why BM_SETIMAGE doesn't work.
|
|
|
|
|
What happens if you create a checkbox like:
CreateWindowEx(..., WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, ...); In other words, does the owner-draw style have any affect? I wouldn't think so but I'm just trying to pare the problem down.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have tried using BS_AUTOCHECKBOX with BS_OWNERDRAW (I do draw them myself so I need that) but it doesn't seem to have an effect, and BM_GETCHECK still always returns 0.
|
|
|
|
|
c. s. wrote:
I have tried using BS_AUTOCHECKBOX with BS_OWNERDRAW (I do draw them myself so I need that) but it doesn't seem to have an effect...
Right, but does the problem persist for non owner-drawn checkboxes?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
c. s. wrote:
hTempWnd = CreateWindowEx (
0, // no extended style
"Button",
"Compression", // toggles chunk compression
WS_VISIBLE | WS_CHILD | BS_OWNERDRAW, // make a visible child window, that we draw ourself (see void DrawCheckbox)
clientRect.right - MM_DBUTTON_WIDTH - MMPADDING_RIGHT, // create it near the top right corner
clientRect.top + MMPADDING_TOP + MM_GROUPPADDING_BOTTOM,
MM_DBUTTON_WIDTH, MM_DBUTTON_HEIGHT, // use our standard checkbox button height and width
hWnd, // our parent window is this popup menu
(HMENU) MMENU_BUTTON_COMPRESSION,
GetModuleHandle ( NULL ),
NULL // pass no extra parms on creation
) ;
According to this[^], an owner-drawn button "has no predefined appearance or usage. Its purpose is to provide a button whose appearance and behavior are defined by the application alone."
Furthermore, your call to Create isn't even specifying one of the possible check box styles (BS_CHECKBOX, BS_AUTOCHECKBOX, BS_3STATE, BS_AUTO3STATE), so it's no wonder the control doesn't react to BM_SETCHECK messages. Try adding BS_CHECKBOX, and if that doesn't work (which may be due because of the owner draw style), I suggest subclassing the control so that you can handle the BM_GETCHECK and BM_SETCHECK messages yourself.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
Furthermore, your call to Create isn't even specifying one of the possible check box styles (BS_CHECKBOX, BS_AUTOCHECKBOX, BS_3STATE, BS_AUTO3STATE), so it's no wonder the control doesn't react to BM_SETCHECK messages.
Did you miss this:
"I also tried ORing BS_CHECKBOX and/or BS_AUTOCHECKBOX with BS_OWNERDRAW but BM_GETCHECK still returned 0."
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
Did you miss this:
"I also tried ORing BS_CHECKBOX and/or BS_AUTOCHECKBOX with BS_OWNERDRAW but BM_GETCHECK still returned 0."
Yes, I missed it. Sorry.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I was hoping to avoid using my own storage, but it seems not too feasible.
I will subclass it and see how it turns out, thanks all.
|
|
|
|
|
c. s. wrote:
I was hoping to avoid using my own storage, but it seems not too feasible.
I will subclass it and see how it turns out, thanks all.
Well, subclassing it would have an additional benefit, since it would allow you to handle the drawing in the control, rather than doing so in the parent. That's in my opinion a better alternative because it's easier to reuse the control with different parents.
Good luck
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Greetings:
I have a simple ListCtrl box in Report mode. I want the parent window (a dialog) to be notified when any vertical scroll operations are requested.
I can't see anyway to do this. Is it a WM_NOTIFY? If so, which code ID is used?
Thank you,
Mark
|
|
|
|
|
|
Hi JLR, thanks for your response...
My application must support Windows down to Win 95. Is there anything I can do?
Mark
|
|
|
|
|
Jethro63 wrote:
My application must support Windows down to Win 95. Is there anything I can do?
What's your need exactly? I mean, you said you need a parent window to receive notifications about scrolling in a listview, but what do you need this for? Perhaps there's another way to do what you actually need.
For example, would subclassing the control with a class derived from CListCtrl help? Doing that would allow you to handle any windows message...
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi Jose:
My problem is that I must provide a list control in report mode that displays records with about five sub-items per row. This view must potentially display a LARGE number of records, sometimes over 200,000. Normally, if the record count was lower, I would just insert all the rows I need and fill out all of the records then the user is free to scroll away. But when the number of records is large, it takes WAY too long to initialize all of those records.
I found that if I simply create the number of rows that I need without filling out any of the record data in the columns, then the amount of time it takes is tolerable (like 30 seconds with a friendly progress bar to amuse the user in the mean time).
My next move, if I can figure out how to do this, is to simply fill out only the records that are currently visible in the view window. Each time the user scrolls by whatever means, I would fill out any rows that become exposed but have not been filled out. This all hinges on me being notified when the user has caused the list control to scroll and to then find out which rows are now visible.
That's my plan. Feel free to rip it apart.
Thanks,
Mark
|
|
|
|
|
Jethro63 wrote:
My problem is that I must provide a list control in report mode that displays records with about five sub-items per row. This view must potentially display a LARGE number of records, sometimes over 200,000.
I figured it was something like that, hence the question
This article seems to be what you need:
Using virtual lists[^]
I haven't tried it, but it's the approach I'd suggest in your case (letting the list ask you for the info as it needs it).
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi Jose:
Thanks, I'll have a look.
Mark
|
|
|
|
|