character-creator.component.ts 10 KB

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