Book about a wizard/sorcerer, a ring carved in the ground around a castle to create a forcefield. evil sorcerer makes spiders or insects appear and a guard runs and touches the forcefield which then collapses. maybe an apprentice with wizard, used to read a lot of choose your own adventure books?
Most likely not because the other details don’t match, but Patricia C. Wrede’s Talking to Dragons does have wizards and a force field over a castle.