Exemplo n.º 1
0
void do_defect(CHAR_DATA *ch, char *argument)
{
    char arg1[MAX_STRING_LENGTH];
    char buf[MAX_STRING_LENGTH];

    argument = one_argument(argument, arg1);

    if (ch->pcdata->kingdom == 0)
    {
        send_to_char("Defect from what?  You are not part of a kingdom!",ch);
        return;
    }

    if (str_cmp(arg1,"defect"))
    {
        send_to_char("If you want to defect you MUST type it twice.\n\rI.e defect defect\n\r",ch);
        return;
    }

    if ( !str_cmp(kingdom_table[ch->pcdata->kingdom].general,ch->name) || !str_cmp(kingdom_table[ch->pcdata->kingdom].leader,ch->name))
    {
        send_to_char("You may not defect without first renouncing your title.\n\r",ch);
        return;
    }

    send_to_char("You defect from your kingdom...",ch);
    sprintf(buf,"%s has defected.",ch->name);
    do_info(ch,buf);
    ch->pcdata->kingdom = 0;
    save_char_obj(ch);
    save_kingdoms();
    return;
}
Exemplo n.º 2
0
bool Game::generate_world()
{
  if (world) {
    delete world;
    world = new World_map;
  }
  world->generate();
  generate_kingdoms();
  world->save_to_file(SAVE_DIR + "world.sav");
  save_kingdoms();
  world_ready = true;
  return true;
}
Exemplo n.º 3
0
bool Game::save_game()
{
// Save the player's city.
  std::ofstream fout;
  std::string filename = SAVE_DIR + "cities/" + city->get_name() + ".sav";
  fout << city->save_data();

  fout.close();

  save_kingdoms();
  world->save_to_file(SAVE_DIR + "world.txt");

  return true;
}
Exemplo n.º 4
0
void do_renounce(CHAR_DATA *ch, char *argument)
{
    char arg1[MAX_STRING_LENGTH];
    char buf[MAX_STRING_LENGTH];

    argument = one_argument(argument, arg1);

    if (ch->pcdata->kingdom == 0)
    {
        send_to_char("Renounce what?  You are not part of a kingdom!",ch);
        return;
    }

    if (str_cmp(arg1,"renounce"))
    {
        send_to_char("If you want to renounce your title you MUST type it twice.\n\rI.e renounce renounce\n\r",ch);
        return;
    }

    if ( str_cmp(kingdom_table[ch->pcdata->kingdom].general,ch->name) && str_cmp(kingdom_table[ch->pcdata->kingdom].leader,ch->name))
    {
        send_to_char("You may not renounce without first possessing a title.\n\r",ch);
        return;
    }

    if ( !str_cmp(kingdom_table[ch->pcdata->kingdom].general,ch->name) )
    {
        free_string(kingdom_table[ch->pcdata->kingdom].general);
        kingdom_table[ch->pcdata->kingdom].general = str_dup("No One!");
    }
    else if( !str_cmp(kingdom_table[ch->pcdata->kingdom].leader,ch->name) )
    {
        free_string(kingdom_table[ch->pcdata->kingdom].leader);
        kingdom_table[ch->pcdata->kingdom].leader = str_dup("No One!");
    }
    send_to_char("You renounce your title...",ch);
    sprintf(buf,"%s has renounced their title..",ch->name);
    do_info(ch,buf);
    save_char_obj(ch);
    save_kingdoms();
    return;
}
Exemplo n.º 5
0
bool Game::start_new_game()
{
  date = Date(1400, 5, 1);

  if (!world_ready) {

    if (file_exists(SAVE_DIR + "world.sav")) {
      if (!query_yn("Load world from save file?")) {
        return false;
      }
      world->load_from_file(SAVE_DIR + "world.sav");

    } else {
      if (!query_yn("We need to generate a world first, is that okay?") ||
          !generate_world()) {
        return false;
      }
      world->save_to_file("world.sav");
      save_kingdoms();
    }

  }

// Pick our race first, so we know where to start placement.
  city->pick_race();

// Let the city pick a location in the world
// Start from the center of the appropriate kingdom.
  Point start;
  Kingdom* city_kingdom = get_kingdom_for_race(city->get_race());
  if (city_kingdom) {
    start.x = (city_kingdom->most_west  + city_kingdom->most_east ) / 2;
    start.y = (city_kingdom->most_north + city_kingdom->most_south) / 2;
  } else {
    debugmsg("Kingdom not found for %s.  %d kingdoms.",
             Race_data[city->get_race()]->name.c_str(), kingdoms.size());
    start = Point(WORLD_MAP_SIZE / 2, WORLD_MAP_SIZE / 2);
  }

  city->set_starting_tiles_seen();

  Point p = world->draw(start, &(city->world_seen));

  if (p.x == -1) {  // We canceled
    return false;
  }

// Put our city there.
  bool placed = false;
  while (!placed) {
    if (!city->world_seen.is_seen(p)) {
      popup("That's unexplored territory!");
    } else if (!world->get_city(p)) {
      city->generate_map(p);
      placed = city->place_keep();
    } else {
      popup("There is already a city there!");
    }
    if (!placed) {
      p = world->draw(p, &(city->world_seen)); // Try again
      if (p.x == -1) {  // We canceled
        return false;
      }
    }
  }

  city->location = p;
// Let us see a little more.
  city->mark_nearby_tiles_seen(4);
  world->set_city(p, city);
// Crude race picker; TODO: replace this.
  city->set_name();
  city->start_new_city();
  city->setup_trade_routes();
  city->set_starting_tiles_seen();

  return true;
}