示例#1
0
task autonomous()
{
	deploy();
	while(true)
	{
		if(SensorValue[waitingButtonRed] == 1)
		{
			if(SensorValue[AutonSelect] < ALEX)
			{
				Alex(); // 15 middle zone
			}
			else if(SensorValue[AutonSelect] < UDIT)
			{
				RedUdit(); // projected 30 pts + spare change (6-14)
			}
			else if(SensorValue[AutonSelect] < DEVANSH)
			{
				skills(); // safe 3-6
		 	}
			else{}
			break;
		}
		else if(SensorValue[waitingButtonBlue] == 1)
		{
			if(SensorValue[AutonSelect] < ALEX)
			  Alex();
			else if(SensorValue[AutonSelect] < UDIT)
				blueUdit();
			else if(SensorValue[AutonSelect] < DEVANSH)
				skills();
			else{}
			break;
		}
	}
}
task autonomous()
{



		while(true){
		if(SensorValue[waitingButtonRed] == 1)
		{
			if(SensorValue[AutonSelect] < ALEX){
				Alex();
			}
			else if(SensorValue[AutonSelect] < UDIT){
				skills();
			}
			else if(SensorValue[AutonSelect] < DEVANSH){
				redDevansh();
		 }
			else{}
			break;
		}
		else if(SensorValue[waitingButtonBlue] == 1)
		{
			if(SensorValue[AutonSelect] < ALEX)
				Alex();
			else if(SensorValue[AutonSelect] < UDIT)
				skills();
			else if(SensorValue[AutonSelect] < DEVANSH)
				blueDevansh();
			else{}
			break;
		}
	}
}
void PlayerCreatureTemplate::parseVariableData(const String& varName, LuaObject* templateData) {
	lua_State* state = templateData->getLuaState();
	if (varName == "defaultLanguage")
		defaultLanguage = Lua::getIntParameter(state);
	else if (varName == "startingSkills") {
		startingSkills->removeAll();

		LuaObject skills(state);

		for (int i = 1; i <= skills.getTableSize(); ++i) {
			startingSkills->add(skills.getStringAt(i));
		}

		skills.pop();
	} else if (varName == "startingItems") {
		startingItems->removeAll();

		LuaObject items(state);

		for (int i = 1; i <= items.getTableSize(); ++i) {
			startingItems->add(items.getStringAt(i));
		}

		items.pop();
	} else {
		templateData->pop();
	}
}
Skill::Secondary Dialog::SelectSecondarySkill(void)
{
    Display & display = Display::Get();
    Cursor & cursor = Cursor::Get();
    LocalEvent & le = LocalEvent::Get();

    std::vector<int> skills(MAXSECONDARYSKILL * 3, 0);

    cursor.Hide();
    cursor.SetThemes(cursor.POINTER);

    for(size_t ii = 0; ii < MAXSECONDARYSKILL * 3; ++ii) skills[ii] = ii;

    const u16 window_w = 310;
    const u16 window_h = 280;

    Dialog::FrameBorder frameborder;
    frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH,
			    (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h);
    frameborder.Redraw(AGG::GetICN(ICN::TEXTBAK2, 0));

    const Rect & area = frameborder.GetArea();

    SelectEnumSecSkill listbox(area);

    listbox.SetListContent(skills);
    listbox.Redraw();

    ButtonGroups btnGroups(area, Dialog::OK|Dialog::CANCEL);
    btnGroups.Draw();

    cursor.Show();
    display.Flip();

    u16 result = Dialog::ZERO;

    while(result == Dialog::ZERO && ! listbox.ok && le.HandleEvents())
    {
        result = btnGroups.QueueEventProcessing();
        listbox.QueueEventProcessing();

        if(!cursor.isVisible())
        {
            listbox.Redraw();
            cursor.Show();
            display.Flip();
        }
    }

    Skill::Secondary skill;

    if(result == Dialog::OK || listbox.ok)
    {
	skill.SetSkill(1 + (listbox.GetCurrent() / 3));
	skill.SetLevel(1 + (listbox.GetCurrent() % 3));
    }

    return skill;
}
示例#5
0
QVector<Skill> Dwarf::read_skills() {
	m_total_xp = 0;
	QVector<Skill> skills(0);
    for(int i=0;i < m_cre.numSkills;i++){
        Skill s(m_cre.skills[i].id, m_cre.skills[i].experience, m_cre.skills[i].rating);
		m_total_xp += s.actual_exp();
		skills.append(s);
	}
	return skills;
}
示例#6
0
void skills(View* view, int lastInd = 0) {
  vector<View::ListElem> options;
  vector<Skill*> s = Skill::getAll();
  for (Skill* skill : s)
    options.push_back(skill->getName());
  auto index = view->chooseFromList("Skills", options, lastInd);
  if (!index)
    return;
  skill(view, s[*index]);
  skills(view, *index);
}
示例#7
0
void Encyclopedia::present(View* view, int lastInd) {
  auto index = view->chooseFromList("Choose topic:",
      {"Advances", /*"Workshop",*/ "Deities", "Skills"}, lastInd);
  if (!index)
    return;
  switch (*index) {
    case 0: advances(view); break;
//    case 1: workshop(view); break;
    case 1: deities(view); break;
    case 2: skills(view); break;
    default: FAIL << "wfepok";
  }
  present(view, *index);
}
// Loads in the skills of a team from csv file to the team's map of skills
void Team::loadSkills() {
	string directory = "..\\CSV Files\\";
	string fileName = directory + mName + "Skills.csv";
	ifstream skills(fileName);
	if (skills.is_open()) {
		while (!skills.eof()) {
			// Grab each line and put it in the map
			string line;
			getline(skills, line);
			string key = line.substr(0, line.find(","));
			string strValue = line.substr(line.find(",") + 1);
			int value = stoi(strValue);
			mSkills.insert(make_pair(key, value));
		}
	}
	else {
		cout << "Error! Could not open the file" << endl;
	}
}
示例#9
0
size_t CClient::Cmd_Skill_Menu_Build( RESOURCE_ID_BASE rid, int iSelect, CMenuItem *item, size_t iMaxSize, bool &fShowMenu, bool &fLimitReached )
{
	ADDTOCALLSTACK("CClient::Cmd_Skill_Menu_Build");
	// Build the skill menu for the curent active skill.
	// Only list the things we have skill and ingrediants to make.
	//
	// ARGS:
	//	m_Targ_UID = the object used to get us here.
	//  rid = which menu ?
	//	iSelect = -2 = Just a test of the whole menu.,
	//	iSelect = -1 = 1st setup.
	//	iSelect = 0 = cancel
	//	iSelect = x = execute the selection.
	//  fShowMenu = whether or not menus can be shown
	//  item = pointer to entries list
	//  iMaxSize = maximum number of entries
	//
	// RETURN: number of entries in menu
	//   m_tmMenu.m_Item = the menu entries.

	ASSERT(m_pChar);
	if ( rid.GetResType() != RES_SKILLMENU )
		return 0;

	// Find section.
	CResourceLock s;
	if ( !g_Cfg.ResourceLock(s, rid) )
		return 0;

	// Get title line
	if ( !s.ReadKey() )
		return 0;

	if ( iSelect == 0 )		// cancelled
	{
		while ( s.ReadKeyParse() )
		{
			if ( !s.IsKey("ON") || (*s.GetArgStr() != '@') )
				continue;

			if ( strcmpi(s.GetArgStr(), "@Cancel") )
				continue;

			if ( m_pChar->OnTriggerRunVal(s, TRIGRUN_SECTION_TRUE, m_pChar, NULL) == TRIGRET_RET_TRUE )
				return 0;

			break;
		}
		return 1;
	}

	if ( iSelect < 0 )
	{
		item[0].m_sText = s.GetKey();
		if ( iSelect == -1 )
			m_tmMenu.m_ResourceID = rid;
	}

	bool fSkip = false;		// skip this if we lack resources or skill.
	int iOnCount = 0;
	size_t iShowCount = 0;
	CScriptTriggerArgs Args;

	while ( s.ReadKeyParse())
	{
		if ( s.IsKeyHead("ON", 2) )
		{
			if ( *s.GetArgStr() == '@' )
			{
				fSkip = true;
				continue;
			}

			// a new option to look at.
			fSkip = false;
			iOnCount++;

			if ( iSelect < 0 )	// building up the list.
			{
				if ( iSelect < -1 && iShowCount >= 1 )		// just a test. so we are done.
					return 1;

				iShowCount++;
				if ( !item[iSelect == -2 ? 0 : iShowCount].ParseLine(s.GetArgRaw(), NULL, m_pChar) )
				{
					// remove if the item is invalid.
					iShowCount--;
					fSkip = true;
					continue;
				}

				if ( iSelect == -1 )
					m_tmMenu.m_Item[iShowCount] = iOnCount;

				if ( iShowCount >= (iMaxSize - 1) )
					break;
			}
			else
			{
				if ( iOnCount > iSelect )	// we are done.
					break;
			}
			continue;
		}

		if ( fSkip )	// we have decided we cant do this option.
			continue;
		if ( iSelect > 0 && iOnCount != iSelect )	// only interested in the selected option
			continue;

		// Check for a skill / non-consumables required.
		if ( s.IsKey("TEST") )
		{
			m_pChar->ParseText(s.GetArgRaw(), m_pChar);
			CResourceQtyArray skills(s.GetArgStr());
			if ( !skills.IsResourceMatchAll(m_pChar) )
			{
				iShowCount--;
				fSkip = true;
			}
			continue;
		}

		if ( s.IsKey("TESTIF") )
		{
			m_pChar->ParseText(s.GetArgRaw(), m_pChar);
			if ( !s.GetArgVal() )
			{
				iShowCount--;
				fSkip = true;
			}
			continue;
		}

		// select to execute any entries here ?
		if ( iOnCount == iSelect )
		{
			// Execute command from script
			TRIGRET_TYPE tRet = m_pChar->OnTriggerRunVal(s, TRIGRUN_SINGLE_EXEC, m_pChar, &Args);
			if ( tRet != TRIGRET_RET_DEFAULT )
				return tRet == TRIGRET_RET_TRUE ? 0 : 1;

			iShowCount++;	// we are good. but continue til the end
		}
		else
		{
			ASSERT(iSelect < 0);
			if ( s.IsKey("SKILLMENU") )
			{
				static int sm_iReentrant = 0;
				if ( sm_iReentrant > 1024 )
				{
					if ( g_Cfg.m_wDebugFlags & DEBUGF_SCRIPTS )
						g_Log.EventDebug("SCRIPT: Too many skill menus (circular menus?) to continue searching in menu '%s'\n", g_Cfg.ResourceGetDef(rid)->GetResourceName());

					fLimitReached = true;
				}
				else
				{
					// Test if there is anything in this skillmenu we can do.
					++sm_iReentrant;
					if ( !Cmd_Skill_Menu_Build(g_Cfg.ResourceGetIDType(RES_SKILLMENU, s.GetArgStr()), -2, *&item, iMaxSize, fShowMenu, fLimitReached) )
					{
						iShowCount--;
						fSkip = true;
					}
					else
						fShowMenu = true;

					--sm_iReentrant;
				}
				continue;
			}

			if ( s.IsKey("MAKEITEM") )
			{
				// test if i can make this item using m_Targ_UID.
				// There should ALWAYS be a valid id here.
				if ( !m_pChar->Skill_MakeItem(static_cast<ITEMID_TYPE>(g_Cfg.ResourceGetIndexType(RES_ITEMDEF, s.GetArgStr())), m_Targ_UID, SKTRIG_SELECT) )
				{
					iShowCount--;
					fSkip = true;
				}
				continue;
			}
		}
	}
	return iShowCount;
}
示例#10
0
文件: ddicrawler.cpp 项目: mtassin/4e
static T_Status Crawl_Data(bool use_cache, T_Glyph_Ptr email, T_Glyph_Ptr password,
                            T_Filename output_folder, bool is_clear)
{
    T_Status                status;
    T_WWW                   internet = NULL;
    bool                    is_exists;
    T_Glyph_Ptr             path_ptr;
    T_Filename              folder;
    T_XML_Document          doc_languages = NULL;
    T_XML_Document          doc_wepprops = NULL;
    T_XML_Document          doc_sources = NULL;
    C_Pool                  pool(10000000,10000000);
    C_DDI_Deities           deities(&pool);
    C_DDI_Skills            skills(&pool);
    C_DDI_Rituals           rituals(&pool);
    C_DDI_Items             items(&pool);
    C_DDI_Classes           classes(&pool);
    C_DDI_Races             races(&pool);
    C_DDI_Paragons          paragons(&pool);
    C_DDI_Epics             epics(&pool);
    C_DDI_Feats             feats(&pool);
    C_DDI_Powers            powers(&pool);
    C_DDI_Monsters          monsters(&pool);
    C_DDI_Backgrounds       backgrounds(&pool);
    vector<C_DDI_Common *>  list;
    vector<C_DDI_Single_Common *>   singles;

    /* Add all of our downloader classes to the list
    */
    list.push_back(&deities);
    list.push_back(&skills);
    list.push_back(&rituals);
    list.push_back(&items);
    list.push_back(&classes);
    list.push_back(&races);
    list.push_back(&paragons);
    list.push_back(&epics);
    list.push_back(&feats);
    list.push_back(&powers);
//Monsters aren't supported yet...
#ifdef NOTYET
    list.push_back(&monsters);
#endif
    list.push_back(&backgrounds);

    /* Find a temporary folder to use
    */
    Get_Temporary_Folder(folder);
    path_ptr = folder + strlen(folder);

    /* Search for the folder and create it if it doesn't exist
    */
    is_exists = FileSys_Does_Folder_Exist(folder);
    if (!is_exists) {
        status = FileSys_Create_Directory(folder);
        if (x_Trap_Opt(!x_Is_Success(status))) {
            Log_Message("Couldn't create temporary folder.");
            x_Status_Return(LWD_ERROR);
            }
        }

    /* If we're not using cached copies, log in to D&D insider (if we don't
        have a username and password, this just establishes the connection)
    */
    if (!use_cache) {
        Log_Message("Connecting to server...\n", true);

        /* Open a connection to the server first
        */
        status = WWW_HTTP_Open(&internet,LOGIN_URL,NULL,NULL,NULL);
        if (x_Trap_Opt(!x_Is_Success(status))) {
            Log_Message("Couldn't open connection to login server!\n", true);
            goto cleanup_exit;
            }

        status = Login(internet, email, password, true);
        if (x_Trap_Opt(!x_Is_Success(status)))
            goto cleanup_exit;
        }

    /* If we're not using the cache, we want to make sure we have fresh copies
        of everything, so delete the files in our temporary folder
    */
    if (!use_cache) {
        strcpy(path_ptr,"*.*");
        FileSys_Delete_Files(folder);
        *path_ptr = '\0';
        }

    /* Create XML documents for deities languages - the crawlers can add their
        own entries for these during processing
    */
    status = Create_Document(&doc_languages, &l_language_root, "language",
                                DTD_Get_Data());
    if (!x_Is_Success(status))
        goto cleanup_exit;
    status = Create_Document(&doc_wepprops, &l_wepprop_root, "weapon property",
                                DTD_Get_Augmentation());
    if (!x_Is_Success(status))
        goto cleanup_exit;
    status = Create_Document(&doc_sources, &l_source_root, "source",
                                DTD_Get_Augmentation());
    if (!x_Is_Success(status))
        goto cleanup_exit;

    /* First, download all the index pages if we need to
    */
    if (!use_cache) {
        for (ddi_iter it = list.begin(); it != list.end(); ++it) {
            status = (*it)->Download_Index(folder, internet);
            if (x_Trap_Opt(!x_Is_Success(status)))
                goto cleanup_exit;
            }
        for (single_iter it = singles.begin(); it != singles.end(); ++it) {
            status = (*it)->Download(folder, internet);
            if (x_Trap_Opt(!x_Is_Success(status)))
                goto cleanup_exit;
            }
        }

    /* Read them in
    */
    for (ddi_iter it = list.begin(); it != list.end(); ++it) {
        status = (*it)->Read_Index(folder);
        if (x_Trap_Opt(!x_Is_Success(status)))
            goto cleanup_exit;
        }
    for (single_iter it = singles.begin(); it != singles.end(); ++it) {
        status = (*it)->Read(folder);
        if (x_Trap_Opt(!x_Is_Success(status)))
            goto cleanup_exit;
        }

    /* Now download the rest of the content all at once
        NOTE: As of March 2011, there's no further content for download unless
            you have a password.
    */
    if (!use_cache && l_is_password) {
        for (ddi_iter it = list.begin(); it != list.end(); ++it) {
            status = (*it)->Download_Content(folder, internet);
            if (x_Trap_Opt(!x_Is_Success(status)))
                goto cleanup_exit;
            }

        /* It's possible that some downloads were screwed up due to the
            servers acting weirdly. If so, they were added to a failed list,
            so try them again
        */
        Retry_Failed_Downloads(internet);
        }

    /* Read it in and process it
    */
    for (ddi_iter it = list.begin(); it != list.end(); ++it) {
        status = (*it)->Read_Content(folder);
        if (x_Trap_Opt(!x_Is_Success(status)))
            goto cleanup_exit;
        }

    /* Process all our stuff
    */
    for (ddi_iter it = list.begin(); it != list.end(); ++it) {
        status = (*it)->Process();
        if (x_Trap_Opt(!x_Is_Success(status)))
            goto cleanup_exit;
        }
    for (single_iter it = singles.begin(); it != singles.end(); ++it) {
        status = (*it)->Process();
        if (x_Trap_Opt(!x_Is_Success(status)))
            goto cleanup_exit;
        }

    /* Post-process all our stuff - this requires it to have been output first,
        and puts finishing touches on everything
    */
    for (ddi_iter it = list.begin(); it != list.end(); ++it) {
        status = (*it)->Post_Process(folder);
        if (x_Trap_Opt(!x_Is_Success(status)))
            goto cleanup_exit;
        }
    for (single_iter it = singles.begin(); it != singles.end(); ++it) {
        status = (*it)->Post_Process(folder);
        if (x_Trap_Opt(!x_Is_Success(status)))
            goto cleanup_exit;
        }

    /* Output our languages to the temporary folder, so we can append
        extensions to them later
    */
    status = Finish_Document(doc_languages, folder, LANGUAGE_FILENAME);
    if (!x_Is_Success(status))
        goto cleanup_exit;

    /* Now append any fixup extensions that are needed to compensate for the
        data being terrible
    */
    Append_Extensions(folder, output_folder);

    /* Load the old "powers" XML document and try and copy any wizard powers
        out of it
    */
//We don't need to do this any more, but keep the code around just in case...
//    Fixup_Wizard_Powers(output_folder);

    /* Sources and weapon properties don't need any extensions, so they can go
        directly into the output folder - plus they're augmentation files,
        which aren't messed with anyway
    */
    status = Finish_Document(doc_sources, output_folder, SOURCE_FILENAME);
    if (!x_Is_Success(status))
        goto cleanup_exit;
    status = Finish_Document(doc_wepprops, output_folder, WEPPROP_FILENAME);
    if (!x_Is_Success(status))
        goto cleanup_exit;

    /* wrapup everything
    */
cleanup_exit:
    l_language_root = NULL;
    if (doc_languages != NULL)
        XML_Destroy_Document(doc_languages);
    l_wepprop_root = NULL;
    if (doc_wepprops != NULL)
        XML_Destroy_Document(doc_wepprops);
    l_source_root = NULL;
    if (doc_sources != NULL)
        XML_Destroy_Document(doc_sources);
    if (internet != NULL)
        WWW_Close_Server(internet);

    /* Delete everything in our folder if required
    */
    if (is_clear) {
        strcpy(path_ptr,"*.*");
        FileSys_Delete_Files(folder);
        *path_ptr = '\0';
        }

    x_Status_Return(status);
}