Hello,

I've got a web application that should simulate different activities as
follows:

- User1 and User2 teamed up for an activity called Activity1.
- Users have skills: skill1, skill2

def simulate_activity
  a = Activity.find(params[:id])
  return execute_1 a if a.activity_type == "1"
  return execute_2 a if a.activity_type == "2"
end

def execute_1 act
  report = ""
  if(calculate_chance(user1.skill1) && calculate_chance(user2.skill1)
    report += "Users successully blah"
    act.status = "succeeded"
  else
    report += "Users did not manage to blah"
    act.status = "failed"
  end
  report
end

def execute_2 act
  report = ""
  if(calculate_chance(user1.skill2) && calculate_chance(user2.skill2)
    report += "Users successully blah"
    act.status = "succeeded"
  else
    report += "Users did not manage to blah"
    act.status = "failed"
  end
  report
end

I hope you get what I mean. My only problem is that I don't really like
the way it's programmed above. Does anyone know a better way to
"simulate" these kind of activities so it's no mess when it gets more
complex etc.?
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to