本文整理汇总了C++中Monster::_方法的典型用法代码示例。如果您正苦于以下问题:C++ Monster::_方法的具体用法?C++ Monster::_怎么用?C++ Monster::_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monster
的用法示例。
在下文中一共展示了Monster::_方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Room_attack
int Room_attack(void *self, int damage) {
Room *room = self;
Monster *monster = room->bad_guy;
if(monster) {
monster->_(attack)(monster, damage);
return 1;
} else {
printf("You flail in the air at nothing. Idiot.\n");
return 0;
}
}
示例2: Room_attack
int Room_attack(void *self, int damage)
{
Room *room = self;
Monster *monster = room->bad_guy;
if(monster) {
monster->_(attack)(monster, damage);
return 1;
} else {
printf("You run in screaming for no reason. Good job.\n");
return 0;
}
}
示例3: Monster_attack
int Monster_attack(void *self, int damage){
Monster* monster = self;
printf("You attack %s!\n", monster->_(description));
monster->hit_points -=damage;
if(monster->hit_points > 0){
printf("It is still alive.\n");
return 0;
}else{
printf("It is dead!\n");
return 1;
}
}
示例4: Room_attack
int Room_attack(void *self, int damage){
assert(self != NULL);
Room *room = self;
Monster *monster = room->bad_guy;
if(monster){
monster->_(attack)(monster, damage);
return 1;
} else {
assert(! (printf("You flail in the air at nothing.\n") < 0));
return 0;
}
}
示例5: Room_attack
bool Room_attack(void *self, int damage) {
assert(self != NULL);
assert(damage >= 0);
Room *room = self;
Monster *monster = room->bad_guy;
if (monster) {
monster->_(attack)(monster, damage);
return true;
} else {
printf("You flail in the air at nothing.\n");
return false;
}
}
示例6: Monster_attack
int Monster_attack(void *self, int damage) {
Monster *monster = self;
// obj->_(func) == obj->proto.func
printf("You attack %s!\n", monster->_(description));
monster->hit_points -= damage;
if (monster->hit_points > 0) {
puts("It is still alive.");
return 0;
}
else {
puts("It is dead.");
return 1;
}
}
示例7: Monster_attack
int Monster_attack(void *self, int damage)
{
assert(damage > 0);
Monster *monster = self;
printf("You attack %s! You inflict %d damage!\n", monster->_(description), damage);
monster->hit_points -= damage;
if(monster->hit_points > 0) {
printf("It is still alive, it has %d hp left.\n", monster->hit_points);
return 0;
} else {
printf("It is dead!\n");
return 1;
}
}
示例8: Room_attack
/*
* Asserts:
* 'damage' is not null.
* 'damage' is not negative.
*/
int Room_attack(void *self, int damage)
{
Room *room = self;
Monster *monster = room->bad_guy;
// Error Catching
assert(damage != NULL);
assert(damage >= 0);
if(monster) {
monster->_(attack)(monster, damage);
return 1;
} else {
printf("You flail in the air at nothing. Idiot.\n");
return 0;
}
}
示例9: Monster_attack
bool Monster_attack(void *self, int damage) {
assert(self != NULL);
assert(damage >= 0);
Monster *monster = self;
printf("You attack %s!\n", monster->_(description));
monster->hit_points -= damage;
if (monster->hit_points > 0) {
printf("It is still alive.\n");
return false;
} else {
printf("It is dead!\n");
return true;
}
}
示例10: Monster_attack
int Monster_attack(void *self, int damage)
{
assert(self != NULL);
Monster *monster = self;
assert(! (printf("You attack %s!\n", monster->_(description)) < 0));
monster->hit_points -= damage;
if(monster->hit_points > 0){
assert(! (printf("It is still alive.\n") < 0));
return 0;
} else {
assert(! (printf("It is dead!\n") < 0));
return 1;
}
}
示例11: Room_attack
int Room_attack(void *self, int damage)
{
Room *room = self;
Monster *monster = room->bad_guy;
if(monster) {
// monster->proto.attack which is a
// function pointer to Monster_attack
// (or Object_attack if not overriden)
// which we call with monster and damage
// as args.
monster->_(attack) (monster, damage);
return 1;
} else {
printf("You flail in the air at nothin. Idiot.\n");
return 0;
}
}
示例12: Monster_attack
int Monster_attack(void *self, int damage)
{
Monster *monster = self;
printf("You attack %s for %dhp of damage\n", monster->_(description), damage);
monster->hit_points -= damage;
if(monster->hit_points > 0) {
printf("It is still alive and has %dhp remaining\n.",
monster->hit_points);
return 0;
} else {
printf("It is dead! it drops %d gold coins\n",
monster->loot);
return 1;
}
}
示例13: Monster_attack
int Monster_attack(void *self, int damage)
{
// Store a pointer to our object on the stack
Monster *monster = self;
// monster->_(description) macros into
// monster->proto.description
printf("You attack %s!\n", monster->_(description));
monster->hit_points -= damage;
if(monster->hit_points > 0) {
printf("It is still alive.\n");
return 0;
} else {
printf("It is dead!\n");
return 1;
}
}