Example #1
0
static void
RicochetMenuHandleEvent (EventPtr event)
{
    switch (event->data.menu.itemID) {
    case menuRicochetRestart:
        RicochetRestart ();
        break;
    case menuRicochetNext:
        RicochetNext ();
        break;
    case menuRicochetNew:
        RicochetNext ();
        break;

    case menuTimerStart:
        TimerStart ();
        break;
    case menuTimerStop:
        TimerStop ();
        break;

    case menuHelpControls:
        Help(controlForm);
        break;
    case menuHelpRules:
        Rules ();
        break;
    case menuHelpGetInfo:
        Help(infoForm);
        break;

    }
}
Example #2
0
//   *ShowMenu
void ShowMenu()//MENU
{
	CalcWinsAndLosses();
	do
	{
		system("cls");//clears command

		MainHeader();

		printf("\n\nOptions: 1, 2, 3, 4, 5 or 6\n");
		printf("\n1: Easy");
		printf("\n2: Medium");
		printf("\n3: Hard");
		printf("\n4: Rules");
		printf("\n5: Reset Scores");
		printf("\n6: Exit");
		printf("\n\nChoice: ");

		fflush(stdin);
		scanf_s("%d",&iChoice);

		iCheckForInt = iChoice;	//validation to only get numbers

		switch (iChoice)
		{
			case 1:
			case 2:
			case 3:
			{
				GroupUsefullFunctions();
				break;
			}
			case 4:
			{
				Rules();
				break;
			}
			case 5:
			{
				ResetScores();		
				break;
			}
			case 6:
			{
				exit(0);
				break;
			}
			default:
			{
				ShowMenu();
			}
		}//Switch
	} while ((iChoice < 1) || (iChoice > NumMainMenuItems) || (iChoice != iCheckForInt));
}//End ShowMenu();
Example #3
0
bool
Ledger::setup (Config const& config)
{
    bool ret = true;

    fees_.base = config.FEE_DEFAULT;
    fees_.units = config.TRANSACTION_FEE_BASE;
    fees_.reserve = config.FEE_ACCOUNT_RESERVE;
    fees_.increment = config.FEE_OWNER_RESERVE;

    try
    {
        if (auto const sle = read(keylet::fees()))
        {
            // VFALCO NOTE Why getFieldIndex and not isFieldPresent?

            if (sle->getFieldIndex (sfBaseFee) != -1)
                fees_.base = sle->getFieldU64 (sfBaseFee);

            if (sle->getFieldIndex (sfReferenceFeeUnits) != -1)
                fees_.units = sle->getFieldU32 (sfReferenceFeeUnits);

            if (sle->getFieldIndex (sfReserveBase) != -1)
                fees_.reserve = sle->getFieldU32 (sfReserveBase);

            if (sle->getFieldIndex (sfReserveIncrement) != -1)
                fees_.increment = sle->getFieldU32 (sfReserveIncrement);
        }
    }
    catch (SHAMapMissingNode &)
    {
        ret = false;
    }
    catch (std::exception const&)
    {
        Rethrow();
    }

    try
    {
        rules_ = Rules(*this, config.features);
    }
    catch (SHAMapMissingNode &)
    {
        ret = false;
    }
    catch (std::exception const&)
    {
        Rethrow();
    }

    return ret;
}
Example #4
0
static Boolean
RicochetKeyHandleEvent (EventPtr event)
{
    Boolean handled = true;

    switch (event->data.keyDown.chr) {
    case 'r':
    case 'R':
        RicochetRestart();
        break;
    case 'n':
    case 'N':
        RicochetNext ();
        break;
    case 'g':
    case 'G':
        RicochetNew ();
        break;
    case 'u':
    case 'U':
        RicochetUndo ();
        break;

    case 't':
    case 'T':
        TimerStart ();
        break;
    case 's':
    case 'S':
        TimerStop ();
        break;

    case 'c':
    case 'C':
        Help (controlForm);
        break;
    case 'l':
    case 'L':
        Rules ();
        break;
    case 'i':
    case 'I':
        Help (infoForm);
        break;

    default:
        handled = false;
        break;
    }
    return handled;
}
Example #5
0
//-----------------------------------------------------------------------------
elRecolorator::elRecolorator(const char *R, int x0, int x1, int y0, int y1)
    : xmin(x0), xmax(x1), ymin(y0), ymax(y1)
{
    QString Rules(R);
    Rules.append("........");
    for (int i = 0; i < elcMax; i++)
        switch (Rules[i].unicode()) {
        case 'o':
            cR[i] = elcDefault;
            break;
        case 'r':
            cR[i] = elcRojo;
            break;
        case 'v':
            cR[i] = elcVerde;
            break;
        case 'a':
            cR[i] = elcAzul;
            break;
        case 'x':
            cR[i] = elcCianico;
            break;
        case 'c':
            cR[i] = elcCastano;
            break;
        case 'z':
            cR[i] = elcMagenta;
            break;
        case '%':
            cR[i] = elcRandomRed;
            break;
        case '*':
            cR[i] = elcRandomAny;
            break;
        default:
        case '.':
            cR[i] = i;
        }
    if (x0 == x1 && y0 == y1) {
        xmin = -2147483648;
        xmax = 2147483647;
        ymin = -2147483648;
        ymax = 2147483647;
    }
}
Example #6
0
int Rules::loadAllRules()
{
    vector<string> rulesFiles = JFileSystem::GetInstance()->scanfolder("rules");
    for (size_t i = 0; i < rulesFiles.size(); ++i)
    {
        Rules * rules = NEW Rules();
        if (rules->load(rulesFiles[i]))
        {
            RulesList.push_back(rules);
        }
        else
        {
            SAFE_DELETE(rules);
        }
    }
    //Kind of a hack here, we sort Rules alphabetically because it turns out to be matching
    // The historical order of Game modes: Classic, Momir Basic, Random 1, Random 2, Story
    std::sort(RulesList.begin(),RulesList.end(),RulesMenuCmp_);
    return 1;
}
Example #7
0
World::World()
{	
	this->rules = Rules();

	this->charon = Charon(Charon::EAST);

	this->goat = Cargo(Cargo::GOAT, Charon::EAST);

	this->wolf = Cargo(Cargo::WOLF, Charon::EAST);

	this->cabbage = Cargo(Cargo::CABBAGE, Charon::EAST);

	cpositions.push_back(goat);

	cpositions.push_back(wolf);

	cpositions.push_back(cabbage);

	gameStatus = 0;
}
Example #8
0
//----------------------------------------------------------------------
FLOCK::FLOCK(RTPSSettings* set, CL* c):System(set,c)
{
    //seed random
    srand ( time(NULL) );

    std::vector<FLOCKParameters> vparams(0);
    vparams.push_back(flock_params);
    cl_FLOCKParameters= Buffer<FLOCKParameters>(cli, vparams);

    calculate();
    updateParams();

    spacing = settings->GetSettingAs<float>("spacing");
    dout<<"spacing ="<<spacing<<endl;

    //set up the grid
    setupDomain(flock_params.smoothing_distance/flock_params.simulation_scale,flock_params.simulation_scale);

    //set up the timers
    setupTimers();

    //setup the sorted and unsorted arrays
    prepareSorted();

#ifdef CPU
    dout<<"RUNNING ON THE CPU"<<endl;
#endif
#ifdef GPU
    dout<<"RUNNING ON THE GPU"<<endl;

    //should be more cross platform
    string flock_source_dir = settings->GetSettingAs<string>("rtps_path") + "/" + std::string(FLOCK_CL_SOURCE_DIR);

    cli->addIncludeDir(flock_source_dir);

    rules = Rules(flock_source_dir, cli, timers["rules_gpu"]);
    euler_integration = EulerIntegration(flock_source_dir, cli, timers["euler_gpu"]);
#endif
        //renderer->setParticleRadius(spacing);
}
Example #9
0
File: RPS.c Project: marcaj317/GAME
int main(void)
{
	enum Choice{
		/* nothing = 0, playRPS = 1, playRPSLS = 2, SeeRules = 3, Exit = 4 */
		nothing, playRPS, playRPSLS, SeeRules, Exit
	};
	int Selection;
	Selection = nothing;
	
	do{ /*loop until user exits*/
	
		printf("\nMAIN MENU: \nWhat would like to play?\n To play Rock/Paper/Scissors enter 1 \n To play Rock/Paper/Scsissors/Lizard/Spock enter 2 \n To see the rules enter 3 \n To Exit enter 4 \n Total Score = %i\nEnter Value: ", TotalScore);
		scanf("%i", &Selection);
		
		switch (Selection){
			case playRPS:
				RPS();
				break;
				
			case playRPSLS:
				RPSLS();
				break;
				
			case SeeRules:
				Rules();
				break;
				
			case Exit:
				break;
				
			default:
				printf("\n Enter one of the listed values. \n");
		}
	}while(Selection != Exit);
	return 0;
} 
Example #10
0
int main(int argc, const char* argv[]) 
{ 
    try {
        Timer timer;
        
        const char* symbolFileName = "./symbols.xmap";
        const char* rulesFileName    = "./rules.xml";
        const char* inOsmFileName    = "./in.osm";
        const char* outXmapFileName  = "./out.xmap";

        if (argc > 1) {
            for (int i = 1; i < argc; ++i) {
                if (std::string(argv[i]) == "-i") {
                    inOsmFileName = argv[++i];
                    checkFileName(inOsmFileName,argv[0]);
                }
                else if (std::string(argv[i]) == "-o") {
                    outXmapFileName = argv[++i];
                    checkFileName(outXmapFileName,argv[0]);
                }
                else if (std::string(argv[i]) == "-s") {
                    symbolFileName = argv[++i];
                    checkFileName(symbolFileName,argv[0]);
                }
                else if (std::string(argv[i]) == "-r") {
                    rulesFileName = argv[++i];
                    checkFileName(rulesFileName,argv[0]);
                }
                else if (std::string(argv[i]) == "--help" ||
                         std::string(argv[i]) == "-h" ||
                         std::string(argv[i]) == "help") {
                    printUsage(argv[0]);
                    return 0;
                }
                else {
                    printUsage(argv[0]);
                    throw Error("Unknown option '" + std::string(argv[i]) + "'");
                }
            }
        }

        info("Using files:");
        info("\t* input OSM file       - " + std::string(inOsmFileName));
        info("\t* output XMAP file     - " + std::string(outXmapFileName));
        info("\t* symbol set XMAP file - " + std::string(symbolFileName));
        info("\t* rules file           - " + std::string(rulesFileName));

        XmlTree inXmapDoc(symbolFileName);
        XmlElement inXmapRoot = inXmapDoc.getChild("map");

        XmlTree inOsmDoc(inOsmFileName);
        XmlElement inOsmRoot = inOsmDoc.getChild("osm");

        const double min_supported_version = 0.5;
        const double max_supported_version = 0.6;

        double version = inOsmRoot.getAttribute<double>("version");
        if (version < min_supported_version || version > max_supported_version) {
            throw Error("OSM data version %.1f isn't supported" + std::to_string(version));
        }

        XmlElement bounds = inOsmRoot.getChild("bounds");
        if (bounds.isEmpty()) {
            throw Error("No bounds");
        }
        double x = bounds.getAttribute<double>("minlon") +
                   bounds.getAttribute<double>("maxlon");
        x /= 2;
        double y = bounds.getAttribute<double>("minlat") +
                   bounds.getAttribute<double>("maxlat");
        y /= 2;
        Coords geographic_ref_point(x,y);

        Georeferencing georef(inXmapRoot, geographic_ref_point);

        Main::transform = CoordsTransform(georef);
        SymbolIdByCodeMap symbolIds(inXmapRoot);
        Main::rules = Rules(rulesFileName,symbolIds);

        osmToXmap(inOsmRoot,outXmapFileName,symbolFileName,georef);

        info("\nExecution time: " + std::to_string(timer.getCurTime()) + " sec.");
    }
    /*
    catch (const char * msg) {
        std::cerr << "ERROR: " << msg << std::endl;
    }
    */
    catch (std::exception& error) {
        std::cerr << "ERROR: " << error.what() << std::endl;
        return 1;
    }
}
Example #11
0
int main(int argc, char* args[])
{
	srand(time(NULL));
 Rules game = Rules();
	return 0;
}