Visual Studio 2008 Express Edition でトランプゲームを作ろう
最終確認
プロジェクトにコピーして利用してください
【ユーザー】【ドキュメント】【Visual Studio 2008】【Projects】【ここにコピー】
実行ファイル【Release.zip】
//stdafx.hの内容
// stdafx.h : 標準のシステム インクルード ファイルのインクルード ファイル、または
// 参照回数が多く、かつあまり変更されない、プロジェクト専用のインクルード ファイル
// を記述します。
#pragma once
// TODO: プログラムに必要な追加ヘッダーをここで参照してください。
#include<stdio.h>
//Form1の内容
#pragma once
static int card[55];
//static int hai[12];
static int keta[12];
static int yaku[12];
static int start_flag=0;
static int tokuten=0;
namespace basictoc {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Form1 の概要
///
/// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた
/// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを
/// 変更する必要があります。この変更を行わないと、
/// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、
/// 正しく相互に利用できなくなります。
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: ここにコンストラクタ コードを追加します
//
}
protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::CheckBox^ checkBox1;
private: System::Windows::Forms::CheckBox^ checkBox2;
private: System::Windows::Forms::CheckBox^ checkBox3;
private: System::Windows::Forms::CheckBox^ checkBox4;
private: System::Windows::Forms::CheckBox^ checkBox5;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::TextBox^ textBox5;
private: System::Windows::Forms::TextBox^ textBox6;
private: System::Windows::Forms::TextBox^ textBox7;
private: System::Windows::Forms::TextBox^ textBox8;
private:
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
System::ComponentModel::Container ^components;
void DispHai( int nohai,int xx){
Graphics^ gr=this->CreateGraphics();
int X0=10,Y0=1;
String^ filename;
filename="c:\\card\\1_sp.gif";
if(nohai==0 ) filename="c:\\card\\0_r1.gif" ;
//Pen^ pen1=gcnew Pen(col);
if(nohai>0 && nohai<14) filename="c:\\card\\"+nohai+"_sp.gif" ;
if(nohai>100 && nohai<114 ){nohai=nohai-100;
filename="c:\\card\\"+nohai+"_cl.gif" ;}
if(nohai>200 && nohai<214 ){nohai=nohai-200;
filename="c:\\card\\"+nohai+"_di.gif" ;}
if(nohai>300 && nohai<314){nohai=nohai-300;
filename="c:\\card\\"+nohai+"_he.gif" ;}
//原画像を左上に描画する
if(xx==1){
Bitmap^ bmap1; //bmap1の確保
bmap1=gcnew Bitmap(filename);
gr->DrawImage(bmap1,X0,Y0);
}
if(xx==2){
Bitmap^ bmap2; //bmap2の確保
bmap2=gcnew Bitmap(filename);
gr->DrawImage(bmap2,X0+100,Y0);
}
if(xx==3){
Bitmap^ bmap3; //bmap3の確保
bmap3=gcnew Bitmap(filename);
gr->DrawImage(bmap3,X0+200,Y0);
}
if(xx==4){
Bitmap^ bmap4; //bmap4の確保
bmap4=gcnew Bitmap(filename);
gr->DrawImage(bmap4,X0+300,Y0);
}
if(xx==5){
Bitmap^ bmap5; //bmap5の確保
bmap5=gcnew Bitmap(filename);
gr->DrawImage(bmap5,X0+400,Y0);
}
}
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
this->checkBox2 = (gcnew System::Windows::Forms::CheckBox());
this->checkBox3 = (gcnew System::Windows::Forms::CheckBox());
this->checkBox4 = (gcnew System::Windows::Forms::CheckBox());
this->checkBox5 = (gcnew System::Windows::Forms::CheckBox());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->button4 = (gcnew System::Windows::Forms::Button());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->textBox5 = (gcnew System::Windows::Forms::TextBox());
this->textBox6 = (gcnew System::Windows::Forms::TextBox());
this->textBox7 = (gcnew System::Windows::Forms::TextBox());
this->textBox8 = (gcnew System::Windows::Forms::TextBox());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(32, 168);
this->button1->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(81, 30);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// button2
//
this->button2->Location = System::Drawing::Point(144, 168);
this->button2->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(82, 26);
this->button2->TabIndex = 1;
this->button2->Text = L"button2";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(256, 168);
this->button3->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(77, 26);
this->button3->TabIndex = 2;
this->button3->Text = L"button3";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
//
// checkBox1
//
this->checkBox1->AutoSize = true;
this->checkBox1->Location = System::Drawing::Point(9, 123);
this->checkBox1->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->checkBox1->Name = L"checkBox1";
this->checkBox1->Size = System::Drawing::Size(80, 16);
this->checkBox1->TabIndex = 3;
this->checkBox1->Text = L"checkBox1";
this->checkBox1->UseVisualStyleBackColor = true;
//
// checkBox2
//
this->checkBox2->AutoSize = true;
this->checkBox2->Location = System::Drawing::Point(98, 123);
this->checkBox2->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->checkBox2->Name = L"checkBox2";
this->checkBox2->Size = System::Drawing::Size(80, 16);
this->checkBox2->TabIndex = 4;
this->checkBox2->Text = L"checkBox2";
this->checkBox2->UseVisualStyleBackColor = true;
//
// checkBox3
//
this->checkBox3->AutoSize = true;
this->checkBox3->Location = System::Drawing::Point(190, 123);
this->checkBox3->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->checkBox3->Name = L"checkBox3";
this->checkBox3->Size = System::Drawing::Size(80, 16);
this->checkBox3->TabIndex = 5;
this->checkBox3->Text = L"checkBox3";
this->checkBox3->UseVisualStyleBackColor = true;
//
// checkBox4
//
this->checkBox4->AutoSize = true;
this->checkBox4->Location = System::Drawing::Point(270, 123);
this->checkBox4->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->checkBox4->Name = L"checkBox4";
this->checkBox4->Size = System::Drawing::Size(80, 16);
this->checkBox4->TabIndex = 6;
this->checkBox4->Text = L"checkBox4";
this->checkBox4->UseVisualStyleBackColor = true;
//
// checkBox5
//
this->checkBox5->AutoSize = true;
this->checkBox5->Location = System::Drawing::Point(359, 123);
this->checkBox5->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->checkBox5->Name = L"checkBox5";
this->checkBox5->Size = System::Drawing::Size(80, 16);
this->checkBox5->TabIndex = 7;
this->checkBox5->Text = L"checkBox5";
this->checkBox5->UseVisualStyleBackColor = true;
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(32, 222);
this->textBox1->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(216, 19);
this->textBox1->TabIndex = 8;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(270, 222);
this->textBox2->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(121, 19);
this->textBox2->TabIndex = 9;
//
// button4
//
this->button4->Location = System::Drawing::Point(378, 174);
this->button4->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(85, 20);
this->button4->TabIndex = 10;
this->button4->Text = L"button4";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(31, 264);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(407, 19);
this->textBox3->TabIndex = 11;
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(30, 300);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(407, 19);
this->textBox4->TabIndex = 12;
//
// textBox5
//
this->textBox5->Location = System::Drawing::Point(28, 347);
this->textBox5->Name = L"textBox5";
this->textBox5->Size = System::Drawing::Size(408, 19);
this->textBox5->TabIndex = 13;
//
// textBox6
//
this->textBox6->Location = System::Drawing::Point(27, 390);
this->textBox6->Name = L"textBox6";
this->textBox6->Size = System::Drawing::Size(411, 19);
this->textBox6->TabIndex = 14;
//
// textBox7
//
this->textBox7->Location = System::Drawing::Point(28, 436);
this->textBox7->Name = L"textBox7";
this->textBox7->Size = System::Drawing::Size(407, 19);
this->textBox7->TabIndex = 15;
//
// textBox8
//
this->textBox8->Location = System::Drawing::Point(28, 479);
this->textBox8->Name = L"textBox8";
this->textBox8->Size = System::Drawing::Size(406, 19);
this->textBox8->TabIndex = 16;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(493, 568);
this->Controls->Add(this->textBox8);
this->Controls->Add(this->textBox7);
this->Controls->Add(this->textBox6);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->button4);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->checkBox5);
this->Controls->Add(this->checkBox4);
this->Controls->Add(this->checkBox3);
this->Controls->Add(this->checkBox2);
this->Controls->Add(this->checkBox1);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Margin = System::Windows::Forms::Padding(2, 2, 2, 2);
this->Name = L"Form1";
this->Text = L"Form1";
this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
Graphics^ gr=this->CreateGraphics();
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if(start_flag ==0){ //一度通過したら度目を禁止する
int amax,xrand,nohai;
int xx,yy,y;
char buf[80];//文字で確認用
Graphics^ gr=this->CreateGraphics();
String^ string1;//文字で確認用
string1="";//文字で確認用
Brush^ brush=gcnew SolidBrush(Color::Black);
System::Drawing::Font^ font=gcnew System::Drawing::Font("MS ゴシック",10);
Random^ rand=gcnew Random(); //で乱数randを生成しておき、
//2) 以上int amax未満の乱数を発生したい場合には、
amax=52;
for(xx=1;xx<54;xx++) card[xx]=0;
yy=1;
while(yy<20){
xrand=rand->Next(amax)+1;
int flag=0;
for(xx=1;xx<53;xx++) {if(card[xx]==xrand) flag=1;}
if(flag==0){ card[yy]=xrand;
//文字で確認
sprintf_s(buf,80," %3d ",card[yy]);//文字で確認用
string1=string1+gcnew String(buf);//文字で確認用
//gr->DrawString(string1,font,brush,(float)16*yy,(float)300);
//文字で確認終了
yy++;}
textBox3->Text=string1;//文字で確認用
}//while end
for(y=1;y<53;y++){
if( card[y] > 13 && card[y] <= 26) card[y] = card[y] + 100 - 13;
if( card[y] > 26 && card[y] <= 39) card[y] = card[y] + 200 - 26;
if( card[y] > 39 && card[y] <= 52) card[y] = card[y] + 300 - 39;
} //end for y
for(xx=1;xx<6;xx++){
DispHai(0,xx);
}
start_flag=1; //一度通過したら度目を禁止するフラッグ
}//end if
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
if(start_flag==1){
int xx,testdata;
char buf[80];//文字で確認用
String^ string1;//文字で確認用
string1="";//文字で確認用
for(xx=1;xx<6;xx++){
//文字で確認
DispHai(card[xx],xx);//文字で確認用
sprintf_s(buf,80," %3d ",card[xx]);//文字で確認用
string1=string1+gcnew String(buf);//文字で確認用
} //Next x
textBox4->Text=string1;//文字で確認終了
start_flag=2;
} // End if
}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
if(start_flag==2){
int x,y,w,oitoku,testdata;
int flash=0;
int flag=0;
char buf[80];
x = 6;
if( checkBox1->Checked ){}else{
card[1] = card[x];
x = x + 1;
}
if( checkBox2->Checked ){}else{
card[2] = card[x];
x = x + 1;
}
if( checkBox3->Checked ){}else{
card[3] = card[x];
x = x + 1;
}
if( checkBox4->Checked ){}else{
card[4] = card[x];
x = x + 1;
}
if( checkBox5->Checked ){}else{
card[5] = card[x];
x = x + 1;
}
for(x=1;x<6;x++) DispHai(card[x],x);
// yaku no kaiseki
// flash no kaiseki
//文字で確認
String^ string1;//文字
string1 = "役なし";//文字
String^ string2;//文字
string2 = "";//文字
String^ string3;//文字で確認用
string3 = "";//文字で確認用
//文字で確認終了
textBox1->Text=string1;
int clab = 0;
int daiya = 0;
int hart = 0;
int supedo = 0;
flash = 0;
for( x = 1 ; x<= 5; x++){
if( card[x] > 0 && card[x] <= 13 ) clab = clab + 1;
if( card[x] > 100 && card[x] <= 113 ) daiya = daiya + 1;
if( card[x] > 200 && card[x] <= 213 ) hart = hart + 1;
if( card[x] > 300 && card[x] <= 313 ) supedo = supedo + 1;
}//Next x
//文字で確認
sprintf_s(buf,80," clab=%3d daiya=%3d hart=%3d spped=%3d ",clab,daiya,hart,supedo);//文字で確認用
string3=gcnew String(buf);//文字で確認用
textBox5->Text=string3;//文字で確認用
//文字で確認終了
if( clab == 5 ){
textBox1->Text= "クラブのフラッシュ";
flash = 1;
tokuten = tokuten + 509;
}//End if
if( daiya == 5 ){
textBox1->Text== "ダイヤのフラッシュ";
flash = 1;
tokuten = tokuten + 509;
}//End if
if( hart == 5 ){
textBox1->Text="ハートのフラッシュ";
flash = 1;
tokuten = tokuten + 509;
}//End if
if( supedo == 5 ){
textBox1->Text="スペードのフラッシュ";
flash = 1;
tokuten = tokuten + 509;
}//End if
//Rem ペアーの解析
for( x = 6 ; x<= 10;x++){
keta[x] = 0;
} //Next x
string3="";//文字で確認
for( x = 1 ; x<= 5;x++){
y = card[x];
//Cells(x, 3) = y
if( card[x] > 100 ) y = card[x] - 100;
if( card[x] > 200 ) y = card[x] - 200;
if( card[x] > 300 ) y = card[x] - 300;
//Cells(x, 4) = y
keta[x] = y;
//文字で確認
sprintf_s(buf,80," keta[%1d] %3d ",x,keta[x]);//文字で確認用
string3=string3+gcnew String(buf);//文字で確認用
} //Next x
textBox6->Text=string3;//文字で確認用
//文字で確認終了
string3="";//文字で確認用
for( x = 1 ; x<= 5;x++){
yaku[x] = 0;
for( w = 1 ; w<= 5;w++){
if( keta[x] == keta[w] ) yaku[x] = yaku[x] + 1;
} //Next w
//Cells(x, 5) = yaku[x)
//文字で確認
sprintf_s(buf,80," yaku[%1d] %3d ",x,yaku[x]);//文字で確認用
string3=string3+gcnew String(buf);//文字で確認用
} //Next x
textBox7->Text=string3;//文字で確認用
int twopai = 0;
int threepai = 0;
for( x = 1 ; x<= 5;x++){
if( yaku[x] == 2 ) twopai = twopai + 1;
if( yaku[x] == 3 ) threepai = 1;
if( yaku[x] == 4 ){
textBox1->Text="フォーカード";
flash = 1;
tokuten = tokuten + 4165;
}
} //Next x
if( twopai == 2 ){
textBox1->Text="ワンペアー";
tokuten = tokuten + 3;
} //End if
if( twopai == 4 ){
textBox1->Text="ツーペアー";
tokuten =tokuten + 21;
} //End if
if( threepai == 1 ){
textBox1->Text="スリーカード";
tokuten =tokuten + 47;
} //End if
if( threepai == 1 && twopai == 2 ){
textBox1->Text="フルハウス";
tokuten =tokuten + 694;
} //End if
//Rem ストレートの解析
for( x = 1 ; x<= 5;x++){
for( y = 1 ; y<= 5;y++){
if( keta[x] < keta[y] ){
oitoku = keta[x];
keta[x] = keta[y];
keta[y] = oitoku;
} //End if
} //Next y
} //Next x
//for( x = 1 ; <= 5;x++){
//Cells(x, 6) = keta[x)
//}//Next x
if( keta[1] == 1 && keta[5] == 13 ){
for( x = 1 ; x<= 5;x++){
if( keta[x] == x ){
keta[x + 5] = keta[x] + 13;
//Cells(x + 5, 7) = keta[x) + 13
} //End If
} //Next x
} //End If
flag = 0;
string3="";//文字で確認用
for( x = 1 ; x<= 9;x++){
if( keta[x] == keta[x + 1] - 1 ){ flag = flag + 1;}
sprintf_s(buf,80," keta[%1d]%2d ",x,keta[x]);//文字で確認用
string3=string3+gcnew String(buf);//文字で確認用
} //Next x
textBox8->Text=string3;//文字で確認用
if( flag >= 4 ){
textBox1->Text="ストレート";
tokuten = tokuten + 255;
if( flash == 1 ){
textBox1->Text="ストレートフラッシュ";
tokuten = tokuten + 72193 - 255;
if( keta[1] == 1 && keta[5] == 13 ){
textBox1->Text="ロイヤルストレートフラッシュ";
tokuten = tokuten + 649740 - 72193;
}//End ifロイヤルストレートフラッシュ
} //End ifストレートフラッシュ
} //End ifストレート
sprintf_s(buf,80," %10d ",tokuten);
string2=gcnew String(buf);
textBox2->Text=string2;
start_flag=0;
}// End if
}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
card[6]=1;
card[7]=102;
card[8]=203;
card[9]=304;
card[10]=13;
}
};
}
見本 元 toranpu.zip コンバート版 basic-to-c.zip
注意 filename="c:\\card\\1_sp.gif";を見て 正しいディレクトリに card を入れてください

