Hat of Many Spells
Wondrous Item, Very Rare
Requires Attunement (by a Wizard).
Spellcasting Focus. The hat is a Wizard Spellcasting Focus; spells cast through it gain a Somatic "pull it from the hat" component.
Unknown Spell. Try to cast a Wizard-list spell you don't know, of a level you can cast, with materials under 1,000 GP. Expend a slot of that level, then make an INT (Arcana) check (DC 10 + the spell's level). Success: cast it as normal — not usable again until a Short or Long Rest. Failure: roll on card 2. Spells use your spell save DC and attack bonus.