Пример #1
0
void BoxContainer::mergeSquares() {
	s2 = findSquare(ok2);

	if (!ok2 || !ok1) {
		clrscr();
		cout << "\tNo such square. Cannot merge\n";
		std::this_thread::sleep_for(std::chrono::milliseconds(700));
		return;
	}
	if (s1 == s2) {
		clrscr();
		cout << "\tCan't merge with the same square. Nothing to do.\n";
		std::this_thread::sleep_for(std::chrono::milliseconds(700));
		return;
	}
	auto smaller = (s1->getLength() <= s2->getLength()) ? s1 : s2;
	auto bigger = (s1->getLength() < s2->getLength()) ? s2 : s1;

	if (*s1 < *s2)
		sqrList.erase(s1);
	else if (*s1 > *s2)
		sqrList.erase(s2);
	else if (s1->overlaps(*s2))
		sqrList.erase(bigger);
	else // they must be strangers
		sqrList.erase(smaller);

	reset1();
	reset2();
}
Пример #2
0
void testNPCResetWithMultipleResets() {

    shared_ptr<Room> room = make_shared<Room>();
    shared_ptr<NPC> npc1 = make_shared<NPC>("50");
    shared_ptr<NPC> npc2 = make_shared<NPC>("35");


    NPCReset reset1(room, npc1, 3);
    NPCReset reset2(room, npc2, 2);


    reset1.performReset();
    reset1.performReset();
    reset1.performReset();
    reset1.performReset();
    reset1.performReset();


    reset2.performReset();
    reset2.performReset();
    reset2.performReset();    
    reset2.performReset();
    reset2.performReset();


    if(room->getNumberOfNPCsWithID("50") == 3) {
        cout << "test passed: 3 npc's with id: 50 added" << endl;
    } else {
        cout << "test failed: only " << room->getNumberOfNPCsWithID("50") << " npc's with id: 50 were added" << endl;
    }

    if(room->getNumberOfNPCsWithID("35") == 2) {
        cout << "test passed: 2 npc's with id: 35 addded" << endl;
    } else {
        cout << "test failed: only " << room->getNumberOfNPCsWithID("35") << " npc's with id: 35 were added" << endl;
    }

    if(room->getNPCs().size() == 5) {
        cout << "test passed: 5 npc's in total were added" << endl;
    } else {
        cout << "test failed: onely " << room->getNPCs().size() << " npc's were added" << endl;
    }

    auto npcs = room->getNPCs();

    if(npcs[0] == npc1) {
        cout << "test failed: not coppied properly" << endl;
    } else {
        cout << "test passed: npc not reference to object - " << npc1 << " : " << npcs[0] << endl;
    }

    if(npcs[0] == npcs[1]) {
        cout << "test failed: two npc's have same reference in room" << endl;
    } else { 
        cout << "test passed: npc's dont have the same reference - " << npcs[0] << " : " <<  npcs[1] << endl;
    }



}
Пример #3
0
void BoxContainer::deleteSquare() {
	if (!ok1) {
		cout << "\tNo square selected. Cannot complete action.\n";
		return;
	}

	sqrList.erase(s1);
	reset1();
}
Пример #4
0
void BoxContainer::moveSquareForward() {
	sqrList.splice(sqrList.end(), sqrList, s1);
	reset1();
}
Пример #5
0
result simplifier::simplify(expr const & e, simp_lemmas const & srss) {
    flet<simp_lemmas> set_srss(m_srss, srss);
    freset<simplify_cache> reset1(m_cache);
    freset<expr_map<expr>> reset2(m_subsingleton_elem_map);
    return simplify(e, true);
}