damaging different enemies

Just wondering if anyone has suggestions on how to write this:

I want my character to be able to damage different types of enemies the same amount. It seems really inefficient to write specific damage statements for each individual enemy i.e.

punch()
if enemy1 is punched then
damage enemy1
end
if enemy2 is punched then
damage enemy2
end
end

if there a more logical way to write this that doesn’t require writing separate statements for each individual enemy?

Would it better to include that code with the enemy section of the code rather than the punch itself ie

enemy1()
create enemy1
move enemy1 towards character
if enemy1 is punched then
damage enemy1
end
end
enemy1()

create enemy2
move enemy2 towards character
if enemy2 is punched then
damage enemy2
end
end

Or is there an entirely different way to write this? [import]uid: 10903 topic_id: 6853 reply_id: 306853[/import]

look around the forum into OOP methods, but basically spawning instances of the enemy with a metatable

each enemy you spawn with eg [lua]enemies[i] = Enemy.new()[/lua] would have a function available like [lua]enemy:punch = function(power)[/lua]

have a look here:
http://developer.anscamobile.com/forum/2011/01/19/big-refactor#comment-17393
http://planetlua.squarespace.com/journal/2011/1/21/put-some-oop-in-your-app-part-1-creating-a-class.html [import]uid: 6645 topic_id: 6853 reply_id: 23920[/import]