Discrete Games in Endogenous Networks