Exemplo n.º 1
0
Potion::Potion(int id){
    setPotion(true);
    setUsable(true);
    this->health = 0;
    this->heal = 0;
    this->attackPower = 0;
    this->defense = 0;
    this->maxTime = 0;
    
    switch(id){
        case POTION_HEAL:
            ressources[RES_SNAKE_HEAD]        = 0;
            ressources[RES_EVER_GREEN]        = 3;
            ressources[RES_WASP_DEATH]        = 0;
            ressources[RES_BLADE_LEAF]        = 0;
            this->heal = 2;
            this->onTimePotion = false;
        break;
        case POTION_POISON:
            ressources[RES_SNAKE_HEAD]        = 3;
            ressources[RES_EVER_GREEN]        = 0;
            ressources[RES_WASP_DEATH]        = 1;
            ressources[RES_BLADE_LEAF]        = 0;
            this->attackPower = 3;
        break;
    }
}
Exemplo n.º 2
0
Potion::Potion(int health,int heal,int atk,int def, float max,int id) {
    this->health = health;
    this->heal = heal;
    this->attackPower = atk;
    this->defense = def;
    this->maxTime = max;
    this->onTimePotion = true;
    setPotion(true);
    setUsable(true);

}
Exemplo n.º 3
0
WindowsSimPort::WindowsSimPort(const char *port) {
	portname = NULL;

	if(NULL == port || 0 == strlen(port)) {
		return;
	}

	portname = strdup(port);

	char fullportname[512];
	_snprintf(fullportname, sizeof(fullportname), "\\\\.\\%s", portname);
	portHandle=CreateFileA(fullportname, GENERIC_READ|GENERIC_WRITE,0, NULL, OPEN_EXISTING, 0, NULL);
	if (portHandle == INVALID_HANDLE_VALUE) {
		fprintf(stderr, "Invalid handle returned by CreateFileA [port \"%s\"]\n", fullportname);
		return;
	}
	COMMCONFIG Win_CommConfig;
	COMMTIMEOUTS Win_CommTimeouts;
	unsigned long confSize = sizeof(COMMCONFIG);
	Win_CommConfig.dwSize = confSize;
	GetCommConfig(portHandle, &Win_CommConfig, &confSize);
	Win_CommConfig.dcb.Parity = 0;
	Win_CommConfig.dcb.fRtsControl = RTS_CONTROL_DISABLE;
	Win_CommConfig.dcb.fOutxCtsFlow = FALSE;
	Win_CommConfig.dcb.fOutxDsrFlow = FALSE;
	Win_CommConfig.dcb.fDtrControl = DTR_CONTROL_DISABLE;
	Win_CommConfig.dcb.fDsrSensitivity = FALSE;
	Win_CommConfig.dcb.fNull=FALSE;
	Win_CommConfig.dcb.fTXContinueOnXoff = FALSE;
	Win_CommConfig.dcb.fInX=FALSE;
	Win_CommConfig.dcb.fOutX=FALSE;
	Win_CommConfig.dcb.fBinary=TRUE;
	Win_CommConfig.dcb.DCBlength = sizeof(DCB);
	Win_CommConfig.dcb.BaudRate = 9600;
	Win_CommConfig.dcb.ByteSize = 8;
	Win_CommTimeouts.ReadIntervalTimeout = 50;
	Win_CommTimeouts.ReadTotalTimeoutMultiplier = 0;
	Win_CommTimeouts.ReadTotalTimeoutConstant = 110;
	Win_CommTimeouts.WriteTotalTimeoutMultiplier = 0;
	Win_CommTimeouts.WriteTotalTimeoutConstant = 110;
	SetCommConfig(portHandle, &Win_CommConfig, sizeof(COMMCONFIG));
	SetCommTimeouts(portHandle,&Win_CommTimeouts);

	readbuf_pos = 0;
	memset(readbuf, '\0', sizeof(readbuf));
	memset(lastread, '\0', sizeof(lastread));

	setUsable(1);
}