Пример #1
0
  public static Thing createHero(String name, String race, String profession) {

    Thing h = createBaseHero(race);
    Game.instance().initialize(h);

    if ((name == null) || (name.equals(""))) name = "Tester";
    setHeroName(h, name);

    // Debug mode modifications
    if (Game.isDebug()) {
      addDebugModifications(h);
    }

    // Race Modifications
    applyRace(h, race);

    // Professions
    applyProfession(h, profession);

    // Bonus items based on skills
    applyBonusItems(h);

    // set up HPS and MPS
    h.set(RPG.ST_HPSMAX, h.getBaseStat(RPG.ST_TG) + RPG.d(6));
    h.set(RPG.ST_MPSMAX, h.getBaseStat(RPG.ST_WP) + RPG.d(6));

    h.set(RPG.ST_HPS, h.getStat(RPG.ST_HPSMAX));
    h.set(RPG.ST_MPS, h.getStat(RPG.ST_MPSMAX));

    Being.utiliseItems(h);

    Wish.makeWish("id", 100);

    // score starts at zero
    h.set("Score", 0);

    // religion
    ArrayList gods = Gods.getPossibleGods(h);
    int gl = gods.size();
    if (gl > 0) {
      h.set("Religion", gods.get(RPG.r(gl)));
    } else {
      Game.warn("No religion available for " + race + " " + profession);
    }

    createHeroHistory(h);

    // performance improvement with flattened properties
    h.flattenProperties();

    return h;
  }
Пример #2
0
  public static Map createWorldMap(int w, int h) {
    Map m = new Map(w, h);

    m.set("EnterMessage", "This fertile valley is known as North Karrain");
    m.set("Description", "North Karrain Valley");
    m.set("WanderingRate", 0);
    m.set("IsWorldMap", 1);
    m.set("Level", 1);
    m.set("VisionRange", 7);
    m.set("OnAction", new EncounterAction());

    // TODO: Increased move costs and times

    for (int x = 0; x < w; x += 4) {
      m.setTile(x, 0, Tile.MOUNTAINS);
      m.setTile(x, h - 1, Tile.MOUNTAINS);
    }
    for (int y = 0; y < h; y += 4) {
      m.setTile(0, y, Tile.MOUNTAINS);
      m.setTile(w - 1, y, Tile.SEA);
    }

    for (int y = 4; y < h - 4; y += 4)
      for (int x = 4; x < w - 4; x += 4) {
        m.setTile(x, y, terrains[Rand.r(terrains.length)]);
      }

    m.setTile(16, 8, Tile.FORESTS);
    m.setTile(16, 12, Tile.FORESTS);
    m.setTile(16, 16, Tile.PLAINS);
    m.setTile(12, 12, Tile.FORESTS);
    m.setTile(8, 12, Tile.HILLS);

    m.fractalizeBlock(0, 0, w - 1, h - 1, 4);

    // starting town + quest
    m.addThing(Portal.create("town"), 16, 16);
    m.addThing(Portal.create("ruin"), 16, 8);

    // mutable thing!
    // addThing(new Mutable("beefcake"),15,15);

    // some other towns
    m.addThing(Portal.create("town"), 0, 0, m.width - 1, m.height - 1);
    m.addThing(Portal.create("town"), 0, 0, m.width - 1, m.height - 1);

    // caves
    m.addThing(Portal.create("caves"), 0, 0, m.width - 1, m.height - 1);

    // graveyard
    m.addThing(Portal.create("graveyard"), 0, 0, m.width - 1, m.height - 1);

    // goblin grotto
    m.addThing(Portal.create("grotto"));

    // graveyard
    m.addThing(Portal.create("deep dungeon"), 0, 0, m.width - 1, m.height - 1);

    // special for Christmas!
    Calendar cal = Calendar.getInstance();
    if ((cal.get(Calendar.MONTH) == Calendar.DECEMBER) && (cal.get(Calendar.DAY_OF_MONTH) == 25)) {
      Game.warn("Merry Christmas!!");
      m.addThing(Portal.create("Old Nyck's hut"), 0, 0, m.width - 1, m.height - 1);
    }

    // goblin villae
    m.addThing(Portal.create("goblin village"), 0, 0, m.width - 1, m.height - 1);

    // wood temple
    Point wp = null;
    for (int i = 0; i < 1000; i++) {
      wp = m.findFreeSquare();
      if (m.getTile(wp.x, wp.y) == Tile.FORESTS) break;
    }
    m.addThing(Portal.create("dark forest"), wp.x, wp.y);

    // dark tower
    m.addThing(Portal.create("dark tower"));

    return m;
  }