Django 中的社交游戏机制
我希望用户在我的应用程序中完成各种任务时获得“积分” - 从标记对象到结交朋友等任务。我还没有找到可以简化此操作的 Django 应用程序。
目前我认为累积积分的最佳方法是每个用户操作创建相当于“流项目”,并且通过计算发布到其流的每个操作的值来计算积分。
显然,社交游戏机制是一个巨大的领域,目前正在进行大量研究。但从开发的角度来看,最简单的入门方法是什么?我是否走错了路,或者有更好/更简单的方法吗?
编辑:对于任何想要一个非常简单的实现的人:
对于任何对这个想法的非常简单的实现感兴趣的人,请尝试创建一个“日志记录”应用程序并将其放入您的 models.py 中:
log_models = [Tag, Post, Vote]
class Point(models.Model):
# model fields
def increase_score(sender, instance, signal, *args, **kwargs):
# score logic
for model in log_models:
post_save.connect(increase_score, sender=model)
post_delete.connect(decrease_score, sender=model)
如果您发现,请参阅此文档post_save 发出两次: http://code.djangoproject.com/wiki/Signals#Helppost_saveseemstobeemissedtwiceforeachsave< /a>
I want users to receive 'points' for completing various tasks in my application - ranging from tasks such as tagging objects to making friends. I havn't yet found a Django application that simplifies this.
At the moment I'm thinking that the best way to accumulate points is that each user action creates the equivalent of a "stream item", and the points are calculated through counting the value of each action published to their stream.
Obviously social game mechanics is a huge area with a lot of research going on at the moment. But from a development perspective what's the easiest way to get started? Am I on the wrong track or are there better / simpler ways?
Edit: for anyone that wants a very simple implementation of this:
For anyone that would be interested in a very simple implementation of this idea try creating a "logging" application and putting this in your models.py:
log_models = [Tag, Post, Vote]
class Point(models.Model):
# model fields
def increase_score(sender, instance, signal, *args, **kwargs):
# score logic
for model in log_models:
post_save.connect(increase_score, sender=model)
post_delete.connect(decrease_score, sender=model)
Refer to this doc if you find that post_save is emitting twice: http://code.djangoproject.com/wiki/Signals#Helppost_saveseemstobeemittedtwiceforeachsave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“流项目”?以前从未听说过。
“日志”是有道理的。听起来您要将事件记录在表中。对记录的事件进行求和或计数。这是最简单、最可扩展的。
您可以定期进行总结(对于大型社交人群,每小时一次,对于小规模人群,每天一次)。
"Stream item"? Never heard that before.
"Log" makes sense. It sounds like you're going to log events in a table. Sum or count the logged events. That's the simplest and most extensible.
You can summarize periodically (hourly for big social crowds, daily for small crowds).