void *Room_move(void *self, Direction direction)
{
    Room *room = self;
    Room *next = NULL;

    if(direction == NORTH && room->north) {
        printf("You go north, into:\n");
        next = room->north;
    } else if(direction == SOUTH && room->south) {
        printf("You go south, into:\n");
        next = room->south;
    } else if(direction == EAST && room->east) {
        printf("You go east, into:\n");
        next = room->east;
    } else if(direction == WEST && room->west) {
        printf("You go west, into:\n");
        next = room->west;
    } else {
        printf("You can't go that direction.");
        next = NULL;
    }

    if(next) {
        next->_(describe)(next);
    }

    return next;
}
Esempio n. 2
0
void *Room_move(void *self, Direction direction)
{
	assert(self != NULL);
	assert(direction == NORTH || direction == SOUTH ||
		   direction == EAST  || direction == WEST);

	Room *room = self;
	Room *next = NULL;

	if(direction == NORTH && room->north){
		assert(! (printf("You go north, into:\n") < 0));
		next = room->north;
	} else if(direction == SOUTH && room->south){
		assert(! (printf("You go south into:\n") < 0));
		next = room->south;
	} else if(direction == EAST && room->east){
		assert(! (printf("You go east into:\n") < 0));
		next = room->east;
	} else if(direction == WEST && room->west){
		assert(! (printf("You go west into:\n") < 0));
		next = room->west;
	} else {
		assert(! (printf("You can't go in that direction!\n") < 0));
		next = NULL;
	}

	if(next){
		next->_(describe)(next);
	}

	return next;
}
int Map_attack(void *self, int damage)
{
    Map* map = self;
    Room *location = map->location;

    return location->_(attack)(location, damage);
}
Esempio n. 4
0
bool Map_attack(void *self, int damage) {
	assert(self != NULL);
	assert(damage >= 0);

	Map *map = self;
	Room *location = map->location;

	return location->_(attack)(location, damage);
}
Esempio n. 5
0
int Map_attack(void *self, int damage)
{
    Map* map = self;
    Room *location = map->location;

    // macro expands statement to location->proto.attack(location, damage)
    // this calls Room_attack
    return location->_(attack)(location, damage);
}
Esempio n. 6
0
int Map_attack(void *self, int damage)
{
	assert(self);
	assert(((Map*)self)->location);

	Map *map = self;
	Room *location = map->location;

	return location->_(attack)(location, damage);
}
Esempio n. 7
0
/*
 * Asserts:
 *     'damage' is not null.
 *     'damage' is not negative.
 */
int Map_attack(void *self, int damage)
{
    Map *map = self;
    Room *location = map->location;

    // Error Catching
    assert(damage != NULL);
    assert(damage >= 0);

    return location->_(attack)(location, damage);
}
Esempio n. 8
0
void *Map_move(void *self, Direction direction) {
    Map *map = self;
    Room *location = map->location;
    Room *next = NULL;

    next = location->_(move)(location, direction);

    if (next)
        map->location = next;

    return next;
}
Esempio n. 9
0
File: game.c Progetto: cdarne/lcthw
void *Map_move(void *self, Direction direction) {
  assert(self != NULL);
  Map *map = self;
  Room *location = map->location;
  Room *next = NULL;

  next = location->_(move)(location, direction);

  if(next) {
    map->location = next;
  }

  return next;
}
Esempio n. 10
0
/*
 * Asserts:
 *     'direction' is not null.
 */
void *Map_move(void *self, Direction direction)
{
    Map *map = self;
    Room *location = map->location;
    Room *next = NULL;

    // Error Catching
    assert(direction != NULL);

    next = location->_(move)(location, direction);

    if(next) {
        map->location = next;
    }

    return next;
}
Esempio n. 11
0
void *Map_move(void *self, Direction direction)
{
	 assert(self != NULL);

	 // Should always be in some valid location
	 Map *map = self;
	 Room *location = map->location;
	 Room *next = NULL;
	 assert(map->location != NULL);
	 
	 next = location->_(move)(location, direction);

	 if(next) {
		  map->location = next;
	 }
	 
	 return next;
}
Esempio n. 12
0
void *Map_move(void *self, Direction direction)
{
	Map *map = self;
	Room *location = map->location;
	Room *next = NULL;

	// We ask a room for it's room in x direction
	// and set that room as the location of the map.
	next = location->_(move)(location, direction);

	if(next) {
		map->location = next;
	}

	// To be on par we return somthing, but we
	// don't really need it.
	return next;
}