private void handleOption(char c) { switch (c) { case '1': moreHealth(); break; case '2': moreSanity(); break; // available only at character creation case '3': buyFocus(); break; case '4': buySkill(); break; // random shop case '5': buyMoney(); break; case '6': buyCommonItem(); break; case '7': buyUniqueItem(); break; case '8': buySpell(); break; case 'G': randomise(character.getName().hashCode()); break; case 'R': randomise(System.currentTimeMillis()); break; case 'U': undo(); break; case 'Q': quit(); break; } }
public void run() { while (buildPoints > 0) { showMenu(); String option = character.readLine(); String trimmed = option.trim(); switch (trimmed.length()) { case 1: handleOption(trimmed.toUpperCase().charAt(0)); break; default: character.println("Please enter a menu option."); break; } } showCharacterInfo(); }
private void quit() { character.println(""); character.println("{text:bold}{text:red}Noooooo! The world is doomed!{text}"); character.println(""); throw new RuntimeException("User has quit."); }
private void moreSanity() { if (character.getSanity() < 7) { character.incSanity(); character.decHealth(); } }
private void showCharacterInfo() { character.println( "{cls}{text:bold}{text:magenta}Character{text}: {text:bold}%s{text}", character.getName()); // start = 5, min = 3, max = 7 character.println( "{text:bold}{text:magenta}Health{text}: {text:bold}%d{text} (min 3, max 7)", character.getHealth()); // start = 5, min = 3, max = 7 character.println( "{text:bold}{text:magenta}Sanity{text}: {text:bold}%d{text} (min 3, max 7)", character.getSanity()); // start = 1, min = 1, max = 3> character.println( "{text:bold}{text:magenta}Focus{text}: {text:bold}%d{text} (min 1, max 3)", character.getFocus()); character.println( "{text:bold}{text:magenta}Items{text}: {text:bold}%s{text}", character.getItemSummary()); character.println( "{text:bold}{text:magenta}Spells{text}: {text:bold}%s{text}", character.getSpellSummary()); character.println( "{text:bold}{text:magenta}Skills{text}: {text:bold}%s{text}", character.getSkillsSummary()); character.println( "{text:bold}{text:magenta}Money{text}: {text:bold}$%d{text}", character.getMoney()); }
private void showMenu() { character.println("{cls}"); character.println("{text:u}{text:bold}{text:blue}Character Creation Menu{text}"); character.println(""); showCharacterInfo(); character.println(""); character.println("Change health and sanity:"); character.println("{text:bold}1){text} +1 health, -1 sanity"); character.println("{text:bold}2){text} +1 sanity, -1 health"); character.println(""); character.println("You have {text:bold}%d{text} build points remaining", getBuildPoints()); character.println(""); character.println("Available at character creation only:"); character.println("{text:bold}3){text} +1 focus = 4 points"); character.println("{text:bold}4){text} +1 skill = %d point", Skill.BUILD_COST); character.println(""); character.println("Items and starting money:"); character.println("{text:bold}5){text} +1 money = 1 point"); character.println("{text:bold}6){text} +1 common item = %d points", CommonItem.BUILD_COST); character.println("{text:bold}7){text} +1 unique item = %d points", UniqueItem.BUILD_COST); character.println("{text:bold}8){text} +1 spell = %d point", Spell.BUILD_COST); character.println(""); character.println("or..."); character.println("{text:bold}U){text} undo points spend"); character.println("{text:bold}G){text} to generate character for this username (quick start)"); character.println("{text:bold}R){text} to generate a purely random character (quick start)"); character.println("{text:bold}Q){text} quit"); character.println(""); character.println("or, type a keyword for help, e.g. focus"); character.print("> "); }