I’ve been stumped about the best implementation path and could use
some help from the experts. I’m implementing a fantasy sports platform
on Rails that needs to be able to support leagues with radically
different rules, all on the same platform. The users get to choose
which ruleset they want to use in their league.
Standard: Each player is owned by at most one team, can be traded.
Owning a player at the time that the player does something that score
points accrues points to the team.
Multi team: Each player can be owned by multiple teams and cannot be
traded. Same scoring as #1.
Elimination 1: Each team selects 10 NFL teams and ranks them from 1-10
(10 being best). Each week, NFL teams that have not been eliminated in
the playoffs accrue points equal to the rank they were given.
Elimination 2: Each week, each team selects an NFL team that they
think will NOT be eliminated. They accrue points if the team is not
eliminated. However, each NFL team may only be chosen once by any
given team in the league
So on and so on… The game mechanics may not make a whole lot of
sense in the context of this question, but this just gives some
examples of how different the mechanics can be. The idea is that
players can choose any of the rule set that they want to when they set
up the league.
How do I go about implementing these different rulesets on a single
platform while maintaining the shared constructs of leagues, managers,
teams, events, etc.? Are there alternatives to either:
- Implementing the differences as a set of case statements in each
- Building a different set of models for each style of play with
their own set of rules, and maybe using inheritance?
Option #2 seems better, but still seems to involve a very messy
database and validation structure.