Esempio n. 1
0
void KickTo::updateFinishFlag(World& w)
{
		if(is_kicked){
			finish_flag = true;
		}
		else{
			finish_flag = false;
            judgement(w);
		}
}
Esempio n. 2
0
KickTo::KickTo(World& w ,double _target_angle){
		// angle:count = 90:15
		//std::cout << "KickTo constructed!!" << std::endl;
    finish_flag = false;

    is_kicked = false;
    target_angle = _target_angle;
    judgement(w);
    updateFinishFlag(w);
}
Esempio n. 3
0
void* controler(void *t)	//control the game's order.
{
	int i, n, j;
	struct msgbuf msg;
	char buf[512], current_user_put_pokers[512], current_round_pokers[512], current_user_claim_pokers[512];
	regist();
	poker_gen();
	poker_sender();
	while(1)
	{
		memset(current_round_pokers, '\0', sizeof(current_round_pokers));
		for(i = 0; i < MAXUSERNUM; i++)
		{
			printf("LOG: controler SEND \"TURN\" TO %d\n", connecter_fd[i]);
			write(connecter_fd[i], "TURN", strlen("TURN"));

			//read the real pokers
			msg = readmsg();	
			strcpy(buf, msg.mtext);
			printf("LOG: %d-----%s\n", msg.mtype, msg.mtext);
			sscanf(buf, "%*s%s", current_user_put_pokers); 		
			printf("LOG: %d CURRENT_USER_PUT_POKERS: %s\n", connecter_fd[i], current_user_put_pokers);
			strcat(current_round_pokers, current_user_put_pokers);
			printf("LOG: %d CURRENT_ROUND_POKERS: %s\n", connecter_fd[i], current_round_pokers);

			//read the claim pokers
			msg = readmsg();
			strcpy(buf, msg.mtext);	
			printf("LOG: %d-----%s\n", msg.mtype, msg.mtext);
			sscanf(buf, "%*s%s", current_user_claim_pokers); 		
			printf("LOG: %d CURRENT_USER_CLAIM_POKERS: %s\n", connecter_fd[i], current_user_claim_pokers);
			broadcast(connecter_fd[i], current_user_claim_pokers);

			//Judge Part
			judgement(i, current_round_pokers, current_user_put_pokers, current_user_claim_pokers);

			//Add pokers part, under consideration, add this function further.
			

			printf("%s\n", msg.mtext);
			if (!strcmp(msg.mtext, "OVER"))
			{
				printf("GAME OVER, THE WINNER IS %d\n", msg.mtype);
				break;
			}
		}
	}
}
Esempio n. 4
0
int judgement_4lua(lua_State *L)
{	
	extern int answer;
	
	judgement((char *)getStr(L));
	
//	printf("answer %d", answer);
	while (!answer) {
		SDL_Delay(50);
	}
	
	putNumber(L, answer);
	answer = 0;
	
	return 1;
}
Esempio n. 5
0
void AdjustToBall::updateFinishFlag(World& w)
{ // 0.73
    // std::cout << "##adjust update##\tbal[0]: " << w.getBAL(0) <<
    // "\tconfBAL: " << w.confBAL() <<
    // "\tabs(w.getBAL): " << abs(w.getBAL(1)) << std::endl;
    if (w.getBAL(0) < 0.9 &&
        w.confBAL() <= 150 &&
        abs(w.getBAL(1)) <= 10 &&
        !w.isFalling())
    {
        finish_flag = true;
    } else {
        finish_flag = false;
        judgement(w);
    }
}
Esempio n. 6
0
AdjustToBall::AdjustToBall(World& w){
    finish_flag = false;
    
    for(int i=0; i<2; i++){
      ballpos[i] = w.getBXY(i);
      bal[i] = w.getBAL(i);
    }
    conf_ballpos = w.confBXY();
    conf_bal = w.confBAL();
    x = w.getXY(0);
    y = w.getXY(1);
    conf_XY = w.confXY();

    t_count = abs(15 * bal[1] / 360);

    judgement(w);
    updateFinishFlag(w);
}
Esempio n. 7
0
Attack::Attack(World& w, double _initpos[]) {

		//d = new Drawing();
    finish_flag = false;
    beam_flag = false;
    start_flag = false;

    ballpos[0] = 0.0;
    ballpos[1] = 0.0;
    bal[0] = w.getBAL(0);
    bal[1] = w.getBAL(1);
    bal[2] = w.getBAL(2);
    mypos[0] = 0.0;
    mypos[1] = 0.0;
    balposconf = w.confBAL();
    myposconf = w.confXY();
    egrconf = w.confEGR();
    eglconf = w.confEGL();
    angle = w.getABSANGLE();
    for (int i = 0; i < 3; i++)
    {
        egr[i] = w.getEGR(i);
        egl[i] = w.getEGL(i);
    }
    updateFandE(w);

    field_x = w.getFieldLengthX();
    field_y = w.getFieldLengthY();

    kickAngle = 0.0;
    passTo = 0;
    ROLE = "NONE";

    initpos[0] = _initpos[0];
    initpos[1] = _initpos[1];
    initpos[2] = _initpos[2];
    judgement(w);
}
Esempio n. 8
0
void Attack::updateFinishFlag(World& w) {
    judgement(w);
    //d->draw(w);
}
int main(int argc, const char *argv[])
{
    printf("judgement = %d\n", judgement()); 
    return 0;
}