Pychievements:一个用来创建和追踪Achievments 的 Python 框架

网友投稿 524 2022-10-28

Pychievements:一个用来创建和追踪Achievments 的 Python 框架

Pychievements:一个用来创建和追踪Achievments 的 Python 框架

Pychievements: The Python Achievements Framework!

Pychievements is a framework for creating and tracking achievements within a Python application. It includes functions specifically for creating command line applications, though it is flexible enough to be used for any application such as web applications.

See the examples to get a good feel for what Pychievements offers. Documentation can be found RTD: http://pychievements.readthedocs.org/en/latest/

Features:

Create Achievements with any number of "goals" (based on levels) that can be reachedFlexible design makes it easy to customize the way levels are trackedEasy to add new achievements laterPluggable backend for storing tracked information in different formats to different locationsAchievements can be filtered by category or keywordsEasily specify "Icons" for individual goals within an achievement for dual states (achieved and unachieved)

Example

A simple achievement.

class MyAchievement(Achievement): name = "My Achievement" category = "achievements" keywords = ("my", "achievement") goals = ( {"level": 10, "name": "Level 1", "icon": icons.star, "description": "Level One"}, {"level": 20, "name": "Level 2", "icon": icons.star, "description": "Level Two"}, {"level": 30, "name": "Level 3", "icon": icons.star, "description": "Level Three"}, )

Increment a level for a user.

tracker.increment(user_id, MyAchievment)

Re-evaluating a level for a user based on arguments (requires the evaluate function to be defined or the Achievement).

tracker.evaluate(user_id, MyAchievement, some, extra, args)

Retrieve achievements.

tracker.achievements() # retrieves all registered achievements in the trackertracker.achieved(uid, achievement) # all achieved goals by uid for achievementtracker.unachieved(uid, achievement) # all unachieved goals by uid for achievementtracker.current(uid, achievement) # goal currently being worked torwards by uid

Installation

To install pychievements, simply:

$ pip install pychievements

License

Pychievements is licensed under the MIT License, see the LICENSE.

Contribute

If you'd like to contribute, simply fork the repository, commit your changes to the master branch (or branch off of it), and send a pull request. Make sure you add yourself to AUTHORS.

Roadmap

More backendsMore icons

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:一个现代、快速、简单的异步python3 web框架
下一篇:使用 Vue.js 开发跨平台应用的前端框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~