#include <windows.h>
#include <string.h>
#include "max.h"
#include "card.h"
#include "ok.h"


/*
	Function:		CardName()

	Parameters:		i -- numeric value of card

	Description:   cards are not zero based 0 not used -- never called with LOWACE value 1 not used
                  JACK = 11, QUEEN = 12 , KING = 13, ACE = 14

	Returns: 	   string indexed into card_names
*/

char * 
CardName(int i, char *buffer, int maxlen)
{
	char *card_names[] = { "", "", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN",
								"EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING",
								"ACE"
								};

   strncpy(buffer, card_names[i], maxlen);

	return (buffer);
}

/*
	Function:		Card::DrawBitmap()

	Parameters:		hdc      -- handle to device context
                  hBitmap  -- graphic file to display
                  xStart   -- horizontal position to place bitmap
                  yStart   -- vertical position to place bitmap

	Description: 	Draws a bitmap to a device context at a particular position on the screen

	Returns: 		nothing
*/

void 
Card::DrawBitmap(HDC hdc, HBITMAP hBitmap, short xStart, short yStart)
{
	BITMAP bm;
	HDC hdcMem;
	DWORD dwSize;
	POINT ptSize, ptOrg;

	hdcMem = CreateCompatibleDC(hdc);
	SelectObject(hdcMem, hBitmap);
	SetMapMode(hdcMem, GetMapMode(hdc));
	GetObject(hBitmap, sizeof(BITMAP), (LPSTR) &bm);
	ptSize.x = bm.bmWidth;
	ptSize.y = bm.bmHeight;
	DPtoLP(hdc, &ptSize, 1);
	ptOrg.x = 0;
	ptOrg.y = 0;
	DPtoLP(hdcMem, &ptOrg, 1);
	BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, ptOrg.x, ptOrg.y, SRCCOPY);
	DeleteDC(hdcMem);

}
