character-creator.component.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. import { Component } from '@angular/core';
  2. import { DataService } from 'src/services/data/data.service';
  3. import { Router } from '@angular/router';
  4. interface characterData {
  5. view: string;
  6. value: string;
  7. }
  8. @Component({
  9. selector: 'app-character-creator',
  10. templateUrl: './character-creator.component.html',
  11. styleUrls: ['./character-creator.component.scss'],
  12. })
  13. export class CharacterCreatorComponent {
  14. selectedValue: string = '';
  15. // Translators
  16. // TODO: Implement the species
  17. public species: characterData[] = [
  18. { view: 'Mensch', value: 'Human' },
  19. { view: 'Zwerg', value: 'Dwarf' },
  20. { view: 'Elf', value: 'Elf' },
  21. { view: 'Eladrin', value: 'Eladrin' },
  22. { view: 'Halbelf', value: 'HalfElf' },
  23. { view: 'Halbelf (Mal des Entdeckens)', value: 'HalfElfDetection' },
  24. { view: 'Halbling', value: 'Halfling' },
  25. { view: 'Gnom', value: 'Gnome' },
  26. { view: 'Halbork', value: 'HalfOrc' },
  27. { view: 'Tiefling', value: 'Tiefling' },
  28. ];
  29. // TODO: Implement the classes
  30. public classes: characterData[] = [
  31. { view: 'Barbar', value: 'Barbarian' },
  32. { view: 'Barde', value: 'Bard' },
  33. { view: 'Druide', value: 'Druid' },
  34. { view: 'Hexenmeister', value: 'Warlock' },
  35. { view: 'Kämpfer', value: 'Fighter' },
  36. { view: 'Kleriker', value: 'Cleric' },
  37. { view: 'Magier', value: 'Wizard' },
  38. { view: 'Mönch', value: 'Monk' },
  39. { view: 'Paladin', value: 'Paladin' },
  40. { view: 'Schurke', value: 'Rogue' },
  41. { view: 'Waldläufer', value: 'Ranger' },
  42. { view: 'Zauberer', value: 'Sorcerer' },
  43. ];
  44. public backgrounds: characterData[] = [
  45. { view: 'Akolyth', value: 'acolyte' },
  46. { view: 'Scharlatan', value: 'charlatan' },
  47. { view: 'Edelmann', value: 'noble' },
  48. { view: 'Entertainer', value: 'entertainer' },
  49. { view: 'Folk Held', value: 'folkHero' },
  50. { view: 'Gelehrter', value: 'sage' },
  51. { view: 'Gladiator', value: 'gladiator' },
  52. { view: 'Gildenhändler', value: 'guildArtisan' },
  53. { view: 'Gildehandwerker', value: 'guildMerchant' },
  54. { view: 'Herumtreiber', value: 'outlander' },
  55. { view: 'Krimineller', value: 'criminal' },
  56. { view: 'Künstler', value: 'artist' },
  57. { view: 'Marine', value: 'sailor' },
  58. { view: 'Scharlatan', value: 'charlatan' },
  59. { view: 'Soldat', value: 'soldier' },
  60. { view: 'Stadtwache', value: 'cityWatch' },
  61. { view: 'Urchin', value: 'urchin' },
  62. ];
  63. public genders: characterData[] = [
  64. { view: 'Weiblich', value: 'Female' },
  65. { view: 'Männlich', value: 'Male' },
  66. { view: 'Divers', value: 'Diverse' },
  67. ];
  68. // Predefined Data
  69. private hitDice: any = {
  70. Barbarian: 12,
  71. Bard: 8,
  72. Cleric: 8,
  73. Druid: 8,
  74. Fighter: 10,
  75. Monk: 8,
  76. Paladin: 10,
  77. Ranger: 10,
  78. Rogue: 8,
  79. Sorcerer: 6,
  80. Warlock: 8,
  81. Wizard: 6,
  82. };
  83. public spellcastingAttributes: any = {
  84. Barbarian: null,
  85. Bard: 'Charisma',
  86. Cleric: 'Wisdom',
  87. Druid: 'Wisdom',
  88. Fighter: null,
  89. Monk: 'Wisdom',
  90. Paladin: 'Charisma',
  91. Ranger: 'Wisdom',
  92. Rogue: 'Intelligence',
  93. Sorcerer: 'Charisma',
  94. Warlock: 'Charisma',
  95. Wizard: 'Intelligence',
  96. };
  97. public characterName: string = '';
  98. public characterClass: string = '';
  99. public characterSpecies: string = '';
  100. public characterBackground: string = '';
  101. public characterGender: string = '';
  102. public constructor(
  103. public dataAccessor: DataService,
  104. private Router: Router
  105. ) {}
  106. public async createCharacter(): Promise<void> {
  107. console.log(this.characterName);
  108. // Creates a new entry in the character collection
  109. this.dataAccessor.addData('characters', { name: this.characterName });
  110. // Creates a new collection with the character name
  111. this.createNewCharacterInDatabase().then(() => {
  112. // Die Funktion muss ertstmal durchlaufen, bevor der Character ausgewählt werden kann
  113. sessionStorage.setItem('characterName', this.characterName);
  114. this.dataAccessor.dataLoaded = false;
  115. this.Router.navigate(['journal']);
  116. });
  117. }
  118. public async createNewCharacterInDatabase(): Promise<void> {
  119. // TODO: Für alle Daten einen eigenen Key/Value Eintrag anlegen addData(collection: string, data: any, key?: string): void
  120. return Promise.all([
  121. // Character Data
  122. this.dataAccessor.addData(
  123. this.characterName,
  124. {
  125. class: this.characterClass,
  126. subclass: '',
  127. race: this.characterSpecies,
  128. background: this.characterBackground,
  129. level: 1,
  130. experience: 0,
  131. image: '',
  132. gender: this.characterGender,
  133. age: '',
  134. height: '',
  135. weight: '',
  136. eyes: '',
  137. skin: '',
  138. hair: '',
  139. },
  140. 'characterData'
  141. ),
  142. // Character Image
  143. this.dataAccessor.addData(
  144. this.characterName,
  145. {
  146. value: undefined,
  147. },
  148. 'image'
  149. ),
  150. // Character Attributes
  151. this.dataAccessor.addData(
  152. this.characterName,
  153. {
  154. strength: { name: 'strength', value: 10, proficiency: false },
  155. dexterity: { name: 'dexterity', value: 10, proficiency: false },
  156. constitution: { name: 'constitution', value: 10, proficiency: false },
  157. intelligence: { name: 'intelligence', value: 10, proficiency: false },
  158. wisdom: { name: 'wisdom', value: 10, proficiency: false },
  159. charisma: { name: 'charisma', value: 10, proficiency: false },
  160. },
  161. 'attributes'
  162. ),
  163. // Character Skills
  164. this.dataAccessor.addData(
  165. this.characterName,
  166. {
  167. acrobatics: { name: 'acrobatics', proficiency: false },
  168. animalHandling: { name: 'animalHandling', proficiency: false },
  169. arcana: { name: 'arcana', proficiency: false },
  170. athletics: { name: 'athletics', proficiency: false },
  171. deception: { name: 'deception', proficiency: false },
  172. history: { name: 'history', proficiency: false },
  173. insight: { name: 'insight', proficiency: false },
  174. intimidation: { name: 'intimidation', proficiency: false },
  175. investigation: { name: 'investigation', proficiency: false },
  176. medicine: { name: 'medicine', proficiency: false },
  177. nature: { name: 'nature', proficiency: false },
  178. perception: { name: 'perception', proficiency: false },
  179. performance: { name: 'performance', proficiency: false },
  180. persuasion: { name: 'persuasion', proficiency: false },
  181. religion: { name: 'religion', proficiency: false },
  182. sleightOfHand: { name: 'sleightOfHand', proficiency: false },
  183. stealth: { name: 'stealth', proficiency: false },
  184. survival: { name: 'survival', proficiency: false },
  185. },
  186. 'skills'
  187. ),
  188. // Character Combat Stats
  189. this.dataAccessor.addData(
  190. this.characterName,
  191. {
  192. armorClass: 10,
  193. initiative: 0,
  194. movement: 30,
  195. deathSaves: [0, 0],
  196. proficiencyBonus: 2,
  197. conditions: [],
  198. exhaustion: 0,
  199. inspiration: false,
  200. },
  201. 'combatStats'
  202. ),
  203. // Character Hit Points
  204. this.dataAccessor.addData(
  205. this.characterName,
  206. {
  207. hitPoints: {
  208. maxHitPoints: 10,
  209. currentHitPoints: 10,
  210. temporaryHitPoints: 0,
  211. },
  212. hitDice: {
  213. diceNumber: 1,
  214. diceType: this.hitDice[this.characterClass],
  215. diceUsed: 0,
  216. },
  217. },
  218. 'hitPoints'
  219. ),
  220. // Character Abilities
  221. this.dataAccessor.addData(
  222. this.characterName,
  223. {
  224. data: [],
  225. },
  226. 'abilities'
  227. ),
  228. // Character Traits
  229. this.dataAccessor.addData(
  230. this.characterName,
  231. {
  232. data: [],
  233. },
  234. 'traits'
  235. ),
  236. // Character Proficiencies
  237. this.dataAccessor.addData(
  238. this.characterName,
  239. {
  240. light: false,
  241. medium: false,
  242. heavy: false,
  243. shields: false,
  244. simple: false,
  245. martial: false,
  246. other: [],
  247. tools: [],
  248. languages: ['Gemeinsprache'],
  249. },
  250. 'proficiencies'
  251. ),
  252. // Character Spellslots
  253. this.dataAccessor.addData(
  254. this.characterName,
  255. {
  256. spellslots: [],
  257. showSpellslots: false,
  258. spellcastingAttribute:
  259. this.spellcastingAttributes[this.characterClass],
  260. },
  261. 'spellslots'
  262. ),
  263. // Ki Points
  264. this.dataAccessor.addData(
  265. this.characterName,
  266. {
  267. totalPoints: 0,
  268. usedPoints: 0,
  269. showKiPoints: false,
  270. },
  271. 'kiPoints'
  272. ),
  273. // Weapons
  274. this.dataAccessor.addData(
  275. this.characterName,
  276. {
  277. data: [],
  278. },
  279. 'favoriteWeapons'
  280. ),
  281. // WEAPONS AND ARMOR
  282. this.dataAccessor.addData(
  283. this.characterName,
  284. {
  285. data: [],
  286. },
  287. 'weaponsAndArmor'
  288. ),
  289. // MISCELLANEOUS
  290. this.dataAccessor.addData(
  291. this.characterName,
  292. {
  293. data: [],
  294. },
  295. 'miscellaneous'
  296. ),
  297. // CONSUMABLES
  298. this.dataAccessor.addData(
  299. this.characterName,
  300. {
  301. data: [],
  302. },
  303. 'consumables'
  304. ),
  305. // MONEY
  306. this.dataAccessor.addData(
  307. this.characterName,
  308. {
  309. platinum: 0,
  310. gold: 0,
  311. silver: 0,
  312. copper: 0,
  313. },
  314. 'money'
  315. ),
  316. // FOOD
  317. this.dataAccessor.addData(
  318. this.characterName,
  319. {
  320. data: [],
  321. },
  322. 'food'
  323. ),
  324. // Favorite Spells
  325. this.dataAccessor.addData(
  326. this.characterName,
  327. {
  328. spells: [],
  329. },
  330. 'favoriteSpells'
  331. ),
  332. // Spells
  333. this.dataAccessor.addData(
  334. this.characterName,
  335. {
  336. spells: [],
  337. id: 1000,
  338. },
  339. 'customSpells'
  340. ),
  341. this.dataAccessor.addData(
  342. this.characterName,
  343. {
  344. spells: [],
  345. },
  346. 'spellLevel0'
  347. ),
  348. this.dataAccessor.addData(
  349. this.characterName,
  350. {
  351. spells: [],
  352. },
  353. 'spellLevel1'
  354. ),
  355. this.dataAccessor.addData(
  356. this.characterName,
  357. {
  358. spells: [],
  359. },
  360. 'spellLevel2'
  361. ),
  362. this.dataAccessor.addData(
  363. this.characterName,
  364. {
  365. spells: [],
  366. },
  367. 'spellLevel3'
  368. ),
  369. this.dataAccessor.addData(
  370. this.characterName,
  371. {
  372. spells: [],
  373. },
  374. 'spellLevel4'
  375. ),
  376. this.dataAccessor.addData(
  377. this.characterName,
  378. {
  379. spells: [],
  380. },
  381. 'spellLevel5'
  382. ),
  383. this.dataAccessor.addData(
  384. this.characterName,
  385. {
  386. spells: [],
  387. },
  388. 'spellLevel6'
  389. ),
  390. this.dataAccessor.addData(
  391. this.characterName,
  392. {
  393. spells: [],
  394. },
  395. 'spellLevel7'
  396. ),
  397. this.dataAccessor.addData(
  398. this.characterName,
  399. {
  400. spells: [],
  401. },
  402. 'spellLevel8'
  403. ),
  404. this.dataAccessor.addData(
  405. this.characterName,
  406. {
  407. spells: [],
  408. },
  409. 'spellLevel9'
  410. ),
  411. // Notes
  412. // Maps
  413. // NPCs
  414. // Quests
  415. ]).then(() => {});
  416. }
  417. }