Esempio n. 1
0
 internal CommunityGoalEvent InvokeEvent(CommunityGoalEvent arg)
 {
     if (_api.ValidateEvent(arg))
     {
         CommunityGoal?.Invoke(_api, arg);
     }
     return(arg);
 }
        public JournalCommunityGoal(JObject evt) : base(evt, JournalTypeEnum.CommunityGoal)
        {
            JArray jmodules = (JArray)evt["CurrentGoals"];

            CommunityGoalList = string.Empty;

            if (jmodules != null)
            {
                CommunityGoals = new List <CommunityGoal>();
                foreach (JObject jo in jmodules)
                {
                    CommunityGoal g = new CommunityGoal(jo);
                    CommunityGoals.Add(g);
                    CommunityGoalList = CommunityGoalList.AppendPrePad(g.Title, ", ");
                }
            }
        }
        private IEnumerable <ApiEvent> ConvertEvent(CommunityGoal e)
        {
            foreach (var goal in e.CurrentGoals)
            {
                yield return(new ApiEvent("setCommunityGoal")
                {
                    Timestamp = e.Timestamp,
                    EventData = new Dictionary <string, object>()
                    {
                        { "communitygoalGameID", goal.Cgid },
                        { "communitygoalName", goal.Title },
                        { "starsystemName", goal.SystemName },
                        { "stationName", goal.MarketName },
                        { "goalExpiry", goal.Expiry },
                        { "tierReached", goal.TierReached },
                        { "tierMax", goal.TopTier?.Name },
                        { "topRankSize", goal.TopRankSize },
                        { "isCompleted", goal.IsComplete },
                        { "contributorsNum", goal.NumContributors },
                        { "contributionsTotal", goal.CurrentTotal },
                        { "completionBonus", goal.TopTier?.Bonus },
                    }
                });

                if (goal.PlayerContribution == 0)
                {
                    continue; // INARA rejects setCommanderCommunityGoalProgress with 0 contribution
                }
                yield return(new ApiEvent("setCommanderCommunityGoalProgress")
                {
                    Timestamp = e.Timestamp,
                    EventData = new Dictionary <string, object>()
                    {
                        { "communitygoalGameID", goal.Cgid },
                        { "contribution", goal.PlayerContribution },
                        { "percentileBand", goal.PlayerPercentileBand },
                        { "percentileBandReward", goal.Bonus },
                        { "isTopRank", goal.PlayerInTopRank }
                    }
                });
            }
            ;
        }
Esempio n. 4
0
 public CommunityGoalEvent(DateTime timestamp, List <CGUpdate> cgupdates, CommunityGoal goal) : base(timestamp, NAME)
 {
     this.updates = cgupdates;
     this.goal    = goal;
 }
Esempio n. 5
0
 public static Request SetCommunityGoal(this Request request, CommunityGoal eventData, DateTime?date = null, int?customID = null)
 {
     return(request.AddEvent("setCommunityGoal", eventData, date, customID));
 }