Home > Back-end >  Consult!!!!! For years, help me to look at the code, just Order_Call last parameter as reference mis
Consult!!!!! For years, help me to look at the code, just Order_Call last parameter as reference mis

Time:09-21

# include
# include

///////////////////

Struct Role {
Int attack;//damage
Int the health;//HP
Int magic;//mana
};
///////////////////

Struct Role Player [4] [7].//create the array, row 0 and 3 lines for role position, two lines among storage after;
Int Role_Num [2]={1, 1};//said the two sides character number (including the heroes and entourage)

///////////////////

Struct Retinue {
char name[10];//set after number
Struct Role Role;
};

///////////////////

Void Order_Call (int the who, int Nob, int pos, Role R []) {//who said the action party number; The name says after number; Pos said call following position in a
int i;
If (who==0) {
If (pos> 0 {
Role_Num [who] + +;//every call, follow the number plus one
}
For (I=Role_Num [who]; I> Pos. I -) {
+ 1 Player [who] [I]=Player + 1] [who] [I - 1; Pos//position and the right side of the following would move to the right to a location, just call to let followers placed in position Pos
}
+ 1 Player [who] [pos] attack=R [R]. Nob attack;
+ 1 Player [who] [pos]. Health=R [Nob]. The health;
}
If (who==3) {
If (pos> 0 {
Role_Num [who] + +;//every call, follow the number plus one
}
For (I=Role_Num [who]; I> Pos. I -) {
Player [1] who [I]=Player [1] who [I - 1); Pos//position and the right side of the following would move to the right to a location, just call to let followers placed in position Pos
}
Player [1] who [R]. Pos attack=R [R]. Nob attack;
Player [11] who [pos]. Health=R [Nob]. The health;
}

}

///////////////////

Void Order_Attack (int the who, int pos1, int pos2) {//who said their number (0 and 3); Pos1 said of his position as pos1 after the attack in a pos2 position of each other after

If (who==0) {
//0 square health change

+ 1 Player [who] [pos1]. Health=Player [pos1]. [who + 1] health - Player [pos2]. [who + 2] attack;
If (Role_Num [1] & gt; 0 {
+ 2 Player [who] [pos2]. Health=Player [who + 2] [pos2]. Health - Player [pos1]. [who + 1] attack;
If (Player [who] [pos1] health<=0) {
Order_Remove (who + 1, pos1);
}
If (Player + 3 [who] [pos2] health<=0) {
Order_Remove (who + 3, pos2);
}
}
The else {
+ 3 Player [who] [0]. Health=Player + 3 [who] [0]. Health - Player [pos1]. [who + 1] attack;//if the location does not follow automatically attack hero
}
}

If (who==3) {
//3 party health change
Player [who] [pos2]. Health=Player [who] [pos2]. Health - Player [3] who [pos1] attack;
If (Role_Num [0] & gt; 0 {
Player [3] who [pos1]. Health=Player [3] who [pos1]. Health - Player [who] [pos2] attack;
If (Player [who] [pos2] health<=0) {
Order_Remove (who, pos2);
}
If (Player [3] who [pos1] health<=0) {
Order_Remove (who - 3, pos1);
}}
}
The else {
Player [3] who [0]. Health=Player [3] who [0]. Health - Player [1] who [pos2] attack;
}
}

///////////////////

Int Order_Remove (int the who, int pos) {//who said their coding; Pos is the location of entourage
int i;
If (pos> 0 {
For (I=pos. IIf (who==0) {
+ 1 Player [who] [I]=Player [who + 1] [I + 1);//remove pos position entourage, pos after all want to move to the left a position on the right side of the
}
If (who==3) {
Player [1] who [I]=Player [1] who [I + 1);//remove pos position entourage, pos after all want to move to the left a position on the right side of the
}
}
}
Role_Num [who] -;//character number - 1
return 0;
}

///////////////////

Void main () {
Int r;
Int M;//number indicates that the command
Int m;
Int the who;
Int pos1, pos2;
//* * * * * * * * * * the first part: the printing after library * * * * * * * * * * * *
//to choose a retinue library in assignment and print according to
Struct Retinue [R]={{" 1 ", 1,1,1}, {" 2 ", 2,2,2}, {" 3 ", 3 filling}, {" 4 ", 4,4,4}, {" v ", 5,5,5}, {" 6 ", 6,6,6}, {" 7 ", 7,7,7}, {" 8, "8,8,8}, {" 9," 9,9,9}};//following assignment

//* * * * * * * * * * in the second part: the initial hero numerical * * * * * * * * * * * * * * * *
Player [0] [0]. Health=30;
Player [0] [0]. Magic=2;
Player [3] [0]. Health=30;
Player [3] [0]. Magic=2;
//* * * * * * * * * in the third section: interface * * * * * * * * * * * * * * * * * * * * *


While (1) {
Printf (" 1 - shows you can choose the following \ n ");
Printf (" 2 - shows that your state (HP mana | | have followed) \ n ");
Printf (" 3 - summons after \ n ");
Printf (" 4 - attack command \ n ");
Printf (" 5 - end this turn \ n ");
Printf (" please enter you need to command: \ n ");
The scanf (" % d ", & amp; M);
The switch (M) {
Case 1://show you can choose the following
Printf (" now you can choose between the two sides after library: \ n ");
Printf (" \ t | -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | \ n ");
Printf (" \ t | following Numbers | weapons | | | health consumption values \ n ");
for(r=0; R<9. R++) {
Printf (" \ t | | | | % s % d % d % d | \ n ", R [R]. Name, R [R]. Role. The attack, R [R]. Role. The health, R [R]. Role. The magic).
}
Printf (" \ t | -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - | \ n ");
Case 2://display your state (HP mana | | have followed)
Printf (" please input the party to query code (0 or 1) \ n ");
The scanf (" % d ", & amp; M);
The switch (m) {
Case 0://party [0]
Printf (" party [0] HP: % d | mana: % d | follow quantity: % d | \ n \ n ", the Player [0] [0]. Health, Player [0] [0]. Magic, Role_Num [0] 1);
break;
Case 1://[3 party]
Printf (" \ n [3 party] HP: % d | mana: % d | follow quantity: % d | \ n \ n ", the Player [3] [0]. Health, Player [3] [0]. Magic, Role_Num [1] 1);
break;
}break;
Case 3://called after
Printf (" haven't finished design, please look \ n ");

Case 4://attack command
Printf (" input format: \ n ");
Printf (" who pos1 pos2 | | your code after the position each other after your location \ n ");
The scanf (" % d % d % d ", & amp; The who, & amp; Pos1, & amp; Pos2);
If ((who!=0 | | the who!=3) & amp; & (pos1 & lt; 0 | | pos1 & gt; 6) & amp; & (pos2 & lt; 0 | | pos2 & gt; 6)) {
Printf (" error!!!!! Please enter the correct code. \ n ");
}
The else {
Order_Attack (who, pos1, pos2);
}

If (Player [0] [0]. Health<=0) {
Printf ("] [3 party win!!!!! \n");
exit(0);
}
Else if (Player [3] [0]. Health<=0) {
Printf (" party [0] to win!!!!! \n");
exit(0);
}
The else {
Printf (" one party both sides still alive, please continue! \n");
}break;
Case 5:
exit(0);//no problem here, can run!!!!!!
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related