Esempio n. 1
0
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, int p0, int p1, int p2, int p3, bool hasAnswer, int p4) {
	cout << "Test " << testNum << ": [" << p0 << "," << p1 << "," << p2 << "," << p3;
	cout << "]" << endl;
	Stairs *obj;
	int answer;
	obj = new Stairs();
	clock_t startTime = clock();
	answer = obj->designs(p0, p1, p2, p3);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << p4 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p4;
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}
Esempio n. 2
0
  void Maze::scanForEntrances() {
    for (uint32_t i = 1; i <= getFloorCount(); i++) {
      Map* curMap = getFloor(i);
      
      if (i == 1) {
        //  In this case, we want up stairs.
        bool foundEntrance = false;
        bool multipleWarned = false;
        for (int32_t y = 0; y < curMap->getHeight(); y++) {
          for (int32_t x = 0; x < curMap->getWidth(); x++) {
            Activatable* act = curMap->getActivatable(x, y);
            if (act) {
              Stairs* stairs = act->asStairs();
              if (stairs && stairs->getDirection() == StairDirection::UP) {
                Facing dstFacing = stairs->getDestinationFacing();
                
                //  Adjust the position so that when the player enters, they're
                //  facing the right direction, and in the right position.
                int32_t dstX = x;
                int32_t dstY = y;
                switch(dstFacing) {
                case Facing::NORTH:
                  dstY--;
                  break;
                case Facing::EAST:
                  dstX++;
                  break;
                case Facing::SOUTH:
                  dstY++;
                  break;
                case Facing::WEST:
                  dstX--;
                  break;
                }

                if (foundEntrance && !multipleWarned) {
                  writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances():  Multiple up stairs found on floor of maze.");
                  multipleWarned = true;
                }
                else {
                  if (!curMap->canEntityEnter(dstX, dstY)) {
                    writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances():  Entrance as specified would place player in solid wall.");
                  }
                  else {
                    mazeEntrance = Entrance(i, dstX, dstY, dstFacing);
                    foundEntrance = true;
                  }
                }
              }
            }
          }
        }
      }
      else {
        //  Otherwise, we're looking for geomagnetic poles.  This is currently
        //  not implemented.  Mostly because geopoles don't exist.
      }
    }
  }
Esempio n. 3
0
/**
 * \brief This function is called when some stairs detect a collision with this entity.
 * \param stairs the stairs entity
 * \param collision_mode the collision mode that detected the event
 */
void CarriedItem::notify_collision_with_stairs(Stairs& stairs, CollisionMode /* collision_mode */) {

  if (is_throwing
      && !is_breaking
      && stairs.is_inside_floor()
      && get_layer() == stairs.get_layer()) {
    break_one_layer_above = true; // show the destruction animation above the stairs
  }
}
Esempio n. 4
0
/**
 * @brief This function is called when some stairs detect a collision with this entity.
 * @param stairs the stairs entity
 * @param collision_mode the collision mode that detected the event
 */
void CarriedItem::notify_collision_with_stairs(Stairs &stairs, CollisionMode collision_mode) {

  if (is_throwing && !is_breaking
      && stairs.is_inside_floor() && get_layer() == LAYER_LOW) {
    break_on_intermediate_layer = true; // show the destruction animation above the stairs
  }
}
Esempio n. 5
0
/**
 * \copydoc MapEntity::is_stairs_obstacle
 */
bool CustomEntity::is_stairs_obstacle(Stairs& stairs) {

    const TraversableInfo& info = get_can_traverse_entity_info(stairs.get_type());
    if (!info.is_empty()) {
        return !info.is_traversable(*this, stairs);
    }
    return Detector::is_stairs_obstacle(stairs);
}
Esempio n. 6
0
int test3() {
    int maxHeight = 359;
    int minWidth = 1;
    int totalHeight = 720;
    int totalWidth = 720;
    Stairs* pObj = new Stairs();
    clock_t start = clock();
    int result = pObj->designs(maxHeight, minWidth, totalHeight, totalWidth);
    clock_t end = clock();
    delete pObj;
    int expected = 7;
    if(result == expected) {
        cout << "Test Case 3: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 0;
    } else {
        cout << "Test Case 3: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl;
        return 1;
    }
}
Esempio n. 7
0
/**
 * \brief Returns whether some stairs are currently considered as an obstacle for this entity.
 * \param stairs an stairs entity
 * \return true if the stairs are currently an obstacle for this entity
 */
bool Boomerang::is_stairs_obstacle(const Stairs& stairs) const {
  return stairs.is_inside_floor() && get_layer() == LAYER_LOW;
}
Esempio n. 8
0
/**
 * \brief Returns whether some stairs are currently considered as an obstacle for this entity.
 * \param stairs an stairs entity
 * \return true if the stairs are currently an obstacle for this entity
 */
bool Arrow::is_stairs_obstacle(Stairs& stairs) {
  return stairs.is_inside_floor() && get_layer() == LAYER_LOW;
}
Esempio n. 9
0
/**
 * \brief Returns whether some stairs are currently considered as an obstacle for this entity.
 * \param stairs an stairs entity
 * \return true if the stairs are currently an obstacle for this entity
 */
bool Boomerang::is_stairs_obstacle(Stairs& stairs) {
  return stairs.is_inside_floor() && get_layer() == stairs.get_layer();
}