character-creator.component.ts 11 KB

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