예제 #1
0
파일: City.cpp 프로젝트: KrisTo-Corp/ESS
Store* City::robStore() {
	REQUIRE(properlyInitialized(), "Object 'City' was not properly properlyInitializedialized when calling robStore()");

	bool success = false;
	Store* ptr;
	int loops = 0;

	while (!success) {
		std::list<Store>::iterator it = stores.begin();
		int randomInt = rand()% stores.size();
		for (int i = 0; i < randomInt; i++) {
			it++;
		}

		ptr = &(*it);
		if (ptr->getState() == normal) {
			success = true;
		}
		if (loops == 100){
			return NULL;
		}
		loops++;
	}

	ptr->setState(beingrobbed);

	ENSURE(ptr->getState() == beingrobbed, "robStore() did not cause a robbery.");

	return ptr;
}
예제 #2
0
파일: City.cpp 프로젝트: KrisTo-Corp/ESS
Store* City::robStore(int x, int y){
	REQUIRE(properlyInitialized(), "Object 'City' was not properly properlyInitializedialized when calling robStore(int, int)");

	CityObjects* ptr;
	ptr = matrix.getObject(x, y);
	Store* storeptr = dynamic_cast<Store*>(ptr);
	if (storeptr->getState() != normal || storeptr->getType() != store){
		return NULL;
	}

	storeptr->setState(beingrobbed);

	ENSURE(storeptr->getState() == beingrobbed, "setFire() did not correctly set fire to the given house.");

	return storeptr;
}