character-creator.component.ts 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. import { Component } from '@angular/core';
  2. import { DataService } from 'src/services/data/data.service';
  3. import { Router } from '@angular/router';
  4. @Component({
  5. selector: 'app-character-creator',
  6. templateUrl: './character-creator.component.html',
  7. styleUrls: ['./character-creator.component.scss'],
  8. })
  9. export class CharacterCreatorComponent {
  10. public constructor(
  11. public dataAccessor: DataService,
  12. private Router: Router
  13. ) {}
  14. public characterName: string = '';
  15. public async createCharacter(): Promise<void> {
  16. // Creates a new entry in the character collection
  17. this.dataAccessor.addData('characters', { name: this.characterName });
  18. // Creates a new collection with the character name
  19. this.createNewCharacterInDatabase().then(() => {
  20. // Die Funktion muss ertstmal durchlaufen, bevor der Character ausgewählt werden kann
  21. sessionStorage.setItem('characterName', this.characterName);
  22. this.dataAccessor.dataLoaded = false;
  23. this.Router.navigate(['journal']);
  24. });
  25. }
  26. public async createNewCharacterInDatabase(): Promise<void> {
  27. // TODO: Für alle Daten einen eigenen Key/Value Eintrag anlegen addData(collection: string, data: any, key?: string): void
  28. return Promise.all([
  29. // Character Data
  30. this.dataAccessor.addData(
  31. this.characterName,
  32. {
  33. class: '',
  34. subclass: '',
  35. race: '',
  36. background: '',
  37. level: 1,
  38. experience: 0,
  39. },
  40. 'characterData'
  41. ),
  42. // Character Attributes
  43. this.dataAccessor.addData(
  44. this.characterName,
  45. {
  46. strength: { name: 'strength', value: 10, proficiency: false },
  47. dexterity: { name: 'dexterity', value: 10, proficiency: false },
  48. constitution: { name: 'constitution', value: 10, proficiency: false },
  49. intelligence: { name: 'intelligence', value: 10, proficiency: false },
  50. wisdom: { name: 'wisdom', value: 10, proficiency: false },
  51. charisma: { name: 'charisma', value: 10, proficiency: false },
  52. },
  53. 'attributes'
  54. ),
  55. // Character Skills
  56. this.dataAccessor.addData(
  57. this.characterName,
  58. {
  59. acrobatics: { name: 'acrobatics', proficiency: false },
  60. animalHandling: { name: 'animalHandling', proficiency: false },
  61. arcana: { name: 'arcana', proficiency: false },
  62. athletics: { name: 'athletics', proficiency: false },
  63. deception: { name: 'deception', proficiency: false },
  64. history: { name: 'history', proficiency: false },
  65. insight: { name: 'insight', proficiency: false },
  66. intimidation: { name: 'intimidation', proficiency: false },
  67. investigation: { name: 'investigation', proficiency: false },
  68. medicine: { name: 'medicine', proficiency: false },
  69. nature: { name: 'nature', proficiency: false },
  70. perception: { name: 'perception', proficiency: false },
  71. performance: { name: 'performance', proficiency: false },
  72. persuasion: { name: 'persuasion', proficiency: false },
  73. religion: { name: 'religion', proficiency: false },
  74. sleightOfHand: { name: 'sleightOfHand', proficiency: false },
  75. stealth: { name: 'stealth', proficiency: false },
  76. survival: { name: 'survival', proficiency: false },
  77. },
  78. 'skills'
  79. ),
  80. // Character Combat Stats
  81. this.dataAccessor.addData(
  82. this.characterName,
  83. {
  84. armorClass: 10,
  85. initiative: 0,
  86. movement: 30,
  87. deathSaves: [0, 0],
  88. proficiencyBonus: 2,
  89. conditions: [],
  90. exhaustion: 0,
  91. inspiration: false,
  92. },
  93. 'combatStats'
  94. ),
  95. // Character Hit Points
  96. this.dataAccessor.addData(
  97. this.characterName,
  98. {
  99. hitPoints: {
  100. maxHitPoints: 10,
  101. currentHitPoints: 10,
  102. temporaryHitPoints: 0,
  103. },
  104. hitDice: {
  105. hitDiceNumber: 1,
  106. hitDiceType: 10,
  107. },
  108. },
  109. 'hitPoints'
  110. ),
  111. // Character Abilities
  112. this.dataAccessor.addData(
  113. this.characterName,
  114. {
  115. data: [],
  116. },
  117. 'abilities'
  118. ),
  119. // Character Traits
  120. this.dataAccessor.addData(
  121. this.characterName,
  122. {
  123. data: [],
  124. },
  125. 'traits'
  126. ),
  127. // Character Proficiencies
  128. this.dataAccessor.addData(
  129. this.characterName,
  130. {
  131. armor: {
  132. light: false,
  133. medium: false,
  134. heavy: false,
  135. },
  136. weapons: {
  137. simple: false,
  138. martial: false,
  139. other: [],
  140. },
  141. tools: [],
  142. languages: ['Gemeinsprache'],
  143. },
  144. 'proficiencies'
  145. ),
  146. // Character Spellslots
  147. this.dataAccessor.addData(
  148. this.characterName,
  149. {
  150. spellslots: [],
  151. showSpellslots: false,
  152. },
  153. 'spellslots'
  154. ),
  155. // Ki Points
  156. this.dataAccessor.addData(
  157. this.characterName,
  158. {
  159. totalPoints: 0,
  160. usedPoints: 0,
  161. showKiPoints: false,
  162. },
  163. 'kiPoints'
  164. ),
  165. // Character Appearance
  166. this.dataAccessor.addData(
  167. this.characterName,
  168. {
  169. age: '',
  170. height: '',
  171. weight: '',
  172. eyes: '',
  173. skin: '',
  174. hair: '',
  175. },
  176. 'appearance'
  177. ),
  178. // Weapons
  179. this.dataAccessor.addData(
  180. this.characterName,
  181. {
  182. data: [],
  183. },
  184. 'favoriteWeapons'
  185. ),
  186. // WEAPONS AND ARMOR
  187. this.dataAccessor.addData(
  188. this.characterName,
  189. {
  190. data: [],
  191. },
  192. 'weaponsAndArmor'
  193. ),
  194. // MISCELLANEOUS
  195. this.dataAccessor.addData(
  196. this.characterName,
  197. {
  198. data: [],
  199. },
  200. 'miscellaneous'
  201. ),
  202. // CONSUMABLES
  203. this.dataAccessor.addData(
  204. this.characterName,
  205. {
  206. data: [],
  207. },
  208. 'consumables'
  209. ),
  210. // MONEY
  211. this.dataAccessor.addData(
  212. this.characterName,
  213. {
  214. platinum: 0,
  215. gold: 0,
  216. electrum: 0,
  217. silver: 0,
  218. copper: 0,
  219. },
  220. 'money'
  221. ),
  222. // FOOD
  223. this.dataAccessor.addData(
  224. this.characterName,
  225. {
  226. data: [],
  227. },
  228. 'food'
  229. ),
  230. // Favorite Spells
  231. this.dataAccessor.addData(
  232. this.characterName,
  233. {
  234. spells: [],
  235. },
  236. 'favoriteSpells'
  237. ),
  238. // Spells
  239. this.dataAccessor.addData(
  240. this.characterName,
  241. {
  242. spells: [],
  243. },
  244. 'spellLevel0'
  245. ),
  246. this.dataAccessor.addData(
  247. this.characterName,
  248. {
  249. spells: [],
  250. },
  251. 'spellLevel1'
  252. ),
  253. this.dataAccessor.addData(
  254. this.characterName,
  255. {
  256. spells: [],
  257. },
  258. 'spellLevel2'
  259. ),
  260. this.dataAccessor.addData(
  261. this.characterName,
  262. {
  263. spells: [],
  264. },
  265. 'spellLevel3'
  266. ),
  267. this.dataAccessor.addData(
  268. this.characterName,
  269. {
  270. spells: [],
  271. },
  272. 'spellLevel4'
  273. ),
  274. this.dataAccessor.addData(
  275. this.characterName,
  276. {
  277. spells: [],
  278. },
  279. 'spellLevel5'
  280. ),
  281. this.dataAccessor.addData(
  282. this.characterName,
  283. {
  284. spells: [],
  285. },
  286. 'spellLevel6'
  287. ),
  288. this.dataAccessor.addData(
  289. this.characterName,
  290. {
  291. spells: [],
  292. },
  293. 'spellLevel7'
  294. ),
  295. this.dataAccessor.addData(
  296. this.characterName,
  297. {
  298. spells: [],
  299. },
  300. 'spellLevel8'
  301. ),
  302. this.dataAccessor.addData(
  303. this.characterName,
  304. {
  305. spells: [],
  306. },
  307. 'spellLevel9'
  308. ),
  309. // Notes
  310. // Maps
  311. // NPCs
  312. // Quests
  313. ]).then(() => {});
  314. }
  315. }