Example #1
0
Template.club_member.events({
  'click .addSing'(event){
    console.log(this._id);
    var club = Clubs.findOne({owner : Meteor.userId()});
    var girl = UserGirls.findOne({_id : this._id});
    if(club.actionPoints >= 1 && girl.fatigue <= 90){
      Meteor.call('usergirls.addSing',this._id,1);
      Meteor.call('usergirls.addFatigue',this._id,10);
      Meteor.call('usergirls.addExp',this._id,5);
      Meteor.call('clubs.spendActionPoints',1);
    }else{
      console.log("not enough actionPoints or the girl is too tired!");
    }
  },
  'click .addDance'(event){
    console.log(this._id);
    var club = Clubs.findOne({owner : Meteor.userId()});
    var girl = UserGirls.findOne({_id : this._id});
    if(club.actionPoints >= 1 && girl.fatigue <= 90){
      Meteor.call('usergirls.addDance',this._id,1);
      Meteor.call('usergirls.addFatigue',this._id,10);
      Meteor.call('usergirls.addExp',this._id,5);
      Meteor.call('clubs.spendActionPoints',1);
    }else{
      console.log("not enough actionPoints or the girl is too tired!");
    }
  },
  'click .addAct'(event){
    console.log(this._id);
    var club = Clubs.findOne({owner : Meteor.userId()});
    var girl = UserGirls.findOne({_id : this._id});
    if(club.actionPoints >= 1 && girl.fatigue <= 90){
      Meteor.call('usergirls.addAct',this._id,1);
      Meteor.call('usergirls.addFatigue',this._id,10);
      Meteor.call('usergirls.addExp',this._id,5);
      Meteor.call('clubs.spendActionPoints',1);
    }else{
      console.log("not enough actionPoints or the girl is too tired!");
    }
  },
  'click .addInstrument'(event){
    console.log(this._id);
    var club = Clubs.findOne({owner : Meteor.userId()});
    var girl = UserGirls.findOne({_id : this._id});
    if(club.actionPoints >= 1 && girl.fatigue <= 90){
      Meteor.call('usergirls.addInstrument',this._id,1);
      Meteor.call('usergirls.addFatigue',this._id,10);
      Meteor.call('usergirls.addExp',this._id,5);
      Meteor.call('clubs.spendActionPoints',1);
    }else{
      console.log("not enough actionPoints or the girl is too tired!");
    }
  },
  'click .reduceFatigue'(event){
    console.log(this._id);
    var club = Clubs.findOne({owner : Meteor.userId()});
    var girl = UserGirls.findOne({_id : this._id});
    if(club.actionPoints >= 1 && girl.fatigue >= 30){
      Meteor.call('usergirls.reduceFatigue',this._id,30);
      Meteor.call('clubs.spendActionPoints',1);
    }else{
      console.log("not enough actionPoints or the girl doesn't need heal!");
    }
  },

})
Example #2
0
Template.club_staff.helpers({
	staffs(){
  	return Staffs.find({}, { sort: { level: 1 } });
  },
})

Template.club_song.helpers({
	songs(){
  	return Songs.find({}, { sort: { level: 1 } });
  },
})

Template.club_member.helpers({
	members(){
  	return UserGirls.find({owner : Meteor.userId()}).fetch();
  },
})



Template.scout.helpers({
  	oneGirl(){
  		var array = Girls.find().fetch();
		var d = new Date();
		//today's star
		var s = Math.round(d.getTime()/1000/60/1); //refresh per min
		console.log(s);
		var index = s % array.length;
		var element = array[index];
  		return element;