int GUIAction::NotifyVarChange(const std::string& varName, const std::string& value)
{
	GUIObject::NotifyVarChange(varName, value);

	if (varName.empty() && !isConditionValid() && mKeys.empty() && !mActionW)
		doActions();
	else if((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue())
		doActions();

	return 0;
}
示例#2
0
文件: action.cpp 项目: Borkata/linux
int GUIAction::NotifyVarChange(std::string varName, std::string value)
{
    if (varName.empty() && !isConditionValid() && !mKey && !mActionW)
        doActions();

    // This handles notifying the condition system of page start
    if (varName.empty() && isConditionValid())
        NotifyPageSet();

    if ((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue())
        doActions();

    return 0;
}
示例#3
0
bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, const CloseData *closePtr, bool allowDefaults) {
	action++;

	if (closePtr) {
		RuleList *rules = &(_rooms[_roomNum]._rules);

		if (rules->empty() && (roomNum == 0)) {
			_resource->readViews(roomNum);
			rules = &(_rooms[roomNum]._rules);
		}

		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
			if ((rule->_ruleType == kRuleTypeAction) &&
				((rule->_param1 == action) || ((rule->_param1 == 0) && allowDefaults))) {
				if (((rule->_param2 == closePtr->_closeUpType) ||
					  ((rule->_param2 == 0) && allowDefaults)) ||
					  ((action == 1) && (rule->_param2 == -closePtr->_closeUpType))) {
					if (checkConditions(rule->_condition)) {
						doActions(rule->_actionList);
						return true;
					}
				}
			}
		}
	}

	return false;
}
int GUIAction::NotifyTouch(TOUCH_STATE state, int x, int y)
{
	if (state == TOUCH_RELEASE)
		doActions();

	return 0;
}
示例#5
0
文件: action.cpp 项目: Borkata/linux
int GUIAction::NotifyKey(int key)
{
    if (!mKey || key != mKey)    return 1;

    doActions();
    return 0;
}
示例#6
0
bool AI::run()
{
  realLight=(playerID())?player1Light():player0Light();
  cout<<"Turn: "<<turnNumber()<<" Player: "<<playerID()<<" Light: "<<realLight<<endl;
  cout<<"Plants: "<<plants.size()<<endl;
  if(plants.size()<2)
  {
    return true;
  }
  //if the queue is empty
  if(que.empty())
  {
  //  cout<<"First time on this turn"<<endl;
    resetDataStructures();
    buildQueue();
  }
  //cout<<"Queue Size: "<<que.size()<<endl;
  //runs once
  return doActions();
  /*
  while(!que.empty())
  {
    que.pop();
  }
  return true;
  */
  //otherwise
  //return doActions();
  /*
  while(!doActions()){};
  return true;
  */
}
示例#7
0
int GUIAction::NotifyTouch(TOUCH_STATE state __unused, int x __unused, int y __unused)
{
    if (state == TOUCH_RELEASE) {
        doActions();
    }

    return 0;
}
示例#8
0
/* Main program (obviously) */
int main(void)
{
    while (1) {
        initialize();
        clearScreen();
        printf("%s", introText);

        while (!gameOver) {
            prompt();
            if (buffer[0] == '\0') {
            } else if (tolower(buffer[0]) == 'h') {
                doHelp();
            } else if (tolower(buffer[0]) == 'i') {
                doInventory();
            } else if ((tolower(buffer[0]) == 'g')
                       || !strcasecmp(buffer, "n") || !strcasecmp(buffer, "s")
                       || !strcasecmp(buffer, "e") || !strcasecmp(buffer, "w")
                       || !strcasecmp(buffer, "u") || !strcasecmp(buffer, "d")
                       || !strcasecmp(buffer, "north") || !strcasecmp(buffer, "south")
                       || !strcasecmp(buffer, "east") || !strcasecmp(buffer, "west")
                       || !strcasecmp(buffer, "up") || !strcasecmp(buffer, "down")) {
                doGo();
            } else if (tolower(buffer[0]) == 'l') {
                doLook();
            } else if (tolower(buffer[0]) == 't') {
                doTake();
            } else if (tolower(buffer[0]) == 'e') {
                doExamine();
            } else if (tolower(buffer[0]) == 'u') {
                doUse();
            } else if (tolower(buffer[0]) == 'd') {
                doDrop();
            } else if (tolower(buffer[0]) == 'q') {
                doQuit();
            } else if (!strcasecmp(buffer, "xyzzy")) {
                printf("Nice try, but that won't work here.\n");
            } else {
                printf("I don't understand. Try 'help'.\n");
            }

            /* Handle special actions. */
            doActions();
        }

        printf("Game over after %d turns.\n", turnsPlayed);
        printf("%s", "Do you want to play again (y/n)? ");
        fgets(buffer, sizeof(buffer)-1, stdin);
        if (tolower(buffer[0]) == 'n') {
            break;
        }
    }
    return 0;
}
示例#9
0
int GUIAction::NotifyKey(int key, bool down)
{
    auto itr = mKeys.find(key);
    if (itr == mKeys.end()) {
        return 1;
    }

    bool prevState = itr->second;
    itr->second = down;

    // If there is only one key for this action, wait for key up so it
    // doesn't trigger with multi-key actions.
    // Else, check if all buttons are pressed, then consume their release events
    // so they don't trigger one-button actions and reset mKeys pressed status
    if (mKeys.size() == 1) {
        if (!down && prevState) {
            doActions();
            return 0;
        }
    } else if (down) {
        for (itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
            if (!itr->second) {
                return 1;
            }
        }

        // Passed, all req buttons are pressed, reset them and consume release events
        HardwareKeyboard *kb = PageManager::GetHardwareKeyboard();
        for (itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
            kb->ConsumeKeyRelease(itr->first);
            itr->second = false;
        }

        doActions();
        return 0;
    }

    return 1;
}
示例#10
0
bool LabEngine::doMainView() {
	RuleList &rules = _rooms[_roomNum]._rules;
	for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
		if (rule->_ruleType == kRuleTypeGoMainView) {
			if (checkConditions(rule->_condition)) {
				doActions(rule->_actionList);
				return true;
			}
		}
	}

	return false;
}
示例#11
0
bool LabEngine::doGoForward() {
	RuleList &rules = _rooms[_roomNum]._rules;

	for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
		if ((rule->_ruleType == kRuleTypeGoForward) && (rule->_param1 == (_direction + 1))) {
			if (checkConditions(rule->_condition)) {
				doActions(rule->_actionList);
				return true;
			}
		}
	}

	return false;
}
示例#12
0
bool LabEngine::doTurn(uint16 from, uint16 to) {
	from++;
	to++;

	RuleList &rules = _rooms[_roomNum]._rules;

	for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) {
		if ((rule->_ruleType == kRuleTypeTurn) ||
			  ((rule->_ruleType == kRuleTypeTurnFromTo) &&
			  (rule->_param1 == from) && (rule->_param2 == to))) {
			if (checkConditions(rule->_condition)) {
				doActions(rule->_actionList);
				return true;
			}
		}
	}

	return false;
}
示例#13
0
void Enemy1::update(std::list<GameCharacter*> characters)
{
	if (health > 0)
	{
		doActions(characters);
	}
	else
	{
		if (target_ != NULL)
		{
			std::get<AVAILABLE>(players[playernum]) = true;
			target_ = NULL;
		}
		framesToEnd--;
		animation("FALLING");
		frame = DEATH_FRAME;
	}
	resizeClips(&Clips[frame / FRAMES_DELIMITOR]);
}
示例#14
0
void Hero::update()
{
	doActions();
	updateStates();
}