character-creator.component.ts 10 KB

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