Giter VIP home page Giter VIP logo

gioco's People

Contributors

everdaniel avatar ferdinandrosario avatar gccostabr avatar jfrux avatar joaomdmoura avatar lucascaton avatar wpolicarpo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gioco's Issues

Fix parameters validation in rakes

In gioco rake taks there some parameter validations like:

if !args.name && !args.points && !args.type

But instead of 'and' concept it should be 'or'

if !args.name || !args.points || !args.type

Various Setup Bugs

Hey,
Just setup in rails 3.2 and ran into a few problems...

in the gioco.rake file:
At line 13: the find_or_create_by throws an error...this can be solved by changing line to

badge_string = "kind = Kind.find_by_name('#{args.kind}') || Kind.create(:name=> '#{args.kind}')\n"

Line 27 has "kinds.id" should be

r.points << Point.create({ :kind_id => kind.id, :value => '#{args.points}'})

Also when the generator makes the Models, it will use the user input to name the "Resource" fields, however the foreign key in the Points table has "user_id" hard coded.

line 5 of the ModelGenerator should be

generate("model", "point #{@model_name}_id:integer kind_id:integer value:integer")

Thanks

Multiple points type support

Implement a new approach option based on the fact that different type of points can give differenties badges to a resource.
I don't know yet how is the best way to add this feature but it should be scheduled as soon as possible to the next versions.

Adding validations in gioco models

Nowadays is possible create different types with the same name, it should not be possible.
When calling remove_badge rake gioco:remove_badge[noob] you don't have to pass the type name, it means that you should not be able to create badges with the same name event for different types. The type_name parameter should be required either.

Use generator snippets

Use some of generator snippets to build a better CLI removing some inline parameters.

Change Gioco installation options

Suppose that you start setting up Gioco with --points and then you perceive that you will gonna need also --types. Today there is no easy way to migrate, first you will gonna have to completely uninstall Gioco, losing all your badges and data, and then set it up again now with the both optionals.

The best solution would be a method that deal with the existent data and files that was generated. Not only to add option but also to remove.

The uninstall order of Gioco, if configured with only --points optional, would be:

  • Remove rake file gioco.rake
  • Remove configuration file gioco.rb (config/initializers/gioco.rb)
  • Remove db/gioco folder and all files inside it.
  • Remove the similar line of the db/seeds.rb: require "#{Rails.root}/db/gioco/db.rb"
  • Remove the following models: Badge, Level
  • Remove migrations related with gioco! Including add_points_to_*(YOUR RESOURCE).rb
  • Remove the following methods of your RESOURCE model: change_points and next_badge?
  • Remove all relations involving badge, level in your RESOURCE model
  • Access your database of all environments, drop the Level and Badge table
  • Also drop the Points column of your RESOURCE table. if you do this using migrations don't forget of delete this migration before keep working.

Setup error

$ rails g gioco:setup user --points --types;
/Users/rod/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1153:in `async_exec': PG::Error: ERROR:  relation "types" does not exist (ActiveRecord::StatementInvalid)
LINE 5:              WHERE a.attrelid = '"types"'::regclass

Points / Percent to next badge

There should be a method that return how many points the resource must win to own a new badge.
Only if it's being used with points system.

behaviour of points

Hi,
I'd like your job but perhaps I didn't understand all

but it's normal that when I setup gioco and then run

rake gioco:add_badge[base_level,5,true]
rake gioco:add_badge[rookie,10,false]
rake gioco:add_badge[recruit,20,false]
rake gioco:add_badge[commander,50,false]
rake gioco:add_badge[strong,75,false]
rake gioco:add_badge[warior,100,false]
rake gioco:add_badge[powerful,200,false]
rake gioco:add_badge[extreme,500,false]
rake gioco:add_badge[heavy,1000,false]
rake gioco:add_badge[imortal,5000,false]

All my user get 5000 points?

I saw that all the user had a level entry in db for each badge. I thought that only base_level was associated to user, or I'm wrong?
Nunzio

rake gioco:add_badge[noob,0,teacher,true] fails with "Last name can't be blank" error.

Hi João - I'm having some trouble following the setup instructions.

Without the 'true' at the end, it works, and I see the entry in the database.

Any thoughts?

Thanks, look forward to getting your gem to work with my simple app!

paul@paul-server:~/Development/inhabition$ rake gioco:add_badge[noob,0,teacher,true] --trace
** Invoke gioco:add_badge (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute gioco:add_badge
rake aborted!
Validation failed: Last name can't be blank, Password is too short (minimum is 6 characters), Password confirmation can't be blank
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/validations.rb:56:in save!' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/attribute_methods/dirty.rb:33:insave!'
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:246:in block in save!' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:295:inblock in with_transaction_returning_status'
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in transaction' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:208:intransaction'
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:293:in with_transaction_returning_status' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/gems/activerecord-3.2.3/lib/active_record/transactions.rb:246:insave!'
/home/paul/Development/inhabition/lib/tasks/gioco.rake:28:in block (3 levels) in <top (required)>' /home/paul/Development/inhabition/lib/tasks/gioco.rake:25:ineach'
/home/paul/Development/inhabition/lib/tasks/gioco.rake:25:in block (2 levels) in <top (required)>' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:incall'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in block in execute' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:ineach'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in execute' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:inblock in invoke_with_call_chain'
/home/paul/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in mon_synchronize' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:ininvoke_with_call_chain'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in invoke' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:ininvoke_task'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in block (2 levels) in top_level' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:ineach'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in block in top_level' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in top_level' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:inblock in run'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:inrun'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in <top (required)>' /home/paul/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:inload'
/home/paul/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in <main>' /home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/bin/ruby_noexec_wrapper:14:ineval'
/home/paul/.rvm/gems/ruby-1.9.3-p194@inhabition/bin/ruby_noexec_wrapper:14:in `

'
Tasks: TOP => gioco:add_badge

Unable to run rake tasks

I couldn't run the rake task following the example in the documentation:

$ rake gioco:add_badge[chuckie, 5, terror]       
zsh: bad pattern: gioco:add_badge[chuckie,

Fix default badge

When a default badge is added the points related must be automatically add to

How do you move badges to production?

Hi João - how do you move your badges to production?

Is there a way to create the rake task commands given what's in the database in dev?

Or do you have some init code that creates your badges when you deploy?

Cheers,

Paul

Gioco::Core.sync_resource_by_points failing

Gioco::Core.sync_resource_by_points(self, new_pontuation, kind)

returns:

ActiveRecord::UnknownAttributeError at /
unknown attribute: user_id

some notes:
this only fails when the point count triggers a new badge creation. otherwise it works...
Running rails 3.2.13

Remove optional parameters

That's a lot of problems related with the optional parameter that should avoid database statements, it should be removed for the next version

Change eval

Use the eval method isn't a good practice, it should be replace for capitalize and constantize.

Apply TrueSkill algorithm

TrueSkill is a Bayesian ranking algorithm developed by Microsoft Research and used in the Xbox matchmaking system.
TrueSkill maintains a belief on the skill of each player; every time a player plays a game, the system accordingly changes the perceived skill of the player and acquires more confidence about this perception.

It certainly is the best ranking algorithm nowadays, mostly because it cares about time factor. Would be awesome had this implemented inside Gioco Ranking Class.

Some interesting links about it:
TrueSkill
TrueSkillDetails

Update README

The README should be updated to let people know about the new features that are being added, as hwo to move your badges to productions using rake db:seed

Fix points logic at default badges

When a default badge is created the rake task end up by adding its points to the user, it's wrong because that might exist default badges created after some while

undefined local variable or method 'options' for Gioco::Resoureces:Class

Hi João,
I have setup the Gioco by follow the example, the difference is I only use --points option.
then when I call the method Gioco::Resources.change_points(current_user.id, 1), it throws exception as follow:

NameError (undefined local variable or method 'options' for Gioco::Resoureces:Class)

How can I solve this issue?
Thanks.

Implement Transactions

Change methods that update the gioco data to use transactions to avoid a mess at database.

Remove dependencies

There is taking too much time to install gioco, remove the dependencies is the faster approach.

Add badges when create, if users already have points to earn it

It's quite a simple logic, you will add badges all the time, and eventually there will gonna be users that already should have a new badged that you are creating cause they already have the amount of points necessary to earn it.

To do this, the create badge rake task need to be changed, the seed generated also have to change.

LICENSE file

Without an explicit license, no one can lawfully use your code.

Badge owned callback

When the change_points method is called, and the operation results in a new badge owned, the Gioco should use a callback informing the application about it.

Confusion about the points system

Hi joao

I'm a little confused about the point system, I created a new project and setup the gem follow the example, everything is ready,

  1. The first time I call the method Gioco::Resources.change_points( user.id, 1, type.id ), I found a new point record inserted with value "1".
    2.The second time I call change_points( user.id, 1, type.id ), a new point record inserted but with value "2".
    3.The third time I call change_points( user.id, 1, type.id ), a new point record inserted but with value "4".

I'm confused about the new record value 1,2,4, why is 1,2,4 not 1,1,1 or 1,2,3 ?

Expressiveness

You could make your gem more expressive. Like here:

rake gioco:add_badge[BADGE_NAME, POINTS, DEFAULT]

A example of this rake task would be:

rake gioco:add_badge["xpto", 9000 , true]

Wouldn't it better if you could do:

rake gioco:add_badge name:xpto points:9000 default:9000 (I still think that "default" is kinda off...)

Also, instead of using methods like this:

Gioco::Resources.change_points( Resource_id, Points, Type_id )

You could use

Gioco::Resources.change_points(:resource_id => 1, :points => 2, :type_id => 2 )

Or even better, with method chaining something like this:

GIoco::Resources(@resource).add(100)

It's just a suggestion and I admire you very much for the effort put in it.

Table is named "type" and it is giving off errors

I am trying to implement your gem in a rails 4 application. When trying to reference the 'Type' class from the User model, it gives an error. I believe this goes back to your model being named 'Type'.

[Feature] Add "Adventure" badges and bonus points

Would be nice if gioco could support "Adventure"
I mean, until now it could be possible only set badges that are "progression" of same points (same type).
However could be nice to earn badge when a particular collection of badges are won ex:

  • superuser badge is assigned when;
    • "badge A" of type 1 and "badge B" of type 2 are earned.

Again, could be useful add,optionally, bonus point to badges to rewards user when badge is assigned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.