Есть такой класс:
class unit {
private:
string name;
int type = 0;
int x_d = 0;
int y_d = 0;
int cost = 0;
int move_cost = 0;
int attack_cost = 0;
bool Spec_attack = 0;
int attack_range = 0;
char symbol = 'S';
int kf = 1;
bool can_move = true;
bool entrench = 0;
public:
unit(int tp, int xd, int yd, int cst, int mc, int ac, bool sa, bool entrenc, bool can, int atr, char sm, std::string names) {
name = names;
type = tp;
x_d = xd;
y_d = yd;
cost = cst;
move_cost = mc;
attack_cost = ac;
Spec_attack = sa;
can_move = can;
entrench = entrenc;
attack_range = atr;
symbol = sm;
};
bool Can_entrench() {
return entrench;
};
int kfh() {
return kf;
};
bool can_moved() {
return can_move;
};
void Edit_kf(int b) {
kf = b;
};
int desx() { return x_d; };
int desy() { return y_d; };
int coste() { return cost; };
int mvcost() { return move_cost; };
int atcost() { return attack_cost; };
bool spatt() { return Spec_attack; };
char smb() { return symbol; };
string getName() { return name; };
};
unit FindAsName(string name){
int i = 0;
while (i < all_lenght) {
if (all[i].getName() == name) { return all[i]; }
else { i++; }
}
}
String^ s = this->listBox1->Text;
std::string unmanaged = msclr::interop::marshal_as<std::string>( s);
unit b = FindAsName(unmanaged);
cout << b.getName()<<endl;
if (units[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] < 1 && territory[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] == current_player){
if (current_player == 1 && P1 >= b.coste() || current_player == 2 && P2 >= b.coste()) {
if (current_player == 1) {
dataGridView1->CurrentCell->Value = (char)(b.smb());
P1= P1 - b.coste();
}
else {
dataGridView1->CurrentCell->Value = (char)(b.smb());
P1 = P2 - b.coste();
}
refreshed();
units[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] = 1;
unit_id[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] = current_id;
current_id++;
team_unit[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] = current_player;
map[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] = b;
std::cout << dataGridView1->SelectedCells[0]->RowIndex << endl;
std::cout << dataGridView1->SelectedCells[0]->ColumnIndex << endl;
}
}
}
и вместо символа выводятся цифры
class unit {
private:
string name;
int type = 0;
int x_d = 0;
int y_d = 0;
int cost = 0;
int move_cost = 0;
int attack_cost = 0;
bool Spec_attack = 0;
int attack_range = 0;
char symbol = 'S';
int kf = 1;
bool can_move = true;
bool entrench = 0;
public:
unit(int tp, int xd, int yd, int cst, int mc, int ac, bool sa, bool entrenc, bool can, int atr, char sm, std::string names) {
name = names;
type = tp;
x_d = xd;
y_d = yd;
cost = cst;
move_cost = mc;
attack_cost = ac;
Spec_attack = sa;
can_move = can;
entrench = entrenc;
attack_range = atr;
symbol = sm;
};
bool Can_entrench() {
return entrench;
};
int kfh() {
return kf;
};
bool can_moved() {
return can_move;
};
void Edit_kf(int b) {
kf = b;
};
int desx() { return x_d; };
int desy() { return y_d; };
int coste() { return cost; };
int mvcost() { return move_cost; };
int atcost() { return attack_cost; };
bool spatt() { return Spec_attack; };
char smb() { return symbol; };
string getName() { return name; };
};
unit FindAsName(string name){
int i = 0;
while (i < all_lenght) {
if (all[i].getName() == name) { return all[i]; }
else { i++; }
}
}
String^ s = this->listBox1->Text;
std::string unmanaged = msclr::interop::marshal_as<std::string>( s);
unit b = FindAsName(unmanaged);
cout << b.getName()<<endl;
if (units[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] < 1 && territory[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] == current_player){
if (current_player == 1 && P1 >= b.coste() || current_player == 2 && P2 >= b.coste()) {
if (current_player == 1) {
dataGridView1->CurrentCell->Value = (char)(b.smb());
P1= P1 - b.coste();
}
else {
dataGridView1->CurrentCell->Value = (char)(b.smb());
P1 = P2 - b.coste();
}
refreshed();
units[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] = 1;
unit_id[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] = current_id;
current_id++;
team_unit[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] = current_player;
map[dataGridView1->SelectedCells[0]->RowIndex][dataGridView1->SelectedCells[0]->ColumnIndex] = b;
std::cout << dataGridView1->SelectedCells[0]->RowIndex << endl;
std::cout << dataGridView1->SelectedCells[0]->ColumnIndex << endl;
}
}
}
и вместо символа выводятся цифры