本文整理汇总了C++中Spell::witchcraft方法的典型用法代码示例。如果您正苦于以下问题:C++ Spell::witchcraft方法的具体用法?C++ Spell::witchcraft怎么用?C++ Spell::witchcraft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spell
的用法示例。
在下文中一共展示了Spell::witchcraft方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char** argv) {
int N; //mber of rounds
int score1 = 0,score2 = 0;
int result = 0;
int i;
Player* player1;
Player* player2;
Ball* ball;
Spell* spell;
if(argc==1) {
srand (time(NULL));
N = -1;
}
if(argc==2) {
srand (time(NULL));
N = atoi(argv[1]);
}
if(argc==3) {
srand (atoi(argv[2]));
N = atoi(argv[1]);
}
for (i=0; i=N-1; i++) {
int random = rand()%4;
if(random==0) player1= new Chasers;
else if(random==1) player1= new Beaters;
else if(random==2) player1= new Keepers;
else player1= new Seekers;
random=rand()%4;
if(random==0) player2= new Chasers;
else if(random==1) player2= new Beaters;
else if(random==2) player2= new Keepers;
else player2= new Seekers;
random=rand()%4;
if(random==0) spell= new InvalidSpells;
else if(random==1) spell= new PenaltySpells;
else if(random==2) spell= new BonusSpells;
else spell= new JamSpells;
random=rand()%3;
if(random==0) ball= new Quaffle;
else if(random==1) ball= new Bludger;
else ball= new GoldenSnitch;
if(result==1) {
player1->add_spell(-2);
}
if(result==2) {
player2->add_spell(-2);
}
result = 0;
random=rand()%2;
if(random==0) spell->witchcraft(player1);
else spell->witchcraft(player2);
result= ball->battle(&score1,&score2,player1,player2);
delete player1;
delete player2;
delete spell;
delete ball;
cout<<result<<endl;
if(result==3) break;
}
cout<<" Team1 "<<score1<<" ,"<<" Team2 "<<score2<<endl;
return 0;
}