SHOW:
|
|
- or go back to the newest paste.
1 | - | public class Context { |
1 | + | package cz.vsb.ekf.lan0116; |
2 | - | private final EventPublisher eventPublisher; |
2 | + | |
3 | - | private final Hero hero; |
3 | + | import ... |
4 | - | private final World world; |
4 | + | |
5 | - | private final ResourceCache cache; |
5 | + | public class Launcher { |
6 | - | private final Scanner scanner; |
6 | + | |
7 | - | private final Localization localization; |
7 | + | public static void main(String[] args) { |
8 | - | private final Session session; |
8 | + | Scanner scanner = new Scanner(System.in, "UTF-8"); |
9 | - | ... |
9 | + | //Volba lokalizace - jazyka hry |
10 | System.out.println("Language/Jazyk"); | |
11 | String pref; | |
12 | do { | |
13 | System.out.println("en/cz"); | |
14 | pref = scanner.nextLine(); | |
15 | } while (!(pref.equals("en") || pref.equals("cz"))); | |
16 | Localization l; | |
17 | switch (pref) { | |
18 | case "en": | |
19 | l = new Localization(ResourceUtil.getResource(ResourceType.LOCALIZATION, "en")); | |
20 | break; | |
21 | case "cz": | |
22 | l = new Localization(ResourceUtil.getResource(ResourceType.LOCALIZATION, "cz")); | |
23 | break; | |
24 | default: | |
25 | l = new Localization(ResourceUtil.getResource(ResourceType.LOCALIZATION, "en")); | |
26 | break; | |
27 | } | |
28 | Localization localization = l; | |
29 | ||
30 | //Načtení potřebných dat do ResourceCache | |
31 | Map<String, Attack> attackMap = ResourceToMapUtil.createAttackMap(ResourceUtil | |
32 | .getResource(ResourceType.ATTACK_ALL, "attacks")); | |
33 | Map<String, Consumable> consumableMap = ResourceToMapUtil.createConsumableMap(ResourceUtil | |
34 | .getResource(ResourceType.CONSUMABLE_ALL, "consumables")); | |
35 | Map<String, Weapon> weaponMap = ResourceToMapUtil.createWeaponMap(ResourceUtil | |
36 | .getResource(ResourceType.WEAPON_ALL, "weapons"), | |
37 | attackMap); | |
38 | Map<String, Creature> creatureMap = ResourceToMapUtil.createCreatureMap(ResourceUtil | |
39 | .getResource(ResourceType.CREATURES_ALL, "creatures"), attackMap, weaponMap); | |
40 | ResourceCache cache = new ResourceCache(attackMap, consumableMap, creatureMap, null, weaponMap); | |
41 | ||
42 | //Vytvoření zbývajících instancí souvisejících s kontextem | |
43 | World world = World.layout(cache); | |
44 | Hero hero = HeroCreationUi.creationOfHero(scanner, localization); | |
45 | ResponseChannel responseChannel = new ResponseChannel(); | |
46 | EventPublisher eventPublisher = new EventPublisher(hero, world, responseChannel); | |
47 | Session session = new Session(eventPublisher, responseChannel); | |
48 | Context context = new Context(eventPublisher, hero, world, cache, scanner, localization, session); | |
49 | TextEvents textEvents = new TextEvents(context); | |
50 | textEvents.playGame(); | |
51 | } | |
52 | } |