Beispiel #1
0
//protected
void GameofLife::update_this_element(stk::mesh::Entity elem)
{
    if (stk::topology::QUAD_4 == m_elemType)
        update_quad(elem);
    else if (stk::topology::HEX_8 == m_elemType)
        update_hex(elem);
    else if (stk::topology::TRIANGLE_3 == m_elemType)
        update_tri(elem);
    else
        ThrowRequire(true);
}
Beispiel #2
0
init_round()
{

    int i;

    for(i = 0; i < n_units; i++) {

        unit[i].moves_left = unit[i].movement;
        if(unit[i].status == DISABLED) {
            unit[i].status = OK;
            update_hex(unit[i].l_hex, unit[i].r_hex);
        }
        unit[i].range_to_ogre =
            range(ogre.l_hex, ogre.r_hex, unit[i].l_hex, unit[i].r_hex);

    }

}
Beispiel #3
0
redraw_screen() {

    int a, b;

    clear_screen();

    for(a = 1; a <= 28; a++) {
        for(b = 1; b <= 28; b++) {
            if(!off_map(a, b)) {
                update_hex(a, b);
            }
        }
    }

    disp_ogre_status(1);
    describe_action(lastaction, lastunit) ;

#ifdef __HELIOS
  fflush(stdout);
#endif
}
Beispiel #4
0
getunit()
{
    char    no_new, bad_char;
    char    olda, oldb;
    char    dir, i;

    no_new = TRUE;
    bad_char = FALSE;

    movecur_hex(a, b);

    while(no_new) {

        olda = a;
        oldb = b;

        dir = readchar();
    
        switch(dir) {
    
            case RIGHT:
                a--;
                b--;
                break;
    
            case UPRIGHT:
                a--;
                break;
    
            case DOWNRIGHT:
                b--;
                break;
    
            case LEFT:
                a++;
                b++;
                break;
    
            case UPLEFT:
                b++;
                break;
    
            case DOWNLEFT:
                a++;
                break;
    
	    case UNDO:
		if ((i = occupied(a, b)) == 0 || unit[--i].status != OK) {
		    bad_char = TRUE ;
		    break ;
		    }
		if (unit[i].type == CP) {
			cp_set = FALSE ;
			armor_points += unit[i].movement ;
			}
		else if (unit[i].type == INFANTRY) infantry_points += 1 ;
		else if (unit[i].type == HOWITZER) armor_points += 2 ;
		else if (unit[i].type == HVYTANK) armor_points += 1 ;
		else if (unit[i].type == MSLTANK) armor_points += 1 ;
		else if (unit[i].type == GEV) armor_points += 1 ;
		else broken("Internal error in init!") ;

		if (i < n_free) n_free = i ;
		unit[i].status = DESTROYED ;
		update_hex(a, b) ;
		no_new = FALSE ;
		break ;
			
            case CP:
                if(cp_set) {
                    bad_char = TRUE;
                }
                else {
                    add_unit(a, b, dir);
                    no_new = FALSE;
                    cp_set = TRUE;
                }
                break;

            case HVYTANK:
            case MSLTANK:
            case GEV:
                if(occupied(a, b) || blocked(a, b) || armor_points == 0) {
                    bad_char = TRUE;
                    break;
                }
                add_unit(a, b, dir);
                no_new = FALSE;
                armor_points--;
                break;
    
            case INFANTRY:
		dir = '3' ;
	    case '3':
	    case '2':
	    case '1':
		dir = dir - '0' ;
                if(blocked(a, b) || infantry_points < dir) {
                    bad_char = TRUE;
                    break;
                }
		if ((i = occupied(a, b)) != 0)
		    if (unit[--i].type != INFANTRY
		    || infantry_on(a, b) + dir > 3) {
			bad_char = TRUE ;
			break ;
			}
		while (dir--) {
                    add_unit(a, b, 'I');
                    infantry_points -= 1 ;
		    }
                no_new = FALSE;
                break;
    
            case HOWITZER:
                if(occupied(a, b) || blocked(a, b) || armor_points <= 1) {
                    bad_char = TRUE;
                    break;
                }
                add_unit(a, b, dir);
                no_new = FALSE;
                armor_points -= 2;
                break;
    
            default:
                bad_char = TRUE;
                break;
    
        }
    
        if(off_obstructed(a, b)  || 
            bad_char)
        {

	    putchar(BEEP) ;
#ifdef __HELIOS
	    fflush(stdout);
#endif
            a = olda;
            b = oldb;
            bad_char = FALSE;
    
        }

        else {

            movecur_hex(a, b);

        }

    }

}