-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
195 lines (173 loc) · 5.49 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "main.h"
#include "db.h"
#include "Pick.h"
#include "Player.h"
#include "Options.h"
#include "About.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfmMain *fmMain;
//---------------------------------------------------------------------------
__fastcall TfmMain::TfmMain(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfmMain::FormCreate(TObject *Sender)
{
fmOptions = new TfmOptions(this);
}
//---------------------------------------------------------------------------
void __fastcall TfmMain::btLocalClick(TObject *Sender)
{
for (;;)
{
fmOptions->SetOptions();
Set1 = CreateSet(fmOptions->cbSet1->Text.c_str());
Set2 = CreateSet(fmOptions->cbSet2->Text.c_str());
Set3 = CreateSet(fmOptions->cbSet3->Text.c_str());
if (Set1.size() * Set2.size() * Set3.size() > 0) break;
//MessageDlg("Íå ìîãó ïðî÷åñòü ñåò.", mtError,
// TMsgDlgButtons() << mbOK, 0);
if (fmOptions->ShowModal() != mrOk) Close();
}
LocalDraft();
}
//---------------------------------------------------------------------------
void TfmMain::LocalDraft()
{
std::auto_ptr<TDraftPlayer> Players[8];
BreakDraft = false;
if (!cbDontPlay->Checked)
{
Players[0] = std::auto_ptr<TDraftPlayer> (CreatePlayer(
fmOptions->edName->Text.c_str(), "Local", fmOptions->cbCompLogs->Checked));
}
else
{
Players[0] = std::auto_ptr<TDraftPlayer> (CreatePlayer(
"Scrub0", "Computer", fmOptions->cbCompLogs->Checked));
}
for (int i=1; i<8; i++)
{
Players[i] = std::auto_ptr<TDraftPlayer> (CreatePlayer(
string("Scrub") + IntToStr(i).c_str(), "Computer", fmOptions->cbCompLogs->Checked));
}
randomize();
for (int i=0; i<10; i++)
{
int a = random(7)+1;
int b = random(7)+1;
if (a != b)
{
std::auto_ptr<TDraftPlayer> p = Players[a];
Players[a] = Players[b];
Players[b] = p;
}
}
TCardPile Boosters[8][3];
for (int i=0; i<8; i++) Boosters[i][0] = GenerateBooster(Set1);
for (int i=0; i<8; i++) Boosters[i][1] = GenerateBooster(Set2);
for (int i=0; i<8; i++) Boosters[i][2] = GenerateBooster(Set3);
for (int i=0; i<BoosterSize; i++)
{
for (int j=0; j<8; j++)
{
if (BreakDraft) return;
Players[j]->Pick(Boosters[(i+j)%8][0]);
}
}
for (int i=0; i<BoosterSize; i++)
{
for (int j=0; j<8; j++)
{
if (BreakDraft) return;
Players[j]->Pick(Boosters[(BoosterSize-i+j)%8][1]);
}
}
for (int i=0; i<BoosterSize; i++)
{
for (int j=0; j<8; j++)
{
if (BreakDraft) return;
Players[j]->Pick(Boosters[(i+j)%8][2]);
}
}
extern bool MaglibFmt;
extern bool DeepAnalysis;
for (int i=0; i<8; i++)
{
//Players[i]->SaveInApprentice(Players[i]->Name+".dec", MaglibFmt);
if (TDraftPlayer::Archetyper != NULL)
{
TDraftPlayer::Archetyper->SaveDeck(
Players[i]->Picked,
Players[i]->Name+".dec",
MaglibFmt,
DeepAnalysis);
}
}
}
void __fastcall TfmMain::btOptionsClick(TObject *Sender)
{
fmOptions->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TfmMain::btTestClick(TObject *Sender)
{
TCardPile Picked;
TCardPile Set1 = CreateSet(fmOptions->cbSet1->Text.c_str());
TCardPile Set2 = CreateSet(fmOptions->cbSet2->Text.c_str());
TCardPile Set3 = CreateSet(fmOptions->cbSet3->Text.c_str());
//TDraftPlayer::UnitTest(GetCard("Wirewood Pride"), Picked);
//TDraftPlayer::UnitTest(GetCard("Wirewood Herald"), Picked);
Picked.push_back(GetCard("Nantuko Husk"));
Picked.push_back(GetCard("Timberwatch Elf"));
Picked.push_back(GetCard("Wirewood Herald"));
Picked.push_back(GetCard("Wirewood Savage"));
Picked.push_back(GetCard("Wirewood Savage"));
Picked.push_back(GetCard("Wirewood Savage"));
Picked.push_back(GetCard("Wirewood Savage"));
Picked.push_back(GetCard("Wirewood Savage"));
TDraftPlayer::UnitTest(GetCard("Wirewood Pride"), Picked);
//TDraftPlayer::UnitTest(GetCard("Wirewood Herald"), Picked);
}
//---------------------------------------------------------------------------
void __fastcall TfmMain::btNetworkClick(TObject *Sender)
{
extern bool StudyMode;
StudyMode = false;
for (;;)
{
fmOptions->SetOptions();
Set1 = CreateSet(fmOptions->cbSet1->Text.c_str());
Set2 = CreateSet(fmOptions->cbSet2->Text.c_str());
Set3 = CreateSet(fmOptions->cbSet3->Text.c_str());
if (Set1.size() * Set2.size() * Set3.size() > 0) break;
//MessageDlg("Íå ìîãó ïðî÷åñòü ñåò.", mtError,
// TMsgDlgButtons() << mbOK, 0);
if (fmOptions->ShowModal() != mrOk) Close();
}
extern void ClientDraft();
extern void ConnectDraftServer();
if (rgNetwork->ItemIndex == 0)
{
ConnectDraftServer();
LocalDraft();
}
else
{
ClientDraft();
}
}
//---------------------------------------------------------------------------
void __fastcall TfmMain::spbAboutClick(TObject *Sender)
{
if (AboutBox == NULL) AboutBox = new TAboutBox(this);
AboutBox->ShowModal();
}
//---------------------------------------------------------------------------