void testClocks()	{
    sput_fail_unless(addClock(testClock) == 1,"Valid: Adding Dummy Test Clock");
    sput_fail_unless(checkUniqueClockType(testClock) == 0,"Invalid: Unique clock checker.  Clocck should already exist");
    sput_fail_unless(addClock(testClock) == 0,"Invalid: Adding non unique Dummy clock");
    sput_fail_unless(checkClock(testClock,10) == 0,"Invalid: Cooldown of 10 has not passed");
    delayGame(10);
    sput_fail_unless(checkClock(testClock,10) == 1,"Valid: Cooldown of 10 has passed");
    sput_fail_unless(checkClock(testClock,10) == 0,"Invalid: Cooldown of 10 hasn't passed after reset of cooldown");
    delayGame(10);
    sput_fail_unless(checkClock(testClock,10) == 1,"Valid: Cooldown of 10 has passed after reset of cooldown");

}
예제 #2
0
/*
 * Add Clock Node
 */
void addClock(clockType type)	{
	
	GameClock clock = getClock(NULL);	
	if(checkUniqueClockType(type))	{
		if(clock->first == NULL)	{
			clock->first = clock->last = createClockNode(type);
		} else {
			clock->last->next = createClockNode(type);
			clock->last = clock->last->next;
		}
	}
}
/*
 * Add Clock Node
 */
int addClock(clockType type)	{
    GameClock clock = getClock(NULL);
    if(checkUniqueClockType(type))	{
        if(clock->first == NULL)	{
            clock->first = clock->last = createClockNode(type);
        } else {
            clock->last->next = createClockNode(type);
            clock->last = clock->last->next;
        }
    } else {
        fprintf(stderr,"Attempt to add non unique clock\n");
        return 0;
    }
    return 1;
}