1// automatically generated by the FlatBuffers compiler, do not modify 2 3import { Attacker, AttackerT } from './attacker'; 4import { BookReader, BookReaderT } from './book-reader'; 5import { Rapunzel, RapunzelT } from './rapunzel'; 6 7 8export enum Character{ 9 NONE = 0, 10 MuLan = 1, 11 Rapunzel = 2, 12 Belle = 3, 13 BookFan = 4, 14 Other = 5, 15 Unused = 6 16} 17 18export function unionToCharacter( 19 type: Character, 20 accessor: (obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null 21): Attacker|BookReader|Rapunzel|string|null { 22 switch(Character[type]) { 23 case 'NONE': return null; 24 case 'MuLan': return accessor(new Attacker())! as Attacker; 25 case 'Rapunzel': return accessor(new Rapunzel())! as Rapunzel; 26 case 'Belle': return accessor(new BookReader())! as BookReader; 27 case 'BookFan': return accessor(new BookReader())! as BookReader; 28 case 'Other': return accessor('') as string; 29 case 'Unused': return accessor('') as string; 30 default: return null; 31 } 32} 33 34export function unionListToCharacter( 35 type: Character, 36 accessor: (index: number, obj:Attacker|BookReader|Rapunzel|string) => Attacker|BookReader|Rapunzel|string|null, 37 index: number 38): Attacker|BookReader|Rapunzel|string|null { 39 switch(Character[type]) { 40 case 'NONE': return null; 41 case 'MuLan': return accessor(index, new Attacker())! as Attacker; 42 case 'Rapunzel': return accessor(index, new Rapunzel())! as Rapunzel; 43 case 'Belle': return accessor(index, new BookReader())! as BookReader; 44 case 'BookFan': return accessor(index, new BookReader())! as BookReader; 45 case 'Other': return accessor(index, '') as string; 46 case 'Unused': return accessor(index, '') as string; 47 default: return null; 48 } 49} 50 51