how do you create a 'barrel' looting quest?

is it possible to make a 'wins /losses at gambling' quest?

what about quests based on event counts i.e. x amount of deaths or  distance kills?

essentially think of it as some sort of rewards system.

thanks!