Exemple #1
0
int setup_bcb_vis(int numagents, struct agent_t *agents, int *argc, char ***argv)
{
	int i;
	if (NULL == initscr())
	{
		fprintf(stderr, "initscr() == NULL");
		return 0;
	}

	curs_set(0);
	clear();
	noecho();
	cbreak();
	
	// don't care about y
	getmaxyx(stdscr, i, SCREEN_WIDTH);
	
	for (i = 0; i < numagents; ++i)
	{
		struct display_t *disp = agents[i].vis = malloc(sizeof *disp);
		int cury = 1 + (PANEL_HEIGHT+1) * i;

		disp->notif = newwin(CARD_HEIGHT, 1, cury, 1);
		disp->card = newwin(CARD_HEIGHT, CARD_WIDTH, cury, 3);
		disp->panel = newwin(PANEL_HEIGHT, PANEL_WIDTH, cury, 4+CARD_WIDTH);

		update_card(disp, -1, 0);
		update_panel(disp, &agents[i], NULL);
	}
	
	// get the sleep time, convert from milliseconds to microseconds
	if (*argc) { --*argc; sscanf((*argv++)[0], "%u", &sleep_time); sleep_time *= 1000u; }

	return 1;
};
Exemple #2
0
static void update_card_layer_B(Layer *me, GContext* ctx)
{
	int card_no = (current % 2 == 1)?current:previous; //"current card" when odd
	card_no = card_no%CACHE_SIZE;
	
	update_card(ctx, card_no);
}
Exemple #3
0
int update_bcb_vis(int numagents, struct agent_t *agents, card_t* cards, const int turn, const char *move)
{
	int i; card_t highcard = 0u;
	for (i = 0; i < numagents; ++i)
		if (cards[i] > highcard) highcard = cards[i];
	
	struct agent_t *a;
	for (i = 0, a = agents; i < numagents; ++i, ++a)
	{
		struct display_t* vis = a->vis;
		update_card(vis, a->pool ? cards[i] : -1, 
			cards[i] == highcard && a->pool);
		update_panel(vis, &agents[i], i == turn ? move : NULL);
		
		// draw notification region
		wclear(vis->notif); wattron(vis->notif, A_BOLD);
		if (i == turn) mvwvline(vis->notif, 0, 0, '>', PANEL_HEIGHT);
		wattroff(vis->notif, A_BOLD); wrefresh(vis->notif);
	}
	
	usleep(sleep_time);
	return 1;
};