// creates a hero according to specified parameters public Thing createHero(boolean prompts) { long start = System.currentTimeMillis(); String race = null; String profession = null; if (!prompts) { race = "human"; profession = "fighter"; Game.setDebug(true); } // get list of races String[] raceherostrings = Hero.heroRaces(); String[] racedescriptions = Hero.heroRaceDescriptions(); if (race == null) { DetailedListScreen ls = new DetailedListScreen("What race are you?", raceherostrings, racedescriptions); ls.setForeground(new Color(128, 128, 128)); ls.setBackground(new Color(0, 0, 0)); ls.bottomString = "Press a letter key to select your race"; switchScreen(ls); while (true) { race = (String) ls.getObject(); // Game.warn(race); if ((race != null) || Game.isDebug()) break; } } if (race == null) { // Debug mode only // have escaped, so choose randomly race = raceherostrings[Rand.r(raceherostrings.length)]; String[] herostrings = Hero.heroProfessions(race); profession = herostrings[Rand.r(herostrings.length)]; } // get list of possible prfessions String[] professionstrings = Hero.heroProfessions(race); String[] professiondescriptions = Hero.heroProfessionDescriptions(race); if (profession == null) { DetailedListScreen ls = new DetailedListScreen( "What is your profession?", professionstrings, professiondescriptions); ls.bottomString = "Press a letter key to select your profession"; ls.setForeground(new Color(128, 128, 128)); ls.setBackground(new Color(0, 0, 0)); switchScreen(ls); while (profession == null) { profession = (String) ls.getObject(); } } Thing h = Hero.createHero(prompts ? null : "QuickTester", race, profession); // hero name and history display String name = "QuickTester"; if (prompts) { // setup screen to get name Screen ss = new Screen(this); ss.setBackground(new Color(0, 0, 0)); ss.setLayout(new BorderLayout()); { InfoScreen ts = new InfoScreen(this, h.getString("HeroHistory")); ts.setBackground(new Color(0, 0, 0)); ss.add("Center", ts); } MessagePanel mp = new MessagePanel(this); Game.messagepanel = mp; ss.add("South", mp); switchScreen(ss); name = getHeroName(true); if (name == null) return null; } Hero.setHeroName(h, name); System.out.println((System.currentTimeMillis() - start) + "ms to createHero"); return h; }