CONDITIO.C

LIB3/STD/BASIC/CONDITIO.C · 1.9 KB

From the archive nm4dos.zip

Download the archive   « Back to the archive contents

#pragma save_binary
int     cond, max_cond, lowest_cond;

void    create()
{
    max_cond = 1;
}

/* This should be masked by the object */
void    break_me()
{
    this_object()->dest_me();
}

string  cond_string()
{
    string  tit;

    if( living( this_object() ) )
	tit = this_object()->query_pronoun();
    else
	tit = "It ";
    switch( (100 * cond) / max_cond )
    {
	case 0:
	    return tit + "is ruined.\n";
	case 1..10:
	    return tit + "is in terrible condition.\n";
	case 11..20:
	    return tit + "is in very bad condition.\n";
	case 21..30:
	    return tit + "is in bad condition.\n";
	case 31..40:
	    return tit + "is poor condition.\n";
	case 51..60:
	    return tit + "is in average condition.\n";
	case 61..70:
	    return tit + "is in reasonable condition.\n";
	case 71..80:
	    return tit + "is in good condition.\n";
	case 81..90:
	    return tit + "is in very good condition.\n";
	case 91..99:
	    return tit + "is in excellent condition.\n";
	case 100:
	    return tit + "is in perfect condition.\n";
	default:
	    return "";
    }
}

int     query_cond()
{
    return cond;
}
void    set_cond( int i )
{
    cond = i;
    if( cond < lowest_cond )
	lowest_cond = cond;
    if( cond > max_cond )
	max_cond = cond;
    if( cond <= 0 )
    {
	this_object()->break_me();
	return 0;
    }
}
int     adjust_cond( int i )
{
    cond += i;
    if( cond < lowest_cond )
	lowest_cond = cond;
    if( cond > max_cond )
	cond = max_cond;
    if( cond <= 0 )
    {
	this_object()->break_me();
	return 0;
    }
    return cond;
}

void    set_lowest_cond( int i )
{
    lowest_cond = i;
}
int     query_lowest_cond()
{
    return lowest_cond;
}

void    set_max_cond( int i )
{
    max_cond = i;
}
int     query_max_cond()
{
    return max_cond;
}

int     set_percentage( int i )
{
    if( i > 100 )
	i = 100;
    cond = (max_cond * i) / 100;
    lowest_cond = (cond * (random( 30 ) + 70)) / 100;
}

Site Stats

Snippets: 1791
Codebases: 571