Both f.o.b and barracks should cost x wealth to make as well as each unit. If there is enough wealth subtract X from the current wealth in order to create the unit/structure. If there isnt dont let the unit/structure be created. Display some short of a message to show you need more wealth