コード例 #1
0
            void EnterCombat(Unit* /*who*/) override
            {
                _EnterCombat();
                events.Reset();
                events.ScheduleEvent(EVENT_SILENCE, 30000);
                events.ScheduleEvent(EVENT_CYCLONE, 20000);
                events.ScheduleEvent(EVENT_STOMP, 30000);

                DoCast(me, SPELL_SUPREME);
                Talk(SAY_AGGRO);

                Map* map = me->GetMap();

                WorldPackets::Misc::Weather weather(WEATHER_STATE_HEAVY_SANDSTORM, 1.0f);
                map->SendToPlayers(weather.Write());

                for (uint8 i = 0; i < NUM_TORNADOS; ++i)
                {
                    Position Point = me->GetRandomPoint(RoomCenter, RoomRadius);
                    if (Creature* Tornado = map->SummonCreature(NPC_SAND_VORTEX, Point))
                        Tornado->CastSpell(Tornado, SPELL_SAND_STORM, true);
                }

                SpawnNextCrystal();
            }
コード例 #2
0
ファイル: main.c プロジェクト: Subhash3497/Program-7
// Main function
int main() {
    int num_day, ans, weather_value, score = 0, completed = FALSE;
    int dragon_strength, dragon_intelligence, dragon_agility;
    
    char name[20], answer[4];
    
    srand(time(0));
    
    printf("Welcome to Dragon Training!\n");
    printf("You've been assigned a new dragon! Would you like to give it a name? (yes/no)\n");
    scanf("%s", answer);
    
    if(strcmp(answer, "yes") == 0) {
        printf("Great! What would like to call your dragon?\n");
        scanf("%s", name);
    }
    else
        strcpy(name, "your dragon");
    
    printf("\nTo complete training, %s must finish the final \nobstacle course with a score of 70 or better.\n", name);
    printf("\nYou may attempt the obstacle course at any time, \nbut you must finish within 10 days.\n");
    printf("\nBetter get started!\n");
    
    set_stats(&dragon_strength, &dragon_intelligence, &dragon_agility);
    
    for (num_day = 1; num_day <= 10; num_day++) {
        printf("\nIt is Day #%d.\n", num_day);
        print_stats(dragon_strength, dragon_intelligence, dragon_agility, name);
        weather_value = weather();
        ans = menu();
        
        switch(ans) {
            case 1:
                dragon_strength += train_strength(weather_value, name);
                break;
            case 2:
                dragon_intelligence += train_intelligence(weather_value, name);
                break;
            case 3:
                dragon_agility += train_agility(weather_value, name);
                break;
            case 4:
                score = obstacle_course(weather_value, dragon_strength, dragon_intelligence, dragon_agility);
                printf("%s scored a %d on their obstacle course run!\n", name, score);
                break;
        }
        
        if(score >= SCORE) {
            completed = TRUE;
            break;
        }
    }
    
    end_message(completed, name);
    
    return 0;
}
コード例 #3
0
ファイル: retrieve_forecast.cpp プロジェクト: jamesg/aether
void aether::task::retrieve_forecast::daily_forecast_received(
        styx::element e
        )
{
    try
    {
        styx::object f(e);
        for(styx::object point : f.get_list("list"))
        {
            daily_forecast f_db;
            f_db.get_int<attr::forecast_dt>() = point.copy_int("dt");

            {
                styx::list weather(point.get_list("weather"));
                if(weather.size() > 0)
                {
                    styx::object first = weather.at(0);
                    f_db.get_string<attr::forecast_weather_main>() =
                        first.get_string("main");
                    f_db.get_string<attr::forecast_weather_description>() =
                        first.get_string("description");
                }
            }

            {
                styx::object& temp(point.get_object("temp"));
                f_db.get_double<attr::forecast_temp_day>() =
                    temp.get_double("day");
                f_db.get_double<attr::forecast_temp_night>() =
                    temp.get_double("night");
                f_db.get_double<attr::forecast_wind_speed>() =
                    point.get_double("speed");
                f_db.get_int<attr::forecast_wind_deg>() =
                    point.get_int("deg");
                f_db.get_int<attr::forecast_clouds_all>() =
                    point.get_int("clouds");
            }

            f_db.save(connection());
        }
        atlas::log::information("aether::task::retrieve_forecast::daily_forecast_received") <<
            "saved daily forecast";
    }
    catch(const std::exception& e)
    {
        atlas::log::error("aether::task::retrieve_forecast::daily_forecast_received") <<
            e.what();
    }

    request_forecast();
}
コード例 #4
0
ファイル: genwf.c プロジェクト: flyingCircusEggSpam/startupAI
/*規則�F	<天気>→晴れ 規則�G	<天気>→曇り  規則�H	<天気>→雨*/
void weather()
{
	int rndval ;
	rndval=setrnd(4) ;
 if(rndval==0){//規則�E
  weather() ;
  system("type tokoroniyori.txt >> out.txt");
  printf("ところにより") ;
  weather() ;
 }
 else if(rndval==1){//規則�F
  system("type hare.txt >> out.txt");
  printf("晴れ") ;
 }
 else if(rndval==2){//規則�G
  system("type kumori.txt >> out.txt");
  printf("曇り") ;
 }
 else {//規則�H
  system("type ame.txt >> out.txt");
  printf("雨") ;
 } 
}
コード例 #5
0
void IChatHandler::_sCmd_Weather(IWorldPlayer *_player, const char *_message)
{
	FDASSERT(_player);
	FDASSERT(_message);

	s32 t_weather = 0;

	sscanf(_message, "%d", &t_weather);

	if (t_weather < 0)
	{
		m_pserver->setWeatherFixed(false);
	}
	else
	{
		m_pserver->setWeatherFixed(true);
		m_pserver->setWeather(weather(t_weather));
	}
}
コード例 #6
0
ファイル: OsgRender.cpp プロジェクト: rongzhou/speed-dreams
/**
 * SDRender
 * Initialises a scene (ie a new view).
 *
 * @return 0 if OK, -1 if something failed
 */
void SDRender::Init(tTrack *track)
{
    SDTrack = track;

    std::string datapath = GetDataDir();
    //datapath +="/";
    thesky = new SDSky;
    GfOut("SDSky class\n");

    // Sky dome / background.
    SDSkyDomeDistance = 20000;
    if (SDSkyDomeDistance > 0 && SDSkyDomeDistance < SDSkyDomeDistThresh)
        SDSkyDomeDistance = SDSkyDomeDistThresh; // If user enabled it (>0), must be at least the threshold.

    SDDynamicSkyDome = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_DYNAMICSKYDOME, GR_ATT_DYNAMICSKYDOME_DISABLED), GR_ATT_DYNAMICSKYDOME_ENABLED) == 0;

    GfLogInfo("Graphic options : Sky dome : distance = %u m, dynamic = %s\n",
              SDSkyDomeDistance, SDDynamicSkyDome ? "true" : "false");

    // Dynamic weather.
    //grDynamicWeather = GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_grDynamicWeather, (char*)NULL, grDynamicWeather);

    // Cloud layers.
    SDNbCloudLayers =
            (unsigned)(GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_CLOUDLAYER, 0, 0) + 0.5);

    GfLogInfo("Graphic options : Number of cloud layers : %u\n", SDNbCloudLayers);

    SDMax_Visibility =
            (unsigned)(GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_VISIBILITY, 0, 0));

    ShadowIndex = 0; // Default value index, in case file value not found in list.
    const char* pszShadow =
            GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_SHADOW_TYPE, GR_ATT_SHADOW_NONE);

    for (int i = 0; i < NbShadowValues; i++)
    {
        if (!strcmp(pszShadow, ShadowValues[i]))
        {
            ShadowIndex = i;
            break;
        }
    }

    TexSizeIndex = 0; // Default value index, in case file value not found in list.
    const char* pszTexSize =
            GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_SHADOW_SIZE, GR_ATT_SHADOW_1024);

    for (int i = 0; i < NbTexSizeValues; i++)
    {
        if (!strcmp(pszTexSize, TexSizeValues[i]))
        {
            TexSizeIndex = i;
            break;
        }
    }

    switch (TexSizeIndex)
    {
    case 0:
        ShadowTexSize = 512;
        break;

    case 1:
        ShadowTexSize = 1024;
        break;

    case 2:
        ShadowTexSize = 2048;
        break;

    case 3:
        ShadowTexSize = 4096;
        break;

    case 4:
        ShadowTexSize = 8192;
        break;

    default:
        ShadowTexSize = 1024;
        break;
    }

    QualityIndex = 0; // Default value index, in case file value not found in list.
    const char* pszQuality =
            GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_AGR_QUALITY, GR_ATT_AGR_LITTLE);

    for (int i = 0; i < NbQualityValues; i++)
    {
        if (!strcmp(pszQuality, QualityValues[i]))
        {
            QualityIndex = i;
            break;
        }
    }

    carsShader = 0; // Default value index, in case file value not found in list.
    const char* pszShaders =
            GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_SHADERS, GR_ATT_AGR_NULL);

    for (int i = 0; i < NbShadersValues; i++)
    {
        if (!strcmp(pszShaders, ShadersValues[i]))
        {
            carsShader = i;
            break;
        }
    }

    GfLogInfo("Graphic options : Shadow Type : %u\n", ShadowIndex);
    GfLogInfo("Graphic options : Shadow Texture Size : %u\n", ShadowTexSize);
    GfLogInfo("Graphic options : Shadow Quality : %u\n", QualityIndex);

    NStars = NMaxStars;
    if (AStarsData)
        delete [] AStarsData;

    AStarsData = new osg::Vec3d[NStars];

    for(int i= 0; i < NStars; i++)
    {
        AStarsData[i][0] = SDRandom() * PI;
        AStarsData[i][1] = SDRandom() * PI;
        AStarsData[i][2] = SDRandom() * 7.0;
    }

    GfLogInfo("  Stars (random) : %d\n", NStars);

    NPlanets = 0;
    APlanetsData = NULL;

    GfLogInfo("  Planets : %d\n", NPlanets);

    const int timeOfDay = (int)SDTrack->local.timeofday;
    const double domeSizeRatio = SDSkyDomeDistance / 80000.0;

    GfLogInfo("  domeSizeRation : %d\n", domeSizeRatio);

    thesky->build(datapath, SDSkyDomeDistance, SDSkyDomeDistance, 800,
                  40000, 800, 30000, NPlanets,
                  APlanetsData, NStars, AStarsData );
    GfOut("Build SKY\n");
    GLfloat sunAscension = SDTrack->local.sunascension;
    SDSunDeclination = (float)(15 * (double)timeOfDay / 3600 - 90.0);

    thesky->setSD( DEG2RAD(SDSunDeclination));
    thesky->setSRA( sunAscension );

    GfLogInfo("  Sun : time of day = %02d:%02d:%02d (declination = %.1f deg), "
              "ascension = %.1f deg\n", timeOfDay / 3600, (timeOfDay % 3600) / 60, timeOfDay % 60,
              SDSunDeclination, RAD2DEG(sunAscension));

    if ( SDSunDeclination > 180 )
        SDMoonDeclination = 3.0 + (rand() % 40);
    else
        SDMoonDeclination = (rand() % 270);

    //SDMoonDeclination = grUpdateMoonPos(timeOfDay);
    //SDMoonDeclination = 22.0; /*(rand() % 270);*/

    const float moonAscension = SDTrack->local.sunascension;

    thesky->setMD( DEG2RAD(SDMoonDeclination) );
    thesky->setMRA( DEG2RAD(moonAscension) );

    GfLogInfo("  Moon : declination = %.1f deg, ascension = %.1f deg\n",
              SDMoonDeclination, moonAscension);

    /*

    SDCloudLayer *layer = new SDCloudLayer(datapath);
    layer->setCoverage(layer->SD_CLOUD_CIRRUS);
    layer->setSpeed(30);
    layer->setDirection(20);
    layer->setElevation_m(3000);
    layer->setThickness_m(400  / domeSizeRatio);
    layer->setTransition_m(400  / domeSizeRatio);
    layer->setSpan_m(SDSkyDomeDistance / 2);
    thesky->add_cloud_layer(layer);

    SDCloudLayer *layer2 = new SDCloudLayer(datapath);
    layer2->setCoverage(layer2->SD_CLOUD_CIRRUS2);
    layer2->setSpeed(60);
    layer2->setDirection(20);
    layer2->setElevation_m(1500);
    layer2->setThickness_m(400  / domeSizeRatio);
    layer2->setTransition_m(400  / domeSizeRatio);
    layer2->setSpan_m(SDSkyDomeDistance / 2);
    thesky->add_cloud_layer(layer2);*/

    // Initialize the whole sky dome.
    SDScenery * scenery = (SDScenery *)getScenery();
    double r_WrldX = scenery->getWorldX();
    double r_WrldY = scenery->getWorldY();
    //double r_WrldZ = SDScenery::getWorldZ();
    osg::Vec3 viewPos(r_WrldX / 2, r_WrldY/ 2, 0.0 );

    weather();
    thesky->set_visibility( SDVisibility ); // Visibility in meters

    thesky->reposition( viewPos, 0, 0);
    sol_angle = (float)thesky->getSA();
    moon_angle = (float)thesky->getMA();
    thesky->repaint(SkyColor, FogColor, CloudsColor, sol_angle, moon_angle, NPlanets,
                    APlanetsData, NStars, AStarsData);
    UpdateLight();

    osg::ref_ptr<osg::Group> sceneGroup = new osg::Group;
    osg::ref_ptr<osg::Group> mRoot = new osg::Group;
    osg::ref_ptr<osgShadow::ShadowMap> vdsm = new osgShadow::ShadowMap;
    m_scene = new osg::Group;
    m_CarRoot = new osg::Group;
    m_RealRoot = new osg::Group;
    shadowRoot = new osgShadow::ShadowedScene;

    osg::ref_ptr<osgParticle::PrecipitationEffect> precipitationEffect = new osgParticle::PrecipitationEffect;

    if (SDVisibility < 2000)
    {
        sceneGroup->addChild(precipitationEffect.get());
    }

    osg::ref_ptr<osg::Group> scene = new osg::Group;
    osg::ref_ptr<osg::Group> background = new osg::Group;
    osg::ref_ptr<osg::Group> cargroup = new osg::Group;

    scene->addChild(scenery->getScene());
    cargroup->addChild(m_CarRoot.get());
    background->addChild(scenery->getBackground());

	if(ShadowIndex > 0)
	{
		switch (QualityIndex+1)
		{
		case 0:
			break;
		case 1:
			scene->setNodeMask( rcvShadowMask );
			background->setNodeMask(~(rcvShadowMask | castShadowMask));
			cargroup->setNodeMask(castShadowMask);
			break;
		case 2:
			scene->setNodeMask( rcvShadowMask );
			background->setNodeMask(~(rcvShadowMask | castShadowMask));
			cargroup->setNodeMask(rcvShadowMask | castShadowMask);
			break;
		case 3:
			scene->setNodeMask( rcvShadowMask | castShadowMask);
			background->setNodeMask(~(rcvShadowMask | castShadowMask));
			cargroup->setNodeMask(rcvShadowMask | castShadowMask);
			break;
		default:
			break;
		}
	}

    m_scene->addChild(scene.get());
    m_scene->addChild(cargroup.get());
    m_scene->addChild(background.get());

    sceneGroup->addChild(m_scene.get());

    stateSet = new osg::StateSet;
    stateSet = m_scene->getOrCreateStateSet();
    stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
    if (SDVisibility < 2000)
        stateSet->setAttributeAndModes(precipitationEffect->getFog());

    float emis = 0.5f * sky_brightness;
    float ambian = 0.8f * sky_brightness;
    osg::ref_ptr<osg::Material> material = new osg::Material;
    material->setColorMode(osg::Material::OFF); // switch glColor usage off
    Scene_ambiant = osg::Vec4f( ambian, ambian, ambian, 1.0f);            ;
    material->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(emis, emis, emis, 1.0f));
    material->setAmbient(osg::Material::FRONT_AND_BACK, Scene_ambiant);
    stateSet->setAttributeAndModes(material, osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
    stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);

    lightSource = new osg::LightSource;
    lightSource->getLight()->setDataVariance(osg::Object::DYNAMIC);
    lightSource->getLight()->setLightNum(0);
    // relative because of CameraView being just a clever transform node
    lightSource->setReferenceFrame(osg::LightSource::RELATIVE_RF);
    lightSource->setLocalStateSetModes(osg::StateAttribute::ON);
    lightSource->getLight()->setAmbient(osg::Vec4(0.0f, 0.0f, 0.0f, 0.0f));
    lightSource->getLight()->setDiffuse(osg::Vec4( 0.2f, 0.2f, 0.2f, 1.0f));
    lightSource->getLight()->setSpecular(osg::Vec4(0.0f, 0.0f, 0.0f, 0.0f));
    sceneGroup->addChild(lightSource);

    // we need a white diffuse light for the phase of the moon
    sunLight = new osg::LightSource;
    sunLight->getLight()->setDataVariance(osg::Object::DYNAMIC);
    sunLight->getLight()->setLightNum(1);
    sunLight->setReferenceFrame(osg::LightSource::RELATIVE_RF);
    sunLight->setLocalStateSetModes(osg::StateAttribute::ON);
    sunLight->getLight()->setAmbient(SceneAmbiant);
    sunLight->getLight()->setDiffuse(SceneDiffuse);
    sunLight->getLight()->setSpecular(SceneSpecular);
    sunLight->setStateSetModes(*stateSet,osg::StateAttribute::ON);

    osg::Vec3f sun_position = thesky->sunposition();
    osg::Vec3f sun_direction = -sun_position;
    osg::Vec4f position(sun_position, 1.0f);
    sunLight->getLight()->setPosition(position);
    sunLight->getLight()->setDirection(sun_direction);

    skyGroup = new osg::Group;
    skyGroup->setName("skyCloudsGroup");
    skyGroup->setNodeMask(thesky->BACKGROUND_BIT);
    skyGroup->addChild(thesky->getPreRoot());
    skyGroup->addChild((thesky->getCloudRoot()));

    skySS = new osg::StateSet;
    skySS = skyGroup->getOrCreateStateSet();
    skySS->setMode(GL_LIGHT0, osg::StateAttribute::OFF);
    skySS->setAttributeAndModes( new osg::ColorMask( true, true, true, false ), osg::StateAttribute::ON );

    skyGroup->setNodeMask(~(rcvShadowMask | castShadowMask));
    sunLight->addChild(skyGroup.get());

    mRoot->addChild(sceneGroup.get());
    mRoot->setStateSet(setFogState().get());
    mRoot->addChild(sunLight.get());

    // Clouds are added to the scene graph later
    osg::ref_ptr<osg::StateSet> stateSet2 = new osg::StateSet;
    stateSet2 = mRoot->getOrCreateStateSet();
    stateSet2->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
    stateSet2->setMode(GL_LIGHTING, osg::StateAttribute::ON);
    stateSet2->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);

    m_RealRoot->addChild(mRoot.get());

    GfOut("LE POINTEUR %d\n", mRoot.get());
}//SDRender::Init
コード例 #7
0
ファイル: Weather.cpp プロジェクト: brecky/TrinityCore
/// Send the new weather to all players in the zone
bool Weather::UpdateWeather()
{
    ///- Send the weather packet to all players in this zone
    if (m_grade >= 1)
        m_grade = 0.9999f;
    else if (m_grade < 0)
        m_grade = 0.0001f;

    WeatherState state = GetWeatherState();

    WorldPackets::Misc::Weather weather(state, m_grade);

    //- Returns false if there were no players found to update
    if (!sWorld->SendZoneMessage(m_zone, weather.Write()))
        return false;

    ///- Log the event
    char const* wthstr;
    switch (state)
    {
        case WEATHER_STATE_FOG:
            wthstr = "fog";
            break;
        case WEATHER_STATE_LIGHT_RAIN:
            wthstr = "light rain";
            break;
        case WEATHER_STATE_MEDIUM_RAIN:
            wthstr = "medium rain";
            break;
        case WEATHER_STATE_HEAVY_RAIN:
            wthstr = "heavy rain";
            break;
        case WEATHER_STATE_LIGHT_SNOW:
            wthstr = "light snow";
            break;
        case WEATHER_STATE_MEDIUM_SNOW:
            wthstr = "medium snow";
            break;
        case WEATHER_STATE_HEAVY_SNOW:
            wthstr = "heavy snow";
            break;
        case WEATHER_STATE_LIGHT_SANDSTORM:
            wthstr = "light sandstorm";
            break;
        case WEATHER_STATE_MEDIUM_SANDSTORM:
            wthstr = "medium sandstorm";
            break;
        case WEATHER_STATE_HEAVY_SANDSTORM:
            wthstr = "heavy sandstorm";
            break;
        case WEATHER_STATE_THUNDERS:
            wthstr = "thunders";
            break;
        case WEATHER_STATE_BLACKRAIN:
            wthstr = "blackrain";
            break;
        case WEATHER_STATE_FINE:
        default:
            wthstr = "fine";
            break;
    }

    TC_LOG_INFO("misc", "Change the weather of zone %u to %s.", m_zone, wthstr);
    sScriptMgr->OnWeatherChange(this, state, m_grade);
    return true;
}
コード例 #8
0
ファイル: Weather.cpp プロジェクト: brecky/TrinityCore
void Weather::SendFineWeatherUpdateToPlayer(Player* player)
{
    WorldPackets::Misc::Weather weather(WEATHER_STATE_FINE);
    player->SendDirectMessage(weather.Write());
}
コード例 #9
0
ファイル: Weather.cpp プロジェクト: brecky/TrinityCore
void Weather::SendWeatherUpdateToPlayer(Player* player)
{
    WorldPackets::Misc::Weather weather(GetWeatherState(), m_grade);
    player->SendDirectMessage(weather.Write());
}
コード例 #10
0
ファイル: Weather.cpp プロジェクト: Diyvol/TrinityCore
void Weather::SendWeatherUpdateToPlayer(Player* player)
{
    WorldPackets::Misc::Weather weather(GetWeatherState(), m_grade);
    player->GetSession()->SendPacket(weather.Write());
}
コード例 #11
0
ファイル: lemonade.c プロジェクト: metroid2010/lemstand
int main()
{ 
  FILE *fp; 
  int whr; //weather
  int diff=2; //variable for difficulty initialized in medium
  int slct1; //main menu selection
  int x,y=0,i=1; //loops
  int totals=50; //total score
  char name[30];
  char c; //gameplay selection loop
  
  
    clearScreen();
    printf("\n\t   ---Welcome to LEMONADE STAND--- ");
    printf("\n\tA C version of the original game from the Apple II.");
    printf("\n\tProgrammed by R");
    printf("\n");
    printf("\n\tPlease, enter your name: ");
    scanf(" %[^\n]s", name);
    while( strlen(name) == 30) {
      printf("\tSorry, the name is too long. Try again...");
      printf("\n\tEnter your name: ");
      scanf(" %30[^\n]", name);
    }
    
    fp=fopen("scores.txt","a");
    
    int slct; //main menu selection
    
    do {
    printf("\n\t1- Start a new game");
    printf("\n\t2- HELP and how to play");
    printf("\n\t3- Options");
    do{
      printf("\n\tEnter: ");
      scanf(" %i",&slct); //menu entry selection
      switch(slct) {
          case 1:                    //GAME START
            x=0; 
	    break;
          case 2:                    //HELP SCREEN
            helpScreen(x);
    	    x=1;
	    clearScreen();
            break;
          case 3:                    //OPTIONS SCREEN
            diff=optionsScreen(diff);
	    x=1;
	    clearScreen();
            break;
	  default:
	    printf("\tOption not recognised");
	    x=2;
	    break;
       }
      }while(x==2);
    } while(x==1);
    
    clearScreen();
    printf("\n\n\t Press ENTER to start the game.\n\tEnjoy and have fun!");
    getchar();
    getchar();
    
    do{
      clearScreen();
      printf("\n\tDay %i", i);
      printf("\n\tMoney: %ic", totals);
      getchar();
      
      whr = weather(diff); //weather screen
      totals += gameplay(diff, whr);
     
      clearScreen();
      printf("\tYour total money is %i", totals);
      do {
        printf("\n\tDo you want to continue? (Y/N) ");
        scanf(" %c", &c);
        switch(c) {
	  case 'y':
	  case 'Y':
	    y=1;
	    break;
	  case 'n':
	  case 'N':
	    y=0;
	    break;
	  default:
	    printf("\tOption not recognised. Try again...");
	    y=2;
	    break;
	}
      } while (y==2);
      i+=1;
    }while(y==1);
    
    clearScreen();
    printf("\n\tYour total earnings were %i", totals);
    printf("\n\tIt will be saved to scores.txt");
    
    fprintf(fp, "\n%s --- %i", name, totals);
    fclose(fp);
    
    printf("\n\tThank you for playing!");
    printf("\n\n\n\tPress Enter to exit...\n\n");
    getchar();
    getchar();
    
    return;
}
コード例 #12
0
void SendFineWeatherUpdateToPlayer(Player* player)
{
    WorldPackets::Misc::Weather weather(WEATHER_STATE_FINE);
    player->GetSession()->SendPacket(weather.Write());
}
コード例 #13
0
ファイル: appmanager.cpp プロジェクト: abranson/rockpool
void AppManager::rescan()
{
    m_appList.clear();
    m_apps.clear();

    AppInfo settingsApp(QUuid(SETTINGS_APP_UUID), false, gettext("Settings"), gettext("System app"));
    m_appList.append(settingsApp.uuid());
    m_apps.insert(settingsApp.uuid(), settingsApp);
    AppInfo watchfaces(QUuid("18e443ce-38fd-47c8-84d5-6d0c775fbe55"), false, gettext("Watchfaces"), gettext("System app"));
    m_appList.append(watchfaces.uuid());
    m_apps.insert(watchfaces.uuid(), watchfaces);
    if (m_pebble->capabilities().testFlag(CapabilityHealth)) {
        AppInfo health(QUuid("36d8c6ed-4c83-4fa1-a9e2-8f12dc941f8c"), false, gettext("Health"), gettext("System app"), true);
        m_appList.append(health.uuid());
        m_apps.insert(health.uuid(), health);
    }
    AppInfo music(QUuid("1f03293d-47af-4f28-b960-f2b02a6dd757"), false, gettext("Music"), gettext("System app"));
    m_appList.append(music.uuid());
    m_apps.insert(music.uuid(), music);
    if(m_pebble->capabilities().testFlag(CapabilityWeather)) {
        AppInfo weather(WeatherApp::appUUID, false, gettext("Weather"), gettext("System app"), true);
        m_appList.append(weather.uuid());
        m_apps.insert(weather.uuid(), weather);
    }
    if(m_pebble->capabilities().testFlag(CapabilitySendSMS)) {
        AppInfo sendsms(SendTextApp::appUUID, false, SendTextApp::appName, gettext("System app"), true);
        m_appList.append(sendsms.uuid());
        m_apps.insert(sendsms.uuid(), sendsms);
    }
    AppInfo notifications(QUuid("b2cae818-10f8-46df-ad2b-98ad2254a3c1"), false, gettext("Notifications"), gettext("System app"));
    m_appList.append(notifications.uuid());
    m_apps.insert(notifications.uuid(), notifications);
    AppInfo alarms(QUuid("67a32d95-ef69-46d4-a0b9-854cc62f97f9"), false, gettext("Alarms"), gettext("System app"));
    m_appList.append(alarms.uuid());
    m_apps.insert(alarms.uuid(), alarms);
    AppInfo ticToc(QUuid("8f3c8686-31a1-4f5f-91f5-01600c9bdc59"), true, "Tic Toc", gettext("Default watchface"));
    m_appList.append(ticToc.uuid());
    m_apps.insert(ticToc.uuid(), ticToc);

    QDir dir(m_pebble->storagePath() + "/apps/");
    qDebug() << "Scanning Apps dir" << dir.absolutePath();
    Q_FOREACH(const QString &path, dir.entryList(QDir::Dirs | QDir::Readable)) {
        QString appPath = dir.absoluteFilePath(path);
        if (dir.exists(path + "/appinfo.json")) {
            scanApp(appPath);
        } else if (QFileInfo(appPath).isFile()) {
            scanApp(appPath);
        }
    }

    QSettings settings(m_pebble->storagePath() + "/apps.conf", QSettings::IniFormat);
    QStringList storedList = settings.value("appList").toStringList();
    if (storedList.isEmpty()) {
        // User did not manually sort the app list yet... We can stop here.
        return;
    }
    // Run some sanity checks
    if (storedList.count() != m_appList.count()) {
        qWarning() << "Installed apps not matching order config. App sort order might be wrong.";
        return;
    }
    foreach (const QUuid &uuid, m_appList) {
        if (!storedList.contains(uuid.toString())) {
            qWarning() << "Installed apps and stored config order cannot be matched. App sort order might be wrong.";
            return;
        }
    }
    // All seems fine, repopulate m_appList
    m_appList.clear();
    foreach (const QString &storedId, storedList) {
        m_appList.append(QUuid(storedId));
    }
コード例 #14
0
void WeatherManager::UpdateClient(uint32_t cnum)
{
    psWeatherMessage::NetWeatherInfo info;

    // Update client with weather for all sectors
    csHash<psSectorInfo*>::GlobalIterator iter = cacheManager->GetSectorIterator();
    while(iter.HasNext())
    {
        psSectorInfo* sector = iter.Next();
        info.has_downfall  = false;
        info.has_lightning = false;
        info.has_fog       = false;
        info.sector = sector->name;

        if(sector->is_raining) // If it is raining
        {
            info.has_downfall = true;
            info.downfall_is_snow = false;

            info.downfall_drops = sector->current_rain_drops;
            info.downfall_fade = 0; // Don't fade in
        }
        else if(sector->is_snowing)  // If it is snowing
        {
            info.has_downfall = true;
            info.downfall_is_snow = true;

            info.downfall_drops = sector->current_rain_drops;
            info.downfall_fade = 0; // Don't fade in
        }
        else
        {
            // Some default vaules in case neither snowing or raining
            info.downfall_is_snow = false;
            info.downfall_drops = 0;
            info.downfall_fade = 0;
        }


        if(sector->fog_density > 0)
        {
            info.has_fog = true;
            info.fog_density = sector->fog_density;
            info.fog_fade = 0; // Don't fade in
            info.r = sector->r;
            info.g = sector->g;
            info.b = sector->b;

        }
        if(info.has_downfall || info.has_fog)
        {
            psWeatherMessage weather(cnum,info);
            weather.SendMessage();
        }
    }

    SendClientGameTime(cnum);

    // Send
#ifdef WEATHER_DEBUG
    printf("Sending weather and time updates to client %u\n",cnum);
#endif

}
コード例 #15
0
ファイル: sim-launcher.cpp プロジェクト: greendisc/devs-slide
//std::string FSpolicy = "server-proactive"; //fixed
//std::string coolPolicy = cmdArgs.coolPolicy ; //fixed, budget
int main (int argc, char* argv[])
{
    try { 

    	SimLauncher* simLauncher = new SimLauncher();
        // Should parse command-line args here!
        //-------------------------------------
        DCParser::CmdLineArgs cmdArgs;
        DCParser::parseCmdLineArgs(cmdArgs);
        // Loading initial configuration
        simLauncher->loadConfig(cmdArgs);
                       
        // Parsing initial configuration
        // ----------------------------------------
        DCSimulator::DCParams layout;
        xercesc::DOMDocument* xmlConfigFile = DCParser::parseDCConfig(layout);
        simLauncher->xmlConfigFile = xmlConfigFile;
        VLOG_1 << "Layout parsed. Constructing simulator";
        
        //==================================================
		DCSimulator sim(layout);
        LOG_INFO << "Simulator created succesfully";
        //==================================================

        VLOG_1 << "Adding room parameters...";
        DCParser::addRoomParams(xmlConfigFile, sim);
        LOG_INFO << "Parameters inserted into simulator";

        //---------------------------------------------------
        VLOG_1 << "Adding room parameters...";
        // FIXME-marina: in the future we'll need to change workload parsing
        DCParser::addWorkload(xmlConfigFile, sim);
        LOG_INFO << "Workload inserted into simulator";

        // Creating allocator
        //====================
        Allocator alloc(cmdArgs.baseTime, cmdArgs.firstSubmit, cmdArgs.allocPath, cmdArgs.offline);
        Weather weather(simLauncher->weatherfile);

        // Creating cooling control policy
        CoolingPolicy* cool = PolicyFactory::createCoolingPolicy(cmdArgs.coolPolicy, sim);
        if (cool == NULL){
            LOG_FATAL << "Cooling policy does not exist!";
        }
        
        //=================================================
        // Run simulator main loop
        //=================================================
        bool fi=false;
        VLOG_2 << "Will now print current allocation";
        alloc.printCurrentAlloc(sim);

        while (!fi){
            // JOSELE: noLog=false;
            int jobId = simLauncher->getJobLoggerLine(sim, alloc);
            // JOSELE: VLOG_1 << "NoLog flag is: " << noLog;
            if (jobId < 0){
                LOG_FATAL << "Error processing job";
            }
            else if (jobId == 0){
                LOG_INFO << "Received exit code";
                break;
            }
            double tempOut = weather.getCurrentWeather(alloc.getCurrentTime(), fi);
            VLOG_1 << "Current time is: " << alloc.getCurrentTime()
                   << " -- outside temperature: " << tempOut
                   << " -- jobId: " << jobId ;
            //Chaging workload allocation
            alloc.updateAllocation(sim, jobId);
            //Printing new workload allocation to file
            alloc.printCurrentAlloc(sim);
                        
            // For this allocation, run a cooling policy
            // and compute the power
            VLOG_1 << "Running cooling policy with outdoor temperature " << tempOut;
            cool->run(tempOut);
            VLOG_2 << "Computing power consumption";
            sim.computePower(tempOut);

            VLOG_1 << "Printing all data";
            sim.printAllPowerValues(alloc.getCurrentTime(), tempOut, simLauncher->powerfile);
        }

        simLauncher->weatherfile.close();
        simLauncher->powerfile.close();

        LOG_INFO << "[==DC Simulator] Computing energy statistics";
        // TODO-marina: add function to compute montly statistics
        sim.printEnergyStatistics(cmdArgs.powerOutFile);
        delete simLauncher;
	}
    catch (std::exception& e)  {
        LOG_FATAL << "[==DC Simulator] Exception: " << e.what() ;
    }

    LOG_INFO << "[==DC Simulator] Program exiting" ;
    return 0;   
}
コード例 #16
0
ファイル: genwf.c プロジェクト: flyingCircusEggSpam/startupAI
/*規則�@	<文>→<地区><時間帯><天気>*/
void sentence()
{
 region() ;//地区の生成
 timezone() ;//時間帯の生成
 weather();//天気の生成
}